Quantcast
Channel: Reverse code using psych package and remove NA in R - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Reverse code using psych package and remove NA in R

$
0
0

My dataset looks like this:

values<-c(1,1,NA,3)acceptance<-c(1,4,NA,1)diffusion<-c(2,2,3,NA)attitudes<-c(2,4,4,NA)df<-data.frame(values,acceptance,diffusion,attitudes)values  acceptance  diffusion  attitudes  1         1          2           2   1         4          2           4  NA        NA         3           4  3         1          NA          NA

I used to psych package to reverse code values and acceptance using this code:

keys <- c("values", "acceptance")df2 <- reverse.code(keys = keys, items = df, mini = NULL, maxi = NULL)

But I keep getting this error:

Error in colMax + colMin : non-numeric argument to binary operatorIn addition: Warning messages:1: In FUN(newX[, i], ...) : no non-missing arguments, returning NA2: In FUN(newX[, i], ...) : no non-missing arguments, returning NA3: In FUN(newX[, i], ...) : no non-missing arguments, returning NA4: In FUN(newX[, i], ...) : no non-missing arguments, returning NA5: In FUN(newX[, i], ...) : no non-missing arguments, returning NA6: In FUN(newX[, i], ...) : no non-missing arguments, returning NA7: In FUN(newX[, i], ...) : no non-missing arguments, returning NA8: In FUN(newX[, i], ...) : no non-missing arguments, returning NA

I thought I could just use na.rm=T but it doesn't seem to work with this code. Any idea on how to fix this?

Thanks in advance!


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images