Hi, all, I'm trying to compose an Rmarkdown document and render it as a PDF file. My first block of R code seems to work okay, but the second on seems to be interpreted as LaTeX code, and not executed as R code. In the output, the three back-ticks that mark the R code block are interpreted as an opening double-quote, followed by an opening single quote.
Here's my test file: ================================ --- title: "An analysis of US 2020 Census Data for the Radnor-Winston neighborhood" author: "E. Kevin Zembower" date: "29 May 2023" output: pdf_document: extra_dependencies: ["array", "booktabs", "dcolumn"] --- ```{r setup, include = FALSE} ``` \section{Abstract} In this document, ... \section{Boundaries of the Radnor-Winston neighborhood} ... For the purposes of this report, the boundaries of RW are as shown in figure \ref{RWneigh}. ... ```{r rw_map, fig.width = 6, fig.height = 4, out.width = "80%", dev = "pdf", fig.cap = "Map of RW neighborhood\label{RWneigh}"} ## Creating a polygon for RW neighborhood, based on CRS 6487 (NAD83 ## (2011) / Maryland ) map in meters: base_x <- 433000 base_y <- 186000 rw_neigh_pg_m <- data.frame( matrix( c(540, 1140, 540, 1070, 480, 1060, 490, 1000, 570, 1000, 570, 940, 550, 930, 550, 890, 580, 890, 590, 820, 640, 820, 650, 590, 520, 580, 470, 580, 350, 660, 350, 710, 180, 725, 190, 900, 220, 900, 220, 1030, 240, 1030, 240, 1110 ), ncol = 2, byrow = TRUE) ) %>% + matrix(c(rep(base_x, nrow(.)), rep(base_y, nrow(.))), nrow = nrow(.)) %>% sf::st_as_sf(coords = c(1,2), dim = "XY") %>% summarize(geometry = st_combine(geometry)) %>% st_cast("POLYGON") %>% st_set_crs(6487) ## Map it: rw_base_blocks <- read_osm(bb(rw_neigh_pg_m, ext = 1.3)) ## Line below gives map in meters (RW_block_map <- tm_shape(rw_base_blocks, projection = 6487) + ## Line below gives map in degrees ## (RW_block_map <- tm_shape(rw_base_blocks, projection = 6487) + tm_rgb() + tm_shape(rw_neigh_pg_m) + tm_fill(col = "green", alpha = 0.2) + tm_borders(lwd = 2, alpha = 1) + tm_scale_bar() + ## tm_grid() + tm_xlab("Long") + tm_ylab("Lat") + tm_grid() + tm_layout(title = "Radnor-Winston Neighborhood") ) ## tmap_save(RW_block_map, "rw_map.png") ``` ==================================================== This code block can also be obtained from https://gist.github.com/kzembower/f9ad52abf82975102cbf715bcfbc0f51. I'm using Emacs and ESS to create this document. This seems to produce its own weirdness, as the text style and font color and sizes change in the R code block as I edit it and add spaces and lines. If the block above is saved as "RW_test.Rmd", I use these lines to create the PDF: =============================== library(rmarkdown) render("RW_test.Rmd") ================================ No errors are generated. Can anyone help me understand what I'm doing wrong? A much shorter test file I created seems to work okay. Thanks in advance for any advice. -Kevin > sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.2 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8 LC_ADDRESS=en_US.UTF-8 [10] LC_TELEPHONE=en_US.UTF-8 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8 time zone: America/New_York tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] kableExtra_1.3.4 tidycensus_1.4 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.2 [7] purrr_1.0.1 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.2 tidyverse_2.0.0 [13] rmarkdown_2.22 loaded via a namespace (and not attached): [1] gtable_0.3.3 xfun_0.39 raster_3.6-20 tigris_2.0.3 rJava_1.0-6 [6] lattice_0.21-8 tzdb_0.4.0 vctrs_0.6.2 tools_4.3.0 generics_0.1.3 [11] curl_5.0.0 proxy_0.4-27 fansi_1.0.4 pkgconfig_2.0.3 KernSmooth_2.23-21 [16] webshot_0.5.4 uuid_1.1-0 lifecycle_1.0.3 compiler_4.3.0 munsell_0.5.0 [21] tinytex_0.45 terra_1.7-29 codetools_0.2-19 htmltools_0.5.5 class_7.3-22 [26] yaml_2.3.7 crayon_1.5.2 pillar_1.9.0 classInt_0.4-9 tidyselect_1.2.0 [31] rvest_1.0.3 digest_0.6.31 stringi_1.7.12 sf_1.0-13 fastmap_1.1.1 [36] grid_4.3.0 colorspace_2.1-0 cli_3.6.1 magrittr_2.0.3 utf8_1.2.3 [41] e1071_1.7-13 withr_2.5.0 scales_1.2.1 rappdirs_0.3.3 sp_1.6-1 [46] timechange_0.2.0 httr_1.4.6 hms_1.1.3 OpenStreetMap_0.3.4 evaluate_0.21 [51] knitr_1.43 rgdal_1.6-7 viridisLite_0.4.2 rlang_1.1.1 Rcpp_1.0.10 [56] glue_1.6.2 DBI_1.1.3 xml2_1.3.4 svglite_2.1.1 rstudioapi_0.14 [61] jsonlite_1.8.4 R6_2.5.1 systemfonts_1.0.4 units_0.8-2 > ______________________________________________ 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.