'Using Cut2 to combine/collapse categories from a dataset
I am new to R and I'm struggling with this.
I am trying to use cut2 to combine preexisting categories from a dataset with variables
I loaded
library(poliscidata)
Followed
freq(gss$polviews, gss$wtss)
Followed by
library(Hmisc)
The results I get back at varying degrees of political affiliation between Liberal, Conservative, and Moderate on the frequency chart from slight to extreme.
I am trying to utilize cut2 to create a new variable by combining the 3 varying degrees of liberal into one liberal category, and for the three varying degrees of conservative into one conservative group.
I tried:
gss$polviews3 = as.numeric(cut2(gss$polviews))
But what I get back is
Error in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 1L), na.rm = FALSE) :
‘min’ not meaningful for factors
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
