title: R error "do not know how to convert 'x' to class “POSIXlt”"
body: <p>I was trying to use R to map with some data saved as 'csv' format. Date in my data is in YYYY-dd-mm format.I want to add some data information,like 'year''month',I used the following code:</p>
  
  <pre><code> effort_df &lt;- effort_df %&gt;% 
    mutate(year  = year(date),
           month = month(date))
  </code></pre>
  
  <p>after running the code, I get the following error:</p>
  
  <blockquote>
    <p>Error in as.POSIXlt.default(x, tz = tz(x)) : 
      do not know how to convert 'x' to class “POSIXlt”</p>
  </blockquote>
  
  <p>And the complete codes are as followings:</p>
  
  <pre><code>#Load packages
  library(tidyverse) # for general data wrangling and plotting
  library(furrr) # for parallel operations on lists
  library(lubridate) # for working with dates
  library(sf) # for vector data 
  library(raster) # for working with rasters
  library(maps) # additional helpful mapping packages
  library(maptools)
  library(rgeos)
  
  
  # World polygons from the maps package
  world_shp &lt;- sf::st_as_sf(maps::map("world", plot = FALSE, fill = TRUE))
  # Load EEZ polygons
  eezs &lt;- read_sf("F:/data/shapefiles/World_EEZ_v10_20180221", layer = 'eez_v10') %&gt;% 
   filter(Pol_type == '200NM') # select the 200 nautical mile polygon layer
  # Specify location of data directory containing daily csv files.  
  data_dir &lt;- ("F:/yjs/data/fishing_effort/fishing_effort")
  # Create dataframe of filenames dates and filter to date range of interest
  effort_files &lt;- tibble(
   file = list.files(paste0(data_dir, 'fishing_effort_byflag'), 
                     pattern ='.csv', recursive = T, full.names = T),
   date =ymd(str_extract(file,
                          pattern = '[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}')))
  # Generate a vector of dates of interest using ymd from lubridate
  effort_dates &lt;- seq(ymd('2016-01-01'), ymd('2016-12-31'), by='days')
  
  # Filter to files within our date range of interest
  effort_files &lt;- filter(effort_files, date %in% effort_dates)
  
  # Read in data (uncomment to read in parallel)
  plan(multisession)
  effort_df &lt;- furrr::future_map_dfr(effort_files$file, .f = read_csv)
  class(effort_df$date)
  # Add date information
  effort_df &lt;- effort_df %&gt;% 
   mutate(year  = year(date),
          month = month(date))
  # Specify new (lower) resolution in degrees for aggregating data
  res &lt;- 0.25
  # Transform data across all fleets and geartypes
  effort_df &lt;- effort_df %&gt;% 
   mutate(
     lat_bin = lat_bin / 100, 
     lon_bin = lon_bin / 100,
     lat_bin = floor(lat_bin/res) * res + 0.5 * res, 
     lon_bin = floor(lon_bin/res) * res + 0.5 * res)
  # Re-aggregate the data to 0.25 degrees
  effort_df &lt;- effort_df %&gt;% 
   group_by(date, year, month, lon_bin, lat_bin, flag, geartype) %&gt;% 
   summarize(vessel_hours = sum(vessel_hours, na.rm = T),
             fishing_hours = sum(fishing_hours, na.rm = T),
             mmsi_present  = sum(mmsi_present, na.rm = T))
  # Aggregate data across all fleets and geartypes
  effort_all &lt;- effort_df %&gt;% 
   group_by(lon_bin,lat_bin) %&gt;% 
   summarize(fishing_hours = sum(fishing_hours, na.rm = T),
             log_fishing_hours = log10(sum(fishing_hours, na.rm = T))) %&gt;% 
   ungroup() %&gt;% 
   mutate(log_fishing_hours = ifelse(log_fishing_hours &lt;= 1, 1, log_fishing_hours),
          log_fishing_hours = ifelse(log_fishing_hours &gt;= 5, 5, log_fishing_hours)) %&gt;% 
   filter(fishing_hours &gt;= 24)
  
  # Linear green color palette function
  effort_pal &lt;- colorRampPalette(c('#0C276C', '#3B9088', '#EEFF00', '#ffffff'), 
                     interpolate = 'linear')
   # Map fishing effort
   p1 &lt;- effort_all %&gt;%
     ggplot() +
     geom_sf(data = world_shp, fill = '#374a6d', color = '#0A1738',size = 0.1) +
     geom_sf(data = eezs,color = '#374a6d',alpha = 0.2,fill = NA,size = 0.1) +
     geom_raster(aes(x=lon_bin,y=lat_bin,fill=log_fishing_hours)) +
     scale_fill_gradientn(
       "Fishing Hours",
       na.value = NA,limits &lt;- c(1, 5),colours = effort_pal(5),
         labels &lt;- c("10","100","1,000","10,000","100,000+"),values = scales::rescale(c(0, 1))) +
     labs(fill  = "Fishing hours (log scale)",
          title = "Global fishing effort in 2016") +
     guides(fill = guide_colourbar(barwidth = 10)) +
     gfw_theme
  </code></pre>
  
  <p>How can I solve this issue?</p>