search for: indicesb

Displaying 3 results from an estimated 3 matches for "indicesb".

Did you mean: indices
2016 Apr 21
0
Data reshaping with conditions
...lt;-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<-svdatstr[row,indicesA][svdatstr[row,indicesA]<svdatstr[row,"maxB"]] svdatstr[row,"x"]<-paste(AltB,collapse=",") Ag...
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