Hi, I am trying to plot a time series from an excel spreadsheet using the code:
plot(number_of_births~birth.data$date, type = "1",
main='Daily total female births in califorina, 1959',
ylab = 'Number of births', xlab='Date')
When I run the code, I get the error "Error in (function (formula, data = NULL, subset = NULL, na.action = na.fail, : invalid type (NULL) for variable ' number of births". Does anyone know what is going wrong? I have included all of my code below:
library(astsa)
set working directory for the folder we will be working with, sets what folder we pull the excel file from
setwd("C:/Users/muirb/OneDrive/Documents/Coursera Time Series Analysis")
read in the datafile
#read.csv("daily-total-female-births-in-cal.csv")
#read data to R variable
birth.data<-read.csv("daily-total-female-births-in-cal.csv")
pull out number of births column
number_of_births<-birth.data$Daily.total.female.births.in.california..1959
use date format for dates
birth.data$date<-as.Date(birth.data$date, "%m/%d/%Y")
plot the series
plot(number_of_births~birth.data$date, type = "1",
main='Daily total female births in califorina, 1959',
ylab = 'Number of births', xlab='Date')
All of the code works up until the last three lines where I try to plot the time series. Does anyone have any ideas what I am doing wrong?
Thanks