Using R, is there a way to take a data set and map out every possible combination of every categorical variable?
For example, let\'s say I had 10,000 rows of custom
That there is:
expand.grid(gender = c("male", "female"), tShirtSize = c("xs", "s","m","l","xl"))
Will return all the combinations in a dataframe. For the summary stats, try aggregate
, e.g:
country = sample(c("america", "canadian"), 30, replace = TRUE)
gender = sample(c("male", "female"), 30, replace = TRUE)
x = abs(rnorm(30) * 1000)
aggregate(data.frame(x), by = list(country, gender), FUN = mean)
I run into errors if there are columns with strings in the dataframe, so I'd subset out the columns with numeric values.