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",
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
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
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
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:
>
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
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
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
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
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:
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(
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
12 matches
Mail list logo