Closed debruine closed 12 months ago
Thanks @debruine! I have just checked it, and inline buttons can be easily used without the need for any additional CSS or tags. You just need to define the button beforehand, and then use the inline syntax to include it in your text, like so:
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(downloadthis)
d_btn <- mtcars %>%
download_this(
output_name = "mtcars dataset",
output_extension = ".csv",
button_label = "Download data as csv",
button_type = "default",
has_icon = TRUE,
icon = "fa fa-save"
)
This is an R Markdown document. Markdown is a r d_btn
simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
I was using it like that already, so I’ll have to explore further what went wrong.
On 7 Feb 2022, at 07:51, Felipe Mattioni Maturana @.***> wrote:
 Thanks @debruine! I have just checked it, and inline buttons can be easily used without the need for any additional CSS or tags. You just need to define the button beforehand, and then use the inline syntax to include it in your text, like so:
title: "Untitled" output: html_document
knitr::opts_chunk$set(echo = FALSE) library(downloadthis)
d_btn <- mtcars %>% download_this( output_name = "mtcars dataset", output_extension = ".csv", button_label = "Download data as csv", button_type = "default", has_icon = TRUE, icon = "fa fa-save" )
R Markdown
This is an R Markdown document. Markdown is a
r d_btn
simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.
Feel free to submit a reprex
Hi Felipe,
when I saved your example from above as a.Rmd
I get:
render(input = "a.Rmd", output_file = I("a.htm"))
processing file: a.Rmd
|.......... | 20%
ordinary text without R code
|.................... | 40%
label: setup (with options)
List of 1
$ include: logi FALSE
|.............................. | 60%
ordinary text without R code
|........................................ | 80%
label: unnamed-chunk-1
Quitting from lines 12-21 (a.Rmd)
Error in readRDS(nsInfoFilePath) : unknown input format
Any ideas what might have gone wrong?
@Helmut01 I could not reproduce your error. Could you please post your entire code (including a.Rmd
)?
@aniruhil I don't get your comment – if you are having problems, please open a new issue.
Thanks @debruine! I have just checked it, and inline buttons can be easily used without the need for any additional CSS or tags. You just need to define the button beforehand, and then use the inline syntax to include it in your text, like so:
--- title: "Untitled" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) library(downloadthis)
d_btn <- mtcars %>% download_this( output_name = "mtcars dataset", output_extension = ".csv", button_label = "Download data as csv", button_type = "default", has_icon = TRUE, icon = "fa fa-save" )
R Markdown
This is an R Markdown document. Markdown is a
r d_btn
simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
@fmmattioni Your example does not work for me. Please see below for a 'reprex':
---
title: "Untitled"
author: "Ani Ruhil"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(downloadthis)
library(tidyverse)
mtcars %>%
download_this(
output_name = "mtcars dataset",
output_extension = ".csv",
button_label = "Download data as csv",
button_type = "default",
has_icon = TRUE,
icon = "fa fa-save"
)
d_btn <- mtcars %>%
download_this(
output_name = "mtcars dataset",
output_extension = ".csv",
button_label = "Download data as csv",
button_type = "default",
has_icon = TRUE,
icon = "fa fa-save"
)
Markdown is a r d_btn
simple formatting syntax for authoring HTML
Results in the button showing up on a separate line altogether, and not inline. See here for a screenshot, for example,
<img width="319" alt="Screen Shot 2022-02-13 at 13 26 14" src="https://user-images.githubusercontent.com/1810206/153769188-2b8b65aa-f612-4177-87da-8ca284bd5c1d.png">
@aniruhil I cannot reproduce this.. could you please post here the result of sessioninfo::session_info()
?
Here it is @fmmattioni and my thanks both for an awesome package and for being so swift in your responses.
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.2.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 knitr_1.37 magrittr_2.0.2 prompt_1.0.1
[5] gert_1.5.0 rlang_1.0.1 fastmap_1.1.0 fansi_1.0.2
[9] stringr_1.4.0 tools_4.1.2 sys_3.4 parallel_4.1.2
[13] rprofile_0.1.7 xfun_0.29 xaringan_0.22 utf8_1.2.2
[17] cli_3.1.1 htmltools_0.5.2 askpass_1.1 ellipsis_0.3.2
[21] remotes_2.4.2 yaml_2.2.2 openssl_1.4.6 digest_0.6.29
[25] tibble_3.1.6 lifecycle_1.0.1 crayon_1.4.2 vctrs_0.3.8
[29] credentials_1.3.2 rsconnect_0.8.25 evaluate_0.14 memoise_2.0.1
[33] glue_1.6.1 cachem_1.0.6 prettycode_1.1.0 rmarkdown_2.11
[37] stringi_1.7.6 compiler_4.1.2 pillar_1.7.0 memuse_4.2-1
[41] pkgconfig_2.0.3
@aniruhil and also attach here your Rmd and resulting HTML files please (the files, not the code)
github will not let me add html file; unspported file type msg when I try. So here is a zip archive with Rmd and html. Hope this will work.
@Helmut01 I could not reproduce your error. Could you please post your entire code (including
a.Rmd
)?
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] downloadthis_0.3.0 rmarkdown_2.11
loaded via a namespace (and not attached):
[1] compiler_4.1.2 magrittr_2.0.2 fastmap_1.1.0 cli_3.1.1
[5] tools_4.1.2 htmltools_0.5.2 knitr_1.37 xfun_0.29
[9] digest_0.6.29 rlang_1.0.1 evaluate_0.14
Thank you all for all the info. I could finally reproduce this using RStudio Cloud. I am going to investigate it further.
Alright, I am going to need some extra time to understand how rmarkdown
is placing these p
tags, but for now you can create a div
around the text you need the inline buttons, and then add a css selector on the p
tags inside this div, like so:
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(downloadthis)
.inline-btns p {
display: inline;
}
d_btn <- mtcars %>%
download_this(
output_name = "mtcars dataset",
output_extension = ".csv",
button_label = "Download data as csv",
button_type = "default",
has_icon = TRUE,
icon = "fa fa-save"
)
Thanks again, @fmmattioni
I believe this issue does not exist anymore? I can't reproduce it anymore. If you still find any issues related to this, feel free to reopen the issue @aniruhil @debruine @Helmut01
Can you add an option for inline buttons?
I think the way the button html is inserted with line breaks means that markdown puts paragraph markers around them, so that would have to be fixed. An inline argument would probably also require a CSS style that you provide (I'm happy to style them myself, but I think an inline option would be confusing for most R users if it didn't actually make the buttons inline).
Thanks for making a cool package!