Dear all,
First of all apologies if I am not reporting correctly my problem, this is my first post within the R community. I am experiencing problems trying to apply a function to a whole data frame (rr) which I then save with a different name (rro). I have tried with a "for" loop, but it returns an empty list. I have also tried with apply, without success. Could anyone help?
Thanks,
Jorge
#> Attempt 1: returns an error: Error in FUN(left, right) : non-numeric argument to binary operator
R_code <-
rro <- rr
func = function(x) summarise_if(rr, is.numeric, 1 + ((rr - 1) * 2))
rro <- apply(rr, MARGIN = c(1,2), FUN = func)
#> Attempt 2: returns an empty list
R_code <-
rro <- rr
rro <- for(j in 1:ncol(rro)) {
if (is.numeric(rro[, j])) {
for(i in 1:nrow(rro)) {
rro[i,j] = 1 + ((rro[i,j] - 1) * 2)
}
}
}