Description Usage Arguments Details Value Author(s) See Also Examples
Return a data.frame
with columns of
class "Date" replaceing all 3-column dates.
1 |
data |
a |
YMD |
a character vector of lenght 3 of patterns to use
in |
The data sets from the
Correlates
of War project include dates coded in triples of columns with
names like c("StartMonth1", "StartDay1", "StartYear1",
"EndMonth1", ..., "EndYear2"). This function will accept a
data.frame
obtained via read.csv
of such a file and replace each such triple with a singe
column of class 'Date' combining the triple appropriately.
Return a data.frame
containing the information in
data
reformatted as described above.
Spencer Graves
1 2 3 4 5 6 7 8 9 10 11 12 13 | cow0 <- data.frame(rec=1:3, startMonth=4:6, startDay=7:9,
startYear=1971:1973, endMonth1=10:12, endDay1=13:15,
endYear1=1974:1976, txt=letters[1:3])
cow0. <- Dates3to1(cow0)
# check
cow0x <- data.frame(rec=1:3, txt=letters[1:3],
start=as.Date(c('1971-04-07', '1972-05-08', '1973-06-09')),
end1=as.Date(c('1974-10-13', '1975-11-14', '1976-12-15')) )
all.equal(cow0., cow0x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.