I'm trying to separate a set of data with an if statement based on if a value is positive. I had it working and it generated correct data but it stopped and generated the unused argument error when I generated new data. Here is the code I used.
In:
data_random1 = runif(100,1,100)
data_random2 = runif(100,1,100)
cd1 = data_grouped1
cd2 = data_grouped2
smth_ln = lowess(cd1,cd2)
dis = smth_ln$y - cd2
data_frame = data.frame(cd1,cd2,dis)
f = c()
y = c()
ifelse(data_frame$dis >= 0, f = c(f,data_frame$dis),y = c(y,data_frame$dis))
This generates the error:
Error in if (x > 0) { : missing value where TRUE/FALSE needed
When I type this function seperate from the if statment it works so I am confused as to the issue. I tried a workaround with:
for(x in c(dis[1:100])){if(x >= 0){f = c(f,x)}else{y=c(y,x)}}
but got the error:
Error in if (x > 0) { : missing value where TRUE/FALSE needed
Not sure how to fix this.
Aucun commentaire:
Enregistrer un commentaire