I have a list of column names in an excel file (sds.drop.csv) that I want to drop from a dataframe already imported into R.
I attempted to read the column names into R as follows
sds.drop <- as.list(read.csv("sds.drop.csv", header = F))
With the intention of then running the code below to drop them from the dataframe called 'dat'
dat1 <- dat[, !(names(dat) %in% sds.drop)]
However, no columns are dropped. I'm guessing the issue resides in the way I am reading in the data. I attempted to read the data in without the as.list() command and it still did not work. Any thoughts?
Here is what the sds.drop.csv df looks like...
> head(read.csv("sds.drop.csv", header = F))
V1
1 Q20
2 Q23
3 Q24
4 Q25
5 Q26
6 Q27