On Oct 4, 2010, at 12:51 PM, Tariq Perwez wrote:
> Hi Everyone,
>
> I am new R user and am trying to learn by reading the online manual
> "An
> Introduction to R" from the R web site. I am trying to practice
> using the
> scan() function as explained in the manual. For this I first created
> three
> vectors (one a character vector and two numeric one) and saved file
> "input.dat" in my working directory as:
>
>> label <- c("Bill", "Tom", "Pat",
"Will", "Sue", "Sam")
>> x <- 1:6
>> y <- 6:1
>> save(label, x, y, file = "input.dat")
>
> Now, when I try the scan() function as explained in the manual as
> below, I
> get the error message:
Typically the output and input functions are paired and the natural
pairing for the save function is with the load() function. The scan()
function is for text files (and requires specification if the vector
types if not all "numeric", while save() stores R objects with a
compressed format that preserves the object identities and attributes.
Other pairings:
dput/dget
write/read
You probably ought to be also reading the R Import/Export Manual:
http://cran.r-project.org/doc/manuals/R-data.pdf
>
>> inp <- scan("input.dat", list("",0,0))
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
> na.strings,
> :
> scan() expected 'a real', got 'X'
?scan
scan() expects a real when not given an argument for "what". Did you
look at that file with a text editor?
--
David.>
> I have not been able to figure out what the problem is. I would
> appreciate
> if someone could please guide me as to what I am doing wrong. Regards,
>
> Tariq
David Winsemius, MD
West Hartford, CT