Hello, w is a matrix of responses to categorical variables. So for example, let the first column of w be a dichotomous variable taking values 1 or 2. I then have an array, arr, which has the number of response categories as its first dimension. I want to use a person's response to the item to select the `row' in the first dimension of the array. tot_c(0) for (i in 1:n){ tot_tot+arr[w[i,1],1,1] } I just tried it in S-Plus and it worked. Should it work in R or is this is a language difference? Thanks for your time. Brian Flaherty -- /"\ \ / ASCII RIBBON CAMPAIGN X AGAINST HTML MAIL / \ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
bxf4 at psu.edu (Brian P. Flaherty) writes:> Hello, > > w is a matrix of responses to categorical variables. So for example, > let the first column of w be a dichotomous variable taking values 1 or > 2. I then have an array, arr, which has the number of response > categories as its first dimension. I want to use a person's response > to the item to select the `row' in the first dimension of the array. > > tot_c(0) > > for (i in 1:n){ > > tot_tot+arr[w[i,1],1,1] > > } > > I just tried it in S-Plus and it worked. Should it work in R or is > this is a language difference? Thanks for your time.Should and does work in the example I tried. What kind of difficulty are you experiencing? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._