Hello, I am new to R and am working on a homework assignment dealing with cleaning and transforming a dataset. Here is a glimpse of my dataset currently:
> glimpse(q4_2016)
Rows: 683,832
Columns: 20
$ ride_id <chr> "12979228", "12979227", "12979226", "12979225", "12…
$ started_at <chr> "12/31/2016 23:57:52", "12/31/2016 23:53:18", "12/3…
$ ended_at <chr> "1/1/2017 00:06:44", "1/1/2017 00:08:13", "1/1/2017…
$ rideable_type <chr> "5076", "5114", "1026", "504", "4451", "5643", "48"…
$ tripduration <dbl> 532, 895, 931, 970, 980, 179, 1863, 1867, 1656, 108…
$ start_staion_id <dbl> 502, 195, 195, 199, 199, 47, 177, 177, 195, 264, 15…
$ start_station_name <chr> "California Ave & Altgeld St", "Columbus Dr & Rando…
$ end_station_id <dbl> 258, 25, 25, 35, 35, 125, 140, 140, 195, 52, 42, 77…
$ end_station_name <chr> "Logan Blvd & Elston Ave", "Michigan Ave & Pearson …
$ member_casual <chr> "casual", "casual", "casual", "member", "member", "…
$ date <date> 2016-12-31, 2016-12-31, 2016-12-31, 2016-12-31, 20…
$ month <chr> "2016-12-31", "2016-12-31", "2016-12-31", "2016-12-…
$ day <chr> "31", "31", "31", "31", "31", "31", "31", "31", "31…
$ year <chr> "2016", "2016", "2016", "2016", "2016", "2016", "20…
$ day_of_week <chr> "Saturday", "Saturday", "Saturday", "Saturday", "Sa…
$ start_date <chr> "12/31/2016", "12/31/2016", "12/31/2016", "12/31/20…
$ start_time <chr> "23:57:52", "23:53:18", "23:53:07", "23:51:31", "23…
$ end_date <chr> "1/1/2017", "1/1/2017", "1/1/2017", "1/1/2017", "1/…
$ end_time <chr> "00:06:44", "00:08:13", "00:08:38", "00:07:41", "00…
$ ride_length <drtn> NA secs, NA secs, NA secs, NA secs, NA secs, NA se…
I am trying to change the 'ride_length' column to read as actual seconds and formatted as num. Here is the code chunk that got me to the glimpse up above:
q4_2016$ride_length <- as.difftime(q4_2016$ended_at,q4_2016$started_at)
I tried taking away the 'as.' in the 'as.difftime' function but it returns an error about not being in an standard unambiguous format. Is there something I am missing in my code chunk to fix this issue? Any help would be appreciated.