Since nobody so far felt fit to point out *why* what you’re trying doesn’t work:

`NA == NA`

doesn’t return`TRUE`

, it returns`NA`

(since comparing to undefined values should yield an undefined result).- You’re trying to call
`apply`

on an atomic vector. You can’t use`apply`

to loop over the elements in a column. - Your subscripts are off – you’re trying to give two indices into
`a$x`

, which is just the column (an atomic vector).

I’d fix up 3. to get to `a$x[is.na(a$x)] <- 0`

### Related Posts:

- Plot multiple lines in one graph
- Create empty data frame with column names by assigning a string vector?
- Changing font size and direction of axes text in ggplot2
- How to randomize ggplot factor color scheme, keeping same default distances on color wheel?
- Count number of occurences for each unique value
- Warning message: line appears to contain embedded nulls [duplicate]
- Find duplicate values in R
- How to change line width in ggplot?
- Change size of axes title and labels in ggplot2
- Multiple If Statements in R
- ggplot geom_text font size control
- What’s the difference between lapply and do.call?
- ggplot2, change title size
- Initial value in ‘vmmin’ is not finite even when changing the starting value
- R “Error: unexpected ‘}’ in “}”
- How to remove outliers from a dataset
- Mean per group in a data.frame
- standard deviation on dataframe does not work
- How to increase font size in a plot in R?
- What is the difference between = and ==?
- Merge r brings error “‘by’ must specify uniquely valid columns”
- Subscripts in plots in R
- promise already under evaluation: recursive default argument reference or earlier problems?
- Aggregate multiple columns at once
- Non-numeric argument to mathematical function
- Plot two graphs in same plot in R
- R – Concatenate two dataframes?
- Producing subscripts in R markdown
- lme4::lmer reports “fixed-effect model matrix is rank deficient”, do I need a fix and how to?
- How do you use “<<-" (scoping assignment) in R?
- Convert data.frame columns from factors to characters
- Re-ordering factor levels in data frame
- Is it possible to have a multi-line comments in R?
- Understanding the result of modulo operator: %%
- R – error “variable lengths differ”
- Simple manual RMarkdown tables that look good in HTML, PDF and DOCX
- Select rows from a data frame based on values in a vector
- how to increase the limit for max.print in R
- dplyr: “Error in n(): function should not be called directly”
- In R formulas, why do I have to use the I() function on power terms, like y ~ I(x^3)
- backward elimination in R
- Error in eval(expr, envir, enclos) : object not found
- Filter data.frame rows by a logical condition
- How do I convert a factor into date format?
- Error while creating heatmaps – NA/NaN/Inf in foreign function call (arg 11)
- Write lines of text to a file in R
- How to compute summation in r
- Plot multiple boxplot in one graph
- R will plot but won’t draw abline
- scale_fill_discrete and scale_fill_manual – legend options confusion
- R – argument is of length zero in if statement
- ‘Incomplete final line’ warning when trying to read a .csv file into R
- How to solve ‘protection stack overflow’ issue in R Studio
- Conditional mean statement
- Warning in GLM analysis
- Error in 2:n : NA/NaN argument
- Error in generating boxplot two variable data frame: adding class “factor” to an invalid object
- What does ‘length of ‘dimnames’ [1] not equal to array extent’ mean?
- How do I flip rows and columns in R
- Remove NA values from a vector
- How to catch integer(0)?
- Print string and variable contents on the same line in R
- Does R have a wildcard expression (such as an asterisk (*))?
- env=baseenv() in R
- Simple for loop in R producing “replacement has length zero” in R
- How to find out which package version is loaded in R?
- How to solve it. error:Error in data[[rowvar]] : attempt to select less than one element
- What does Continuous x aesthetic — did you forget aes(group=…) mean?
- use first row data as column names in r
- Gradient of n colors ranging from color 1 and color 2
- How to prevent scientific notation in R?
- What is the difference between require() and library()?
- Launching R help: Error in file(out, “wt”) : cannot open the connection
- R Sweave: NO TeX installation detected
- R avoiding “restarting interrupted promise evaluation” warning
- How to increase the font size of ggtitle in ggplot2
- do-while loop in R
- ERROR: [on_request_read] connection reset by peer in R shiny
- Error in as.vector(x, mode) : cannot coerce type ‘closure’ to vector of type ‘any’
- Suppress output of a function
- Error in G * t(hat) : non-conformable arrays
- Get dplyr count of distinct in a readable way
- Error: isTRUE(gpclibPermitStatus()) is not TRUE
- Merge two rows in data.frame
- r function unzip error 1 in extracting from zip file
- Get the list of installed packages by user in R
- How to access the last value in a vector?
- increase legend font size ggplot2
- How To Create Vector of Vector In R
- Round down a numeric
- Use of ~ (tilde) in R programming Language
- Code to clear all plots in RStudio
- Error: x must be atomic for ‘sort.list’
- Installing R on Android
- Transposing in dplyr
- Does the c command create a row vector or a column vector by default in R
- Can dplyr join on multiple columns or composite key?
- Error in summary.connection(connection) : invalid connection
- Converting from a character to a numeric data frame
- How to create lag variables