search for: indicesa

Displaying 4 results from an estimated 4 matches for "indicesa".

Did you mean: indices
2016 Apr 21
0
Data reshaping with conditions
In R, square brackets [] are called "extraction operators" as they are interpreted so as to "extract" the parts of an object specified by the information within them. Your message contained only part of the line below: AltB<-svdatstr[row,indicesA][svdatstr[row,indicesA]<svdatstr[row,"maxB"]] Extraction operators may be specified sequentially or nested. Both are used in this line. However, to understand how it works, first look at the line that defines the value of "indicesA": indicesA<-count_ind[as.logical(match...
2016 Apr 21
0
Data reshaping with conditions
...svdatstr<-stretch_df(svdat,"id",c("Count","type")) count_ind<-grep("Count",names(svdatstr)) type_ind<-grep("type",names(svdatstr)) svdatstr$maxA<-NA svdatstr$maxB<-NA svdatstr$x<-NA svdatstr$y<-NA for(row in 1:nrow(svdatstr)) { indicesA<-count_ind[as.logical(match(svdatstr[row,type_ind],"A",0))] svdatstr[row,"maxA"]<-max(svdatstr[row,indicesA]) indicesB<-count_ind[as.logical(match(svdatstr[row,type_ind],"B",0))] svdatstr[row,"maxB"]<-max(svdatstr[row,indicesB]) AltB<-svdat...
2016 Apr 21
2
Data reshaping with conditions
Hi Jim, Thanks for your time. But somehow this code did not help me to achieve my expected output. Problems: 1) x, y are coming as logical rather than values as I mentioned in my post 2) The values that I get for Max A and Max B not correct 3) It looks like a pretty big data, but I just need to concatenate the values with a comma, the final output will be a character
2016 Apr 20
0
Data reshaping with conditions
Hi sri, As your problem involves a few logical steps, I found it easier to approach it in a stepwise way. Perhaps there are more elegant ways to accomplish this. svdat<-read.table(text="Count id name type 117 335 sally A 19 335 sally A 167 335 sally B 18 340 susan A 56 340 susan A 22 340 susan B 53 340 susan B 135 351 lee A 114 351 lee A 84 351 lee A 80 351 lee A 19 351 lee A 8 351 lee A