[R] character to numeric conversion

Greg Snow Greg.Snow at intermountainmail.org
Mon Mar 19 18:21:05 CET 2007


Could you replace 'system' with 'pipe' and read directly from the pipe
connection rather than the intermediate step of having a text string?
If the external function just returns the numbers with commas and spaces
(but no line feeds), then you should be able to use 'scan' directly on
the connection.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Robin Hankin
> Sent: Monday, March 19, 2007 5:20 AM
> To: Peter Dalgaard
> Cc: RHelp help; Robin Hankin
> Subject: Re: [R] character to numeric conversion
> 
> Hello everybody
> 
> thanks for the tips.
> 
> I *think* this should be the same thread....
> 
> 
> The manpage for system() says that lines of over 8095 
> characters will be split.  This is causing me problems.
> How do I get round the 8095 character limit?
> 
> 
> Simple toy example follows:
> 
> 
> 
> jj <- system("echo 4 | awk '{for(i=1;i<100;i++){printf(\"%s,\",
> $1)}}'| sed -e \"s/,$//\"",intern=T)
> 
> 
> This is  fine.  But .. . .
> 
> 
> jj <- system("echo 4 | awk '{for(i=1;i<10000;i++){printf(\"%s,\", 
> $1)}}'| sed -e \"s/,$//\"",intern=T)
> 
> 
> 
> has  "jj"  split into three bits, which is upsetting my call.  In my  
> application
> the split occurs in the middle of a multi-digit number, which 
> messes up
> my conversion to numeric?
> 
> 
> 
> 
> 
> 
> 
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
>   tel  023-8059-7743
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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