rr-markdownshapefile

message in shapefile with st_read


I am working on Rmakdown, but when I make the pdf it prints messages that I cannot delete.

Reading layer `ine_barrios_mvd_nbi85' from data source `C:\Users\54427965\Desktop\Hom Barrios y Secc\BARRIOS\ine_barrios_mvd_nbi85.shp' using driver `ESRI Shapefile'
Simple feature collection with 62 features and 4 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 551982.7 ymin: 6133499 xmax: 589227.2 ymax: 6159810
CRS:           NA
[1] 0
[1] 0

I tried from chunk but it didn't work:

```{r warning=FALSE, echo=FALSE, message=FALSE, error=FALSE} 

Solution

  • That printout is not a warning, message nor error; and echo option is for including/excluding source code in rendered document.

    You can use include = FALSE option for chunks that should not appear in the rendered report :

    ---
    title: "st_read"
    output: pdf_document
    ---
    
    ```{r include = FALSE}
    library(sf)
    nc <- st_read(system.file("shape/nc.shp", package="sf"))
    ```
    
    ```{r}
    plot(nc$geometry)
    ```
    

    Renders as: screenshot of knitted RMarkdown document


    Check knitr manual for details on chunk options that control text output - https://yihui.org/knitr/options/#text-output