problems with as.factor function

Hi! I'm new to R and I'm having problems plotting my categorical data. I'm using the as.factor function to make my variable, which is not numeric, into something that can be graphed but I keep getting this error:
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf

I'm using preloaded data and Im typing it in as

See if it helps to change



protest$condition <- as.factor(protest$condition)

That worked! the bar graph doesn't show me the exact number of individuals in each variable. Do you know a function to show how many of each variables there are in categorical data?

It says my two levels but Im wondering how many are in each level

Hi there try fct_count() from the forcats package

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.