dfmerge_BR = read.csv(file ="dfmerge_BR.csv", header=TRUE)
dfmerge_CO = read.csv(file ="dfmerge_CO.csv", header=TRUE)
dfmerge_BL = read.csv(file ="dfmerge_BL.csv", header=TRUE)
dfmerge_KC = read.csv(file ="dfmerge_KC.csv", header=TRUE)
dflist <- list(dfmerge_BR,dfmerge_CO,dfmerge_BL, dfmerge_KC)
new_list <- lapply(dflist, function(x) x[1,])
}
I have four different csv files here, I read them and put them into the list. I iterated through the list of data frames such that I choose first row of each data frame(now the component of list) and assign them to new_list. Now I want to extract the each component of list. but when I do
a <- new_list[[1]]
b <- new_list[[2]]
When I view both the vectors, vector b has all the values as NA and also why the a and b aren't data frames but vectors?