I have a data.frame called world. This data frame lists countries in column name.y, I have a column for languages named languages. I need to List the names of countries where more than 4 languages are spoken.
My first take on this is to aggregate country and languages.
language <- data.frame(table(World$name.y,World$language))
when I run head(language) it doesn't work out.
library(data.table); as.data.table(World)[, .(n=length(unique(language))),by=.(country)][n>=4,]
$\endgroup$Error in
[.data.table(as.data.table(World), , .(n = length(unique(language))), : column or expression 1 of 'by' or 'keyby' is type list. Do not quote column names. Usage: DT[,sum(colC),by=list(colA,month(colB))]
$\endgroup$