Re: [R] i'm so stuck with text file and contour plot

2009-08-05 Thread David Winsemius
Doubtful. The OP did have spaces in his header. but by specifying that only tabs should be used as delimiters the default parameters to both read.table and read.csv would have converted the spaces to periods. See: read.table(file="http://www.nabble.com/file/p24777697/small.txt";, sep="\t",

Re: [R] i'm so stuck with text file and contour plot

2009-08-05 Thread Tal Galili
Hi Hannes, >From my experience, this error usually happens when you've got spaces in the header row, in the column names. An easy solution would be to open the file in excel, then run search-and-replace on the header row for all spaces and replace them with a hyphen "-". Hope it helped (please let

Re: [R] i'm so stuck with text file and contour plot

2009-08-05 Thread Jason Rupert
You can also try: readLines(...) This seems to be able to read in difficult txt files. Good luck. --- On Wed, 8/5/09, hannesPretorius wrote: > From: hannesPretorius > Subject: Re: [R] i'm so stuck with text file and contour plot > To: r-help@r-project.org > Date: Wednesda

Re: [R] i'm so stuck with text file and contour plot

2009-08-05 Thread David Winsemius
What do you get with: count.fields(c:/small.txt', sep='\t', header=TRUE) On Aug 5, 2009, at 5:09 AM, hannesPretorius wrote: When I read the entire text file in I get the following message x <- read.table('c:/small.txt', sep='\t', header=TRUE) Warning message: number of items read is not a

Re: [R] i'm so stuck with text file and contour plot

2009-08-05 Thread Mark Difford
Hannes, >> When I read the entire text file in I get the following message Then you have not followed the very simple instructions I gave you above, which I repeat below. Or you have changed small.txt. ## TDat <- read.csv("small.txt", sep="\t") TDat str(TDat) Mark. hannesPretorius wrote: >

Re: [R] i'm so stuck with text file and contour plot

2009-08-05 Thread hannesPretorius
When I read the entire text file in I get the following message > x <- read.table('c:/small.txt', sep='\t', header=TRUE) Warning message: number of items read is not a multiple of the number of columns. thanks. hannesPretorius wrote: > > Ok i feel pretty stupid.. been trying to read a tex

Re: [R] i'm so stuck with text file and contour plot

2009-08-03 Thread Mark Difford
And I meant to add, but somehow forgot, that the default for read.csv is header=TRUE (which is different from read.table, where it is FALSE). Regards, Mark. Mark Difford wrote: > > Hi David, > >>> I think he may also need to add the header=TRUE argument: > > No! The argument header= is not r

Re: [R] i'm so stuck with text file and contour plot

2009-08-02 Thread Mark Difford
Hi David, >> I think he may also need to add the header=TRUE argument: No! The argument header= is not required in this case. ## > TDat <- read.csv("small.txt", sep="\t") > str(TDat[,1:3]) 'data.frame': 10 obs. of 3 variables: $ Placename: Factor w/ 10 levels "Aankoms","Aapieshoek",..: 1 2

Re: [R] i'm so stuck with text file and contour plot

2009-08-02 Thread jim holtman
Seems to read in fine; what errors were you getting? > x <- read.table('/small.txt', sep='\t', header=TRUE) > str(x) 'data.frame': 10 obs. of 7 variables: $ Placename : Factor w/ 10 levels "Aankoms","Aapieshoek",..: 1 2 3 4 5 6 7 8 9 10 $ X_coord

[R] i'm so stuck with text file and contour plot

2009-08-02 Thread hannesPretorius
Ok i feel pretty stupid.. been trying to read a text file that contains heading in the first line in to R but cant. all i need to do is make a contour plot for a friend but after weeks i feel like giving up.. i included the first few lines of the file.. any help will be great Thanks Hannes http:

Re: [R] i'm so stuck with text file and contour plot

2009-08-02 Thread David Winsemius
I think he may also need to add the header=TRUE argument: tdat <- read.csv("http://www.nabble.com/file/p24777697/small.txt";, header=TRUE, sep="\t") Note: read.table with those arguments should have worked as well. And then use names(tdat) <- c() Perhaps along these lines: tdnames <- names(

Re: [R] i'm so stuck with text file and contour plot

2009-08-02 Thread Mark Difford
Hannes, >> been trying to read a text file that contains heading in the first line >> in to R but cant. You want the following: ## TDat <- read.csv("small.txt", sep="\t") TDat str(TDat) See ?read.csv Regards, Mark. hannesPretorius wrote: > > Ok i feel pretty stupid.. been trying to read a