Did you mean 'tolower' instead of 'to lower' in your example?
Or is there a similarly named function that converts the levels
of a factor to lower case instead of converting the factor to
a character vector and then lower-casing that?
> d %>% dplyr::mutate_if(is.factor, tolower)
NumF1 F2
1
Use tolower on the levels of the factor columns. E.g.,
> d <- data.frame(Num=1:3, F1=c("One","Two","Three"), F2=c("A","B","a"))
> str(d)
'data.frame': 3 obs. of 3 variables:
$ Num: int 1 2 3
$ F1 : Factor w/ 3 levels "One","Three",..: 1 3 2
$ F2 : Factor w/ 3 levels "a","A","B": 2 3 1
> fo
To: r-help@r-project.org
Subject: [R] Simple loop problem
Hi everybody,
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 re
Hi everybody,
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
4 matches
Mail list logo