所以我加载了几个csv文件:
tbl = list.files(pattern="*.csv")
> tbl
[1] "F1.csv" "F10.csv" "F11.csv" "F12.csv" "F13.csv" "F14.csv" "F15.csv" "F16.csv"
[9] "F17.csv" "F18.csv" "F19.csv" "F2.csv" "F20.csv" "F3.csv" "F4.csv" "F5.csv"
[17] "F6.csv" "F7.csv" "F8.csv" "F9.csv"
现在我想从F6.csv文件中删除两列。这些列是7和8。 如何从以下位置删除这些列:
tbl[17]
我是否可以直接访问此数据,或者我必须单独加载此表并删除这些数据。
答案 0 :(得分:1)
根据上面的注释,您必须将这些文件读入R.然后,您可以在本地环境中操作它们
# read all of the files into R
for(i in list.files(pattern = '*.csv')){
name <- paste(i)
dat <- read.csv(i, header = T)
assign(name, dat)
}
# remove columns 7 & 8 from F6.csv
F6.csv <- F6.csv[, -c(7, 8)]
# if you want to write this new data set to F6.csv
# write.csv(F6.csv, 'F6.csv', row.names = F)