58095

Question:
So i know you can skip columns with read.table by providing a NULL to colClasses vector, but this is usually only helpful if you know how many columns are in your table.
What if I want to skip first 2 columns of table but read all the rest (which I know are numeric). Something like:
colClasses = c(NULL,NULL,rep("numeric", k))
except I don't know what k is. What would be best way to handle this?
Answer1:If you use the default white-space separation on a file named "fil.txt" then use this
colClasses = c(NULL,NULL,rep("numeric", count.fields("fil.txt")[1] -2 ))
If you use a different separator then something like
colClasses = c(NULL,NULL,rep("numeric", count.fields("fil.txt", sep=",")[1] -2 ))