nutterb / lazyweave Goto Github PK
View Code? Open in Web Editor NEWR package lazyWeave
R package lazyWeave
When passing a character variable to cattable
, the label on the variable is lost when it is converted to a factor. The results is unlabeled variables in the output and is not the desired result. Labels should be preserved.
Adding a line as simple as as.data.frame(data)
in these cases should be enough.
This isn't an exported function, so back compatibility shouldn't be too big an issue.
Still to do.
Completed
pvalString
as an exported functionlazy.table
, lazy.matrix
, write.ctable
, write.univ
, lazy.figure
lazy.table
, lazy.matrix
, write.ctable
, write.univ
, lazy.figure
to act on the cat
argument.pvalue.QHS
pvalue.QHS
with pvalString
The only purpose for the survival
dependency is in the examples. With the addition of the Delivery
data, this isn't necessary anymore. Adjustments to the examples would allow for removal of the survival
dependency.
Unfortunately, the labeling functions in Hmisc
are pretty essential to cattable
and conttable
. This dependency can't be avoided because not all of the labelling functions are exported in the Hmisc
namespace. I'm contemplating copying those functions into lazyWeave
so that Hmisc
won't be a dependency any more. In my ideal world, I'd like to see the labeling functions have their own package, but this might require too many changes to Hmisc
.
latexTranslate
is the other function I rely on heavily, but this is exported in Hmisc
's namespace, so we can at least access that one.
lazy.footnote
, for HTML files, requires the user to provide two tag names to generate the links between the footnote and the in-document reference. This could probably be simplified by having the user provide a tag name and appending it with [tag]_doc and [tag]_end.
The documentation claims it does midranks, but it doesn't.
write.ctable
doesnt' play nicely with hooks for numbering and referencing tables
title: "Auto-numbering and cross-referencing of figures and tables in rmarkdown"
# This is a knitr hook to enable figure and table captions
# number figures
# from http://stackoverflow.com/a/18672268/1036500
library("knitr")
tn = local({
i = 0
function(x) {
i <<- i + 1
paste("<table><caption>", 'Figure ', i, ': ', x, "</caption><colgroup><col width='100'></col></colgroup><thead><tr class='header'></tr></thead><tbody></tbody></table><p>", sep = '')
}
})
knit_hooks$set(fig.cap = function(before, options, envir) {
if(!before)
tn(options$fig.cap)
})
default_output_hook = knit_hooks$get("output")
knit_hooks$set(output = function(x, options) {
if (is.null(options$fig.cap) == F)
x
else
default_output_hook(x,options)
})
# number tables
# from http://stackoverflow.com/a/18672268/1036500
to = local({
i = 0
function(x) {
i <<- i + 1
paste("<table><caption>", 'Table ', i, ': ', x, "</caption><colgroup><col width='100'></col></colgroup><thead><tr class='header'></tr></thead><tbody></tbody></table><p>", sep = '')
}
})
knit_hooks$set(tab.cap = function(before, options, envir) {
if(!before)
to(options$tab.cap)
})
default_output_hook = knit_hooks$get("output")
knit_hooks$set(output = function(x, options) {
if (is.null(options$tab.cap) == F)
x
else
default_output_hook(x,options)
})
library(knitr)
library(kfigr) # devtools::install_github("github mkoohafkan/kfigr")
opts_chunk$set(message=FALSE, warning=FALSE)
library(lazyWeave)
library(stringr)
options(lazyReportFormat = "markdown")
Using the knitr option "echo=F" seems to cause the problem.
data(mtcars)
mtcars$group = sample(c("Bad", "Good"), size=nrow(mtcars), replace=T)
tab1 = catconttable(data = mtcars,
vars = c("mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb"),
normal = c("mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb"),
byVar = "group")
tab = write.ctable(tab1)
tab = str_split(tab, "\n")[[1]]
tab = tab[c(6,4,5,7:length(tab))]
tab = paste(tab, collapse="\n")
cat(tab)
See r figr("ATable", T,F)
for summaries of the variables in the cars dataset.
data(mtcars)
mtcars$group = sample(c("Bad", "Good"), size=nrow(mtcars), replace=T)
tab1 = catconttable(data = mtcars,
vars = c("mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb"),
normal = c("mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb"),
byVar = "group")
tab = write.ctable(tab1)
tab = str_split(tab, "\n")[[1]]
tab = tab[c(6,4,5,7:length(tab))]
tab = paste(tab, collapse="\n")
cat(tab)
See r figr("ATable2", T,F)
for summaries of the variables in the cars dataset.
Currently, using the text.size argument produces a warning that the argument was scheduled for deletion in 2013. It's almost 2015. Maybe I should take this out finally.
When building the zip folder for an HTML document, lazy.build copies everything into a top level directory. This is because I hadn't yet figured out how to avoid copying the whole directory tree into the file. I can avoid some of this overhead work by using the "-j" flag in the flags
argument of zip
Would allow tables to break over multiple pages more naturally.
The big question is if this will give me the same control over tables. Can I have columns spanning multiple cells? Can I control the HTML fonts? Can I add shading?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.