[R] handling missing values

Mintewab Bezabih Mintewab.Bezabih at economics.gu.se
Thu Mar 15 18:00:39 CET 2012

Dear R users, 

I have problems handling missing values. THe problem is that after running my codes the result I get just skips the missing values. What I want is for the missing values to appear in my results as well. I have put a workable example below and as you could see the missing value in x1 (the 18thh value) does not appear in the list y.fitted. 

Any help appreciated


y.list <- list(y1=runif(10), y2 <- runif(10), y3 <- runif(10))
y.list <- list(y1=runif(20))
x1 <- 1:20
x2 <- c(11, 15, 17, 2, 18, 6, 7, NA, 12, 10,21, 25, 27, 12, 28, 16, 17, NA, 12, 10)
y.gam <-lapply(y.list, function(y)gam(y~s(x1,x2, k=10)))
y.fitted <- lapply(y.gam, fitted) # list of fitted values

More information about the R-help mailing list