Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Why is R returning an error that my variable must be an integer if the variable already is an integer?

$
0
0

I am attempting to run a multi-level regression and poststratification in R, and I keep getting an error that my dependent variable "must be integer values of 0 / 1 or logical". I ran the following

punitive.data <- within(punitive.data, punall <- as.integer(punall))

followed by

is.integer(punitive.data$punall)

which returned a response of TRUE.

Then I ran

mrp.simple <- mrp(punall ~ statenum + f.race , data = punitive.data, population = census.data)

which returned the following error:

Error in checkResponse(response, response.varname) : 
'punall' must be integer values of 0 / 1 or logical.

I rechecked the variable type with the is.integer function and got a TRUE response again. The variable also shows as an integer in the Environment. All values in the variable are either 0 or 1.

Any advice or help would be greatly appreciate.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>