Removing Whitespace From a Whole Data Frame in R

后端 未结 10 600
孤街浪徒
孤街浪徒 2020-12-05 03:01

I\'ve been trying to remove the white space that I have in a data frame (using R). The data frame is large (>1gb) and has multiple columns that contains whi

10条回答
  •  不思量自难忘°
    2020-12-05 03:44

    One possibility involving just dplyr could be:

    data %>%
     mutate_if(is.character, trimws)
    

    Or considering that all variables are of class character:

    data %>%
     mutate_all(trimws)
    

提交回复
热议问题