【问题标题】:What is the dot (".") notation in R? [duplicate]R中的点(“。”)符号是什么? [复制]
【发布时间】:2021-02-19 02:01:36
【问题描述】:

我想按宗教对 tidyr 数据集relig_income 进行分组,用N_People 显示信徒的平均值,并通过平均值对他们进行排序DESC。我尝试了第一个代码,但根据我的在线课程,正确答案似乎是第二个。排列功能中的点是什么意思?

我得到了两个不同的结果。

  1. 我的代码:

    tidy_df %>% group_by(religion) %>% summarise(mean_believers = mean(N_People)) %>% 安排(mean_believers, desc(mean_believers))

  2. 正确答案:

    tidy_df %>% group_by(religion) %>% summarise(mean_believers = mean(N_People)) %>% arrange(., desc(mean_believers))

【问题讨论】:

  • 酷,我现在明白了!感谢您的回复和文档。

标签: r tidyr


【解决方案1】:

. 是通过%>% 传递的数据的符号。 例如,您可以使用.$your_column 引用数据的特定列

看看documentation 对应pipe

【讨论】:

  • 我现在明白了。点等于数据集(在本例中为 tidy_df)。我错误地使用了排列功能。
猜你喜欢
  • 1970-01-01
  • 2018-01-20
  • 1970-01-01
  • 2018-07-26
  • 2016-02-24
  • 2016-05-25
  • 2016-07-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多