Entering edit mode
2.9 years ago
j_weld
▴
10
I have different cancer types like this (the unique cancer types are 36). I want to know the number of each cancer type.
I have different cancer types like this (the unique cancer types are 36). I want to know the number of each cancer type.
table
from base R, or count
from the dplyr library will do this.
rpolicastro got the answer, but spelling it out explicitly here because table()
is a great function for counting word or item frequencies, and it's fun to see the output:
> cancers <- c("CLL",
"BLCA",
"LUAD",
"BLCA",
"KIRC",
"KIRC",
"GBM")
> table(cancers)
cancers
BLCA CLL GBM KIRC LUAD
2 1 1 2 1
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
cancers
is the vector storing values.