Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Created August 8, 2018 14:19
Show Gist options
  • Select an option

  • Save yutannihilation/35a9e30ce329204e022d33e7b79e24e7 to your computer and use it in GitHub Desktop.

Select an option

Save yutannihilation/35a9e30ce329204e022d33e7b79e24e7 to your computer and use it in GitHub Desktop.
Use knitr's output hook to hide path
library(sf)
## Linking to GEOS 3.6.1, GDAL 2.2.3, proj.4 4.9.3
nc <- st_read(system.file("shape/nc.shp", package="sf"))
## Reading layer `nc' from data source `C:\path\to\R\win-library\3.5\sf\shape\nc.shp' using driver `ESRI Shapefile'
## Simple feature collection with 100 features and 14 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
## epsg (SRID):    4267
## proj4string:    +proj=longlat +datum=NAD27 +no_defs
---
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
orig_hook <- knitr::knit_hooks$get("output")
knitr::knit_hooks$set(
output = function(x, options) {
x <- orig_hook(x, options)
ptn <- normalizePath(Sys.getenv("HOME"))
gsub(ptn, "C:\\path\\to", x, fixed = TRUE)
}
)
```
```{r}
library(sf)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment