> ---------- Forwarded message ----------
> From: David Winsemius <[email protected]>
> To: Brandon Hurr <[email protected]>
> Cc: [email protected]
> Date: Wed, 29 Aug 2012 14:43:15 -0700
> Subject: Re: [R-SIG-Mac] "¬" in Script Editor
>
> On Aug 29, 2012, at 1:13 AM, Brandon Hurr wrote:
>
>  I've been noticing lately some weirdness in the editor when copying
>> and pasting code.
>>
>> Last night when I was trying to run some code from the ggplot2 mailing
>> list I pasted the code in from gmail. As usual, there were extra line
>> breaks that caused the code to fail.
>>
>> I pasted the code into the script editor to fix the line breaks and
>> then copy/pasted it into R-GUI. I then got a lot more errors than I
>> did previously, all of which were caused by the insertion of an
>> invisible "¬" symbol (a logical not).
>>
>> Here: 
>> https://plus.google.com/**116319893425910717496/posts/**5Yxkk7GFwts<https://plus.google.com/116319893425910717496/posts/5Yxkk7GFwts>
>> is a screen shot.
>>
>>
> I have had similar problems with stuff copied from web postings and
> generally solve them by pasting first into an editing session with
> TextWrangler and using it's sanitizing functions, Zap Gremlins, IIRC. I
> first tried to delete them with TextEdit.app but they proved remarkably
> persistent.
>
>
>  The code in question is from this question:
>> https://groups.google.com/**forum/?fromgroups=#!topic/**
>> ggplot2/BxSDoDjJgSA<https://groups.google.com/forum/?fromgroups=#%21topic/ggplot2/BxSDoDjJgSA>
>> ... but this has happened before a few times (I cannot recall when it
>> started, recently... perhaps since installing ML, but maybe before
>> that). If I hit up to input the previous previous command the "¬" are
>> not there and when I search in the editor for this symbol nothing is
>> found.
>>
>> Is there something going on with the editor or the clipboard or ...?
>> Where should I be looking?
>>
>> Brandons-MacBook-Air:~ bhurr$ system_profiler SPSoftwareDataType
>> Software:
>>
>
> --
>
>
> David Winsemius, MD
> Alameda, CA, USA
>

I do a scary amount of copy-and-paste into an R console, and have seen
several similar errors.  I copy to an editor (Komodo Edit with SciViews-K)
then to R console if I'm trying code from the web though.  My most common
problem has been tab characters.  My R console's tab auto-complete gets
tripped up when pasting code with embedded tabs.  Not the newlines, and
only rarely with UTF-8 non-ASCII characters that somehow get mangled in
transit.  The tabs.  I'd hear it beeping away and briefly see it try to ask
if I'd like to see all 1800 possibilities (like if you type 'a' then hit
tab twice), then continue on with a subset of code after some random
character was accepted by the prompt.  I stopped doing that quickly.  :-)

It is bad ("risky" bad, not just "bad form" bad) to copy-paste code from a
website without going through at least text editor first.  Here's why:
-- you never know what characters are actually in the clipboard, best not
paste into a *live* session before you find out.  Used to be a common web
trick to hide characters that only a search engine spider could see.  Get a
text editor that can either auto-clean tab characters at least, or makes it
easy to auto-clean them.
-- sometimes code is embedded out of order.  *So* frustrating but
frequently with font changes and highlighting, some chunks of code get out
of order.  If you slowly click and drag across the text in some PDF files,
and on some R-highlighted web sites, you'll see the selected text change in
non-linear manner. When you paste, the characters are illogically ordered
-- very not user-friendly.  Recent use of things like knitr and Gist do
much better at providing paste-able code.  (I.e. without the '>' and '+'
characters which granted are beautiful on their own, but choke up the R
terminal.)
-- hinted above, but almost all PDF vignettes are composed of
non-paste-able R code because of the '+'s.  Kind of defeats the primary
purpose of even having a vignette, but it is what it is.  Still way better
than having no vignette at all.

I don't much mind the copying-pasting R code into a terminal.  I like that
it decouples my R editing from R execution, and so it doesn't hang my R
editor whenever the R session needs to go compute genome-wide read
coverages across numerous samples for an hour or so.  The first time that
happened (back when I used Eclipse/StatET) I used my newly acquired free
hour to search for an alternate editor, since my Eclipse was hung waiting
for R to finish processing and I literally *had* to use something else.

My currently problem is a line limit -- whenever I try to paste too many
lines at once, after about maybe 12 or so lines the pasted text gets
garbled, and the R command fails due to mangled text.  If I copy/paste
fewer lines it works fine.  I've not been able to find this symptom via
Google, and don't know if it is something from Mac OSX or from R's readline
call, or what.  It does happen in OSX "Terminal.app" and in "iTerm2.app",
so not specific to either one.  Anyway I just copy/paste in chunks of 6-8
lines at a time.  If anyone recognizes this symptom though, I'd love to
resolve it!

Best,

James
-- 
James M. Ward
Computational Biologist and Genome Informaticist
NIEHS Bioinformatics, RTP, NC
(919) 699-3631 (cell)
(919) 613-4642 (work)
[email protected]
[email protected]

        [[alternative HTML version deleted]]

_______________________________________________
R-SIG-Mac mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to