[R] Linux-Windows problem

Duncan Murdoch murdoch.duncan at gmail.com
Tue Jul 6 19:08:26 CEST 2010


On 06/07/2010 11:54 AM, Bos, Roger wrote:
> Its not an R problem, but an editor problem (therefore slightly off-topic I admit).  I do most of the coding in Windows and somestimes the Rkward editor (in linux) will not open the file and it tells me it cannot determine the encoding.  If I try to source that file into R (in the linux version) I sometimes get an unexpected character on line such and such, but I don't see any problem and the code runs fine in windows.  The fix, I discovered is to open the file in notepad (in windows) and resave it.  Then Rkward will open it just fine.  
>
> I am sure there is an easy setting I can change to make the two work more smoothly together, but I just haven't found it yet.
>   

If you avoid non-ascii characters, you shouldn't have problems.  (Ascii 
is a subset of most of the encodings used on Windows and Linux.)  The 
only likely problem would come if you save in "Unicode" (UCS-2), which 
your Linux system may have trouble recognizing.

Duncan Murdoch
> Thanks,
>
> Roger
>
>
> -----Original Message-----
> From: henrik.bengtsson at gmail.com [mailto:henrik.bengtsson at gmail.com] On Behalf Of Henrik Bengtsson
> Sent: Tuesday, July 06, 2010 9:24 AM
> To: Bos, Roger
> Cc: Uwe Ligges; Ildiko Varga; r-help
> Subject: Re: [R] Linux-Windows problem
>
> Sorry for asking the obvious, but have you confirmed that you are running the same version of R on both systems?
>
> /H
>
> On Tue, Jul 6, 2010 at 2:11 PM, Bos, Roger <roger.bos at rothschild.com> wrote:
> > Uwe,
> >
> > I suspect I might be having a similar problem as the R code I generate 
> > in Windows editor (Tinn-R) doesn't always open properly in my Linux 
> > editor (Rkward), but I don't know how to change the default encoding 
> > in either one.
> >
> > In R on both machines, getOption("encoding") returns "native.enc", so 
> > the problem is not with R, but rather at the OS or editor level.  If 
> > you or anyone could help me out that would be appreciated.
> >
> > Thanks,
> >
> > Roger
> >
> > -----Original Message-----
> > From: r-help-bounces at r-project.org 
> > [mailto:r-help-bounces at r-project.org]
> > On Behalf Of Uwe Ligges
> > Sent: Monday, July 05, 2010 10:04 AM
> > To: Ildiko Varga
> > Cc: r-help at r-project.org
> > Subject: Re: [R] Linux-Windows problem
> >
> >
> >
> > On 05.07.2010 14:31, Ildiko Varga wrote:
> >> Dear All,
> >>
> >> I faced the following problem. With the same data.frame the results 
> >> are different under Linux and Windows.
> >> Could you help on this topic?
> >
> > I guess you read in the data differently since you have different 
> > default encodings on both platforms (e.g. latin1 vs. UTF-8) and you 
> > data is probably not plain ASCII.
> >
> > Best,
> > Uwe Ligges
> >
> >> Thanks in advance,
> >> Ildiko
> >>
> >> Linux:
> >>   >  d = read.csv("CRP.csv")
> >>   >  d$drugCode = as.numeric(d$drug)
> >>   >  cor(d, use="pairwise.complete.obs")
> >>             PATIENT     BL.CRP   X24HR.CRP   X48HR.CRP drug   
> >> drugCode PATIENT        NA         NA          NA          NA   NA         
> >> NA BL.CRP         NA  1.0000000  0.84324880 -0.05699590   NA 
> >> -0.3367147 X24HR.CRP      NA  0.8432488  1.00000000 -0.06162383   NA 
> >> -0.3557316 X48HR.CRP      NA -0.0569959 -0.06162383  1.00000000   NA  
> >> 0.1553356 drug           NA         NA          NA          NA   NA         
> >> NA drugCode       NA -0.3367147 -0.35573159  0.15533562   NA  
> >> 1.0000000 Warning message:
> >> In cor(d, use = "pairwise.complete.obs") : NAs introduced by coercion
> >>   >  str(d)
> >> 'data.frame':   41 obs. of  6 variables:
> >>    $ PATIENT  : Factor w/ 41 levels "RV13","RV14",..: 2 3 4 6 7 12 13
> >> 14
> >> 15 17 ...
> >>    $ BL.CRP   : num  7.3 31.2 4.2 6.7 1.6 7.7 5.3 38.9 1 7.3 ...
> >>    $ X24HR.CRP: num  6.1 24.9 11.1 4.9 1 5 3.7 18 1 7.3 ...
> >>    $ X48HR.CRP: num  121.5 40 28.4 34.5 33.3 ...
> >>    $ drug     : Factor w/ 2 levels "active","placebo": 1 1 1 1 1 1 1 
> >> 1
> > 1
> >> 1 ...
> >>    $ drugCode : num  1 1 1 1 1 1 1 1 1 1 ...
> >>
> >>           Windows:
> >>   >  d = read.csv("CRP.csv")
> >>   >  d$drugCode = as.numeric(d$drug)
> >>   >  cor(d, use="pairwise.complete.obs") Error in cor(d, use =
> >> "pairwise.complete.obs") : 'x' must be numeric
> >>   >  str(d)
> >> 'data.frame':   41 obs. of  6 variables:
> >>    $ PATIENT  : Factor w/ 41 levels "RV13","RV14",..: 2 3 4 6 7 12 13
> >> 14
> >> 15 17 ...
> >>    $ BL.CRP   : num  7.3 31.2 4.2 6.7 1.6 7.7 5.3 38.9 1 7.3 ...
> >>    $ X24HR.CRP: num  6.1 24.9 11.1 4.9 1 5 3.7 18 1 7.3 ...
> >>    $ X48HR.CRP: num  121.5 40 28.4 34.5 33.3 ...
> >>    $ drug     : Factor w/ 2 levels "active","placebo": 1 1 1 1 1 1 1 
> >> 1
> > 1
> >> 1 ...
> >>    $ drugCode : num  1 1 1 1 1 1 1 1 1 1 ...
> >>
> >>       [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> R-help at r-project.org mailing list
> >> 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.
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > 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.
> > ***************************************************************
> >
> > This message is for the named person's use only. It 
> > may\...{{dropped:20}}
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > 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.
> >
> ***************************************************************
>
> This message is for the named person's use only. It may
> contain confidential, proprietary or legally privileged
> information. No right to confidential or privileged treatment
> of this message is waived or lost by an error in transmission.
> If you have received this message in error, please immediately
> notify the the sender by e-mail, delete the message and all 
> copies from your system and destroy any hard copies.  You must
> not, directly or indirectly, use, disclose, distribute, 
> print or copy any part of this message if you are not
> the intended recipient.
>
> ****************************************************************
>
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email 
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>



More information about the R-help mailing list