Comments (9)
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.
Because sometimes I too am forced to work with "reprex" code other people have posted somewhere that includes the prompts.
from reprex.
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.
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.
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.
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.
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.
OK got it.
from reprex.
Thanks, works great!
from reprex.
Related Issues (20)
- Warning that R appears to crash when it does not HOT 1
- Thoughts about talking about reprexes HOT 1
- Error in xfun::normalize_path() : unused argument (resolve_symlink = FALSE) HOT 2
- reprex:::reprex_addin() on posit cloud does not show the preview HOT 1
- Take advantage of some backtrace improvements HOT 3
- Running in non-interactive mode using the `input` argument seems to use an existing `<input>_reprex.R` HOT 2
- Reprex v2.0.2 does not print all columns of bench::mark() HOT 1
- Upkeep for reprex
- Reprex skipping some statements (these should cause an error) HOT 2
- Add wd panel to Rstudio Addins Menu HOT 1
- Error in `reprex_render_impl()` HOT 3
- Unable to generate a reprex due to possibly clipboard or file connection issue HOT 2
- Question: Does `{reprex}` support MS Teams? HOT 4
- Error in reprex_render_impl() HOT 1
- Don't show the full backtrace HOT 1
- Output when following documentation instructions does not match expected result HOT 2
- Release reprex 2.1.0
- Enhance `would_clobber()` with more help getting rid of the offending file
- Error in read_xml.raw(res) : Start tag expected, '<' not found [4] HOT 4
- Warning exists when `reprex(... style = FALSE)` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reprex.