0

So I have a "calendar" that reminds me of certain things that need to be done on an excel spreadsheet, sent through with email (MailR). There are two columns, one is the date and the other is the task. The format of the spreadsheet looks like this:

date(dd/mm/yyyy) | Task

This is the code that I've written so far:

library(zoo)
library(xts)
library(lubridate)
library(xtable)

setwd('Documents')
getwd()
data <- read.csv(file = 'email_calendar.csv', header = TRUE, sep = ',')
## NA values for blanks to match x(nrows)
data2 <- read.csv(file = 'email_calendar.csv', header = TRUE, sep = ',', na.strings = c('','NA')) 

xtsdata <- xts(data2, order.by = as.Date(data2$Date),"%d/%m/%y")
body = print(xtable(data,caption = '30 Day Tasks'),type='html',caption.placement='top')

However, the output looks like this:

Date (XTS)   Date    Task
0001-01-20  1/01/20 Road Trip
0001-10-19  1/10/19 Buy Groceries
0001-11-19  1/11/19 Meeting with manager
0002-01-20  2/01/20 NA
0002-03-20  2/03/20 Dentists
0002-10-19  2/10/19 NA
0002-12-19  2/12/19 Go to the Gym
0003-01-20  3/01/20 Buy Groceries
0003-02-20  3/02/20 Pick up kids

I cannot sort by the date and when I send the email to myself as a test, the dates are completely jumbled. I cannot figure out how to align the two date types together.

What I would like in the final version is the date ordered and to only show the next 30 days with no historical dates in the email.

Can anyone shed some light, thanks?

datacookies
  • 13
  • 1
  • 8

0 Answers0