install.packages("tidytable")
library(tidytable)
mydata <- data.table(
group = c(rep("G1", 3), rep("G2", 4)),
value = 1:7
)
mydata
mydata1 <- as_tidytable(mydata)
mydata1
mydata1 %>%
select(value)
mydata1 %>%
filter(group == "G1")
mydata1 %>%
mutate(mean_value = mean(value),
double_value = value * 2)
mydata1 %>%
group_by(group) %>%
summarize(mean_value = mean(value))
mydata1 %>%
filter(group == "G2") %>%
mutate(mean_value = mean(value), double_value = value * 2) %>%
arrange(desc(double_value)) %>%
select(-value)
mydata2 <-
data.table(group = c("G1", "G3"),
label = c("A", "B")) %>%
as_tidytable()
mydata2
mydata_co <- inner_join(mydata1, mydata2, by = "group")
mydata_co
[1]. https://markfairbanks.github.io/tidytable/
成为我们的课程推广大使,赢取高额回报!
【通过公众号菜单栏--联系我们--招推广员】