Hello everyone.
I want to extract a specific column from some .csv files that have same rows and columns.
I wrote the code below and it works but without the column names. (see the screen shot)
The question is how I can save the selected each column with files names.
library(tidyr)
library(readr)
mylist <- list.files(path = "Y:/project2020/Data/texture/Extracting_data", pattern = "*.csv", full.names = T)
mass<- lapply(mylist, function(i){
x= read.csv(i)
x= x[c(42:140), c(2)]
})
print (mass)
write.csv(mass, file = "Y:/project2020/Data/texture/output.csv", row.names = F)
If we assume the data in MASS is numeric, it looks I think you have column names. The top row of that screenshot looks like character data. How you gt those names I don't know.
What happens if you issue the command
names(MASS)
We need some sample data to work with.
Introduction If you’ve found yourself here, you’ve probably been asked to create a reproducible example, or reprex, in response to a question you asked on the RStudio Community Site. This post provides a cursory overview of both creating a reprex as...
system
Closed
January 11, 2021, 9:21pm
4
This topic was automatically closed 54 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.