R:计算向量中的元素。计数()不起作用

时间:2021-08-01 13:58:07

标签: r count

有谁知道一个函数可以计算向量中的观察次数?并给我正确数量的表情符号?函数 count() 不起作用。

谢谢!

1 个答案:

答案 0 :(得分:0)

你可以使用

library(dplyr)
library(tidyr)

Emoji %>%  
  unnest(emoji) %>% 
  count(id) %>% 
  right_join(Emoji, by = "id") %>% 
  arrange(id)

哪个返回

# A tibble: 30 x 5
      id     n text                                                                            emoji   emoji_name
   <int> <int> <chr>                                                                           <list>  <list>    
 1     1    NA "yzy foam runner mx cream clay available august   httpstcopzsxngplbu  confirme~ <NULL>  <NULL>    
 2     2     1 "still original \U0001f9e0\n\n celebrate  year anniversary  nerdarmy’s debut a~ <chr [~ <chr [1]> 
 3     3    NA "introducing flexpark  swimwear collection created  confidently flex  day  sum~ <NULL>  <NULL>    
 4     4    NA "creativity     side  inspiration \n\nfeel  spirit  openness  slowthai  beabad~ <NULL>  <NULL>    
 5     5    NA "slowthai  beabadbee stay open   classic silhouette refreshed   bold new color~ <NULL>  <NULL>    
 6     6    NA "filmed   cotswolds  abbeyroad soundtracked  castofficials john power embark  ~ <NULL>  <NULL>    
 7     7    NA " open mind can take    path  anywhere \n\nsee  itsjeremyscott  waffle crew ex~ <NULL>  <NULL>    
 8     8    NA "fueled   passion  sport  adidasforprada ap luna rossa  brings primegreen  ser~ <NULL>  <NULL>    
 9     9    NA " open mind   way  life one  itsjeremyscott  kidthewiz live  \n\nwelcome  open~ <NULL>  <NULL>    
10    10    NA "   open mind take  \n\nshare  creativity   replies   chance  get  exclusive e~ <NULL>  <NULL>    
# ... with 20 more rows

因此在 n 列中,您可以找到已计数的表情符号数。