I was curious to see if there is a way to craft a for loop to do apply as.numeric() for a certain columns, since the entire DF is considered to be as a character. Perhaps I have a very large data set, and I want to make a certain column, until the very last column, to be applied.
I looked into lapply, but I think I am more confused on that.
DF =
Person | KLAS | XDXS | ASDD | BBHS | JKJA |
---|---|---|---|---|---|
First | Meyer | 33 | 22 | 21 | 12 |
Second | Walmart | 34 | 23 | 28 | 19 |
Third | Safeway | 35 | 29 | 21 | 11 |
Fourth | ... | ... | ... | ... | ... |
Is there a way to make a for loop where I can do as.numeric() for each column, say starting at column 3 and until the very end? I would be working with large data sets, so I was wondering if there was a way to do that. Cause I dont think I can do as.numeric when there are actual characters in column 1 and 2, and using unlist() makes the problem worse.
Person <- c("First", "Second", "Third", "Fourth")
KLAS <- c("Meyer", "Walmart", "Safeway", "Kroger")
XDXS <- c("33", "34", "35", "22")
ASDD <- c("21", "28", "21", "11")
BBHS <- c("22", "23", "21", "18")
JKJA <- c("12", "19", "11", "8")
DF <- data.frame(Person, KLAS, XDXS, ASDD, BBHS, JKJA)