copy/paste of large amount of code to terminal leads to scrambled/missing characters

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

copy/paste of large amount of code to terminal leads to scrambled/missing characters

R help mailing list-2
Dear R-users,

This question might not be restricted to R, but I hope that some might have experienced similar problems and could help me.

When using R, I usually work with a text-editor (textmate2) in which I prepare the script.
To execute code, I then copy and paste it to an R-session running in the terminal/shell (on Mac OS).

Unfortunately, when pasting too much code into the terminal (e.g. 60 lines), some characters are occasionally and randomly scrambled or missing.
For example "col <- ifelse(..." turns into "col < col < cse(…".

This happens very randomly, is difficult to predict, and while it only affects a hand full of characters in total, it leads to a lot of errors in the code execution along the way.
Apparently, it has to do with the buffer size and paste-speed of the terminal.

So far, I could not find any solution to the problem.

Therefore, I wanted to ask;
Do others here use a similar workflow (i.e. having a text-editor for coding and using copy/paste to the terminal for code execution) and encountered similar problems with big chunks of code in the clipboard?
Are there any solutions for this problem, specifically for running R over the shell?

Thank you very much!

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: copy/paste of large amount of code to terminal leads to scrambled/missing characters

Jeff Newmiller
This sounds like a problem with your editor or the OS clipboard support rather than R. You might get a response here, but R-sig-mac seems more appropriate to me for such discussion.
--
Sent from my phone. Please excuse my brevity.

On February 3, 2018 4:23:54 PM PST, Martin Batholdy via R-help <[hidden email]> wrote:

>Dear R-users,
>
>This question might not be restricted to R, but I hope that some might
>have experienced similar problems and could help me.
>
>When using R, I usually work with a text-editor (textmate2) in which I
>prepare the script.
>To execute code, I then copy and paste it to an R-session running in
>the terminal/shell (on Mac OS).
>
>Unfortunately, when pasting too much code into the terminal (e.g. 60
>lines), some characters are occasionally and randomly scrambled or
>missing.
>For example "col <- ifelse(..." turns into "col < col < cse(…".
>
>This happens very randomly, is difficult to predict, and while it only
>affects a hand full of characters in total, it leads to a lot of errors
>in the code execution along the way.
>Apparently, it has to do with the buffer size and paste-speed of the
>terminal.
>
>So far, I could not find any solution to the problem.
>
>Therefore, I wanted to ask;
>Do others here use a similar workflow (i.e. having a text-editor for
>coding and using copy/paste to the terminal for code execution) and
>encountered similar problems with big chunks of code in the clipboard?
>Are there any solutions for this problem, specifically for running R
>over the shell?
>
>Thank you very much!
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: copy/paste of large amount of code to terminal leads to scrambled/missing characters

Bert Gunter-2
Obvious suggestion: use a more capable IDE instead of Textmate2 with
copy/paste.

RStudio is very popular now, but there are many others . Search on e.g. "R
IDE For MAC" to see some alternatives.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sat, Feb 3, 2018 at 4:51 PM, Jeff Newmiller <[hidden email]>
wrote:

> This sounds like a problem with your editor or the OS clipboard support
> rather than R. You might get a response here, but R-sig-mac seems more
> appropriate to me for such discussion.
> --
> Sent from my phone. Please excuse my brevity.
>
> On February 3, 2018 4:23:54 PM PST, Martin Batholdy via R-help <
> [hidden email]> wrote:
> >Dear R-users,
> >
> >This question might not be restricted to R, but I hope that some might
> >have experienced similar problems and could help me.
> >
> >When using R, I usually work with a text-editor (textmate2) in which I
> >prepare the script.
> >To execute code, I then copy and paste it to an R-session running in
> >the terminal/shell (on Mac OS).
> >
> >Unfortunately, when pasting too much code into the terminal (e.g. 60
> >lines), some characters are occasionally and randomly scrambled or
> >missing.
> >For example "col <- ifelse(..." turns into "col < col < cse(…".
> >
> >This happens very randomly, is difficult to predict, and while it only
> >affects a hand full of characters in total, it leads to a lot of errors
> >in the code execution along the way.
> >Apparently, it has to do with the buffer size and paste-speed of the
> >terminal.
> >
> >So far, I could not find any solution to the problem.
> >
> >Therefore, I wanted to ask;
> >Do others here use a similar workflow (i.e. having a text-editor for
> >coding and using copy/paste to the terminal for code execution) and
> >encountered similar problems with big chunks of code in the clipboard?
> >Are there any solutions for this problem, specifically for running R
> >over the shell?
> >
> >Thank you very much!
> >
> >______________________________________________
> >[hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: copy/paste of large amount of code to terminal leads to scrambled/missing characters

Eric Berger
Hi Martin,
Why not just do the following?
In your editor after you create the script save it to a file, say "foo.R".
Then in your R session you give the command
> source("foo.R")

HTH,
Eric


On Sun, Feb 4, 2018 at 6:33 AM, Bert Gunter <[hidden email]> wrote:

> Obvious suggestion: use a more capable IDE instead of Textmate2 with
> copy/paste.
>
> RStudio is very popular now, but there are many others . Search on e.g. "R
> IDE For MAC" to see some alternatives.
>
> Cheers,
> Bert
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Sat, Feb 3, 2018 at 4:51 PM, Jeff Newmiller <[hidden email]>
> wrote:
>
> > This sounds like a problem with your editor or the OS clipboard support
> > rather than R. You might get a response here, but R-sig-mac seems more
> > appropriate to me for such discussion.
> > --
> > Sent from my phone. Please excuse my brevity.
> >
> > On February 3, 2018 4:23:54 PM PST, Martin Batholdy via R-help <
> > [hidden email]> wrote:
> > >Dear R-users,
> > >
> > >This question might not be restricted to R, but I hope that some might
> > >have experienced similar problems and could help me.
> > >
> > >When using R, I usually work with a text-editor (textmate2) in which I
> > >prepare the script.
> > >To execute code, I then copy and paste it to an R-session running in
> > >the terminal/shell (on Mac OS).
> > >
> > >Unfortunately, when pasting too much code into the terminal (e.g. 60
> > >lines), some characters are occasionally and randomly scrambled or
> > >missing.
> > >For example "col <- ifelse(..." turns into "col < col < cse(…".
> > >
> > >This happens very randomly, is difficult to predict, and while it only
> > >affects a hand full of characters in total, it leads to a lot of errors
> > >in the code execution along the way.
> > >Apparently, it has to do with the buffer size and paste-speed of the
> > >terminal.
> > >
> > >So far, I could not find any solution to the problem.
> > >
> > >Therefore, I wanted to ask;
> > >Do others here use a similar workflow (i.e. having a text-editor for
> > >coding and using copy/paste to the terminal for code execution) and
> > >encountered similar problems with big chunks of code in the clipboard?
> > >Are there any solutions for this problem, specifically for running R
> > >over the shell?
> > >
> > >Thank you very much!
> > >
> > >______________________________________________
> > >[hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > >https://stat.ethz.ch/mailman/listinfo/r-help
> > >PLEASE do read the posting guide
> > >http://www.R-project.org/posting-guide.html
> > >and provide commented, minimal, self-contained, reproducible code.
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> > posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: copy/paste of large amount of code to terminal leads to scrambled/missing characters

Berend Hasselman
In reply to this post by R help mailing list-2

Why not use the R bundle for TextMate and run your script directly in TextMate? You'll get nice output.

And if you want to run R directly and get the output in a .Rout file you can add a command to the R bundle, create a small script that runs R in batch.
Create a new command in the R bundle, give it an appropriate name  and then put this in the body of the command:

#!/bin/bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"

if [[ ${#TM_DIRECTORY} -gt 0 ]]; then
        cd "${TM_DIRECTORY}"
else
    exit_show_tool_tip "Save file first!"    
fi

R CMD BATCH --encoding=UTF-8 --no-save --no-timing ${TM_FILENAME}
mate ${TM_FILENAME}out

Berend Hasselman

> On 4 Feb 2018, at 01:23, Martin Batholdy via R-help <[hidden email]> wrote:
>
> Dear R-users,
>
> This question might not be restricted to R, but I hope that some might have experienced similar problems and could help me.
>
> When using R, I usually work with a text-editor (textmate2) in which I prepare the script.
> To execute code, I then copy and paste it to an R-session running in the terminal/shell (on Mac OS).
>
> Unfortunately, when pasting too much code into the terminal (e.g. 60 lines), some characters are occasionally and randomly scrambled or missing.
> For example "col <- ifelse(..." turns into "col < col < cse(…".
>
> This happens very randomly, is difficult to predict, and while it only affects a hand full of characters in total, it leads to a lot of errors in the code execution along the way.
> Apparently, it has to do with the buffer size and paste-speed of the terminal.
>
> So far, I could not find any solution to the problem.
>
> Therefore, I wanted to ask;
> Do others here use a similar workflow (i.e. having a text-editor for coding and using copy/paste to the terminal for code execution) and encountered similar problems with big chunks of code in the clipboard?
> Are there any solutions for this problem, specifically for running R over the shell?
>
> Thank you very much!
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.