I have a dataset (Crime) with 6,847,944 observations. I am trying to downsize this data to only those occurring in the relevant year of 2016. The dates can be found in the "Date" column. I have tried all of the following for code:
#change dates to proper format#
Crime$Date = as.Date(Crime$Date, format = "%m/%d/%y")
#filter crimes to 2016#
ATTEMPT 1: Crime16 = subset(Crime$Date = as.Date("2016"))
RESULT 1: Error: unexpected '=' in "Crime16 = subset(Crime$Date ="
ATTEMPT 2: Crimes_2016 <- Crime[year(Date)==2016,]
RESULT 2: Error in as.POSIXlt.default(x, tz = tz(x)) : do not know how to convert 'x' to class “POSIXlt”
ATTEMPT 3: Crimes_2016 = subset(Crime, Date >=2016/1/1 & Date <= 2016/31/12)
RESULT 3: Creates data frame, but contains no observations.
ATTEMPT 4: morecrimes = subset(Crime, Date == 2016)
RESULT 4: Creates data frame, but contains no observations.
ATTEMPT 5: Crimes.2016 = selectByDate(Crime$Date = 2016)
RESULT 5: Error: unexpected '=' in "Crimes.2016 = selectByDate(Crime$Date ="