Thanks for your suggestions,
I have still more to do, like subsetting, V1,...., value is or equal or greater than Max_V1,... respectively, and then save them into data frame individually.
I did the following codes.
DF <- data.frame(V1=1:11,
V2=c(0,1,0,50,1,0,-10,0,1,0,NA),
V3=21:31,
V4=c(0,1,0,50,1,0,-10,0,1,0,NA))
library(dplyr,warn.conflicts = FALSE)
v=list("V1", "V2","V3","V4")
DF <- DF %>% mutate(across(.cols = c("V1", "V2","V3","V4"), .fns = list( Max = ~mean(.x,na.rm=TRUE) + 2*sd(.x,na.rm=TRUE)),
.names = "{fn}_{col}"))
Subsetting them into individual data frame once V1,..., is greater or equal to Max_V1,--- respectively .
for ( i in v) {
print(i)
M<-paste0("Max_",i,sep="")
assign(paste0("s",i),subset(DF, i >= M))
}
The subsetting doesn't apply them with that condition, and still is saving all rows
sV4
V1 V2 V3 V4 Max_V1 Max_V2 Max_V3 Max_V4
1 1 0 21 0 12.63325 37.08279 32.63325 37.08279
2 2 1 22 1 12.63325 37.08279 32.63325 37.08279
3 3 0 23 0 12.63325 37.08279 32.63325 37.08279
4 4 50 24 50 12.63325 37.08279 32.63325 37.08279
5 5 1 25 1 12.63325 37.08279 32.63325 37.08279
6 6 0 26 0 12.63325 37.08279 32.63325 37.08279
7 7 -10 27 -10 12.63325 37.08279 32.63325 37.08279
8 8 0 28 0 12.63325 37.08279 32.63325 37.08279
9 9 1 29 1 12.63325 37.08279 32.63325 37.08279
10 10 0 30 0 12.63325 37.08279 32.63325 37.08279
11 11 NA 31 NA 12.63325 37.08279 32.63325 37.08279
Once V4 is 50 and Max_V4=37.08279, should subset only the row of it, but not happens, please suggest!!