yonicd / carbonate

carbon.js for R
https://yonicd.github.io/carbonate/
Other
212 stars 5 forks source link

reprex & carbonate #14

Closed maelle closed 6 years ago

maelle commented 6 years ago

The problem I am wondering how to use carbonate and reprex together. I.e. I'd like something similar to choosing a new venue for reprex, that'd let me obtain a carbonate image and URL of the code I'd copied to clipboard, together with its output.

Describe solutions you've considered I think it might only be a documentation need.

yonicd commented 6 years ago

Quick solution would be to run reprex.

The solution is placed on the clipboard by reprex.

Use the clipboard in a obj <- carbon$new().

Setting obj$add_tiny <- TRUE would add a tinyurl to the image.

yonicd commented 6 years ago
Simple <- R6::R6Class("Simple",
                  public = list(
                    x = 1,
                    getx = function() self$x
                  )
)

Simple$set('public','foo',list(NULL))

Simple$public_fields
Rendering reprex...
Rendered reprex is on the clipboard.
obj <- carbonate::carbon$new()
obj$add_tinyurl <- TRUE
obj$tiny()
[1] "http://tinyurl.com/yaz3cg88"
obj$carbonate()

reprex

maelle commented 6 years ago

Nice! Only improvement I'd see would be to use venue=r in reprex. Do you want me to make a PR to document this "somewhere"?

yonicd commented 6 years ago

indeed the venue should be r good catch.

reprex

If you could make a PR that would be great! probably a vignette, seeing that the Readme is already overloaded and needs to be trimmed anyways. (If you want to add it as a new details chunk in the sharing subsection of the Readme that is also great, when I get a chance I can reorganize).

I'm interested to know what the use case you had in mind to combine the two outputs?

Thanks!

maelle commented 6 years ago

Will write a vignette soon then!

The reason for my asking is that I'm preparing a talk including a section about where/how to get help. It'll include a reprex demo. Now I'm curious how to make reprex interact with carbonate to show how one could e.g. tweet a question.

One workflow I had in mind but that's maybe a bit cumbersome to show some code (buggy or not) would involve a reprex, reprex, gistr and carbonate (just as a way to advertise the thing on Twitter/Slack with a nice pic, and with the gist URL as URL).

No well-formed ideas yet though.

yonicd commented 6 years ago

sounds cool. you can directly tweet from the carbon object.

yonicd commented 6 years ago

it would be cool if the venue for reprex could be gist and then it would set up for you the gist with the reprexed code and add the gist link to the footer of the reprex output to clipr.

maelle commented 6 years ago

Cf https://github.com/tidyverse/reprex/issues/190

cderv commented 6 years ago

it would be cool if the venue for reprex could be gist

I would find this cool too ! 😉 It still is in my TODO. Should prioritize that maybe... 🤔 Thanks for the cross-referencing @maelle.

Using carbonate and reprex together was also on my mind. I try to have a look at what you already have done!

maelle commented 6 years ago

My experiments https://github.com/maelle/reprex_demo

I will contribute a README section to carbonate (rather than a vignette) once I can take a screenshot cf #15

yonicd commented 6 years ago

closing.