[R] More difficulties in getting data into R

Ajay Shah ajayshah at mayin.org
Mon Jul 5 12:58:39 CEST 2004


In order to get around the problems of my posting a few minutes ago, I
thought:

$ awk -F\| '(NR > 2) {print $2}' cmie_firm_data.text > col2
$ awk -F\| '(NR > 2) {print $4}' cmie_firm_data.text > col4
$ paste col2 col4 | head -2
-510.45 -510.27
60700   101900
$ paste col2 col4 | tail -2
28648.12        31617.02
491014.77       494308.52
$ wc -l col2 col4
  89323 col2
  89323 col4
 178646 total

So all is well.

But R doesn't like it:

$ R --vanilla < picture.R 

R : Copyright 2004, The R Foundation for Statistical Computing
Version 1.9.1  (2004-06-21), ISBN 3-900051-00-3

> col2 <- read.table(file="col2")
> col4 <- read.table(file="col4")
> print(nrow(col2))
[1] 89323
> print(nrow(col4))
[1] 88746

Why might I be getting 89,323 and 88,746 obs for two files which `wc'
believes are each 89,323 lines long?

I checked, and there is no single quote or C-m in either file.

-- 
Ajay Shah                                                   Consultant
ajayshah at mayin.org                      Department of Economic Affairs
http://www.mayin.org/ajayshah           Ministry of Finance, New Delhi




More information about the R-help mailing list