Skip to content

Converting sf to sp in rmarkdown #478

@jsta

Description

@jsta

I have two documents.

  • An Rmd file with the following:
library(sf)
x = st_sfc(st_point(c(5,5)), st_point(c(6,9)), crs = 4326)
as(x, "Spatial")
  • A build script with the following:
knitr::knit("test.Rmd", "test.md")

I am able to render the rmarkdown if I run knitr interactively. However, I if run the build script with Rscript I get an error:

## Error in as(x, "Spatial"): could not find function "as".

It does not seem to matter whether I set the envir argument to new.env() or globalenv().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions