Maurely Acosta Maurely Acosta - 10 days ago 5
R Question

how to display user defined title in r markdown?

I am new to R and R markdown. In my R code I used a textOutput so the user can enter a title in a blank field. The title is given to a variable called 'title'. How can I display that in an R markdown script that generates pdf, html, and doc files.

Thanks

SOLUTION:

In my Rmd file I wrote this:

r dfdrctitle$title
and in my server.R file I used this code to get the value for the textOutput:

drctitle <- as.character(input$drc.title)
dfdrctitle <- data.frame( title = drctitle)

Answer

Try this in the title field of your header. I believe that you can do this to output any r variable from a code chunk as text, even in a header.

---
title: `r title`
author: "your_name"
date: "11/18/2016"
output: pdf_document
---

R markdown: Accessing variable from code chunk (variable scope)

Comments