[R-sig-Debian] piping to littler

Sebastian P. Luque spluque at gmail.com
Mon Jun 1 23:38:31 CEST 2009


On Mon, 1 Jun 2009 13:53:54 -0500,
Dirk Eddelbuettel <edd at debian.org> wrote:

> On 1 June 2009 at 13:06, Sebastian P. Luque wrote:
>> Hi,
>> 
>> This code used to work well until a few months ago (I haven't used it
>> since), but now it's giving this:
>> 
>> ---<--------------------cut
>> here---------------start------------------->--- $ cat <<EOF | r -
>> locs <- read.csv(list.files(pattern="ds_.+_.+\\.csv"),
>> colClasses=c(rep("character", 2), "numeric", "character",
>> rep("numeric", 2), rep("character", 4), rep("numeric", 3),
>> rep("logical", 4))) EOF > > > > > Loading required package: methods
>> littler: Incomplete Line! Need more code!
>> ---<--------------------cut
>> here---------------end--------------------->---
>> 
>> It seems like a quoting issue but I can't pinpoint it.  Thanks.

> Maybe it is something else.  Did you change shells?

No I didn't, I still use bash with the same ~/.bashrc.


> Reading from '-' still works for me when needed. Here is a quick
> throw-away example using awk to pick file size from a directory
> listing and letting r summarize it [1]

> edd at ron:~$ ls -l /etc | awk '/^-/ {print $5}' | r
> -e'print(summary(as.numeric(readLines())))' - Min. 1st Qu.  Median
> Mean 3rd Qu.  Max.  0 272 843 7980 2540 219000 edd at ron:~$

Yes, there's no problems with that here either, nor with:

---<--------------------cut here---------------start------------------->---
$ cat <<EOF | r -
print(summary(read.csv("ds_060910_090528.csv", colClasses=c(rep("character", 2), "numeric", "character", rep("numeric", 2), rep("character", 4), rep("numeric", 3), rep("logical", 4)))))
EOF
> > Loading required package: methods
      id              prognum              locid           ptt           
 Length:15284       Length:15284       Min.   :    1   Length:15284      
 Class :character   Class :character   1st Qu.:21168   Class :character  
 Mode  :character   Mode  :character   Median :26996   Mode  :character  
                                       Mean   :24264                     
                                       3rd Qu.:33271                     
                                       Max.   :37566                     
                                       NA's   :   32                     
     nlines        nsensors      satname              date          
 Min.   : 4.0   Min.   : 3.0   Length:15284       Length:15284      
 1st Qu.: 8.0   1st Qu.:11.0   Class :character   Class :character  
 Median :10.0   Median :15.0   Mode  :character   Mode  :character  
 Mean   :11.7   Mean   :17.6                                        
 3rd Qu.:14.0   3rd Qu.:31.0                                        
 Max.   :59.0   Max.   :31.0                                        
 NA's   :32.0   NA's   :32.0                                        
     time              class                lon             lat      
 Length:15284       Length:15284       Min.   :-94.6   Min.   :54.4  
 Class :character   Class :character   1st Qu.:-80.0   1st Qu.:56.6  
 Mode  :character   Mode  :character   Median :-79.8   Median :56.8  
                                       Mean   :-78.7   Mean   :57.2  
                                       3rd Qu.:-79.5   3rd Qu.:57.1  
                                       Max.   :-61.2   Max.   :65.0  
                                                                     
   transfreq         tripRMS        firstPass       secondPass     
 Min.   :4.02e+08   Mode :logical   Mode :logical   Mode :logical  
 1st Qu.:4.02e+08   FALSE:1966      FALSE:101       FALSE:3072     
 Median :4.02e+08   TRUE :13318     TRUE :15183     TRUE :12212    
 Mean   :4.02e+08   NA's :0         NA's :0         NA's :0        
 3rd Qu.:4.02e+08                                                  
 Max.   :4.02e+08                                                  
 NA's   :3.20e+01                                                  
 thirdPass      
 Mode :logical  
 FALSE:128      
 TRUE :15156    
 NA's :0        
---<--------------------cut here---------------end--------------------->---

which only differs by list.files() with the problem code.  But check
this:

---<--------------------cut here---------------start------------------->---
$ cat <<EOF | r -
print(summary(read.csv("ds_060910_090528.csv",
> > colClasses=c(rep("character", 2), "numeric", "character", rep("numeric", 2), rep("character", 4), rep("numeric", 3), rep("logical", 4)))))
EOF
> Loading required package: methods
littler: Incomplete Line! Need more code!
---<--------------------cut here---------------end--------------------->---

which differs by the newline in read.csv() compared to above code.  It
seems as if now the expression should be complete on the first line?


-- 
Seb



More information about the R-SIG-Debian mailing list