27 Apr 2017, at 9:19 AM, Ng Bo Lin wrote:
>
> 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,
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 Paul,
Using the example provided by Ulrik, where
> exdf1 <- data.frame(Date = c("1985-10-01", "1985-11-01", "1985-12-01”,
> "1986-01-01"), Transits = c(NA, NA, NA, NA))
> exdf2 <- data.frame(Date = c("1985-10-01", "1986-01-01"), Transits =
> c(15,20)),
You could also try the following funct
abbreviated
version of the Month, and %y refers to the Year provided in a “2-integer”
format.
Hope this helps!
Thank you.
Regards,
Bo Lin
> On 28 Mar 2017, at 10:12 PM, Paul Bernal wrote:
>
> Dear friends Ng Bo Lin, Mark and Ulrik, thank you all for your kind and
> valuable replie
Hi Elahe,
You can do so using the mean function, mean(), by specifying an additional
argument, na.rm = TRUE. In this case, you specify that you wish to remove (rm)
all NA values in the columns.
—> mean($X2016.Q1, na.rm = T).
By default, na.rm is set to FALSE, so mean() will return a NA value.
5 matches
Mail list logo