If you do this sort of thing a lot you may find the psych package helpful:
# make example data
x <- 1:3
dat <- data.frame(expand.grid(Item1=x, Item2=x, Item3=x, Item4=x))
# make scoring ky
key <- c(Item1=1, Item2=2, Item3=1, Item4=1)
# load psych library
library(psych)
# score
(scores <- score.
re, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Jeremy Miles
> Sent: Monday, February 25, 2013 5:41 PM
> To: Craig J
> Cc: r-help
> Subject: Re: [R] Converting code to R
Here's a direct translation:
Variable <- 0
Variable <- ifelse(item1 == 1, Variable +1, Variable)
Variable <- ifelse(item2 == 1, Variable +1, Variable)
Variable <- ifelse(item3 == 1, Variable +1, Variable)
Variable <- ifelse(item4 == 1, Variable +1, Variable)
Here's another way to do it:
Vari
I'm learning R and am converting some code from SPSS into R. My background
is in SAS/SPSS so the vectorization is new to me and I'm trying to learn
how to NOT use loops...or use them sparingly. I'm wondering what the
most efficient to tackle a problem I'm working on is. Below is an example
piece
4 matches
Mail list logo