Code Monkey home page Code Monkey logo

Comments (9)

jennybc avatar jennybc commented on June 16, 2024

This doesn't come up for me, I think, because I'm always composing in an editor and would copy prompt-free code from there.

But I see what you mean! I can't think of any legitimate reason to have leading prompts in reprex() input so I suppose I can automatically strip. I'll do this ... only question is whether to do for clipboard input only or just across the board.

from reprex.

jennybc avatar jennybc commented on June 16, 2024

Because sometimes I too am forced to work with "reprex" code other people have posted somewhere that includes the prompts.

from reprex.

jasonmtroos avatar jasonmtroos commented on June 16, 2024

Then maybe an optional parameter strip_prompt = NULL that can accept a string? For me the use cases probably involve emailing students or generating code to be inserted into non-markdown slides. These are certainly edge cases.

from reprex.

jennybc avatar jennybc commented on June 16, 2024

Note to self: maybe I should trigger reading from clipboard via default behaviour of the input argument (instead of when both x and input are NULL). Then I could enact prompt stripping there for all non-expression input?

from reprex.

jennybc avatar jennybc commented on June 16, 2024

For me the use cases probably involve emailing students or generating code to be inserted into non-markdown slides. These are certainly edge cases.

Now here you seem to be talking about output, not handling of input. Do you want to add the prompt to your reprex() output? Because I can show you how to do that.

from reprex.

jennybc avatar jennybc commented on June 16, 2024

If you want to make it look like an R transcript, you can override the default chunk options like so:

This input:

reprex({
  x <- 1:4
  y <- 2:5
  x + y
}, opts_chunk = list(comment = NA, prompt = TRUE))

gives this output:

> x <- 1:4
> y <- 2:5
> x + y
[1] 3 5 7 9

from reprex.

jasonmtroos avatar jasonmtroos commented on June 16, 2024

Sorry for the confusion, that's not what I mean: I am indeed talking about handling of input. What I mean is that I am sometimes working interactively in the command window and need to just copy the last few lines I executed. This sometimes happens when emailing a student (e.g. to make sure a code snippet actually executes as expected before sending)...

from reprex.

jennybc avatar jennybc commented on June 16, 2024

OK got it.

from reprex.

jasonmtroos avatar jasonmtroos commented on June 16, 2024

Thanks, works great!

from reprex.

Related Issues (20)

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.