The data:
Itun <- data.frame(v1 = c(1,1,2,1,2,1), v2 = c(NA, 1, 2, 1, 2, NA))
This will remove all columns containing at least one NA
:
Itun[ , colSums(is.na(Itun)) == 0]
An alternative way is to use apply
:
Itun[ , apply(Itun, 2, function(x) !any(is.na(x)))]
Related Posts:
- Emulate ggplot2 default color palette
- ggplot wrong color assignment
- How to rename a single column in a data.frame?
- Critical t values in R
- t-stat for feature selection
- Reasons for using the set.seed function
- What does na.rm=TRUE actually means?
- Error in if/while (condition) {: missing Value where TRUE/FALSE needed
- How do I replace NA values with zeros in an R dataframe?
- How to change legend title in ggplot
- Changing column names of a data frame
- Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)
- R on MacOS Error: vector memory exhausted (limit reached?)
- Counting the number of elements with the values of x in a vector
- Non-numeric Argument to Binary Operator Error in R
- Non-numeric Argument to Binary Operator Error in R
- R issue “object not found”
- Error in Confusion Matrix : the data and reference factors must have the same number of levels
- Why do I get “number of items to replace is not a multiple of replacement length”
- Error in file(file, “rt”) : invalid ‘description’ argument in complete.cases program
- Extracting value specific rows in R
- “Error: Mapping should be created with `aes()` or `aes_()`.”
- Error in file(file, “rt”) : invalid ‘description’ argument in complete.cases program
- Longer object length is not a multiple of shorter object length?
- plot.new has not been called yet
- Error in lm.fit(x,y,offset = offset, singular.ok,…) 0 non-NA cases with boxcox formula
- Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, …) : NA/NaN/Inf in ‘y’, tried every possible way
- Logistic regression – eval(family$initialize) : y values must be 0 <= y <= 1
- Opposite of %in%: exclude rows with values specified in a vector
- Add text to ggplot
- Rotating and spacing axis labels in ggplot2
- Arcsine transformation of percentage data
- R loop that adds following numbers to each element in list
- Can I calculate z-score with R?
- Reading PSV (pipe-separated) file or string
- Function to clear the console in R and RStudio
- plot.new has not been called yet
- “replace” function examples
- Why I get this error writing data to a file
- Remove NA values from a vector
- Correlation between multiple variables of a data frame
- character string is not in a standard unambiguous format
- Remove rows with all or some NAs (missing values) in data.frame
- duplicate ‘row.names’ are not allowed error
- Function to clear the console in R and RStudio
- Adding a regression line on a ggplot
- Invalid factor level, NA generated warning
- R: “Unary operator error” from multiline ggplot2 command
- invalid type (list) for variable
- not a Stata version 5-12 .dta file
- Error: unexpected ‘}’ in “}” in R [duplicate]
- No non-missing arguments warning when using min or max in reshape2
- How to convert a factor to integer\numeric without loss of information?
- Having trouble setting working directory
- Understanding `scale` in R
- Add empty columns to a dataframe with specified names from a vector
- `fread` with headers with special characters (latin1) and unusual nested quotes
- Generate a set of random unique integers from an interval
- How to move or position a legend in ggplot2
- Rotating and spacing axis labels in ggplot2
- “installation of package ‘FILE_PATH’ had non-zero exit status” in R
- Plot multiple lines (data series) each with unique color in R
- Replace all particular values in a data frame
- Plot a legend outside of the plotting area in base graphics?
- Still getting error in dev.off() : cannot shut down device 1 (the null device)
- How to sum a variable by group
- lme4 error: boundary (singular) fit: see ?isSingular
- How to get summary statistics by group
- Non-conformable arrays error in code
- object of type ‘builtin’ is not subsettable
- What causes an R script to get Killed?
- Combine two data frames by rows (rbind) when they have different sets of columns
- Function to calculate R2 (R-squared) in R
- dplyr mutate with conditional values
- `Error in file(con, “r”) : cannot open the connection` from running BRugsFit()
- Getting invalid model formula in ExtractVars when using rpart function in R
- Too few periods for decompose()
- How to solve prcomp.default(): cannot rescale a constant/zero column to unit variance
- incorrect number of subscripts on matrix in R
- How Do You Compare Two Strings in R?
- changing title in multiplot ggplot2 using grid.arrange
- How to split data into training/testing sets using sample function
- Correct syntax for mutate_if
- Creating a Plot Window of a Particular Size
- Error:attempt to apply non-function
- Error in xj[i] : invalid subscript type ‘list’
- How do you specifically order ggplot2 x axis instead of alphabetical order?
- Sample random rows in dataframe
- Error in eval(predvars, data, env) : object ‘Rm’ not found
- How to initialize a vector with fixed length in R
- Efficiently sum across multiple columns in R
- How do I clean up R memory without restarting my PC?
- Side-by-side plots with ggplot2
- lib unspecified & Error in loadNamespace
- How to convert data.frame column from Factor to numeric [duplicate]
- Merge data frames based on rownames in R
- What do these R glm error messages mean: “Error: no valid set of coefficients has been found: please supply starting values”
- What is the meaning of the dollar sign “$” in R function()?
- How can I change the name of a data frame
- How to calculate combination and permutation in R?