R语言 count()报错

Python012

R语言 count()报错,第1张

>df%>%count(name)

Error in count(., name) : object 'name' not found

>df %>% dplyr::count (name,type)# 注意指定dplyr包

# A tibble: 6 x 3

  name  type        n

  <chr><chr>  <int>

1 Alice english    1

2 Alice math        1

3 Bob  english    1

4 Bob  math        1

5 Carol english    1

6 Carol math        1

思路

首先转为 matrix

然后再转为vector

data11 <- read.table("Dcs.txt",header=F,na.string="999.99")

ee <-as.matrix(data11)

dd <- as.vector(ee)