r dplyr包上的示例代码。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r dplyr包上的示例代码。相关的知识,希望对你有一定的参考价值。

library(dplyr)

iris_df <- as_data_frame(iris)
iris_df %>% rename_(.dots = setNames(names(.), toupper(names(.)))) %>% head(2)
# A tibble: 2 × 5
# SEPAL.LENGTH SEPAL.WIDTH PETAL.LENGTH PETAL.WIDTH SPECIES
# <dbl>       <dbl>        <dbl>       <dbl>  <fctr>
# 1          5.1         3.5          1.4         0.2  setosa
# 2          4.9         3.0          1.4         0.2  setosa

x <- c("A", "B", "C", "A", "B")
recode(x, .dots = setNames(c(1, 2, 3), c("A", "B", "C")))
# [1] 1 2 3 1 2

x <- c(1, 2, 3, 2, 1)
recode(x, .dots = setNames(c("A", "B", "C"), c(1, 2, 3)))
# [1] "A" "B" "C" "B" "A"

以上是关于r dplyr包上的示例代码。的主要内容,如果未能解决你的问题,请参考以下文章

包上的 `del` 有某种记忆

访问捆绑包上的资源[重复]

如何删除 nuget 包上的预发布指定?

工作包上的 ITMS-90086 + ITMS-90203 错误

茶包上的日记——Ruby Silvious

S3 服务 mpeg-dash,将加载清单,但包上的 CORS 失败