Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8994939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:32:08+00:00 2026-06-15T23:32:08+00:00

This will make more sense with an example. Typical R manuals from CRAN show

  • 0

This will make more sense with an example. Typical R manuals from CRAN show R code with a line starting with > and indentations indicated with +. See
http://cran.r-project.org/web/packages/doMC/vignettes/gettingstartedMC.pdf
for an example.

The trouble is that you can’t cut and paste that into a console without copying it into an editor and removing those arrow and plus characters. Is there an easier way to execute that text as R code? I figured that somebody must have dealt with this problem. Otherwise, I guess I’ll write a script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:32:10+00:00Added an answer on June 15, 2026 at 11:32 pm

    The writing has already been done.

    2009 post by Duncan Murdoch:

    CleanTranscript <- function(lines) {
             lines <- grep("^[[:blank:]]*[^>+[:blank:]]*[>+]", lines, value = TRUE) 
             lines <- sub("^[[:blank:]]*[^>+[:blank:]]*[>+] ?", "", lines) }
    
    source(textConnection(CleanTranscript(
           # This is the Windows input strategy
           readLines("clipboard")
           # See below for Mac version
                          )), 
                          echo = TRUE, max.deparse.length=Inf) 
    

    Subsequent 2009 R-help post by Gabor Grothendieck:

    process.source <- function(action = c("both", "run", "show"), echo = TRUE,
        max.deparse.length = Inf, ...) { 
        # This is the Mac input strategy
        L <- readLines(pipe("pbpaste"))
        #  for Windows devices use
        #  L <- readLines("clipboard")
        rx <- "^[[:blank:]]*[^>+[:blank:]]*[>+]" 
        is.cmd <- grepl(rx, L) 
        L[is.cmd] <- gsub(paste(rx, "?"), "", L[is.cmd]) 
        L[!is.cmd] <- paste("#", L[!is.cmd]) 
        action <- match.arg(action) 
      if (action != "run") for(el in L) cat(el, "\n") 
      if (action == "both") cat("##################################\n") 
      if (action != "show") 
           source(textConnection(L), echo = echo, 
           max.deparse.length = max.deparse.length, ...) 
    invisible(L) }
    

    Note: The upvotes prompted me to post this as a “feature request” on the RStudio Discussion Board. Although I have not broken it yet, it might need more testing if it were to be built in to the RStudio framework.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this line of code will make the cell text-wrap: $objPHPExcel->getActiveSheet()->getStyle('D1')->getAlignment()->setWrapText(true); 'D1'
I don't know if this question will make sense to begin with... Example Given:
[This will only make sense if you've seen Kevin Smith's 'Erlang in Practice' screencasts]
Hopefully this explanation will make sense, but what is the best way (if it
Ho to make this simple xml with php using DOM? Full code will be
From a logical perspective it sometime doesn't make sense, for example, to add an
Hopefully this will make sense. I have a page where an user can create
I will make this quick. I'm using Ruby/LDAP to search using my base_dn criteria.
I will make this quick and simple I have a query and I want
How do you sort an array of strings in C++ that will make this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.