[R] substitute NA values

Jorge Cornejo-Donoso jorgecornejo at uach.cl
Wed Mar 28 16:47:04 CEST 2007


This could work, but not with big matrix!

year <- c(1990,1995,2000,2005)
Prod <- c(2478,3192,NA,1594)

matrix <- data.frame(cbind(year,Prod))
for (i in 1:dim(matrix)[1])
	{
	if (is.na(matrix[i,2])) {matrix[i,2] <- 0}
	}



More information about the R-help mailing list