I have a data set comprising 1000 rows and 5000 columns, and I want to select specific columns ("mydata"). The target columns are listed in the data frame "cols". I've tried some of the examples posted here, but no success! Could anyone please suggest it to me?
cols[1:5,]
c("S100024810", "S100024905", "S100024920", "S100024923", "S100025437"
)
mydata[1:3,1:5]
structure(list(S100024732 = c("1", "0", "1"), S100024733 = c("-",
"0", "0"), S100024803 = c("0", "0", "-"), S100024810 = c("1",
"1", "1"), S100024817 = c("-", "1", "-")), row.names = c(NA,
3L), class = "data.frame")
mydata[,cols[cols %in% names(mydata)]]
Error in .subset(x, j) : invalid subscript type 'list'