Skip to content
Prev 243788 / 398506 Next

The behaviour of read.csv().

On Dec 2, 2010, at 8:33 PM, Duncan Murdoch wrote:
snipped
In both Excel and in OO,org you can select a column (or any other  
range) and set its format to text. (The default is numeric, not that  
different that read.table()'s default behavior.) Once a format has  
been set, you then do not need leading quotes. I just created a small  
example with OO.org Calc entered leading "0" without leading quotes  
and this code runs as desired after copying the three cells to the  
clipboard:

 > read.table(pipe("pbpaste"), colClasses="character")
     V1
1   01
2  004
3 0005

The same applies to date field in both OO.org and Excel. In this  
regard, it is simply a matter of understanding what is the defined  
behavior of your software and how one can manipulate it. This is no  
different than learning R's classes, coercing them to your ends, and  
dealing with other formatting issues.
No argument there. I know one physician whose weapon of choice is  
Stata who always uses "|" as his separator, but that's perhaps because  
he works entirely in Windows. I imagine that might not be the most  
uncommon character in *NIXen.

--

David Winsemius, MD
West Hartford, CT