Newbie R question:
I'd like to use the ceiling function to round up the y variable in each of ten training datasets, train1 through train10.
> for (i in 1:10){ x <- get(paste0("train",i)); x$y <- ceiling(x$y) }
The above code runs without error. However when I check the y values of my datasets, I discover they haven't been rounded:
> head(train1$y)
[1] 29561.06 0.00 0.00 4660.24 440.00 924.60
But if I try this:
> head(x$y)
[1] 29562 0 0 4661 772 440
> head(x$Fold)
[1] 10 10 10 10 10 10
it turns out the code is working correctly, but only on the renamed dataset "x" which gets overwritten after each loop, not datasets train1-train10.
What am I doing wrong?