dplyr包的使用例子。...R包
library(tidyverse)
iris_df <- as_tibble(iris)
print(iris_df, n = 3)
head(iris_df$Species)
## 变量选择函数...>%
select(sepal_length = Sepal.Length,
sepal_width = Sepal.Width) %>%
print(n = 3)
## 变量重命名函数...print(n = 5)
df <- tribble(
~height, ~width,
10, 12,
42, 24,
14, 12
)
## 变量生成函数...mean_income
)
) %>% spread(key = "year", value = "mean_income")
温馨提示:
第一步:运行一边代码,掌握相应的包和函数使用