Dear Users, I am trying to locate work days of the weeks for a data import automation function. The function below is for practice. If the day of the week is Saturday or Sunday, function will delete that rows and at the end the date series will be my reference date series. So, I can make an automation function which will find missing days and rearrange my main data frame according to the reference (if there is already one, I could not find it and sorry for extra disturbance.) and for example imputting the missing data in that date with spline. The problem, I could not delete the Nas' from tarih1 which I could find with if(is.na(tarih[i,1])). How should code "..." part? I tried tarih1<-tarih1[-i,], but it did not work. I feel that when u
function () { library(chron) tarih<-data.frame(tarih=seq.dates("01/03/05","01/14/05",by="days")) print(tarih) tarih1<-data.frame(tarih=array(dim=c(nrow(tarih),1))) print(tarih1) for(i in 1:nrow(tarih)) { if(weekdays(tarih[i,1])!="Sat" & weekdays(tarih[i,1])!="Sun") { tarih1[i,1]<-tarih[i,1] } } for(i in 1:nrow(tarih1)) { if(is.na(tarih1[i,1])) { ... } } tarih1[,1]<-dates(tarih1[,1],format="m/d/y") print(tarih1) } [[alternative HTML version deleted]] ______________________________________________ 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.