at.columbia.edu/~gelman/arm/missing.pdf
best, Fraser
From: Val [valkr...@gmail.com]
Sent: Wednesday, April 26, 2017 8:45 PM
To: r-help@R-project.org (r-help@r-project.org)
Subject: [R] missing and replace
HI all,
I have a data frame with three variabl
Apologies, I re-read the question and realised you hope to replace the missing
values rounded to the nearest whole number.
Here’s the code in full.
df1 <- data.frame(x = c(25, 30, 40, 26, 60), y = c(122, 135, NA, 157, 195), z =
c(352, 376, 350, NA, 360))
means <- sapply(df1, mean, na.rm = T);
Hi Val,
You could do this by nesting 2 for loops, and defining a function such that it
returns the mean of the column when the value is ‘NA’.
df1 <- data.frame(x = c(25, 30, 40, 26, 60), y = c(122, 135, NA, 157, 195), z =
c(352, 376, 350, NA, 360)); df2 <- df1[0, ]
means <- sapply(df1, mean, n
HI all,
I have a data frame with three variables. Some of the variables do
have missing values and I want to replace those missing values
(1represented by NA) with the mean value of that variable. In this
sample data, variable z and y do have missing values. The mean value
of y and z are152. 25
4 matches
Mail list logo