Jonathan Baron
2001-Feb-27 11:29 UTC
[R] How to read a text table? A bit of trouble with Using R - An Introduction
> Ok...So I actually *typed* the table with WordPad, using the Tab button >in order to separate the columns, and saved it in rich text format. As you >might have guessed, it didn´t work. I got a: > Error in count.fields(file, sep, quote, skip, blank.lines.skip) : > string terminated by newline or EOFRTF is not what is meant by text. What I am writing is text. Your email is almost text (perhaps even legal). Look at the RTF file itself in an editor such as Emacs or (ugh) Notepad. I don't know if Wordpad can even make text, although I think it can.> I cut and pasted austpop.R text content and saved it as...austpop.txt in >my working directory. > Then, I went for the kill :-) > > austpop <- read.table("C:/R/austpop.txt", header=T) > but it read: > >row.lens> [1] 9 11 11 12 12 15 14 15 11 14 15 16 >Error in read.table("C:/R/austpop.txt", header = T) : > all rows must have the same length.The instructions you quoted said to use source() rather than read.table(). I have not tried it, but that may be worth a try. Jon -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
John Hendrickx
2001-Feb-27 12:47 UTC
[R] How to read a text table? A bit of trouble with Using R - An Introduction
Try TextPad, http://www.textpad.com/. There's an add-on for syntax colouring for Splus, works for R as well. --- Jonathan Baron <baron at cattell.psych.upenn.edu> wrote:> > Ok...So I actually *typed* the table with WordPad, using the > Tab button > >in order to separate the columns, and saved it in rich text > format. As you > >might have guessed, it didn´t work. I got a: > > Error in count.fields(file, sep, quote, skip, > blank.lines.skip) : > > string terminated by newline or EOF > > RTF is not what is meant by text. What I am writing is text. > Your email is almost text (perhaps even legal). Look at the RTF > file itself in an editor such as Emacs or (ugh) Notepad. I don't > know if Wordpad can even make text, although I think it can. > > > I cut and pasted austpop.R text content and saved it > as...austpop.txt in > >my working directory. > > Then, I went for the kill :-) > > > austpop <- read.table("C:/R/austpop.txt", header=T) > > but it read: > > > >row.lens> > [1] 9 11 11 12 12 15 14 15 11 14 15 16 > >Error in read.table("C:/R/austpop.txt", header = T) : > > all rows must have the same length. > > The instructions you quoted said to use source() rather than > read.table(). I have not tried it, but that may be worth a try. > > Jon >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-> r-help mailing list -- Read > http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: > r-help-request at stat.math.ethz.ch >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Mark Myatt
2001-Feb-27 14:13 UTC
[R] How to read a text table? A bit of trouble with Using R - An Introduction
Hzi Writes:>Hello everyone! > > Here?s a *truly newbie question*! (Oh, and BTW, I did read the >documentation and the mailing list archive)[Stuff deleted] First ... you need to use a plain text editor. Use NotePad under Windows if you have nothing else. Type the file like this: "Year" "NSW" "Vic." "Qld" "SA" "WA" "Tas." "NT" "ACT" "Aust." 1917 1904 1409 683 440 306 193 5 3 4941 1927 2402 1727 873 565 392 211 4 8 6182 1937 2693 1853 993 589 457 233 6 11 6836 1947 2985 2055 1106 646 502 257 11 4 1947 1957 3625 2656 1413 873 688 326 21 38 9640 1967 4295 3274 1700 1110 879 375 62 103 11799 1977 5002 3837 2130 1286 1204 415 104 214 14192 1987 5617 4210 2675 1393 1496 449 158 265 16264 1997 6274 4605 3401 1480 1798 474 187 310 18532 Note the double quotes round the column labels and the space (not TAB) between each item of data. You can line them up with spaces (as above) or just use a single space. Save the file as austpop.txt Notepad is a truly awful program and will not allow you to add extensions to file names so you will have to save it without the .txt extension (which NotePad will add for you). All should be well now. Mark -- Mark Myatt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
KINLEY_ROBERT@lilly.com
2001-Feb-27 15:14 UTC
[R] How to read a text table? A bit of trouble with Using R - An Introduction
> Notepad is a truly awful programMuch better (free) Windows text editors are available Try for example pfe32 available via http://softseek.zdnet.com/Programming/Editors/ last time I looked. Bob Kinley Mark Myatt <mark at myatt.demon.co.uk> on 27/02/2001 14:13:06 To: hzi <hzi at uol.com.br> cc: r-help at stat.math.ethz.ch (bcc: Robert Kinley/EMA/LLY) bcc: Robert Kinley/EMA/LLY Subject: Re: [R] How to read a text table? A bit of trouble with Using R - An Introduction Hzi Writes:>Hello everyone! > > Here?s a *truly newbie question*! (Oh, and BTW, I did read the >documentation and the mailing list archive)[Stuff deleted] First ... you need to use a plain text editor. Use NotePad under Windows if you have nothing else. Type the file like this: "Year" "NSW" "Vic." "Qld" "SA" "WA" "Tas." "NT" "ACT" "Aust." 1917 1904 1409 683 440 306 193 5 3 4941 1927 2402 1727 873 565 392 211 4 8 6182 1937 2693 1853 993 589 457 233 6 11 6836 1947 2985 2055 1106 646 502 257 11 4 1947 1957 3625 2656 1413 873 688 326 21 38 9640 1967 4295 3274 1700 1110 879 375 62 103 11799 1977 5002 3837 2130 1286 1204 415 104 214 14192 1987 5617 4210 2675 1393 1496 449 158 265 16264 1997 6274 4605 3401 1480 1798 474 187 310 18532 Note the double quotes round the column labels and the space (not TAB) between each item of data. You can line them up with spaces (as above) or just use a single space. Save the file as austpop.txt Notepad is a truly awful program and will not allow you to add extensions to file names so you will have to save it without the .txt extension (which NotePad will add for you). All should be well now. Mark -- Mark Myatt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Jonathan Baron
2001-Feb-27 16:18 UTC
[R] How to read a text table? A bit of trouble with Using R - An Introduction
On the topic of editors, I have compiled a list at the bottom of http://www.psych.upenn.edu/cattell/edit.html But the favorite around here, for Windows afficionados, seems to be Nedit from www.nedit.org - also free, cross-platform, and with default key settings that are similar to Word, rather than Emacs. Of course, there is Emacs is great (especially with ESS). But, once you start using it, it is very hard to go back to anything set up like Word. You are at risk for serious mind-boggle (AKA retroactive and proactive interference). Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~jbaron -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
John Maindonald
2001-Feb-27 21:36 UTC
[R] How to read a text table? A bit of trouble with Using R - An Introduction
Mark Myatt wrote>Type the file like this: > >"Year" "NSW" "Vic." "Qld" "SA" "WA" "Tas." "NT" "ACT" "Aust." >1917 1904 1409 683 440 306 193 5 3 4941 >1927 2402 1727 873 565 392 211 4 8 6182 >1937 2693 1853 993 589 457 233 6 11 6836 >1947 2985 2055 1106 646 502 257 11 4 1947 >1957 3625 2656 1413 873 688 326 21 38 9640 >1967 4295 3274 1700 1110 879 375 62 103 11799 >1977 5002 3837 2130 1286 1204 415 104 214 14192 >1987 5617 4210 2675 1393 1496 449 158 265 16264 >1997 6274 4605 3401 1480 1798 474 187 310 18532 > >Note the double quotes round the column labels and the space (not TAB) >between each item of data. You can line them up with spaces (as above) >or just use a single space.Actually the quotes around the column headers are not necessary, unless the names contain spaces. John Maindonald email : john.maindonald at anu.edu.au Statistical Consulting Unit, phone : (6125)3998 c/o CMA, SMS, fax : (6125)5549 John Dedman Mathematical Sciences Building Australian National University Canberra ACT 0200 Australia -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
hzi
2001-Feb-27 22:13 UTC
[R] How to read a text table? A bit of trouble with Using R - An Introduction
Hello everyone! Here?s a *truly newbie question*! (Oh, and BTW, I did read the documentation and the mailing list archive) I?m having a bit of difficulty regarding J. Maindonald booklet (pdf) "Data Analysis and Graphics Using R - An Introduction"). It starts off with the task to get some data on a text file (austpop.txt). > austpop <- read.table("a:/austpop.txt", header=T) Ok...So I actually *typed* the table with WordPad, using the Tab button in order to separate the columns, and saved it in rich text format. As you might have guessed, it didn?t work. I got a: Error in count.fields(file, sep, quote, skip, blank.lines.skip) : string terminated by newline or EOF So I went back, read the R Data Import/Export documentation, and came to the conclusion that the problem might be that other pieces of information were missing. So I input: > austpop <- read.table("C:/R/austpop.txt", header=T, row.names=1, quote="", sep="\n", blank.lines.skip=TRUE) and then (when everything seemed OK, since I got no error message): > austpop and got: NULL data frame with 11 rows *Then* I visited JM?s page (http://room.anu.edu.au/~johnm/) and saw a link that I thought might be just what I needed: Data sets for "Using R...". In a directory I found austpop.R which when clicked on led to the following: "austpop" <- structure(list(Year = c(1917, 1927, 1937, 1947, 1957, 1967, 1977, 1987, 1997), NSW = c(1904, 2402, 2693, 2985, 3625, 4295, 5002, 5617, 6274), Vic. = c(1409, 1727, 1853, 2055, 2656, 3274, 3837, 4210, 4605), Qld = c(683, 873, 993, 1106, 1413, 1700, 2130, 2675, 3401), SA = c(440, 565, 589, 646, 873, 1110, 1286, 1393, 1480 ), WA = c(306, 392, 457, 502, 688, 879, 1204, 1496, 1798), Tas. = c(193, 211, 233, 257, 326, 375, 415, 449, 474), NT = c(5, 4, 6, 11, 21, 62, 104, 158, 187), ACT = c(3, 8, 11, 17, 38, 103, 214, 265, 310), Aust. = c(4941, 6182, 6836, 7579, 9640, 11799, 14192, 16264, 18532)), .Names = c("Year", "NSW", "Vic.", "Qld", "SA", "WA", "Tas.", "NT", "ACT", "Aust."), class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9")) In the site?s home page, there was something that read like this: All data sets, other than those that are available from one of the R libraries, are in the file dsets.R that is in the directory dsets. Use a command of the form source("dsets.R") to import them into the R working directory. I cut and pasted austpop.R text content and saved it as...austpop.txt in my working directory. Then, I went for the kill :-) > austpop <- read.table("C:/R/austpop.txt", header=T) but it read: row.lens [1] 9 11 11 12 12 15 14 15 11 14 15 16 Error in read.table("C:/R/austpop.txt", header = T) : all rows must have the same length. Ok, it seems I got all the pieces of the puzzle, right? How do I go about putting them together? What do I do with all of these? Help is *greatly* appreciated! Thank you, Best regards, Henry L., in ding-state (in dire need of guidance) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._