hello, I am new to R (convert from Stata) and I am wondering if there is an R command/function for generating a summated scale from, for example, four separate variables in a data set. In other words, I want to transform the variables x1, x2, x3, and x4 (which have high inter-item reliability) into one new summated variable x'. Can't seem to find it in the psy or psych package ... Thanks for any suggestions! [[alternative HTML version deleted]]
Hi Anthony, Perhaps ?rowSums ?apply ?aggregate ?ave Here is an example: set.seed(123) X <- matrix(rnorm(40), ncol = 4) colnames(X) <- c('x1','x2','x3','x4') X x <- rowSums(X) x cbind(X, x) HTH, Jorge On Sat, Mar 20, 2010 at 4:02 PM, Anthony Lopez <> wrote:> hello, > > I am new to R (convert from Stata) and I am wondering if there is an R > command/function for generating a summated scale from, for example, four > separate variables in a data set. In other words, I want to transform the > variables x1, x2, x3, and x4 (which have high inter-item reliability) into > one new summated variable x'. Can't seem to find it in the psy or psych > package ... > > Thanks for any suggestions! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Hi Anthony, Have a look at ?rowSums (if you just want to calculate the score) or ?score.items in the psych package (if you want to calculate alpha's, item-by-scale correlations etc.). -Ista On Sat, Mar 20, 2010 at 4:02 PM, Anthony Lopez <skytrek820 at gmail.com> wrote:> hello, > > I am new to R (convert from Stata) and I am wondering if there is an R > command/function for generating a summated scale from, for example, four > separate variables in a data set. ?In other words, I want to transform the > variables x1, x2, x3, and x4 (which have high inter-item reliability) into > one new summated variable x'. ?Can't seem to find it in the psy or psych > package ... > > Thanks for any suggestions! > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org