[R] how to read this data file into R?

Felipe Carrillo mazatlanmexico at yahoo.com
Wed Feb 3 16:13:05 CET 2010


That's strange because I was able to read the file into R just fine


--- On Tue, 2/2/10, David Winsemius <dwinsemius at comcast.net> wrote:

> From: David Winsemius <dwinsemius at comcast.net>
> Subject: Re: [R] how to read this data file into R?
> To: "Felipe Carrillo" <mazatlanmexico at yahoo.com>
> Cc: r-help at r-project.org, "song song" <rprojecthelp at gmail.com>
> Date: Tuesday, February 2, 2010, 3:40 PM
> 
> On Feb 2, 2010, at 6:31 PM, Felipe Carrillo wrote:
> 
> >
> > Convert the file into a csv file( myfile.csv),
> > delete some of the unwanted rows before importing into
> R.
> > Save the file on your working directory and then
> import into R:
> >
> > x <- read.csv("myfile.csv")
> > # Change column names
> > names(x) <- LETTERS[1:ncol(x)];x
> 
> The problem with that solution is that there are an
> irregular number  
> of numbers per row ranging from 8 to 6. You could read in
> as text with  
> readLines but then need to extract by 25 lines at a time
> and then  
> cbind the segments. Doable mind you, but I suspect faster
> with a  
> spreadsheet intermediate solution.
> 
> The real solution is to grab the miscreant sender by the
> throat , er,   
> tactfully discuss with your valued customer ,,, and shake
> out a  
> machine readable form that has all of one row in a row.
> 
> -- 
> David.
> 
> >
> > Change your column names to whatever you want
> >
> > Felipe D. Carrillo
> > Supervisory Fishery Biologist
> > Department of the Interior
> > US Fish & Wildlife Service
> > California, USA
> >
> >
> > --- On Tue, 2/2/10, song song <rprojecthelp at gmail.com>
> wrote:
> >
> >> From: song song <rprojecthelp at gmail.com>
> >> Subject: [R] how to read this data file into R?
> >> To: r-help at r-project.org
> >> Date: Tuesday, February 2, 2010, 2:55 PM
> >>
> >>    [,1]      [,2]
> >>    [,3]     [,4]
> >>    [,5]     [,6]
> >>    [,7]
> >> [,8]
> >>   [1,] 2.010061 -5.223624 2.010061
> 2.010061 1.463336
> >> 1.463336 2.010061
> >> 2.010061
> >>   [2,] 2.057502 -5.101445 2.057502
> 2.057502 2.057502
> >> 2.057502 2.057502
> >> 2.057502
> >>   [3,] 2.011081 -5.227745 2.011081
> 2.011081 2.011081
> >> 2.011081 2.011081
> >> 2.011081
> >>   [4,] 2.031695 -5.147776 2.031695
> 2.031695 2.031695
> >> 2.031695 2.031695
> >> 2.031695
> >>   [5,] 1.982144 -5.219977 2.578551
> 1.982144 1.982144
> >> 1.982144 1.982144
> >> 1.982144
> >>   [6,] 1.997830 -5.197152 1.997830
> 1.997830 1.997830
> >> 1.997830 1.229965
> >> 1.997830
> >>   [7,] 1.987102 -5.202288 1.987102
> 1.987102 1.987102
> >> 1.987102 1.987102
> >> 2.045108
> >>   [8,] 2.004351 -5.263740 2.004351
> 2.004351 2.004351
> >> 2.004351 2.004351
> >> 2.004351
> >>   [9,] 1.860640 -5.281771 1.947604
> 1.947604 1.947604
> >> 1.947604 1.947604
> >> 1.947604
> >> [10,] 2.034417 -5.268606 1.917726 1.917726
> 1.917726
> >> 1.917726 1.917726
> >> 1.917726
> >> [11,] 1.892761 -5.254092 1.892761 1.892761
> 1.892761
> >> 1.892761 1.892761
> >> 1.892761
> >> [12,] 1.878266 -4.725234 1.878266 1.878266
> 2.265870
> >> 1.878266 1.878266
> >> 1.878266
> >> [13,] 1.941847 -5.293714 1.941847 1.941847
> 1.941847
> >> 2.212040 1.941847
> >> 1.941847
> >> [14,] 3.280856 -5.295412 1.891672 1.891672
> 1.891672
> >> 1.891672 2.295541
> >> 1.891672
> >> [15,] 1.833538 -5.381407 2.417865 1.833538
> 1.833538
> >> 1.833538 1.833538
> >> 1.833538
> >> [16,] 1.813212 -5.256472 1.813212 2.337103
> 1.813212
> >> 1.813212 1.813212
> >> 1.813212
> >> [17,] 1.763356 -5.262836 1.763356 2.538904
> 3.202743
> >> 1.763356 1.763356
> >> 1.763356
> >> [18,] 2.718888 -5.269976 1.824456 1.824456
> 1.824456
> >> 1.824456 1.824456
> >> 1.824456
> >> [19,] 1.868374 -5.237574 1.868374 1.868374
> 1.868374
> >> 1.868374 1.868374
> >> 1.868374
> >> [20,] 1.879976 -5.195960 1.879976 1.879976
> 2.400419
> >> 1.879976 1.879976
> >> 1.879976
> >> [21,] 1.897184 -5.195960 1.897184 1.897184
> 1.897184
> >> 1.897184 1.897184
> >> 1.897184
> >> [22,] 1.946035 -5.195960 1.946035 1.946035
> 1.946035
> >> 1.946035 1.946035
> >> 1.946035
> >> [23,] 1.531107 -5.195960 2.005964 2.005964
> 2.005964
> >> 2.005964 1.012178
> >> 2.005964
> >> [24,] 1.966488 -5.195960 1.966488 3.300449
> 1.966488
> >> 1.966488 1.966488
> >> 1.966488
> >> [25,] 1.922473 -5.132915 1.922473 1.922473
> 1.922473
> >> 1.922473 1.327156
> >> 1.922473
> >>
> >>    [,9]     [,10]
> >>    [,11]      [,12]
> >>    [,13]    [,14]
> >> [,15]
> >>   [1,]  2.0100609 -5.223624
> 2.0100609 2.01006088
> >> 2.0100609 2.010061
> >> 2.0100609
> >>   [2,]  2.0575018 -5.217940
> 2.0575018 2.05750183
> >> 2.0575018 2.057502
> >> 2.0575018
> >>   [3,]  2.0110810 -5.227745
> 2.0110810 1.25251992
> >> 1.1365329 2.011081
> >> 2.0110810
> >>   [4,]  2.0316951 -5.147776
> 2.0316951 0.53524458
> >> 2.0316951 2.031695
> >> 2.0316951
> >>   [5,]  1.9821437 -5.219977
> 1.9821437 1.98214375
> >> 1.9821437 1.982144
> >> 1.9821437
> >>   [6,]  1.9978302 -5.197152
> 1.9978302 1.99783017
> >> 1.9978302 1.997830
> >> 1.9978302
> >>   [7,]  1.4779031 -5.202288
> 1.9871021 1.98710207
> >> 1.9871021 1.477903
> >> 1.9871021
> >>   [8,]  2.0043512 -5.263740
> 2.0043512 2.00435118
> >> 2.0043512 2.004351
> >> 2.0043512
> >>   [9,]  1.9476036 -5.281771
> 1.9476036 1.86063972
> >> 1.9476036 1.947604
> >> 1.9476036
> >> [10,]  2.0344169 -5.268606 2.0344169
> 1.91772554
> >> 1.9177255 2.034417
> >> 1.9177255
> >> [11,]  1.8927610 -5.254092 2.2300986
> 1.89276104
> >> 1.8927610 1.892761
> >> 1.8927610
> >> [12,]  2.2658697 -5.279645 1.8782663
> 1.87826632
> >> 0.9758728 1.878266
> >> 1.8782663
> >> [13,]  1.9418472 -5.293714 1.9418472
> 1.94184718
> >> 1.9418472 1.941847
> >> 1.9418472
> >> [14,]  1.8916717 -5.295412 1.8916717
> 1.89167168
> >> 1.8916717 1.891672
> >> 1.8916717
> >> [15,]  1.8335379 -5.381407 1.8335379
> 1.83353786
> >> 1.8335379 1.833538
> >> 1.8335379
> >> [16,]  1.8132119 -5.256472 1.8132119
> 1.81321188
> >> 2.3371032 1.813212
> >> 1.8132119
> >> [17,]  1.7633565 -5.262836 1.7633565
> 2.53890421
> >> 1.7633565 1.763356
> >> 1.7633565
> >> [18,]  1.8244564 -5.269976 1.8244564
> 1.82445645
> >> 1.8244564 1.824456
> >> 1.8244564
> >> [19,]  1.8683740 -5.237574 1.8683740
> 1.86837403
> >> 1.8683740 1.868374
> >> 1.8683740
> >> [20,]  1.0173668 -5.195960 1.8799758
> 1.87997583
> >> 1.8799758 2.685630
> >> 1.8799758
> >> [21,]  1.8971842 -5.195960 1.8971842
> 1.89718417
> >> 1.8971842 2.438014
> >> 1.8971842
> >> [22,]  1.9460347 -5.195960 1.9460347
> 1.94603470
> >> 1.7662487 1.946035
> >> 1.9460347
> >> [23,]  0.7982354 -5.195960 2.0059635
> 2.00596350
> >> 2.0059635 2.005964
> >> 2.0059635
> >> [24,]  1.9664877 -5.195960 1.9664877
> 1.96648770
> >> 1.9664877 1.966488
> >> 1.9664877
> >> [25,]  1.9224727 -5.132915 3.2417843
> 1.92247274
> >> 1.9224727 1.922473
> >> 1.9224727
> >>            [,16]
> >>   [,17] 
>    [,18]
> >>   [,19] 
>    [,20]
> >> [,21]     [,22]
> >>   [1,] -5.223624 2.010061
> -5.223624  1.4633362
> >> -5.223624 2.010061 -5.090333
> >>   [2,] -5.217940 2.057502
> -5.217940  1.0054481
> >> -5.217940 2.057502 -5.217940
> >>   [3,] -5.227745 2.011081
> -5.040568  2.0110810
> >> -5.227745 2.011081 -5.227745
> >>   [4,] -5.147776 1.819924
> -5.147776  2.0316951
> >> -5.147776 2.031695 -5.147776
> >>   [5,] -5.219977 1.982144
> -4.965402  0.2863589
> >> -5.219977 1.982144 -5.219977
> >>   [6,] -5.197152 1.997830
> -5.197152  1.9978302
> >> -5.197152 1.997830 -5.197152
> >>   [7,] -5.202288 1.987102
> -5.202288  1.9871021
> >> -5.202288 1.987102 -5.202288
> >>   [8,] -4.665015 2.004351
> -5.263740  2.0043512
> >> -4.665015 2.004351 -5.263740
> >>   [9,] -5.281771 1.947604
> -5.281771  1.9476036
> >> -5.281771 1.947604 -5.281771
> >> [10,] -4.787324 1.917726 -5.268606 
> 1.9177255
> >> -5.268606 1.917726 -5.268606
> >> [11,] -5.254092 1.892761 -5.254092 
> 1.8927610
> >> -4.740590 1.892761 -5.254092
> >> [12,] -5.279645 1.878266 -5.279645 
> 1.8782663
> >> -5.279645 1.878266 -5.279645
> >> [13,] -5.293714 1.941847 -5.293714 
> 2.2120401
> >> -4.208322 1.941847 -5.293714
> >> [14,] -5.295412 1.891672 -5.295412 
> 1.8916717
> >> -4.041867 1.891672 -5.295412
> >> [15,] -5.381407 2.281394 -5.381407 
> 1.8335379
> >> -3.885552 1.833538 -5.381407
> >> [16,] -5.256472 1.813212 -5.256472 
> 1.8132119
> >> -5.256472 1.813212 -5.256472
> >> [17,] -5.262836 1.763356 -5.262836 
> 1.7633565
> >> -5.262836 1.763356 -5.262836
> >> [18,] -5.269976 2.890181 -5.269976 
> 1.8244564
> >> -5.269976 1.824456 -5.269976
> >> [19,] -5.237574 1.868374 -5.237574 
> 1.8683740
> >> -5.237574 1.868374 -5.237574
> >> [20,] -5.195960 1.879976 -5.195960 
> 1.8799758
> >> -5.195960 1.879976 -5.195960
> >> [21,] -5.195960 1.897184 -5.195960 
> 1.8971842
> >> -5.195960 1.897184 -5.195960
> >> [22,] -5.195960 1.946035 -5.195960 -0.2933984
> -5.195960
> >> 1.946035 -5.195960
> >> [23,] -5.195960 2.005964 -5.195960 
> 0.7982354
> >> -5.195960 2.005964 -5.195960
> >> [24,] -5.195960 1.966488 -5.195960 
> 1.9664877
> >> -5.195960 1.966488 -5.195960
> >> [25,] -5.132915 1.922473 -5.132915 
> 0.9233183
> >> -5.132915 1.922473 -5.132915
> >>         
>    [,23]
> >>    [,24]      [,25]
> >>   [,26]    [,27]
> >>    [,28]    [,29]
> >>   [1,]  2.0100609 2.0100609
> -0.2265311 2.010061
> >> 2.010061 -5.223624 2.010061
> >>   [2,]  2.0575018
> 2.0575018  0.4005312
> >> 2.057502 2.057502 -5.217940 2.057502
> >>   [3,]  2.0110810
> 2.0110810  2.0110810
> >> 2.011081 2.011081 -5.227745 2.011081
> >>   [4,]  2.0316951
> 2.0316951  2.0316951
> >> 2.031695 2.031695 -5.147776 2.031695
> >>   [5,]  1.9821437
> 1.9821437  1.4806333
> >> 1.982144 1.982144 -5.219977 1.982144
> >>   [6,]  1.9978302
> 1.9978302  1.9978302
> >> 1.517729 1.997830 -5.197152 1.997830
> >>   [7,]  1.9871021
> 1.9871021  1.9871021
> >> 1.987102 1.477903 -5.202288 1.987102
> >>   [8,]  1.4458665
> 2.0043512  2.0043512
> >> 2.004351 2.004351 -5.263740 2.004351
> >>   [9,]  1.9476036
> 1.9476036  1.8606397
> >> 1.947604 1.947604 -4.713271 1.947604
> >> [10,]  1.9177255 1.9177255  1.9177255
> 1.917726
> >> 2.034417 -5.268606 1.917726
> >> [11,]  1.8927610 1.3224297  1.8927610
> 2.230099
> >> 1.892761 -5.254092 1.892761
> >> [12,]  1.8782663 1.8782663  1.8782663
> 1.878266
> >> 1.878266 -5.279645 1.878266
> >> [13,]  1.9418472 1.9418472  1.9418472
> 1.941847
> >> 1.941847 -4.208322 2.212040
> >> [14,]  1.8916717 1.8916717  1.8916717
> 1.891672
> >> 1.891672 -5.295412 1.891672
> >> [15,]  1.8335379 1.8335379  2.2813944
> 1.833538
> >> 2.281394 -5.381407 1.833538
> >> [16,]  1.8132119 1.8132119  1.8132119
> 2.337103
> >> 1.813212 -5.256472 1.813212
> >> [17,]  1.7633565 2.5389042  2.5389042
> 2.595662
> >> 1.763356 -5.262836 1.763356
> >> [18,]  2.7188879 1.8244564  1.8244564
> 1.824456
> >> 1.824456 -5.269976 1.824456
> >> [19,]  1.8683740 2.6859935  1.8683740
> 1.868374
> >> 1.868374 -5.237574 1.868374
> >> [20,]  1.8799758 1.8799758  1.8799758
> 1.879976
> >> 1.879976 -5.195960 3.699892
> >> [21,]  1.8971842 1.8971842  1.8971842
> 1.897184
> >> 1.897184 -5.195960 1.897184
> >> [22,]  1.9460347 1.9460347  1.9460347
> 1.946035
> >> 1.946035 -5.195960 3.781882
> >> [23,]  1.0121785 2.0059635  2.0059635
> 2.005964
> >> 2.005964 -5.195960 2.005964
> >> [24,]  1.9664877 1.9664877  1.9664877
> 2.025442
> >> 1.966488 -5.195960 1.966488
> >> [25,]  1.3271565 1.9224727  0.9233183
> 1.922473
> >> 1.922473 -5.132915 3.241784
> >>
> >>    [,30]     [,31]
> >>    [,32]    [,33]
> >>     [,34]   
>    [,35]
> >>   [1,]  1.46333623 2.0100609
> -5.090333 2.010061
> >> -0.226531126  2.01006088
> >>   [2,]  2.05750183 1.3105841
> -5.217940
> >> 2.057502  0.029241895  0.02761610
> >>   [3,]  2.01108103 2.0110810
> -5.227745
> >> 2.011081  0.339256598  2.01108103
> >>   [4,]  2.03169511 2.0316951
> -5.147776 2.031695
> >> -5.147775829  1.50221329
> >>   [5,]  1.55774038 1.9821437
> -5.219977
> >> 1.982144  0.286358885  0.28635889
> >>   [6,]  1.99783017 1.9978302
> -5.197152
> >> 1.997830  1.997830167  1.99783017
> >>   [7,]  1.47790312 0.7237104
> -5.202288
> >> 1.987102  0.723710361  0.73504349
> >>   [8,]  2.00435118 1.4332984
> -5.263740 2.004351
> >> -0.619465588  2.00435118
> >>   [9,]  1.94760360 1.9476036
> -5.281771 1.947604
> >> -0.976910576  1.86063972
> >> [10,]  1.91772554 1.9177255 -5.268606
> 1.917726
> >> -1.791538434  1.91772554
> >> [11,]  1.89276104 1.8927610 -5.254092
> 2.230099
> >> -1.791538434  2.23009859
> >> [12,]  1.87826632 1.8782663 -5.279645
> 1.878266
> >> 0.975872753  1.87826632
> >> [13,]  1.94184718 1.9418472 -5.293714
> 1.146211
> >> -5.293713913  1.94184718
> >> [14,]  1.89167168 1.8916717 -5.295412
> 1.891672
> >> -4.041867058  1.44591603
> >> [15,]  1.83353786 1.8335379 -5.381407
> 2.281394
> >> -2.411775517  1.83353786
> >> [16,]  2.33710323 1.8132119 -5.256472
> 1.813212
> >> -3.032447437  1.81321188
> >> [17,]  1.76335647 1.7633565 -5.262836
> 1.763356
> >> -1.791538434  1.76335647
> >> [18,]  1.82445645 1.8244564 -5.269976
> 2.718888
> >> -2.802877612  1.82445645
> >> [19,]  1.86837403 1.8683740 -5.237574
> 1.868374
> >> -0.583427551  1.86837403
> >> [20,]  1.87997583 2.4004191 -5.195960
> 1.879976
> >> -0.221729569  1.87997583
> >> [21,]  1.89718417 1.8971842 -5.195960
> 1.897184
> >> -0.335125564  1.89718417
> >> [22,]  1.94603470 1.9460347 -5.195960
> 1.946035
> >> -0.293398374  1.94603470
> >> [23,]  2.00596350 2.0059635 -5.195960
> 2.005964
> >> -1.791538434  0.02761610
> >> [24,]  1.96648770 1.9664877 -5.195960
> 1.966488
> >> 0.642854756  0.11557730
> >> [25,]  1.92247274 1.9224727 -5.132915
> 1.922473
> >> -5.132915158  1.92247274
> >>
> >> -----Inline Attachment Follows-----
> >>
> >> ______________________________________________
> >> 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.
> 
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
> 
> 






More information about the R-help mailing list