27 November 2007 1:59 p.m.
> To: r-help
> Subject: [R] calculate column means when missing data is present
>
> # Hello,
>
> # I have a matrix that contains some missing values denoted by NA.
> # I would like to calculate the mean for each column and not
> have the # NA value
colMeans(X,na.rm=T)
?colMeans
2007/11/27, Luke Neraas <[EMAIL PROTECTED]>:
> # Hello,
>
> # I have a matrix that contains some missing values denoted by NA.
> # I would like to calculate the mean for each column and not have the
> # NA values included. here is a sample matrix "X" below.
>
>
>
# Hello,
# I have a matrix that contains some missing values denoted by NA.
# I would like to calculate the mean for each column and not have the
# NA values included. here is a sample matrix "X" below.
c1 <- c(1,4,3,2,NA,2,5,6,4,2)
c2 <- c(1,3,6,NA,NA,2,9,6,1,2)
c3 <- c(2,4,2,NA,4,2,NA,6,3,5)
3 matches
Mail list logo