相关疑难解决方法(0)

R dplyr:使用字符串函数重命名变量

(有些相关的问题:在dplyr的重命名函数中输入新的列名作为字符串)

dplyrchain(%>%)的中间,我想用旧名称的函数替换多个列名(使用tolowergsub等)

library(tidyr); library(dplyr)
data(iris)
# This is what I want to do, but I'd like to use dplyr syntax
names(iris) <- tolower( gsub("\\.", "_", names(iris) ) )
glimpse(iris, 60)
# Observations: 150
# Variables:
#   $ sepal_length (dbl) 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6,...
#   $ sepal_width  (dbl) 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4,...
#   $ petal_length (dbl) 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4,...
#   $ …
Run Code Online (Sandbox Code Playgroud)

regex r rename dplyr

43
推荐指数
6
解决办法
3万
查看次数

标签 统计

dplyr ×1

r ×1

regex ×1

rename ×1