Entering edit mode
7.2 years ago
Neuls
▴
20
Hi,
I'm trying to loop through a string vector called iter in order to subset a data frame in R. I would like to filter that data frame using i iter value in the loop and assign it to a variable using iter value i. however, it wasnt working I think variable assignment is not properly done.
for ( i in iter) {
paste0(i)<-subset(out,TestId==paste0(i) & AddId=="Curve_F_Cor")
}
I have tried with assign built in R function but i havent and seems to work
for ( i in iter) {
assign(i, subset(out,TestId==paste0(i) & AddId=="Curva_F_Cor"))
}
I have read several times that using assign in this way is not very nice. I've read about lapply but i cannot figure out how to use it Which one would be the best option to do it?
Thanks