'calculate lengh of data with multiple conditions
I am a beginner in R. and I have a data set with different variables (NES,y,z) and NES contain names as (AET1Gv20.......,TRITD7Av1.....,TRITD7Bv1.....), i want to have the length of NES(classes) when the variable z is below(-2) in different classes separatly (1st class: "NES"->start with AET, second CONTAIN Bv and third contain Av". so i tried the script below it works but it is heavy and takes time. do you have any practical sugestion "THANK YOU IN ADVANCE"
j$b<-substr(j$NES,1,3)
jD<-subset(j,b=="AET")
jAB<-subset(j,b=="TRI")
jAB$y<-substr(jAB$NES,7,8)
jA<-subset(jAB,y=="Av")
jB<-subset(jAB,y=="Bv")
length(which(jD[,3]>(2)))
length(which(jD[,3]<(-2)))
length(which(jA[,3]>(2)))
length(which(jA[,3]<(-2)))
length(which(jB[,3]>(2)))
length(which(jB[,3]<(-2)))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
