I'm still getting familiar with lapply I have this date sequence x <- seq(as.Date("01-Jan-2010",format="%d-%b-%Y"), Sys.Date(), by=1) #to generate series of dates
I want to apply the function for all values of x . so I use lapply (Still a newbie!) I wrote this test function pFun <- function (x) { print(paste("This is: ",x,sep="")) } When I run it: > lapply(x,pFun(x)) It gives the result correctly.. but end with an error Error in match.fun(FUN) : 'pFun(x)' is not a function, character or symbol Question 1: What is the issue here?? Now, to the real problem. I wrote a function to cmDownFun(sDate)which is working correctly If I do cmDownFun (x[6]) .. it works correctly .. (i.e. my function was ok this time around!) Hoewever if I do, lapply (x,cmDownFun(x)) It fails at 01-Jan-2010 .... this is because of: HTTP status was '404 Not Found' This is OK, because the file does not exist ... but I want to continue for the remaining values of x lapply(x,try(cmDownFun(x),silent = TRUE)) .. does not work I also put the try inside the function itself but does not work either. ---------------------------------------------------------------------------- -------------------------- Thanks R-Helpers. Yes, this is a silly question and it will not be repeated! :-) ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.