sonable answer can be extracted from a given body of
data.
~ John Tukey
-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens rafamoral
Verzonden: woensdag 14 januari 2009 23:32
Aan: r-help@r-project.org
Onderwerp: [R] Logical function to t
Dear rafamoral,
Try this:
x[is.na(x)]<-0
HTH,
Jorge
On Wed, Jan 14, 2009 at 5:32 PM, rafamoral wrote:
>
> I have a dataset which contains some missing values, and I need to replace
> them with zeros. I tried using the following:
>
> x <- matrix(data=rep(c(1,2,3,NA),6), ncol=6, nrow=6)
>
> y <-
Hello rafamoral,
Try this:
ifelse(is.na(x),0,x)
On Wed, Jan 14, 2009 at 8:32 PM, rafamoral wrote:
>
> I have a dataset which contains some missing values, and I need to replace
> them with zeros. I tried using the following:
>
> x <- matrix(data=rep(c(1,2,3,NA),6), ncol=6, nrow=6)
>
> y <- matr
I have a dataset which contains some missing values, and I need to replace
them with zeros. I tried using the following:
x <- matrix(data=rep(c(1,2,3,NA),6), ncol=6, nrow=6)
y <- matrix(data=0, ncol=ncol(x), nrow=nrow(x))
for(i in 1:nrow(x)) {
for(j in 1:ncol(x)) {
y[i,j] <- ifelse(x[i,j]==NA
4 matches
Mail list logo