Trouble with summary()

I am wondering why the summary() function is not showing min, median, etc. for income and fast food variables? but it is for age?

Hi @hepppy,

Without seeing the actual data, my guess is that both Income and Fast.Food are actually character vectors (i.e. string data), instead of numeric data. You can tell this is the case from the fact that the numbers are presented with commas.

Try doing this:


# Replace `Income` with the full name, it is cut off in your image above...
Research %>%
  mutate_at(vars(Income, Fast.Food), ~str_replace_all(., ',', '')) %>%
  mutate_at(vars(Income, Fast.Food), as.numeric) %>%

Hi hepppy -
and welcome to the RStudio community!

It appears that you have two variables (Income.. and Fast.Food) that are either character or factor variables, Age is numeric, and Region is likely also a factor variable.

summary() will only give means or medians for numeric variables.

You can find out their variable types by using

str(Research) #for the whole dataset

You can convert Income.. and Fast.Food to numeric variables
with the as.numeric() function,
as in

Research %>%
mutate(fast_food = as.numeric(Fast.Food))

and then you can run

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.