csgillespie/efficientR

1.6.3 - missing extdata/out-ice.Rds

engineerchange opened this issue · 1 comments

Code snippet in 1.6.3 references an Rds: extdata/out-ice.Rds, which doesn't appear in the current repo.

Code snippet from 1.6.3:

library("profvis")
profvis(expr = {
  
  # Stage 1: load packages
  # library("rnoaa") # not necessary as data pre-saved
  library("ggplot2")
  
  # Stage 2: load and process data
  out = readRDS("extdata/out-ice.Rds")
  df = dplyr::rbind_all(out, id = "Year")
  
  # Stage 3: visualise output
  ggplot(df, aes(long, lat, group = paste(group, Year))) +
    geom_path(aes(colour = Year)) 
  ggsave("figures/icesheet-test.png")
}, interval = 0.01, prof_output = "ice-prof")

Minor tweaks and it works 🎉

if(!file.exists("extdata/out-ice.Rds")) {
  library("rnoaa")
  library("ggplot2")
  yrs = seq(1985, 2019, by = 10)
  out = sapply(yrs, function(x)
    sea_ice(year = x, mo = 'Sep', pole = 'N'))
  names(out) = yrs
  dir.create("extdata")  
  saveRDS(out, "extdata/out-ice.Rds")
} else {
  out = readRDS("extdata/out-ice.Rds")
}
#> Warning in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS =
#> dumpSRS, : Discarded ellps Hughes 1980 in CRS definition: +proj=stere +lat_0=90
#> +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs
#> Warning in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS =
#> dumpSRS, : Discarded datum Not_specified_based_on_Hughes_1980_ellipsoid in CRS
#> definition: +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273
#> +b=6356889.449 +units=m +no_defs
#> Warning in showSRID(wkt2, "PROJ"): Discarded ellps Hughes 1980 in CRS
#> definition: +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273
#> +rf=298.279411123064 +units=m +no_defs
#> Warning in showSRID(wkt2, "PROJ"): Discarded datum
#> Not_specified_based_on_Hughes_1980_ellipsoid in CRS definition
#> Regions defined for each Polygons
#> Warning in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS =
#> dumpSRS, : Discarded ellps Hughes 1980 in CRS definition: +proj=stere +lat_0=90
#> +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs
#> Warning in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS =
#> dumpSRS, : Discarded datum Not_specified_based_on_Hughes_1980_ellipsoid in CRS
#> definition: +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273
#> +b=6356889.449 +units=m +no_defs
#> Warning in showSRID(wkt2, "PROJ"): Discarded ellps Hughes 1980 in CRS
#> definition: +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273
#> +rf=298.279411123064 +units=m +no_defs
#> Warning in showSRID(wkt2, "PROJ"): Discarded datum
#> Not_specified_based_on_Hughes_1980_ellipsoid in CRS definition
#> Regions defined for each Polygons
#> Warning in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS =
#> dumpSRS, : Discarded ellps Hughes 1980 in CRS definition: +proj=stere +lat_0=90
#> +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs
#> Warning in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS =
#> dumpSRS, : Discarded datum Not_specified_based_on_Hughes_1980_ellipsoid in CRS
#> definition: +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273
#> +b=6356889.449 +units=m +no_defs
#> Warning in showSRID(wkt2, "PROJ"): Discarded ellps Hughes 1980 in CRS
#> definition: +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273
#> +rf=298.279411123064 +units=m +no_defs
#> Warning in showSRID(wkt2, "PROJ"): Discarded datum
#> Not_specified_based_on_Hughes_1980_ellipsoid in CRS definition
#> Regions defined for each Polygons
#> Warning in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS =
#> dumpSRS, : Discarded ellps Hughes 1980 in CRS definition: +proj=stere +lat_0=90
#> +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs
#> Warning in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS =
#> dumpSRS, : Discarded datum Not_specified_based_on_Hughes_1980_ellipsoid in CRS
#> definition: +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273
#> +b=6356889.449 +units=m +no_defs
#> Warning in showSRID(wkt2, "PROJ"): Discarded ellps Hughes 1980 in CRS
#> definition: +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +x_0=0 +y_0=0 +a=6378273
#> +rf=298.279411123064 +units=m +no_defs
#> Warning in showSRID(wkt2, "PROJ"): Discarded datum
#> Not_specified_based_on_Hughes_1980_ellipsoid in CRS definition
#> Regions defined for each Polygons
df = dplyr::rbind_all(out, id = "Year")
#> Warning: 'dplyr::rbind_all' is deprecated.
#> Use 'bind_rows()' instead.
#> See help("Deprecated")
#> Warning in bind_rows_(x, id = id): Unequal factor levels: coercing to character
#> Warning in bind_rows_(x, id = id): binding character and factor vector, coercing
#> into character vector

#> Warning in bind_rows_(x, id = id): binding character and factor vector, coercing
#> into character vector
#> Warning in bind_rows_(x, id = id): Unequal factor levels: coercing to character
#> Warning in bind_rows_(x, id = id): binding character and factor vector, coercing
#> into character vector

#> Warning in bind_rows_(x, id = id): binding character and factor vector, coercing
#> into character vector

#> Warning in bind_rows_(x, id = id): binding character and factor vector, coercing
#> into character vector

#> Warning in bind_rows_(x, id = id): binding character and factor vector, coercing
#> into character vector

#> Warning in bind_rows_(x, id = id): binding character and factor vector, coercing
#> into character vector

#> Warning in bind_rows_(x, id = id): binding character and factor vector, coercing
#> into character vector
xlims = quantile(df$lat, probs = c(0.01, 0.90))
ylims = quantile(df$long, probs = c(0.01, 0.99))
ggplot(df, aes(long, lat, group = paste(group, Year))) +
  geom_path() +
  geom_polygon(aes(fill = Year), alpha = 0.3) +
  xlim(xlims) +
  ylim(ylims) +
  scale_fill_brewer(type = "seq") +
  theme_minimal() +
  theme(axis.title = element_blank(),
        axis.text = element_blank())
#> Warning: Removed 656 row(s) containing missing values (geom_path).

ggsave("figures/icesheet-change.png")
#> Saving 7 x 5 in image
#> Error in grid.newpage(): could not open file 'figures/icesheet-change.png'

Created on 2020-05-03 by the reprex package (v0.3.0)