Extract final values from one run of a simulation

#1
I ran a simulation using R and because there were a large number of permutations (>10,000) we stored the output of each permutation in a separate file.

For each permutation we did 1000 runs of the simulation.
The attached file contains the 1000 runs that make up one of these permutations.
I want to pull the tail values the key variables (labelled S,I1,I2,L) of each run in to a table.

When i do
df <- tail(X,1) R generates a new dataset containing all the information from the last 1000 runs.
I had thought that if I then did
tail (df,1)
it would give me the penultimate value of the that specific run but no go.

Suggestions welcomed.
 
Last edited:

TheEcologist

Global Moderator
#3
Try something like this:

Code:
## Make a test file
write.table(1:1000,file="myfilename")

## Read only one file
con<-file('myfilename')
open(con)
read.table(con,skip=999,nrow=1) #read only the 999-th line
close(con)

## clean up
file.remove('myfilename')