Anyone see what I might be doing wrong? Corrupted rds file maybe. The error
would suggest I'm using an older version of R except I'm running both the
latest RStudio and R versions.

# Load in the tidyverse, raster, and sf packages
library(tidyverse)
library(raster)
library(sf)

# Read the climate data from an rds file
climate <- readRDS("Datasets/climate_raster.rds")

# Have a look at the variables in the climate data
colnames(climate)

# Convert to SpatialPixelDataFrame for plotting
climate_df <- mutate(
  .data = climate, 
  rasters = map(
    .x = rasters, 
    ~ as_tibble(as(.x, "SpatialPixelsDataFrame")))) %>%
  unnest(cols = c(rasters))

> climate <- readRDS("Datasets/climate_raster.rds")
Error in readRDS("Datasets/climate_raster.rds") : 
  ReadItem: unknown type 0, perhaps written by later version of R

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to