各位大神,R语言小白在对照网站所给的代码编写时出现了自己解决不了的问题,求好心的大神帮忙解决
# World polygons from the maps package
> world_shp <- sf::st_as_sf(maps::map("world", plot = FALSE, fill = TRUE))
> # Specify location of data directory containing daily csv files.
> data_dir <- ("F:/yjs/data/fishing_effort/fishing_effort")
> # Create dataframe of filenames dates and filter to date range of interest
> effort_files <- 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 <- seq(ymd('2016-01-01'), ymd('2016-12-31'), by='days')
> # Filter to files within our date range of interest
> effort_files <- filter(effort_files, date %in% effort_dates)
> # Read in data (uncomment to read in parallel)
> plan(multisession)
> effort_df <- furrr::future_map_dfr(effort_files$file, .f = read_csv)
> # Add date information
> effort_df <- effort_df %>%
+ mutate(year = year(date),
+ month = month(date))
Error in as.POSIXlt.default(x, tz = tz(x)) :
do not know how to convert 'x' to class “POSIXlt”