我想根据每年的纸张数量创建一组列,因此通过总结过滤dplyr中的多个条件:
这是我的代码:
words_list <- data %>%
select(Keywords, year) %>%
unnest_tokens(word, Keywords) %>%
filter(between(year,1990,2017)) %>%
group_by(word) %>%
summarise(papers_count = n()) %>%
arrange(desc(papers_count))
上面的代码为我提供了两列,&#39; word&#39;和&#39; papers_count&#39;,我想根据1990年到2017年之间的每年创建更多的专栏,如papers_count(papers_count1990,papers_count1991等)。
我正在寻找类似的东西:
words_list <- data %>%
select(Keywords, year) %>%
unnest_tokens(word, Keywords) %>%
filter(between(year,1990,2017)) %>%
group_by(word) %>%
summarise(tot_papers_count = n(), papers_count_1991 = n()year="1991", ...) %>%
arrange(desc(papers_count))
请有人有任何建议吗?
答案 0 :(得分:2)
我建议将group_by
添加到spread
,然后使用library(tidyr)
words_list_by_year <- data %>%
select(Keywords, year) %>%
unnest_tokens(word, Keywords) %>%
filter(between(year,1990,2017)) %>%
group_by(year,word) %>%
summarise(papers_count = n()) %>%
spread(year,papers_count,fill=0)
创建多个摘要列。
<div> I have some contents </div>
<script>
$('footer').offset().top;
</script>
<footer>This is footer</footer>