Maurely Acosta Maurely Acosta - 1 year ago 76
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.



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 Source

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)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download