我正在尝试向数据集添加索引,该数据集太大而无法容纳在 RAM 中。添加索引的 tidyverse 方法是:
library(tidyverse)
df = mtcars
df |>
mutate(row_id = 1:nrow(cyl)) # any column name in the df
Run Code Online (Sandbox Code Playgroud)
Arrow 的 Dplyr 后端不允许执行此操作。我还能怎样做呢?
我很清楚 和 等snakecase允许janitor字符串转换为蛇形大小写的软件包,但我无法仅使用基本 R而不使用任何其他软件包找到答案。做到这一点最优雅的方法是什么?
例如,以下字符串:
strings <- c("foo bar", "fooBar", "FooBar", "foo21bar",
"lowerCamelCase", "ALL_CAPS", "IDontKNOWWhat_thisCASE_is")
Run Code Online (Sandbox Code Playgroud)
应转换为蛇形外壳。
这本质上复制了snakecase::to_snake_case()