Below is a sample data set
area periodyear period employment date
01 2020 08 100 2020-08-01
01 2020 09 105 2020-09-01
01 2020 10 110 2020-10-01
02 2020 08 101 2020-08-01
02 2020 09 102 2020-09-01
02 2020 10 103 2020-10-01
The question is how I get R to return the last TWO rows. I created the date using the following code as a way of having a single value (instead of periodyear and period) that a max value can be found for.
substate$date<- ymd(paste(substate$PERIODYEAR,substate$PERIOD,"1",sep="-"))
I know how to have it find the max value of a column (date, in this instance) but unclear how to have it create a data frame that looks like below
area periodyear period employment date
01 2020 09 105 2020-09-01
01 2020 10 110 2020-10-01
02 2020 09 102 2020-09-01
02 2020 10 103 2020-10-01
The reason for wanting the last TWO is that one month is brand new data and the one before is revised. From here, I update a SQL database.