Thanks, Tony.
I got a very good idea of using flush in scan() from
your reply, so that I successfully did my little job.
But, my next question arises if I want to extract the
list of the price items only in the 2nd column in my
example.
I did it the following way. Is it the right way to do?
Or do
Dear Andy,
Why does my 'read.table()' NOT work in this example?
I have the error, subscript out of bounds, as you
see below. My R version is 1.9.0.
system(more mtx.ex.1)
i1-apple 10$ New_York
i2-banana 5$ London
i3-strawberry 7$ Japan
read.table(mtx.ex.1,
colClasses=c(character,NULL,NULL),
On Thu, 4 Nov 2004, John wrote:
Dear Andy,
Why does my 'read.table()' NOT work in this example?
I have the error, subscript out of bounds, as you
see below. My R version is 1.9.0.
^
That is your problem. It works in the current version of R, 2.0.0. Using
Hello All,
I'd like to read first words in lines into a new file.
If I have a data file the following, how can I get the
first words: apple, banana, strawberry?
i1-apple10$ New_York
i2-banana 5$London
i3-strawberry 7$Japan
Is there any similar question already posted
Using R-2.0.0 on WinXPPro, cut-and-pasting the data you have:
read.table(clipboard, colClasses=c(character, NULL, NULL))
V1
1 i1-apple
2 i2-banana
3 i3-strawberry
HTH,
Andy
From: j lee
Hello All,
I'd like to read first words in lines into a new file.
If I have a
Liaw, Andy wrote:
Using R-2.0.0 on WinXPPro, cut-and-pasting the data you have:
read.table(clipboard, colClasses=c(character, NULL, NULL))
V1
1 i1-apple
2 i2-banana
3 i3-strawberry
... and if only the words after - are of interest, the statement can
be followed by
Something like this should work:
foo - read.table(text2read.txt, colClasses=c(character, NULL,
NULL))$V1
foo - gsub(i[0-9]-, , foo)
HTH, Andy
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting
Uwe and Andy's solutions are great for many applications but won't
work if not all rows have the same numbers of fields. Consider for
example the following modification of Lee's example:
i1-apple10$ New_York
i2-banana
i3-strawberry 7$Japan
If I copy this to clipboard
Don't give up on read.table() just yet:
read.table(clipboard, colClasses=c(character, NULL, NULL),
fill=TRUE)
V1
1 i1-apple
2 i2-banana
3 i3-strawberry
Andy
From: Spencer Graves
Uwe and Andy's solutions are great for many
applications but won't
work if not
Trying to make it work when not all rows have the same numbers of fields
seems like a good place to use the flush argument to scan() (to skip
everything after the first field on the line):
With the following copied to the clipboard:
i1-apple10$ New_York
i2-banana
i3-strawberry 7$
Dear Andy Tony:
That's great. Unfortunately, I still spend most of my life in the
S-Plus world, and read.table in S-Plus 6.2 does not have the fill
argument. However, Tony's solution (and my ugly hack) work in both
S-Plus 6.2 and R 2.0.0.
Thanks again.
Spencer Graves
11 matches
Mail list logo