Center ppt slide title - r

Using ReporteRs package we can create power point presenation from R code.
I tried to create a power point slide having a centered title.
Here the basic code I am using to create the slide:
library( ReporteRs )
mydoc = pptx( ) # try adding argument: template = 'template.pptx' here
mydoc = addSlide( mydoc, "Title and Content" )
mydoc = addTitle( mydoc, "This is a title" )
writeDoc( mydoc, "pp_simple_example.pptx" )
This creates a slide with title positioned at the left. Unfortunately addTitle don't expose any argument to format text or change its position. I looked also in the package options :
options()[grep('ReporteRs',names(options()))]
but without success.

One solution is to use a predefined template (as commented below my question)
To create a template:
Create a presentation
Choose a template where the text is centered. You can add a dummy slide with text and choose one from the predefined themes ( Design tab)
Don't forget to remove the slide. and save the presentation as basic_template.ppx
Now in the R code to use this template :
mydoc = pptx( template='basic_template.pptx') ## give the whole path here

Related

DT outputtable in r Shiny bleeds out of shiny box

I am having an issue where the data for my DT table is "bleeding" past the edge of the box in my fluid row.
Here is the tabPanel section
tabPanel("Table title", h1('dataset', style = 'color: #23A595'),
p('Here we will have a paragraph of explanatory text to talk about the graphs below. Here we will have a paragraph of explanatory text to talk about the graphs below. Here we will have a paragraph of explanatory text to talk about the graphs below. Here we will have a paragraph of explanatory text to talk about the graphs below. Here we will have a paragraph of explanatory text to talk about the graphs below.', style = 'color: black'),
fluidRow(
box(DT::dataTableOutput(outputId = "table"), width = NULL, solidHeader = TRUE, status = "primary"),
),
When the app is run here is the result of the render DT.
Here is what the data set looks like.
The red box highlights the issue.
Here is what i have tried:
First,
output$table<- renderDT(
outputtable,options = list(columns.width = "3px"
),
rownames= FALSE
)
Second,
fluidRow(box(DT::dataTableOutput(outputId = "table"),width = #),
)
I was under the impression that shiny just automatically calculates the size needed despite window size an such.
in simple terms, shiny creates box + add DT table to box = box with DT table INSIDE of it.
I want the highlighted issue to not happen what do I need to do?
If there is anything I can add let me know.
The scrollX comment above answered the question.

How to use a vertical layout stepper within R Shiny?

I would like to create a nice vertical stepper (like that) within my Shiny app, for which some of the steps would be displaying R/shiny widget/reactive values (such as graphs, tables, etc.). Is there any specific widget that allows that?
It could looks like something like this within ui.R:
ShinyStepper(vertical = TRUE,
linear = TRUE,
theme = "default",
step1.title = "Title of first step",
step1.body = {
h3("This is a reactive barplot"),
plotOutput(outputId = "reactive_barplot")
},
step2.title = ...
)

Shiny Application: Add logo to each choice of selectizeInput

I create a shiny app and I need to add a language option. I would like add a selectizeInput like :
selectizeInput("language",
"Select language:",
choices = c("English"="en","Français"="fr"),
selected = app_default_languague, multiple=FALSE, width = '70%'
)
but with flags in front of each country. Flags logo are in "www/" directory. Do you know how i can make this please ?
There is an example in Rstudio gallery but i don't understand it ....
http://shiny.rstudio.com/gallery/selectize-rendering-methods.html
selectizeInput is based on the Javascript library selectize.js which has powerful settings including templates to render your own options and the selected item.
In order to do that you have to use a bit of Javascript code. This code is stored in rendersjsItem. That is a Javascript function that generates and returns a piece of HTML like this:
<div class="option">
<img width="25" height="25" class="flag" src="fr.svg" />
French
</div>
This assumes that your files are located in the www folder with the country code as name, e.g. "fr.svg". The example below specifies names and country codes in the vector countries.
All you need to do is take rendersjsItem and use it as render option for the selectizeInput. If you want to change the styling you can modify the CSS of the flag class.
Full Solution
library(shiny)
countries <- c(German = "de", Czech = "cz", French = "fr")
app_default_languague <- "cz"
# Assuming the flag icons are directly in the 'www' folder with names "de.svg", "cz.svg", etc.
rendersjsItem <-
I("{
option: function(item, escape) {
return '<div class=\"option\"><img width=\"25\" height=\"25\" class=\"flag\"' +
'src=\"' + item.value + '.svg\" />' +
item.label + '</div>';
}
}")
ui <- fluidPage(
tags$head(
# Add CSS to format the language selection options with flag + text
tags$style(HTML(".flag {height:24px; width:24px; margin-right: 12px}"))
),
title = "Selectize Test",
selectizeInput("language", "Select language",
choices = countries,
selected = app_default_languague, multiple=FALSE, width = "70%",
options = list(
placeholder = "Type a language name, e.g. German",
render = rendersjsItem
)),
textOutput("SelectedLanguage")
)
server <- function(input, output, session) {
output$SelectedLanguage <- renderText(input$language)
}
shinyApp(ui, server)
Side Note
The World Wide Web Consortium (W3C) recommends that flag icons should not be used to indicate languages. There are multiple reason. Instead, use the name of the language in it's target language, i.e. do not write "German" but "Deutsch". Examples: Deutsch, English, Español, Français, Italiano, ...
See also ux.stackexchange.
Import them using jpeg library and and create a vector

Change line spacing in footnote of docx using ReporteRs in R

In a word document, I want single spaced footnotes while the body of the document is 1.5 spaced.
No matter what I try, the footnote spacing stays at 1.15 spacing instead of single spacing.
I've tried changing the style of the footnote and changing the padding around each line of the footnote (treating each as a different paragraph). Styles don't seem to work on footnotes and changing the padding to zero still left the default 1.15 space between each "paragraph."
My current code:
footnote1 = Footnote()
footnote1 = addParagraph( footnote1,
value = pot("footnote text",
textProperties(font.size = 10, font.family = "Arial"))
)
doc <- addParagraph( doc,
value = "\tparagraph text" +
pot("addfootnotehere.", footnote = footnote1 ) +
"more text.",
stylename = "NormalLeft",
bookmark = "paragraph1"
)
Your problem may be fixed if you used your own created template instead of the default doc <- docx().
Set up a template with the spacing required, save it, then call the newly created template with:
doc <- docx(template = 'D:/docs/template/my_corporate_template.docx')
then addFootnote should read your template sizing without auto correcting.

Add new line to text in UI of shiny app

is there a way to add a new line when putting text through the UI?
I currently have something like
mainPanel(
h3("This is my app!\n\n"),
h4("Download your data using the choose file button\n\n"),
h4("Thank you for using the app!")
)
but the new lines don't seem to be working.
\n doesn't work in shiny app.
For the new line, you could use HTML tag <br/>:
mainPanel(
HTML(
paste(
h3("This is my app!"),'<br/>',
h4("Download your data using the choose file button"),'<br/>',
h4("Thank you for using the app!")
)
)
)

Resources