Re: [R] Simple loop problem

2016-10-31 Thread William Dunlap via R-help
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

Re: [R] Simple loop problem

2016-10-31 Thread William Dunlap via R-help
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

Re: [R] Simple loop problem

2016-10-31 Thread David L Carlson
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

[R] Simple loop problem

2016-10-31 Thread Yahya Laraki
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