[R] Problem Reading from .txt

chao gai chaogai at duineveld.demon.nl
Thu Oct 19 19:12:11 CEST 2006


Bill,

It looks like you are having from some source a hard return in your string. 
When that hard return is in the middle of a number, R sees this as two 
numbers, not separated by a comma (,) and throws an error. Like this:
> c(13,12
+ .3)
Error: syntax error in:
"c(13,12
.3"
When the hard return is next to a comma (,) it is valid R, so it passes.
In your case it might be around 990th character that the hard occurs.

However, the txt file you added had some additional hard returns so my 
observations might be wrong.

Kees

On Thursday 19 October 2006 15:06, Bill Wyatt wrote:
> I apologize that I've asked a similar question before, but being new to
> R I don't think I did a very good job of formating the question.
>
> I've included a text file since the date set is somewhat large.
>
> What I have is a huge string of numbers in a text file. The numbers are
> all separated by comma's and the groups are separated by a semicolon.
> What I would like to do is read each group in as a single column.
>
> I had hoped that I could just do something like
>
> a<-cbind(c("big string of numbers"))
>
> However I receive several syntax errors when I do that.
>
> Included in the text document are two lines that represent the first
> point that error occurs in the included data set.
>
> If I run line one it works. Line two is identical I just selected one
> more number from the data set and it will not work.
>
> If anyone could tell me why this is happening, and possibly some way to
> read these large strings into a single column I would be grateful.
> --------------------------------------------------------------------
> Bill Wyatt
> Associate Instructor
> Ergonomics Graduate Student
> Department of Kinesiology
> School of Health, Physical Education, and Recreation
> Indiana University
> O:(812)856-5924
> wwyatt at indiana.edu
> --------------------------------------------------------------------



More information about the R-help mailing list