WebMar 23, 2016 · If you have already your table loaded, you can act as follows: foo [foo==""] <- NA Then to keep only rows with no NA you may just use na.omit (): foo <- na.omit (foo) Or to keep columns with no NA: foo <- foo [, colSums (is.na (foo)) == 0] Share Improve this answer Follow edited Oct 6, 2012 at 21:44 Andrej 3,691 10 43 73 WebApr 14, 2016 · We could use rowSums on logical matrix ( is.na (df [1:2]) ), check whether it is not equal to 0 to get a logical vector and use that to subset. df [rowSums (is.na (df [1:2]))!=0,] # col1 col2 col3 #5 NA 5 5 #6 NA 6 6 #7 5 NA 7 Or with Reduce and lapply df [Reduce (` `, lapply (df [1:2], is.na)),] Share Improve this answer Follow
r - Locate index of rows in a dataframe that have the value of NA
WebApr 13, 2016 · To keep the rows without Inf we can do: df [apply (df, 1, function (x) all (is.finite (x))), ] Also NA s are handled by this because of: a rowindex with value NA will remove this row in the result. Also rows with NaN are not in the result. WebStack Overfill Public questions & answers; Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Your Build your employer brand ; Advertising Reach our & technologists worldwide; About the society rice cake hawaii
R: data.table count !NA per row - Stack Overflow How do I get …
WebAug 30, 2012 · Option 2 -- data.table. You could use data.table and set. This avoids some internal copying. DT <- data.table (dat) invisible (lapply (names (DT),function (.name) set (DT, which (is.infinite (DT [ [.name]])), j = .name,value =NA))) Or using column numbers (possibly faster if there are a lot of columns): WebAt the end I managed to solve the problem. Apparently there are some issues with R reading column names using the data.table library so I followed one of the suggestions provided here: read.table doesn't read in column names so the code became like this: WebNov 4, 2015 · Using dplyr, you can also use the filter_at function. library (dplyr) df_non_na <- df %>% filter_at (vars (type,company),all_vars (!is.na (.))) all_vars (!is.na (.)) means that all the variables listed need to be not NA. If you want to keep rows that have at least one value, you could do: red hot lips flower seeds