Replace all occurrences of a string in a data frame

后端 未结 6 691
面向向阳花
面向向阳花 2020-11-27 02:54

I\'m working on a data frame that has non-detects which are coded with \'<\'. Sometimes there is a space after the \'<\' and sometimes not e.g. \'<2\' or \'< 2\

6条回答
  •  余生分开走
    2020-11-27 03:34

    late to the party. but if you only want to get rid of leading/trailing white space, R base has a function trimws

    For example:

    data <- apply(X = data, MARGIN = 2, FUN = trimws) %>% as.data.frame()
    

提交回复
热议问题