I'm using scan in a script to record a series of responses of the user as
a function
of some graphs that I put up on the screen. A toy version would be,
y <- rep(NA, 3)
for (ix in seq( length(y) ) ) {
y[ix] <- scan( n = 1 )
}
However, if I include any code after this loop, for example,
y <- rep(NA, 3)
for (ix in seq( length(y) ) ) {
y[ix] <- scan( n = 1 )
}
y
I get an error after I've entered my first number.
1: y
1: 3
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
scan() expected 'a real', got 'y'
scan seems to be trying to read the commands after the loop. In the real
case,
the loop is longer and there are more commands after the loop.
If I have more commands, I get the error right away, before the prompt to
enter a number.
I didn't see anything in the scan help that would allow me to circumvent
this error.
Can anyone suggest a way to get around this error.
Thank you.
Ken
Here is my info
sessionInfo()
R version 2.4.1 Patched (2007-01-23 r40561)
i386-apple-darwin8.8.1
locale:
C
attached base packages:
[1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
[7] "base"
other attached packages:
MASS
"7.2-31"
--
Ken Knoblauch
Inserm U846
Institut Cellule Souche et Cerveau
Département Neurosciences Intégratives
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.pizzerialesgemeaux.com/u846/
______________________________________________
[email protected] 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.