Re: [R] Argh! Trouble using string data read from a file

2008-10-15 Thread Ted Byers
Thank you Prof. Ripley. I appreciate this. Have a good day. Ted On Thu, Oct 16, 2008 at 12:20 AM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > On Wed, 15 Oct 2008, Ted Byers wrote: > >> Thanks Jim, >> >> I hadn't seen the distinction between the commandline in RGui and what >> happens within

Re: [R] Argh! Trouble using string data read from a file

2008-10-15 Thread Prof Brian Ripley
On Wed, 15 Oct 2008, Ted Byers wrote: Thanks Jim, I hadn't seen the distinction between the commandline in RGui and what happens within my code. I have, however seen other differences I don't understand. For example, looking at the documentation for RScript, I see: Rscript [options] [-e expr

Re: [R] Argh! Trouble using string data read from a file

2008-10-15 Thread Ted Byers
Thanks Jim, I hadn't seen the distinction between the commandline in RGui and what happens within my code. I have, however seen other differences I don't understand. For example, looking at the documentation for RScript, I see: Rscript [options] [-e expression] file [args] And the example: Rs

Re: [R] Argh! Trouble using string data read from a file

2008-10-15 Thread jim holtman
You have to explicitly 'print' the value of x in the loop:print(x) 'x' by itself is just it value. At the command line, typing an objects name is equivalent to printing that object, but it only happens at the command line. If you want a value printed, the 'print' it. Also works at the comma

Re: [R] Argh! Trouble using string data read from a file

2008-10-15 Thread Rolf Turner
On 16/10/2008, at 11:07 AM, Prof Brian Ripley wrote: [[ ]] works on vectors! So it does. My bad. letters[[3]] [1] "c" See help("[["). But strictly V4 is a factor and hence not a vector: [[ ]] also works on factors. Yes. I had forgotten that not everyone sets options (stringsAsF

Re: [R] Argh! Trouble using string data read from a file

2008-10-15 Thread Prof Brian Ripley
[[ ]] works on vectors! letters[[3]] [1] "c" See help("[["). But strictly V4 is a factor and hence not a vector: [[ ]] also works on factors. On Thu, 16 Oct 2008, Rolf Turner wrote: On 16/10/2008, at 10:03 AM, jim holtman wrote: try putting as.character in the call: x = read.csv(as.c

Re: [R] Argh! Trouble using string data read from a file

2008-10-15 Thread Ted Byers
Actually, I'd tried single brackets first. Here is what I got: > for (i in 1:length(V4) ) { x = read.csv(V4[i], header = FALSE, > na.strings="");x } Error in read.table(file = file, header = header, sep = sep, quote = quote, : 'file' must be a character string or connection > the advice to

Re: [R] Argh! Trouble using string data read from a file

2008-10-15 Thread Rolf Turner
On 16/10/2008, at 10:03 AM, jim holtman wrote: try putting as.character in the call: x = read.csv(as.character(V4[[i]]), header = FALSE No. This won't help. V4 is a column of the data frame optdata, and hence is a vector. Not a list! Use single brackets --- V4[i] --- and all will be well

Re: [R] Argh! Trouble using string data read from a file

2008-10-15 Thread jim holtman
try putting as.character in the call: x = read.csv(as.character(V4[[i]]), header = FALSE On Wed, Oct 15, 2008 at 4:46 PM, Ted Byers <[EMAIL PROTECTED]> wrote: > > Here is what I tried: > > optdata = > read.csv("K:\\MerchantData\\RiskModel\\AutomatedRiskModel\\soptions.dat", > header = FALSE, na.s

[R] Argh! Trouble using string data read from a file

2008-10-15 Thread Ted Byers
Here is what I tried: optdata = read.csv("K:\\MerchantData\\RiskModel\\AutomatedRiskModel\\soptions.dat", header = FALSE, na.strings="") optdata attach(optdata) for (i in 1:length(V4) ) { x = read.csv(V4[[i]], header = FALSE, na.strings="");x } And here is the outcome (just a few of the 60 reco