Displaying 4 results from an estimated 4 matches for "dfdates".
Did you mean:
ddates
2017 Nov 01
0
Adding Records to a Table in R
...a copy of your data
dtOrig <- as.Date( c("1985-04-01","1985-07-01","1985-12-01","1986-04-01"))
dfOrig <- data.frame( TransitDate=dtOrig, Transits=c(100,100,500,325),
CargoTons=c(1000,1080,3785,4200) )
#Generate the complete set of dates as a data frame
dfDates<- data.frame( TransitDate=seq(from=as.Date("1985-04-01"),by="1
month",length=13) )
# do the merge adding the "missing" rows (where NA will appear)
dfNew <- merge(dfDates, dfOrig, by="TransitDate", all.x=TRUE )
# replace the NA's by zero
dfNew[is....
2017 Nov 01
3
Adding Records to a Table in R
Dear R friends,
I am currently working with time series data, and I have a table(as data
frame) that has looks like this (TransitDate are in format = "%e-%B-%Y") :
TransitDate Transits CargoTons
1985-04-01 100 2500
1985-05-01 135 4500
1985-06-01 120 1750
1985-07-01 100 3750
1985-08-01 200
2017 Nov 08
3
Adding Records to a Table in R
...ig <- as.Date( c("1985-04-01","1985-07-01","1985-12-01","1986-04-01"))
> dfOrig <- data.frame( TransitDate=dtOrig, Transits=c(100,100,500,325),
> CargoTons=c(1000,1080,3785,4200) )
>
> #Generate the complete set of dates as a data frame
> dfDates<- data.frame( TransitDate=seq(from=as.Date("1985-04-01"),by="1
> month",length=13) )
>
> # do the merge adding the "missing" rows (where NA will appear)
> dfNew <- merge(dfDates, dfOrig, by="TransitDate", all.x=TRUE )
>
> # replace th...
2017 Nov 08
0
Adding Records to a Table in R
...;1985-04-01","1985-07-01","1985-12-01","1986-04-01"))
> > dfOrig <- data.frame( TransitDate=dtOrig, Transits=c(100,100,500,325),
> > CargoTons=c(1000,1080,3785,4200) )
> >
> > #Generate the complete set of dates as a data frame
> > dfDates<- data.frame( TransitDate=seq(from=as.Date("1985-04-01"),by="1
> > month",length=13) )
> >
> > # do the merge adding the "missing" rows (where NA will appear) dfNew
> > <- merge(dfDates, dfOrig, by="TransitDate", all.x=TRUE )
>...