1

I have a model that calculates hourly disease severity for 3000 hours and writes them in a csv file ( 3000 rows and eight columns). In addition to such output, I also want to have a file with just specific rows (here hours) and the same number of columns. In other words, I want a file that only writes the results in row(hour) 10, 20, 30, 40, 50, 100, 120 and 150 ( or any other desired row number)? I would be grateful if someone helps me how to do it in R.

Thanks

Hank
  • 70
  • 2
  • 8
  • Something like this: http://stackoverflow.com/questions/21891841/importing-only-every-nth-row-from-a-csv-file-in-r Then you would want to do write.csv() of the new data. – William Gearty Mar 18 '15 at 23:23

1 Answers1

2

In R you can select rows/columns directly: for tableX

tableX[Row,Column]

#Select all columns and only the rows you want:
export <- tableX[c("10","20","30","40","50","100","120","150"),]

#To select the first 8 columns as well:
export <- tableX[c("10","20","30","40","50","100","120","150"),1:8]

#Then export:
write.csv2(export, file= "disease.csv")
Kvasir EnDevenir
  • 907
  • 1
  • 10
  • 25
  • 1
    Thanks@Kvasir EnDevenir, it worked like a char, that would save me a lot of time. – Hank Mar 19 '15 at 13:26