I’m new to R and i’m trying to learn fundamentals. I’m facing a small problem for which i can’t find a solution online.
What i want to do: write a function to lower case for all the columns in my data.frame if they respect a condition (class = factor)
This code works, but for all my columns :
lower = function(x) {data.frame(tolower(as.matrix(x)))}
I need more something like this, but it doesn’t work:
lower = function (x) { for (i in 1:length(x)) {
if (class(i)=="factor") {
data.frame(tolower(as.matrix(x)))
}
}}
x is my data.frame
Thank you
Y.P
Aucun commentaire:
Enregistrer un commentaire