Re: [R] Dinamic variables in loop

2018-05-09 Thread MacQueen, Don
In addition to which, the original question uses an incorrect way to reference columns in the data frame. It should probably have been: newMyData <-MyData[!is.na(MyData$col1) | !is.na(MyData$col2) | !is.na(MyData$col3) | !is.na(MyData$col4) | !is.na(MyData$col5) , ] That is assuming that "col

Re: [R] Dinamic variables in loop

2018-05-08 Thread Thierry Onkelinx
Dear Laura, It looks like you want to remove all rows for which each column is NA. You can to that with the code below. na.matrix <- is.na(MyData) all.na.row <- apply(na.matrix, 1, all) MyData[!all.na.row, ] Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Gove

[R] Dinamic variables in loop

2018-05-08 Thread Laura RingienÄ—
Hello, I am a newbie in R and I have a problem. I want this line: newMyData <-MyData[!(is.na(col1)) | !(is.na(col2)) | !(is.na(col3)) | !( is.na(col4)) | !(is.na(col5)),] write in for loop. The number of col[number] may be different from 3 to 8 Is there any ideas? Thank you Laura [[al