Type: | Package |
Title: | Reproducible Research with a Table of R Codes |
Version: | 0.3.0 |
Imports: | stringr, ggplot2 (≥ 2.2.0), officer (≥ 0.4.1), purrr (≥ 0.2.4), flextable (≥ 0.4.4), rvg, magrittr, devEMF, moonBook (≥ 0.1.8), rmarkdown, shiny, editData, shinyWidgets, ggpubr, rlang, readr (≥ 1.1.1), ztable (≥ 0.1.8) |
Description: | Makes documents containing plots and tables from a table of R codes. Can make "HTML", "pdf('LaTex')", "docx('MS Word')" and "pptx('MS Powerpoint')" documents with or without R code. In the package, modularized 'shiny' app codes are provided. These modules are intended for reuse across applications. |
Depends: | R(≥ 2.10) |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.1.2 |
VignetteBuilder: | knitr |
Suggests: | knitr |
NeedsCompilation: | no |
Packaged: | 2022-04-05 01:16:45 UTC; cardiomoon |
Author: | Keon-Woong Moon [aut, cre] |
Maintainer: | Keon-Woong Moon <cardiomoon@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2022-04-05 02:30:02 UTC |
Convert HTML table to latex table
Description
Convert HTML table to latex table
Usage
HTMLcode2latex(data)
Arguments
data |
a data.frame |
Make a data.frame with character strings encoding R code
Description
Make a data.frame with character strings encoding R code
Usage
Rcode2df(result, eval = TRUE)
Arguments
result |
character strings encoding R code |
eval |
logical. Whether or not evaluate the code |
Make a data.frame with character strings encoding R code
Description
Make a data.frame with character strings encoding R code
Usage
Rcode2df2(result, eval = TRUE)
Arguments
result |
character strings encoding R code |
eval |
logical. Whether or not evaluate the code |
Save R code to Microsoft Word format
Description
Save R code to Microsoft Word format
Usage
Rcode2docx(...)
Arguments
... |
further arguments to be passed to plot2office |
Examples
## Not run:
code="summary(lm(mpg~hp+wt,data=mtcars))"
Rcode2docx(code=code,title="R code to Word")
## End(Not run)
Make a flextable object with character strings encoding R code
Description
Make a flextable object with character strings encoding R code
Usage
Rcode2flextable(result, format = "pptx", eval = TRUE)
Arguments
result |
character strings encoding R code |
format |
desired format. choices are "pptx" or "docx" |
eval |
logical. Whether or not evaluate the code |
Examples
Rcode2flextable("str(mtcars)\nsummary(mtcars)",eval=FALSE)
Make R code slide
Description
Make R code slide
Usage
Rcode2office(
code,
preprocessing = "",
title = "",
type = "pptx",
target = "Report",
append = FALSE
)
Arguments
code |
A character string encoding R codes |
preprocessing |
A character string of R code as a preprocessing |
title |
A character |
type |
desired format. choices are "pptx" or "docx" |
target |
name of output file |
append |
logical |
Examples
## Not run:
code="summary(lm(mpg~hp+wt,data=mtcars))"
Rcode2office(code=code)
## End(Not run)
Save R code to Microsoft Powerpoint format
Description
Save R code to Microsoft Powerpoint format
Usage
Rcode2pptx(...)
Arguments
... |
further arguments to be passed to plot2office |
Examples
## Not run:
code="summary(lm(mpg~hp+wt,data=mtcars))"
Rcode2pptx(code=code,title="R code to pptx")
## End(Not run)
Add two flextables into a document object
Description
Add two flextables into a document object
Usage
add_2flextables(mydoc, ft1, ft2, echo = FALSE, width = 3, code = "")
Arguments
mydoc |
A document object |
ft1 |
The first flextable |
ft2 |
The second flextable |
echo |
whether or not display R code |
width |
plot width in inches |
code |
R code string |
Value
a document object
Examples
## Not run:
require(rrtable)
require(officer)
require(magrittr)
title="Two Tables"
ft1=df2flextable(head(iris[1:4]))
ft2=df2flextable(tail(iris[1:4]))
doc=read_docx()
doc %>% add_text(title=title) %>%
add_2flextables(ft1,ft2)
doc=read_pptx()
doc %>% add_text(title=title) %>%
add_2flextables(ft1,ft2)
## End(Not run)
Add two ggplots into a document object
Description
Add two ggplots into a document object
Usage
add_2ggplots(mydoc, plot1, plot2, width = 3, height = 2.5, top = 2)
Arguments
mydoc |
A document object |
plot1 |
An R code encoding the first ggplot |
plot2 |
An R code encoding the second ggplot |
width |
plot width in inches |
height |
plot height in inches |
top |
top plot position in inches |
Value
a document object
Examples
## Not run:
require(ggplot2)
require(magrittr)
require(officer)
require(rvg)
plot1 <- "ggplot(data = iris, aes(Sepal.Length, Petal.Length)) + geom_point()"
plot2 <- "ggplot(data = iris, aes(Sepal.Length, Petal.Length, color = Species)) + geom_point()"
read_pptx() %>% add_text(title="Two ggplots") %>% add_2ggplots(plot1=plot1,plot2=plot2)
read_docx() %>% add_text(title="Two ggplots") %>% add_2ggplots(plot1=plot1,plot2=plot2)
## End(Not run)
Add two plots into a document object
Description
Add two plots into a document object
Usage
add_2plots(
mydoc,
plotstring1,
plotstring2,
plottype = "auto",
width = NULL,
height = NULL,
echo = FALSE,
top = 2
)
Arguments
mydoc |
A document object |
plotstring1 |
An R code string encoding the first plot |
plotstring2 |
An R code string encoding the second plot |
plottype |
character One of c("auto","plot","ggplot") |
width |
plot width in inches |
height |
plot height in inches |
echo |
logical Whether or not show R code |
top |
top plot position in inches |
Value
a document object
Examples
require(magrittr)
require(officer)
require(ggplot2)
plotstring1="plot(iris)"
plotstring2="ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width))+geom_point()"
read_pptx() %>% add_text(title="Two plots") %>% add_2plots(plotstring1,plotstring2)
read_docx() %>% add_text(title="Two plots") %>% add_2plots(plotstring1,plotstring2)
Make a R code slide into a document object
Description
Make a R code slide into a document object
Usage
add_Rcode(mydoc, code, format = "pptx")
Arguments
mydoc |
A document object |
code |
A character string encoding R codes |
format |
desired format. choices are "pptx" or "docx" |
Value
a document object
Examples
library(rrtable)
library(magrittr)
library(officer)
code="summary(lm(mpg~hp+wt,data=mtcars))"
read_pptx() %>% add_text(title="Regression Analysis") %>%
add_Rcode(code)
Add a ggplot or a plot to the Microsoft Office Document
Description
Add a ggplot or a plot to the Microsoft Office Document
Usage
add_anyplot(
doc,
x = NULL,
plottype = "auto",
left = 1,
top = 2,
width = 8,
height = 5.5
)
Arguments
doc |
A document object |
x |
An object of class ggplot2 or a string encoding plot or ggplot |
plottype |
character One of c("auto","plot","ggplot","emf") |
left |
left margin |
top |
top margin |
width |
desired width of the plot |
height |
desired height of the plot |
Add a flextable or mytable object into a document object
Description
Add a flextable or mytable object into a document object
Usage
add_flextable(mydoc, ftable, echo = FALSE, code = "", landscape = FALSE)
Arguments
mydoc |
A document object |
ftable |
A flextable or mytable object |
echo |
whether or not display R code |
code |
R code string |
landscape |
Logical. Whether or not make a landscape section. |
Value
a document object
Examples
## Not run:
require(rrtable)
require(moonBook)
require(officer)
require(magrittr)
ftable=mytable(Dx~.,data=acs)
title="mytable Example"
ft=df2flextable(head(iris))
title2="df2flextable Example"
doc=read_docx()
doc %>% add_text(title=title) %>%
add_flextable(ftable) %>%
add_text(title=title2) %>%
add_flextable(ft)
## End(Not run)
Add ggplot into a document object
Description
Add ggplot into a document object
Usage
add_ggplot(mydoc, code = "", top = 2)
Arguments
mydoc |
A document object |
code |
R code for table |
top |
top position of plot |
Value
a document object
Examples
require(rrtable)
require(ggplot2)
require(officer)
require(magrittr)
code <- "ggplot(mtcars, aes(x = mpg , y = wt)) + geom_point()"
read_pptx() %>% add_text(title="ggplot") %>% add_ggplot(code=code)
read_docx() %>% add_text(title="ggplot") %>% add_ggplot(code=code)
Add plot into a document object
Description
Add plot into a document object
Usage
add_image(
mydoc,
x = NULL,
preprocessing = "",
left = 1,
top = 2,
width = 8,
height = 5.5,
units = "in",
res = 300,
format = "emf",
...
)
Arguments
mydoc |
A document object |
x |
An string of R code encoding plot |
preprocessing |
A string of R code or "" |
left |
left margin |
top |
top margin |
width |
the width of the device. |
height |
the height of the device. |
units |
The units in which height and width are given. Can be px (pixels, the default), in (inches), cm or mm. |
res |
The nominal resolution in ppi which will be recorded in the bitmap file, if a positive integer. Also used for units other than the default, and to convert points to pixels. |
format |
plot format |
... |
additional arguments passed to png() |
Value
a document object
Examples
require(officer)
require(rrtable)
require(magrittr)
require(ggplot2)
read_pptx() %>% add_text(title="Add image") %>% add_image("plot(iris)")
read_docx() %>% add_text(title="Add image") %>% add_image("plot(1:10)",format="png")
Add plot into a document object
Description
Add plot into a document object
Usage
add_plot(mydoc, plotstring, width = 6, height = 6, top = 2)
Arguments
mydoc |
A document object |
plotstring |
String of an R code encoding a plot |
width |
width of plot |
height |
height of plot |
top |
top position of plot |
Value
a document object
Examples
require(rrtable)
require(officer)
require(rvg)
require(magrittr)
read_pptx() %>% add_text(title="Plot") %>% add_plot("plot(iris)")
read_docx() %>% add_text(title="Plot") %>% add_plot("plot(iris)")
add self data to document
Description
add self data to document
Usage
add_self(mydoc, data)
Arguments
mydoc |
A document object |
data |
a data.frame |
Add text to document
Description
Add text to document
Usage
add_text(
mydoc,
title = "",
text = "",
code = "",
echo = FALSE,
eval = FALSE,
style = "Normal",
landscape = FALSE
)
Arguments
mydoc |
A document object |
title |
An character string as a plot title |
text |
text string to be added |
code |
An R code string |
echo |
logical Whether or not show R code |
eval |
logical whether or not evaluate the R code |
style |
text style |
landscape |
Logical. Whether or not make a landscape section. |
Add hyperlink text
Description
Add hyperlink text
Usage
add_text2hyperlink(mydoc, text)
Arguments
mydoc |
A document object |
text |
text string to be added |
Add title to docx file
Description
Add title to docx file
Usage
add_title(x, title = "", size = 20, color = NULL, before = TRUE, after = TRUE)
Arguments
x |
A document object |
title |
Title |
size |
font size |
color |
font color |
before |
Whether or not add blank paragraph before title |
after |
Whether or not add blank paragraph after title |
Add title slide
Description
Add title slide
Usage
add_title_slide(mydoc, title = "", subtitle = "")
Arguments
mydoc |
A document object |
title |
An character string as a title |
subtitle |
An character string as a subtitle |
Examples
require(magrittr)
require(officer)
read_pptx() %>% add_title_slide(title="Web-based analysis with R")
coerce an object of type "numeric"
Description
coerce an object of type "numeric"
Usage
as.mynumeric(x)
Arguments
x |
A vector |
Examples
x=c("1,200","2","3.5")
x=factor(3:1)
x=c(1:3,"tt")
as.mynumeric(x)
Server function of chooser Module
Description
Server function of chooser Module
Usage
chooser(
input,
output,
session,
leftChoices,
rightChoices = reactive(c()),
size = reactive(0),
width = reactive(130)
)
Arguments
input |
input |
output |
output |
session |
session |
leftChoices |
choices for left column |
rightChoices |
choices for right column |
size |
number of column lines to be displayed |
width |
width of left and right columns in pixel |
Server function of chooser2 Module
Description
Server function of chooser2 Module
Usage
chooser2(
input,
output,
session,
leftChoices,
rightChoices = reactive(c()),
size = reactive(0),
width = reactive(130)
)
Arguments
input |
input |
output |
output |
session |
session |
leftChoices |
choices for left column |
rightChoices |
choices for right column |
size |
number of column lines to be displayed |
width |
width of left and right columns in pixel |
UI of chooser2 Module Add 'all select' and 'reset' button to chooser module
Description
UI of chooser2 Module Add 'all select' and 'reset' button to chooser module
Usage
chooser2UI(id)
Arguments
id |
id |
Chooser Input
Description
Chooser Input
Usage
chooserInput(
inputId,
leftLabel,
rightLabel,
leftChoices,
rightChoices,
size = 5,
multiple = FALSE,
width = 100
)
Arguments
inputId |
input Id |
leftLabel |
Label for left column |
rightLabel |
Label for right column |
leftChoices |
choices for left column |
rightChoices |
choices for right column |
size |
number of column lines to be displayed |
multiple |
logical enable multiple selection |
width |
width of left and right columns in pixel |
UI of chooser Module
Description
UI of chooser Module
Usage
chooserUI(id)
Arguments
id |
id |
Save plot/ggplot code to Microsoft Powerpoint format
Description
Save plot/ggplot code to Microsoft Powerpoint format
Usage
code2docx(...)
Arguments
... |
further arguments to be passed to code2office |
Examples
## Not run:
code2docx(plot(iris))
require(ggplot2)
gg=ggplot(data=mtcars,aes(x=wt,y=mpg))+geom_point()
code2docx(ggobj=gg)
## End(Not run)
Save plot/ggplot code to Microsoft Powerpoint format
Description
Save plot/ggplot code to Microsoft Powerpoint format
Usage
code2office(
...,
ggobj = NULL,
target = "Report",
append = FALSE,
title = "",
type = "pptx",
preprocessing = "",
plottype = "auto",
echo = FALSE,
parallel = FALSE,
left = 1,
top = 1,
width = NULL,
height = NULL,
aspectr = NULL
)
Arguments
... |
Further argument to be passed to function dml() |
ggobj |
a ggplot object |
target |
name of output file |
append |
logical value |
title |
Optional character vector of plot title |
type |
"pptx" or "docx" |
preprocessing |
A string of R code or "" |
plottype |
character One of c("auto","plot","ggplot","emf") |
echo |
logical. If true, show code. |
parallel |
logical. If true, add two plots side by side |
left |
left margin |
top |
top margin |
width |
desired width of the plot |
height |
desired height of the plot |
aspectr |
desired aspect ratio of the plot |
Examples
## Not run:
code2office(plot(iris))
require(ggplot2)
gg=ggplot(data=mtcars,aes(x=wt,y=mpg))+geom_point()
code2office(ggobj=gg)
## End(Not run)
Save plot/ggplot code to Microsoft Powerpoint format
Description
Save plot/ggplot code to Microsoft Powerpoint format
Usage
code2pptx(...)
Arguments
... |
further arguments to be passed to code2office |
Examples
## Not run:
code2pptx(plot(iris))
require(ggplot2)
gg=ggplot(data=mtcars,aes(x=wt,y=mpg))+geom_point()
code2pptx(ggobj=gg)
## End(Not run)
Make a HTML5 file with a data.frame
Description
Make a HTML5 file with a data.frame
Usage
data2HTML(
data,
preprocessing = "",
path = ".",
filename = "report.HTML",
rawDataName = NULL,
rawDataFile = "rawData.RDS",
type = "HTML",
vanilla = FALSE,
echo = TRUE,
showself = FALSE,
out = NULL
)
Arguments
data |
A data.frame |
preprocessing |
A character string of R code |
path |
A name of destination file path |
filename |
A name of destination file |
rawDataName |
The name of the rawData |
rawDataFile |
The name of the rawData file which the data are to be read from. |
type |
character "HTML" or "pdf" |
vanilla |
logical. Whether or not make vanilla table |
echo |
Logical. Whether or not show R code of plot and table |
showself |
Logical. Whether or not show R code for the paragraph |
out |
An object or NULL |
Examples
## Not run:
library(moonBook)
library(rrtable)
library(ggplot2)
data2HTML(sampleData2)
## End(Not run)
convert data to docx file
Description
convert data to docx file
Usage
data2docx(...)
Arguments
... |
arguments to be passed to data2office() |
Examples
## Not run:
library(rrtable)
library(moonBook)
library(ggplot2)
data2docx(sampleData2,echo=TRUE)
## End(Not run)
Make a word file with a data.frame
Description
Make a word file with a data.frame
Usage
data2docx2(...)
Arguments
... |
further arguments to be passed to data2HTML |
convert data to pptx file
Description
convert data to pptx file
Usage
data2office(
data,
preprocessing = "",
path = ".",
filename = "Report",
format = "pptx",
width = 7,
height = 5,
units = "in",
res = 300,
rawDataName = NULL,
rawDataFile = "rawData.RDS",
vanilla = FALSE,
echo = FALSE,
landscape = FALSE,
showself = FALSE,
out = NULL
)
Arguments
data |
A document object |
preprocessing |
A string |
path |
A name of destination file path |
filename |
File name |
format |
desired format. choices are "pptx" or "docx" |
width |
the width of the device. |
height |
the height of the device. |
units |
The units in which height and width are given. Can be px (pixels, the default), in (inches), cm or mm. |
res |
The nominal resolution in ppi which will be recorded in the bitmap file, if a positive integer. Also used for units other than the default, and to convert points to pixels. |
rawDataName |
raw Data Name |
rawDataFile |
raw Data File |
vanilla |
logical. Whether or not make vanilla table |
echo |
logical Whether or not show R code |
landscape |
Logical. Whether or not make a landscape section. |
showself |
Logical. Whether or not show R code for the paragraph |
out |
An object or NULL |
Make a pdf file with a data.frame
Description
Make a pdf file with a data.frame
Usage
data2pdf(...)
Arguments
... |
further arguments to be passed to data2HTML |
Examples
library(moonBook)
library(ztable)
library(ggplot2)
## Not run:
data2pdf(sampleData2)
## End(Not run)
Make zipped plot file with a data.frame
Description
Make zipped plot file with a data.frame
Usage
data2plotzip(
data,
path = ".",
filename = "Plot.zip",
format = "PNG",
width = 8,
height = 6,
units = "in",
res = 300,
start = 0,
preprocessing = "",
rawDataName = NULL,
rawDataFile = "rawData.RDS",
out = NULL
)
Arguments
data |
A data.frame |
path |
A name of destination file path |
filename |
A path of destination file |
format |
Plot format. Choices are c("PNG","SVG","PDF") |
width |
A plot width |
height |
A plot height |
units |
The units in which height and width are given. Can be px (pixels, the default), in (inches), cm or mm. |
res |
The nominal resolution in ppi |
start |
Plot start number |
preprocessing |
A character string of R code |
rawDataName |
The name of the rawData |
rawDataFile |
The name of the rawData file which the data are to be read from. |
out |
An object or NULL |
Examples
## Not run:
library(moonBook)
library(ztable)
library(rrtable)
library(ggplot2)
data2plotzip(sampleData2,path="tmp")
## End(Not run)
convert data to pptx file
Description
convert data to pptx file
Usage
data2pptx(...)
Arguments
... |
arguments to be passed to data2office() |
Examples
## Not run:
library(rrtable)
library(moonBook)
library(ggplot2)
data2pptx(sampleData2,echo=TRUE)
## End(Not run)
Make a Powerpoint file with a data.frame
Description
Make a Powerpoint file with a data.frame
Usage
data2pptx2(...)
Arguments
... |
further arguments to be passed to data2HTML |
Make a flextable with a data.frame
Description
Make a flextable with a data.frame
Usage
df2RcodeTable(df, bordercolor = "gray", format = "pptx", eval = TRUE)
Arguments
df |
A data.frame |
bordercolor |
A border color name |
format |
desired format. choices are "pptx" or "docx" |
eval |
logical. Whether or not evaluate the code |
Value
A flextable object
Convert data.frame to flextable
Description
Convert data.frame to flextable
Usage
df2flextable(
df,
vanilla = FALSE,
fontname = NULL,
fontsize = 12,
add.rownames = FALSE,
even_header = "transparent",
odd_header = "#5B7778",
even_body = "#EFEFEF",
odd_body = "transparent",
vlines = TRUE,
colorheader = FALSE,
digits = 2,
digitp = 3,
align_header = "center",
align_body = "right",
align_rownames = "left",
NA2space = TRUE,
pcol = NULL,
...
)
Arguments
df |
A data.frame |
vanilla |
A Logical |
fontname |
Font name |
fontsize |
font size |
add.rownames |
logical. Whether or not include rownames |
even_header |
background color of even_header |
odd_header |
background color of even_header |
even_body |
background color of even_body |
odd_body |
background color of even_body |
vlines |
Logical. Whether or not draw vertical lines |
colorheader |
Logical. Whether or not use color in header |
digits |
integer indicating the number of decimal places |
digitp |
integer indicating the number of decimal places of p values |
align_header |
alignment of header. Expected value is one of 'left', 'right', 'center', 'justify'. |
align_body |
alignment of body. Expected value is one of 'left', 'right', 'center', 'justify'. |
align_rownames |
alignment of rownames. Expected value is one of 'left', 'right', 'center', 'justify'. |
NA2space |
A logical. If true, convert NA value to space |
pcol |
An integer indicating p value. If specified, convert value less than 0.01 to "< 0.001" in given column. |
... |
further arguments to be passed to flextable |
Examples
require(flextable)
require(officer)
df2flextable(head(iris),vanilla=TRUE,colorheader=TRUE)
## Not run:
df2flextable(head(iris),vanilla=TRUE,digits=c(1,2,3,4))
df2flextable(head(iris),vanilla=FALSE)
df2flextable(head(iris),vanilla=FALSE,vlines=FALSE,fontsize=14)
df2flextable(head(mtcars/2000),digits=3,pcol=8,digitp=4,add.rownames=TRUE)
## End(Not run)
Make flextable with limited width
Description
Make flextable with limited width
Usage
df2flextable2(df, mincol = 0.7, maxcol = 4, ...)
Arguments
df |
a data.frame |
mincol |
minimum column width in inch |
maxcol |
maximum column width in inch |
... |
further arguments to be passed to df2flextable() |
Export pptxList file to desired format
Description
Export pptxList file to desired format
Usage
exportCSV(
file,
format = "HTML",
rawDataName = NULL,
rawDataFile = "rawData.RDS"
)
Arguments
file |
The name of the file which the data are to be read from. |
format |
desired output format. Possible choices are one of the c("HTML","pdf","word","pptx","plotzip") |
rawDataName |
The name of the rawData |
rawDataFile |
The name of the rawData file which the data are to be read from. |
read data file and make a HTML file
Description
read data file and make a HTML file
Usage
file2HTML(file, selected = NULL, ...)
Arguments
file |
The name of the file which the data are to be read from. |
selected |
A numeric vector or NULL(default). If specified, only selected data are printed. |
... |
Further argument to be passed to data2HTML() |
read data file and make a docx file
Description
read data file and make a docx file
Usage
file2docx(file, selected = NULL, ...)
Arguments
file |
The name of the file which the data are to be read from. |
selected |
A numeric vector or NULL(default). If specified, only selected data are printed. |
... |
Further argument to be passed to data2docx() |
read data file and make a docx file with Rmd file
Description
read data file and make a docx file with Rmd file
Usage
file2docx2(file, selected = NULL, ...)
Arguments
file |
The name of the file which the data are to be read from. |
selected |
A numeric vector or NULL(default). If specified, only selected data are printed. |
... |
Further argument to be passed to data2docx() |
read data file and make a pdf file
Description
read data file and make a pdf file
Usage
file2pdf(file, selected = NULL, ...)
Arguments
file |
The name of the file which the data are to be read from. |
selected |
A numeric vector or NULL(default). If specified, only selected data are printed. |
... |
Further argument to be passed to data2pdf() |
read data file and make a zip file with plots
Description
read data file and make a zip file with plots
Usage
file2plotzip(file, selected = NULL, ...)
Arguments
file |
The name of the file which the data are to be read from. |
selected |
A numeric vector or NULL(default). If specified, only selected data are printed. |
... |
Further argument to be passed to data2plotzip() |
read data file and make a pptx file
Description
read data file and make a pptx file
Usage
file2pptx(file, selected = NULL, ...)
Arguments
file |
The name of the file which the data are to be read from. |
selected |
A numeric vector or NULL(default). If specified, only selected data are printed. |
... |
Further argument to be passed to data2pptx() |
read data file and make a pptx file with Rmd file
Description
read data file and make a pptx file with Rmd file
Usage
file2pptx2(file, selected = NULL, ...)
Arguments
file |
The name of the file which the data are to be read from. |
selected |
A numeric vector or NULL(default). If specified, only selected data are printed. |
... |
Further argument to be passed to data2pptx() |
Convert flextable to ztable
Description
Convert flextable to ztable
Usage
flextable2ztable(ft, type = "html", ...)
Arguments
ft |
An object of class flextable |
type |
"html" or "latex" |
... |
Further argument to be passed to ztable |
Value
an object of class ztable
Convert html5 code to latex
Description
Convert html5 code to latex
Usage
html2latex(df)
Arguments
df |
A data.frame |
Save plot/ggplot to Microsoft Word format
Description
Save plot/ggplot to Microsoft Word format
Usage
image2docx(...)
Arguments
... |
further arguments to be passed to image2office |
Examples
## Not run:
require(ggplot2)
x<-ggplot(iris,aes(x=Sepal.Length))+geom_histogram()
image2docx(x)
image2docx(x="plot(iris)",title="A ggplot",append=TRUE)
p2="ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width))+geom_point()"
image2docx(p2,append=TRUE)
## End(Not run)
Save plot/ggplot as image to Microsoft Powerpoint format
Description
Save plot/ggplot as image to Microsoft Powerpoint format
Usage
image2office(
x,
target = "Report",
append = FALSE,
title = "",
type = "pptx",
preprocessing = "",
left = 1,
top = 1,
width = 8,
height = 5.5
)
Arguments
x |
A string vector encoding plot or ggplot |
target |
name of output file |
append |
logical value |
title |
Optional character vector of plot title |
type |
"pptx" or "docx" |
preprocessing |
A string of R code or "" |
left |
left margin |
top |
top margin |
width |
desired width of the plot |
height |
desired height of the plot |
Examples
## Not run:
require(ggplot2)
image2pptx("ggplot(data=iris,aes(x=Sepal.Length))+geom_density()")
## End(Not run)
Save plot/ggplot to Microsoft Powerpoint format
Description
Save plot/ggplot to Microsoft Powerpoint format
Usage
image2pptx(...)
Arguments
... |
further arguments to be passed to image2office |
Examples
## Not run:
require(ggplot2)
x<-ggplot(iris,aes(x=Sepal.Length))+geom_histogram()
image2pptx(x)
x="plot(iris)"
image2pptx(x,title="A plot",append=TRUE)
p2="ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width))+geom_point()"
image2pptx(p2,append=TRUE)
## End(Not run)
replace argument of a function
Description
replace argument of a function
Usage
insert_argument(code, argument, value)
Arguments
code |
string of function call |
argument |
argument of function to be set |
value |
value to be set |
Reports whether plotstring encode a ggplot object
Description
Reports whether plotstring encode a ggplot object
Usage
is_ggplot(plotstring)
Arguments
plotstring |
A character |
Examples
require(ggplot2)
is_ggplot("plot(iris)")
is_ggplot("ggplot(iris,aes(x=Sepal.Length))+geom_histogram()")
Reports whether plotstring encode a ggsurvplot object
Description
Reports whether plotstring encode a ggsurvplot object
Usage
is_ggsurvplot(x)
Arguments
x |
A character encoding a plot |
Make flextable with a data.frame
Description
Make flextable with a data.frame
Usage
myFlextable(df, numericCol = NULL)
Arguments
df |
A data.frame |
numericCol |
Numeric. Columns to be treated as numeric |
Concatenate to file
Description
Concatenate to file
Usage
mycat(..., file = "report2.Rmd")
Arguments
... |
R object |
file |
A connection |
grep string in all files in subdirectory
Description
grep string in all files in subdirectory
Usage
mygrep(x, file = "*")
Arguments
x |
string |
file |
files to seek |
Make zipped plots with a data.frame
Description
Make zipped plots with a data.frame
Usage
myplot2(
data,
format = "PNG",
width = 7,
height = 7,
units = "in",
res = 300,
start = 0,
rawDataName = NULL,
rawDataFile = "rawData.RDS"
)
Arguments
data |
A data.frame |
format |
Plot format. Choices are c("PNG","SVG","PDF") |
width |
A plot width |
height |
A plot height |
units |
The units in which height and width are given. Can be px (pixels, the default), in (inches), cm or mm. |
res |
The nominal resolution in ppi |
start |
Plot start number |
rawDataName |
The name of the rawData |
rawDataFile |
The name of the rawData file which the data are to be read from. |
Convert mytable object to flextable
Description
Convert mytable object to flextable
Usage
mytable2flextable(result, vanilla = TRUE, fontname = NULL, fontsize = 10)
Arguments
result |
An object of class "mytable" |
vanilla |
A Logical. |
fontname |
Font name |
fontsize |
font size |
Examples
## Not run:
require(moonBook)
require(flextable)
require(officer)
result=mytable(smoking+Dx~.,data=acs)
mytable2flextable(result)
mytable2flextable(result,vanilla=FALSE)
result=mytable(Dx~.,data=acs)
mytable2flextable(result)
mytable2flextable(result,vanilla=FALSE)
## End(Not run)
Make/open office document with file name
Description
Make/open office document with file name
Usage
open_doc(target = "Report", type = "pptx", append = FALSE)
Arguments
target |
name of output file |
type |
"pptx" or "docx" |
append |
logical |
Change p value to string
Description
Change p value to string
Usage
p2character(x, digits = 3)
Arguments
x |
A numeric vector |
digits |
integer indicating the number of decimal places |
Examples
x=c(0.000001,NA,0.1234567,0.00123,0.000123)
p2character(x)
p2character(x,digits=4)
Side by side pickerInput
Description
Side by side pickerInput
Usage
pickerInput3(...)
Arguments
... |
Further arguments to be passed to pickerInput |
Save plot/ggplot to Microsoft Word format
Description
Save plot/ggplot to Microsoft Word format
Usage
plot2docx(...)
Arguments
... |
further arguments to be passed to plot2office |
Examples
## Not run:
require(ggplot2)
x<-ggplot(iris,aes(x=Sepal.Length))+geom_histogram()
plot2docx(x)
plot2docx(x,title="A ggplot",append=TRUE)
p2=ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width))+geom_point()
plot2docx(p2,append=TRUE)
plot2docx(x="plot(iris)",append=TRUE,title="plot(iris)")
plot2docx(x="ggplot(iris,aes(x=Sepal.Length))+geom_histogram()",append=TRUE)
## End(Not run)
Save plot/ggplot to Microsoft Powerpoint format
Description
Save plot/ggplot to Microsoft Powerpoint format
Usage
plot2office(
x = NULL,
target = "Report",
append = FALSE,
title = "",
type = "pptx",
preprocessing = "",
plottype = "auto",
echo = FALSE,
parallel = FALSE,
left = 1,
top = 1,
width = NULL,
height = NULL,
aspectr = NULL,
out = NULL
)
Arguments
x |
An object of class ggplot2 or a string vector encoding plot or ggplot |
target |
name of output file |
append |
logical value |
title |
Optional character vector of plot title |
type |
"pptx" or "docx" |
preprocessing |
A string of R code or "" |
plottype |
character One of c("auto","plot","ggplot","emf") |
echo |
logical. If true, show code. |
parallel |
logical. If true, add two plots side by side |
left |
left margin |
top |
top margin |
width |
desired width of the plot |
height |
desired height of the plot |
aspectr |
desired aspect ratio of the plot |
out |
An object or NULL |
Examples
## Not run:
require(ggplot2)
x=c("plot(iris)","ggplot(mtcars,aes(x=hp,y=mpg))+geom_point()")
plot2office(x,title="2 plots",parallel=TRUE)
plot2office(x,title="2 plots",parallel=TRUE,echo=TRUE,append=TRUE)
plot2office(x,parallel=TRUE,echo=TRUE,append=TRUE)
## End(Not run)
Save plot/ggplot to Microsoft Powerpoint format
Description
Save plot/ggplot to Microsoft Powerpoint format
Usage
plot2pptx(...)
Arguments
... |
further arguments to be passed to plot2office |
Examples
## Not run:
require(ggplot2)
x<-ggplot(iris,aes(x=Sepal.Length))+geom_histogram()
plot2pptx(x)
plot2pptx(x,title="A ggplot",append=TRUE)
p2=ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width))+geom_point()
plot2pptx(p2,append=TRUE)
plot2pptx(x=c("plot(iris)","ggplot(iris,aes(x=Sepal.Length))+geom_histogram()"),
append=TRUE,title=c("plot","ggplot"),echo=TRUE)
## End(Not run)
Make png file with a plot code
Description
Make png file with a plot code
Usage
plotPNG2(
x,
file,
type,
width = 7,
height = 7,
units = "in",
res = 300,
ggplot = FALSE
)
Arguments
x |
A R code string for plot |
file |
A path of destination file |
type |
A character |
width |
A plot width |
height |
A plot height |
units |
The units in which height and width are given. Can be px (pixels, the default), in (inches), cm or mm. |
res |
The nominal resolution in ppi |
ggplot |
A logical. Set this argument true if the R code is for ggplot |
Server function of pptxList shiny module
Description
Server function of pptxList shiny module
Usage
pptxList(
input,
output,
session,
data = reactive(""),
preprocessing = reactive("")
)
Arguments
input |
input |
output |
output |
session |
session |
data |
A data object |
preprocessing |
A character string of R code |
UI of pptxList shiny module
Description
UI of pptxList shiny module
Usage
pptxListInput(id)
Arguments
id |
A string |
Examples
library(shiny)
library(ggplot2)
library(editData)
library(moonBook)
library(readr)
if(interactive()){
ui=fluidPage(
pptxListInput("pptxlist")
)
server=function(input,output,session){
mydf=callModule(pptxList,"pptxlist")
}
shinyApp(ui,server)
}
Read a csv file with comment
Description
Read a csv file with comment
Usage
readCSVComment(file)
Arguments
file |
A path for destination file |
Read comment from a file
Description
Read comment from a file
Usage
readComment(filename, comment = "#")
Arguments
filename |
A path for destination file |
comment |
A string used to identify comments |
replace argument of a function
Description
replace argument of a function
Usage
replace_argument(substring, argument, value)
Arguments
substring |
string of function call |
argument |
argument of function to be set |
value |
value to be set |
Convert numeric columns of data.frame to character
Description
Convert numeric columns of data.frame to character
Usage
roundDf(df, digits = 2)
Arguments
df |
A data.frame |
digits |
integer indicating the number of decimal places |
Examples
roundDf(iris,digits=c(1,2,3,4))
roundDf(mtcars,digits=2)
Sample data for pptxList A dataset containing five objects for reproducible research
Description
Sample data for pptxList A dataset containing five objects for reproducible research
Usage
sampleData2
Format
A data frame with 5 rows and three columns
- type
type of data
- title
title of data
- code
R code of data
Sample data for pptxList A dataset containing five objects for reproducible research
Description
Sample data for pptxList A dataset containing five objects for reproducible research
Usage
sampleData3
Format
A data frame with 5 rows and three columns
- type
type of data
- title
title of data
- text
text
- code
R code of data
- option
option for R code
set argument of a function
Description
set argument of a function
Usage
set_argument(code, argument, value = TRUE)
Arguments
code |
string of function call |
argument |
argument of function to be set |
value |
value to be set |
Examples
code="df2flextable( ) "
code="df2flextable(vanilla=TRUE,head(iris[1:10,]))"
code="df2flextable(mtcars)"
code="df2flextable(sampleData3)"
code="df2flextable(head(iris[1:10,]),vanilla=TRUE)"
set_argument(code,"vanilla",FALSE)
Export data.frame or statistical output to Microsoft Word format
Description
Export data.frame or statistical output to Microsoft Word format
Usage
table2docx(...)
Arguments
... |
further arguments to be passed to table2office |
Examples
## Not run:
require(moonBook)
x=mytable(Dx~.,data=acs)
table2docx(x)
table2docx(head(iris),title="head(iris)",append=TRUE,vanilla=FALSE)
fit=lm(mpg~wt*hp,data=mtcars)
table2docx(fit,title="Linear regression",append=TRUE,vanilla=TRUE)
fit2=aov(yield ~ block + N * P + K, data = npk)
table2docx(fit2,title="Linear regression",append=TRUE,vanilla=TRUE)
## End(Not run)
Export data.frame or statistical output to a table in Microsoft Office
Description
Export data.frame or statistical output to a table in Microsoft Office
Usage
table2office(
x = NULL,
target = "Report",
append = FALSE,
title = "",
vanilla = FALSE,
echo = FALSE,
add.rownames = TRUE,
preprocessing = "",
type = "pptx",
landscape = FALSE,
left = 1,
top = 1
)
Arguments
x |
An object or string |
target |
name of output file |
append |
logical value |
title |
Optional character of plot title |
vanilla |
A logical |
echo |
logical |
add.rownames |
logical |
preprocessing |
A character string |
type |
"pptx" or "docx" |
landscape |
logical |
left |
left margin |
top |
top margin |
Export data.frame or statistical output to Microsoft Powerpoint format
Description
Export data.frame or statistical output to Microsoft Powerpoint format
Usage
table2pptx(...)
Arguments
... |
further arguments to be passed to table2office |
Examples
## Not run:
require(moonBook)
x="mytable(Dx~.,data=acs)"
table2pptx(x,title="mytable object",echo=TRUE)
table2pptx("head(iris)",title="data.Frame",append=TRUE,vanilla=FALSE,echo=TRUE)
x="fit<-lm(mpg~wt*hp,data=mtcars);fit"
table2pptx(x,title="Linear regression",append=TRUE,vanilla=TRUE,echo=TRUE)
fit2="aov(yield ~ block + N * P + K, data = npk)"
table2pptx(fit2,title="ANOVA",append=TRUE,vanilla=TRUE,echo=TRUE)
## End(Not run)
Split strings with desired length with exdent
Description
Split strings with desired length with exdent
Usage
tensiSplit(string, size = 82, exdent = 3)
Arguments
string |
String |
size |
desired length |
exdent |
exdent |
Value
splitted character vector
Remove File and sink()
Description
Remove File and sink()
Usage
unsink(temp)
Arguments
temp |
character file name |
Write a csv file with comment
Description
Write a csv file with comment
Usage
writeCSVComment(data, file, metadata = "", comment = "#")
Arguments
data |
A data.frame |
file |
A path for destination file |
metadata |
A character string representing R codes as a preprocessing |
comment |
A string used to identify comments |
Make ztable with desired width
Description
Make ztable with desired width
Usage
ztable2(df, cwidth = NULL, width = 80, ...)
Arguments
df |
a data.frame |
cwidth |
desired column width |
width |
desired table width in column |
... |
further argument to be passed to ztable() |
Convert ztable to flextable
Description
Convert ztable to flextable
Usage
ztable2flextable(z, ...)
Arguments
z |
An object of class ztable |
... |
Further argument to be passed to df2flextable |
Value
an object of class flextable