[R] How to read this data properly?

Jinsong Zhao jszhao at yeah.net
Sat Mar 3 16:28:21 CET 2012


On 2012-3-3 23:15, Bogaso Christofer wrote:
> Dear all, I have been given a data something like below:
>
>
>
> Dat = "2 3 28.3 3.05 8 3 3 22.5 1.55 0 1 1 26.0 2.30 9 3 3 24.8 2.10 0
>
> 3 3 26.0 2.60 4 2 3 23.8 2.10 0 3 2 24.7 1.90 0 2 1 23.7 1.95 0
>
> 3 3 25.6 2.15 0 3 3 24.3 2.15 0 2 3 25.8 2.65 0 2 3 28.2 3.05 11
>
> 4 2 21.0 1.85 0 2 1 26.0 2.30 14 1 1 27.1 2.95 8 2 3 25.2 2.00 1
>
> 2 3 29.0 3.00 1 4 3 24.7 2.20 0 2 3 27.4 2.70 5 2 2 23.2 1.95 4"
>
>
>
>
>
> I want to create a matrix out of those data for my further calculations. I
> have tried with readLines() but got error:
>
>
>
>> readLines(Dat)
>
> Error in file(con, "r") : cannot open the connection
>
> In addition: Warning message:
>
> In file(con, "r") :
>
>    cannot open file '2 3 28.3 3.05 8 3 3 22.5 1.55 0 1 1 26.0 2.30 9 3 3 24.8
> 2.10 0
>
> 3 3 26.0 2.60 4 2 3 23.8 2.10 0 3 2 24.7 1.90 0 2 1 23.7 1.95 0
>
> 3 3 25.6 2.15 0 3 3 24.3 2.15 0 2 3 25.8 2.65 0 2 3 28.2 3.05 11
>
> 4 2 21.0 1.85 0 2 1 26.0 2.30 14 1 1 27.1 2.95 8 2 3 25.2 2.00 1
>
> 2 3 29.0 3.00 1 4 3 24.7 2.20 0 2 3 27.4 2.70 5 2 2 23.2 1.95 4': No such
> file or directory
>

is there blank line between the data lines?

if no, try ?scan...

>
>
> Can somebody help to put that data in some workable format?
>
>
>
> Thanks and regards,
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list