我有一个模型,可以计算3000小时的每小时疾病严重程度,并将它们写入csv文件(3000行和8列)。除了这样的输出,我还想要一个只有特定行(这里是几小时)和相同列数的文件。换句话说,我想要一个只在行(小时)10,20,30,40,50,100,120和150(或任何其他所需的行号)中写入结果的文件?如果有人帮我在R中做到这一点,我将不胜感激。
由于
答案 0 :(得分:2)
在R中,您可以直接选择行/列: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")