Giter Site home page Giter Site logo

ztable's Introduction

title author date output vignette
ztable Update
Keon-Woong Moon
2018-05-14
rmarkdown::html_vignette
%\VignetteIndexEntry{ztable_update} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8}

Installation

You can install R package "ztable" from CRAN. Current version is 0.1.8.

install.packages("ztable")

You can install the developmental version of ztable from github. Current github version is 0.1.9.

if(!require(devtools)) install.packages("devtools")
devtools::install_github("cardiomoon/ztable")

Make table from a data.frame

Package "ztable" make everything possible about table. Basically, An object of "ztable" made from a data.frame. The default output format of ztable is RStudio::viewer or web-browser format(type="viewer"). So if you want to use ztable in a "html" format, you should change the parameter ztable.type to "html". If you want to use ztable in latex format, you should change the parameter ztable.type to "latex".

library(ztable)
library(magrittr)
options(ztable.type="html")
z=ztable(head(iris),caption="Table 1. Basic Table")
z
Table 1. Basic Table
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.10 3.50 1.40 0.20 setosa
2 4.90 3.00 1.40 0.20 setosa
3 4.70 3.20 1.30 0.20 setosa
4 4.60 3.10 1.50 0.20 setosa
5 5.00 3.60 1.40 0.20 setosa
6 5.40 3.90 1.70 0.40 setosa

You can see the full vignette here:

  1. ztable vignette: https://cran.r-project.org/web/packages/ztable/vignettes/ztable.html

  2. ztable update: http://rpubs.com/cardiomoon/388645

ztable's People

Contributors

cardiomoon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ztable's Issues

table caption number non-automatic

Hello @cardiomoon!

I've started using ztable and it's great!
I think one of the things that could be useful is to have an option for captions to be automatically generated.

For example, when I use ztable with other latex outputting packages (e.g. xtable or stargazer), I think I'd rather have the captions be automatically generated and flow with the other tables created by other packages.

I'll try to work on this if I have some time. If you have any suggestions as to where I should look in the source code that would be great. Thanks!

Formulas are not escaped correctly

See 🔗 http://stackoverflow.com/q/29773068/1968. The following gives invalid LaTeX output because ^ is used outside of a math environment unescaped:

model <- nls(y~x^c1, start=list(c1=1), control=list(maxiter=200))
z <- ztable(model, type="latex")

The fact that ~ is translated to $\sim$ suggests that the whole formula, not just parts of it, should be translated to LaTeX.

digits in flextable do not work following ztable2flextable

This works as expected (no decimal places on 6th column):

head(mtcars) %>%
  flextable() %>%
  colformat_double(j=6, digits = 0)

This doesn't work as expected (significant digits showing after the decimal in the 6th column):

ztable(head(mtcars)) %>% 
  makeHeatmap(palette="YlOrRd",cols=c(1,3,4),margin=2) %>%
  ztable2flextable() %>%
  colformat_double(j=6, digits = 0)

ztable changes font family in Rmarkdown

I've noticed that as soon as soon as the ztable package is loaded all the tables in my markdown documents change font from sans serif to serif. This is reproducible:

`

title: "Ztable Test"
author: "some author"
date: "October 18, 2017"
output: html_document

knitr::opts_chunk$set(echo = TRUE)

Kable (from knitr) in markdown

cars <- cars
knitr::kable(head(cars))

`
The above renders with sans serif font. Now if I load ztable:

`

title: "Ztable Test"
author: "some author"
date: "October 18, 2017"
output: html_document

knitr::opts_chunk$set(echo = TRUE)

Kable (from knitr) in markdown

cars <- cars
knitr::kable(head(cars))

Using ztable

library(moonBook)
library(ztable)

options(ztable.type="html")
options(ztable.zebra=1)
options(ztable.zebra.color="platinum")
options(ztable.colnames.bold=TRUE)
ztable(head(cars))

`

All tables use serif fonts. How can I override this behavior? I want my fonts to remain sans serif.

Package load error

I get this error when trying to load the package

> library(ztable)
Error: package or namespace load failed for ‘ztable’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/gdtools/libs/gdtools.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/gdtools/libs/gdtools.so, 6): Library not loaded: /opt/X11/lib/libcairo.2.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/gdtools/libs/gdtools.so
  Reason: image not found

LaTeX references & caption line wrapping

I really like the motivation of this package, but I noticed a couple issues that might prevent me from using it. Consider this minimal example (see here for source). Is there a way to get the caption to wrap according to the table width? Also, the LaTeX reference link is there (it's really hard to see), but the numbering doesn't appear (any idea how to make it appear?).

I also think it's better practice to avoid the assumption that users will have the appropriate preamble/definitions to support the default options (that is, I think booktabs & zebra should be FALSE by default).

html output with each table in a separate browser tab

Hi,

I've tried to use ztable to make some tables in rmarkdown, but each table seems to get put in its own html file in separate tabs on the internet browser that I have open when I render the rmarkdown document. An example is below:


title: "Interpretive Survey for OU Children's: Cross-Tables"
author: "James Cutler"
date: "9/17/2020"
output: html_document

Two tables

library(ztable)
library(magrittr)
# options(ztable.type="html")

z=ztable(head(iris))
z

z=ztable(tail(iris))
z

This does three things, actually. It opens up the two separate html tabs with one of the two tables in each. It also creates an editor window that shows only this (below) and no tables in the actual editor window:

ztable tables
James Cutler

9/17/2020

Two tables
library(ztable)

Welcome to package ztable ver 0.2.1

library(magrittr)

options(ztable.type="html")

z=ztable(head(iris))
z

z=ztable(tail(iris))
z

Is there any particular reason why this would happen?

Thank you,
James Cutler

ztable caption and position arguments ignored when using ztable on mytable object

When trying to wirte a caption and using position arguments, these are ignored when applied to an mytable object.

Example:

This works as expected and prints caption and positions table to the left:
options(ztable.type="html")
tb4 <- t(round(rbind(table(eco$p2_described), prop.table(table(eco$p2_described))*100),2))
ztable(tb4, caption="Parent 2 - described economy", position="l")

This does not print any caption or respects positioning:
options(ztable.type="html")
ztable(mytable(youth_described~p1_hhincome, data=eco), caption="test", position="l")

ztable position="left" (or "right") renders incorrectly when printing multiple tables

When I try to align multiple tables on the left side of the page (arg: position="left"), the subsequent tables are rendered next to the first table. This happens even when I manually insert a </br> between the tables. The default (position="center") works as expected.

The following code illustrates the problem:

# CENTERED
z1 <- ztable(head(iris,3))
z2 <- ztable(head(cars,3))
z1; z2  # <-- renders correctly
# LEFT
z1 <- ztable(head(iris,3), position="left")
z2 <- ztable(head(cars,3), position="left")
z1; z2   # <-- z2 ends up immediately to the right of z1
# RIGHT
z1 <- ztable(head(iris,3), position="right")
z2 <- ztable(head(cars,3), position="right")
z1; z2  # <-- these are rendered right-aligned (again next to each other)
        # but on the same vertical position as the "left" tables

The only differences in the html seems to be the <table align="left" vs. <table align="center"
Any ideas what is happening?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.