RE: [R] More difficulties in getting data into R

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Tue 06 Jul 2004 - 22:33:20 EST


Could it be that you happen you have `#' in `col4'? Try either (or both):

  1. read.table(..., comment.char="")
  2. scan(...)

HTH,
Andy

> From: Ajay Shah
>
> 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@mayin.org Department of Economic Affairs
> http://www.mayin.org/ajayshah Ministry of Finance, New Delhi
>



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jul 06 22:38:26 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:43 EST