Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preview mode not work #7

Closed
hdeng88 opened this issue Jun 7, 2018 · 20 comments
Closed

preview mode not work #7

hdeng88 opened this issue Jun 7, 2018 · 20 comments

Comments

@hdeng88
Copy link

@hdeng88 hdeng88 commented Jun 7, 2018

the html table will be shown in viewer mode not inline mode. works fine in knit html but not notebook.

@benjaminrich
Copy link
Owner

@benjaminrich benjaminrich commented Jun 7, 2018

I don't really use notebook, is that RStudio specific, or a general problem?

@hdeng88
Copy link
Author

@hdeng88 hdeng88 commented Jun 7, 2018

I think it is Rstudio specific. but I have seen this happened to other packages but fixed afterwards quickly so I guess it is not a difficult fix.

Also could you provide a default option to output median [Q1,Q3]? I think this is more academically standard from a reviewer standpoint. If there are multiple variables needed to be presented in different format, how could I format them differently? say age for median[Q1,Q3] but weight for mean (SD).

@benjaminrich
Copy link
Owner

@benjaminrich benjaminrich commented Jun 7, 2018

I will try to look into it, but I don't know when. If you can provide information on how notebook works in RStudio and how to feed it HTML that will be helpful.

As to your other question, you can. Here is an example:

library(table1)

dat <- data.frame(Age=runif(100, 40, 65), Weight=rnorm(100, 75, 10))

rndr <- function(x, name, ...) {
    what <- switch(name,
        Weight = "Mean (SD)",
        Age    = "Median [Q1, Q3]")

    parse.abbrev.render.code(c("", what))(x)
}

table1(~ Age + Weight, data=dat, render=rndr)

Edit: cleaned up the example slightly.

@benjaminrich
Copy link
Owner

@benjaminrich benjaminrich commented Jun 20, 2018

This is working now in pull request #9. Do you want to test it?

@hdeng88
Copy link
Author

@hdeng88 hdeng88 commented Jun 20, 2018

@benjaminrich
Copy link
Owner

@benjaminrich benjaminrich commented Jun 20, 2018

Are you using the right branch? The change has not been merged into the master branch yet, so you want to be installing with:

devtools::install_github("benjaminrich/table1#9")
@hdeng88
Copy link
Author

@hdeng88 hdeng88 commented Jun 20, 2018

@hdeng88
Copy link
Author

@hdeng88 hdeng88 commented Jun 20, 2018

@benjaminrich
Copy link
Owner

@benjaminrich benjaminrich commented Jun 21, 2018

OK, my bad, it did not work as I expected. Try this instead:

devtools::install_github("benjaminrich/table1@issue-%237")
@hdeng88
Copy link
Author

@hdeng88 hdeng88 commented Jun 21, 2018

@benjaminrich
Copy link
Owner

@benjaminrich benjaminrich commented Jun 21, 2018

Which one is still not working, the installation, or the preview in RStudio?

@hdeng88
Copy link
Author

@hdeng88 hdeng88 commented Jun 21, 2018

@benjaminrich
Copy link
Owner

@benjaminrich benjaminrich commented Jun 21, 2018

It is working for me. Here's a screenshot:

screenshot_issue7

@hdeng88
Copy link
Author

@hdeng88 hdeng88 commented Jun 21, 2018

@benjaminrich
Copy link
Owner

@benjaminrich benjaminrich commented Jun 21, 2018

Here is the output of sessionInfo():

> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] table1_1.1    rmarkdown_1.9

loaded via a namespace (and not attached):
 [1] compiler_3.5.0  backports_1.1.2 magrittr_1.5    rprojroot_1.3-2
 [5] tools_3.5.0     htmltools_0.3.6 Rcpp_0.12.17    stringi_1.1.7  
 [9] knitr_1.20      Formula_1.2-3   stringr_1.3.1   digest_0.6.15  
[13] evaluate_0.10.1

Does that help?

@benjaminrich
Copy link
Owner

@benjaminrich benjaminrich commented Jun 21, 2018

And my RStudio version is 1.1.453.

@hdeng88
Copy link
Author

@hdeng88 hdeng88 commented Jun 21, 2018

@hdeng88
Copy link
Author

@hdeng88 hdeng88 commented Jun 21, 2018

@benjaminrich
Copy link
Owner

@benjaminrich benjaminrich commented Jun 21, 2018

Excellent. Then I am closing the issue. Thanks.

@hdeng88
Copy link
Author

@hdeng88 hdeng88 commented Jun 21, 2018

benjaminrich referenced this issue Jun 21, 2018
Added RStudio notebook preview support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.