Is it possible to populate an R-markdown file with code from a separate R script?
I am trying to generate a picture guide based on names stored in a data-frame and a list of photos. Each data-frame row of names refers to one photo.
Is it possible to populate an R-markdown file with code from a separate R script?
I am trying to generate a picture guide based on names stored in a data-frame and a list of photos. Each data-frame row of names refers to one photo.
If I am understanding your question correctly, you want to run an R script inside an R Markdown file? This can be done either by either of the following methods:
---
output: html_document
---
```{r}
source('myRscript.R')
```
Any objects defined in the R script will be made inside the R session running the R Markdown file. Does this answer your question?
Hi Matt,
Thanks for answering. Here's an example of my question with 2 animals:
#####R code
#this produces eg. dataframe
library(dplyr)
animal1<-c("cat","Felis catus", "gato", "mao", "cat.jpeg")
animal2<-c("dog", "Canis lupus familiaris", "perro", "go", "dog.jpeg")
all<-rbind(animal1,animal2)
colnames(all)<-c("English","Latin", "Spanish", "Chinese", "Image")
#url links to generic dog and cat picture
cat.jpeg<- .urlopener "https://unsplash.com/photos/IbPxGLgJiMI"
dog.jpeg<- .urlopener " https://tinyurl.com/t7ux7t8"
#code to convert each row into a populated page in Rmarkdown?
######## Rmarkdown format for page produced
Scientific name: Felis catus
Other names: Gato (Spanish), Mao (Chinese)
Scientific name: Canis lupus familiaris
Other names: Perro (Spanish), Go (Chinese)
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.