0

I'm setting up a data table & expected to transform all data to be in lower-case, thought it would look neat. How can I do that ?

Mr.KT
  • 23
  • 6
  • 1
    Please you need to provide more info, what you have tried or where are you stuck or what issue you are facing. thanks – Jithin Scaria Apr 17 '19 at 12:40

2 Answers2

3

We can use

library(data.table)
setDT(TestData)[, lapply(.SD, tolower)]

Or using tidyverse

library(tidyverse)
TestData %>%
     mutate_if(is.character, tolower)
akrun
  • 874,273
  • 37
  • 540
  • 662
1

Here is an alternative that can also be combined with mutate from dplyr:

purrr::map(Filter(is.character,my_data),~tolower(.x))

We can also achieve the same using a combination of dplyr and purrr as suggested by @Shinobi_Atobe

my_data %>% 
keep(is.character) %>% 
map(~tolower(.x))
NelsonGon
  • 13,015
  • 7
  • 27
  • 57