So I have a dataset (states) - the built-in R dataset, in fact.
States have 9 variables.
> names(states)
[1] "Population" "Income" "Illiteracy" "Life.Exp" "Murder"
"HS.Grad" "Frost" "Area"
[9] "Region"
I am interested in seeing the unique levels within each variable.
For one variable, I can do
> unique(states$Region)
[1] South West Northeast North Central
Levels: Northeast South North Central West
How can I repeat this process for all 9 variables?
> unique <- function(var){
+ unique(states$var)
+ }
> lapply(names(states),unique)
Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?
Error during wrapup: evaluation nested too deeply: infinite recursion /
options(expressions=)?
Why does this error appear? And how can I fix this?
Thanks!