Ingo Holz wrote:
Hi,
I want to read a ascii-file using the function read.table.
With 'skip' and 'nrows' I can select the rows to read from this file.
Is there a way to select columns (in the selected rows)?
Yes, use the colClasses argument.
(I won't rewrite the help page here; I
Roland Rau wrote:
Dear all,
in the past I have been able to access websites with data directly. For
example the following code works nicely
mydata -
read.table(http://www.lifetable.de/data/MPIDR/POL_2004.txt;,
header=TRUE)
But what happens if I need a username and password
On Wed, 16 May 2007, Roland Rau wrote:
Dear all,
in the past I have been able to access websites with data directly. For
example the following code works nicely
mydata -
read.table(http://www.lifetable.de/data/MPIDR/POL_2004.txt;,
header=TRUE)
But what happens if I need a
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] read.table opening a website incl Password
Roland Rau wrote:
Dear all,
in the past I have been able to access websites with data directly.
For example the following code works nicely
mydata -
read.table(http://www.lifetable.de/data/MPIDR
Dear all,
so far I tried various things but I did not really succeed:
- starting R with --internet2
- using url()
- using read.table(http://myusr:[EMAIL PROTECTED]/adir/afile.txt)
I just have an idea what the problem could be for me:
The username is actually an email address. So the
elyakhlifi mustapha wrote:
sorry,
I don't undersatnd what happens
Annee_O;Id_Essai;Id_Rep;Id_Geno;Id_Cult;Lib_Geno;St_Cult;Id_Par;X_Par;Y_Par;Id_Cara;Surf_O;Val_O;Ori_O;Stade_O;Date_O;Id_Bloc;Id_TrT1
2004;1006003;1;55094;1012988;XF 338/1;;1;1;1;137;;9.4;P;;09/09/2004;1;0
Try this:
# test data
Input - 4547;1970.01.01 00:00-1970.01.01 01:00; noData
4547;1970.01.01 00:00-1970.01.01 01:00; noData
# replace next line with Lines - readLines(myfile.dat)
Lines - readLines(textConnection(Input))
Lines - gsub([;-], , Lines)
read.table(textConnection(Lines))
On
: Sun, 11 Mar 2007 21:33:04 -0500
From: jim holtman [EMAIL PROTECTED]
Subject: Re: [R] read.table for a subset of data
To: Wensui Liu [EMAIL PROTECTED]
Cc: r-help r-help@stat.math.ethz.ch
Message-ID:
[EMAIL PROTECTED]
Content-Type: text/plain
If you know what 10 rows to read, then you can 'skip
limit on a variable's size. Version 4 removes this limitation; I'm
hopeful some day that an R package will be an interface to the NetCDF
version
4 library.
John Thaden
Message: 22
Date: Sun, 11 Mar 2007 21:33:04 -0500
From: jim holtman [EMAIL PROTECTED]
Subject: Re: [R] read.table
as far as I've know, I don't think you can do so with read.table. But
I am also thinking about RODBC and wondering if you could assign a DSN
to your .csv file and then use sql to fetch the subset.
On 3/11/07, gnv shqp [EMAIL PROTECTED] wrote:
Hi R-experts,
I have data from four conditions of
Why cann't you read in the whole data set and then create the subsets? This
is easily done with 'split'. If the data is too large, then consider a data
base.
On 3/11/07, gnv shqp [EMAIL PROTECTED] wrote:
Hi R-experts,
I have data from four conditions of an experiment. I tried to create
Jim,
Glad to see your reply.
Refering to your email, what if I just want to read 10 rows from a csv
table with 10 rows? Do you think it a waste of resource to read
the whole table in?
Anything thought?
wensui
On 3/11/07, jim holtman [EMAIL PROTECTED] wrote:
Why cann't you read in the
If you know what 10 rows to read, then you can 'skip' to them, but it the
system still has to read each line at a time.
I have a 200,000 line csv file of numerics that takes me 4 seconds to read
in with 'read.csv' using 'colClasses', so I would guess your 100K line file
would take half of that.
On Thu, 2006-10-19 at 16:10 -0400, Weiwei Shi wrote:
hi,
how could I let the colname be the numbers instead of X plus numbers
when I use read.table. Or there is an alternative way?
thanks
Sounds like you have imported the data, perhaps using 'header = TRUE'
either without an actual header
thanks. i know how to go around it but i feel read.table should have
something like that to disable the process of adding X to the header
:)
On 10/19/06, Marc Schwartz [EMAIL PROTECTED] wrote:
On Thu, 2006-10-19 at 16:10 -0400, Weiwei Shi wrote:
hi,
how could I let the colname be the
On Thu, 2006-10-19 at 17:06 -0400, Weiwei Shi wrote:
thanks. i know how to go around it but i feel read.table should have
something like that to disable the process of adding X to the header
:)
You could try setting 'check.names = FALSE' to see what you end up with
in terms of column names.
January == January Weiner [EMAIL PROTECTED] writes:
Dear all, I am having troubles importing values written as
scientific notation using read.table(). I'm sure this is a
frequent problem, as many people in my lab have this
problem as well, so I'm sure that I just have
Note: this is advocacy for education in clear quantitative
language and is a border-line off topic rant...
The other day I read a paper from a student who used notation
like 2e-4 in the text - blech! I sent it back for revisions.
You have sent it back for revisions just because the student
Your example does not exhibit that behavior when I try it (below).
Can you provide a reproducible example following the style
shown here:
Lines - a 1 2e-4
+ b 2 3e-8
DF - read.table(textConnection(Lines))
str(DF)
'data.frame': 2 obs. of 3 variables:
$ V1: Factor w/ 2 levels a,b: 1 2
$
On FC5 Linux:
gannet% cat foo.dat
a 1 2e-4
b 2 3e-8
gannet% R
...
read.table(foo.dat)
V1 V2V3
1 a 1 2e-04
2 b 2 3e-08
sapply(read.table(foo.dat), class)
V1V2V3
factor integer numeric
so please tell us your environment and give a reproducible example.
Oh, thanks, that was hint enough :-) I see it now. I turns that R does
not understand
e-10
...which stands for 1e-10 and is produced by some of the bioinformatic
applications that I use (notably BLAST). However, R instead of being
verbose on that just assumes that the whole column is a string.
I think the colClasses argument to read.table() is what you need.
Either that, or explicitly cast columns in the data.frame that's
returned by read.table(). That's how you get data types that aren't
directly supported by read.table(), like various date formats.
- Martin
January Weiner wrote:
On Tue, 10 Oct 2006, January Weiner wrote:
Oh, thanks, that was hint enough :-) I see it now. I turns that R does
not understand
e-10
...which stands for 1e-10 and is produced by some of the bioinformatic
applications that I use (notably BLAST).
And that is not standard C notation.
A cheeky solution by subverting the coerce mechanism and read.table:
# install a coerce function which can fix the e+10 syntax for an
imaginary class myDouble:
setAs(character, myDouble, function(from)as.double(sub('^(-?)
e','\\11e',from)))
Warning message:
in the method signature for
read.table segments rows by separators, not by format of entry.
Suppose your data.txt is like:
1.00 2.01 3.003
4.10 5.22 6.333
7.22 8.88 9.99
Then
read.table(data.txt, sep = )
Best Regards
XiaoQuoting YIHSU CHEN [EMAIL PROTECTED]:
Dear R Users
Does anyone know how to read a text with a
See 2.16 of the R Windows FAQ.
On 5/8/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
G'day,
I am trying to read in a table and am getting an error message stating that R
is unable to open a connection to the file.
➢ Avonvegen- read.table(Y:\Study
I guess you use R under windows,then use \\ instead of \.
or use file.choose() to choose the file directly.
2006/5/9, [EMAIL PROTECTED] [EMAIL PROTECTED]:
G'day,
I am trying to read in a table and am getting an error message stating that R
is unable to open a connection to the file.
➢
Matias Mayor Fernandez wrote:
Hi,
I have some column vector in txt or xls and I need to load into R as numeric
vector.
I use the read.table (X=read.table(123.txt”) command but the program say
that “X is not a numeric vector”
No, I think you got:
Error: syntax error in
From: Uwe Ligges
Matias Mayor Fernandez wrote:
Hi,
I have some column vector in txt or xls and I need to load
into R as
numeric vector.
I use the read.table (X=read.table(123.txt) command but
the program
say that X is not a numeric vector
No, I think
On 3/8/06 8:31 AM, Liaw, Andy [EMAIL PROTECTED] wrote:
From: Uwe Ligges
Matias Mayor Fernandez wrote:
Hi,
I have some column vector in txt or xls and I need to load
into R as
numeric vector.
I use the read.table (X=read.table(123.txt) command but
the program
say
Does using read.delim instead of read.table fix your problem?
Sean
On 2/22/06 7:40 AM, I.Szentirmai [EMAIL PROTECTED] wrote:
Dear R users,
I'm trying to read data from a tab-delimited text file to
R, but I have problems with missing values. R gives this
kind of error messages: line 1 did
might be, but I have already found another solution:
reat.table(file,sep=\t)
Thanks,
Istvan
On Wed, 22 Feb 2006 07:54:49 -0500
Sean Davis [EMAIL PROTECTED] wrote:
Does using read.delim instead of read.table fix your
problem?
Sean
On 2/22/06 7:40 AM, I.Szentirmai [EMAIL PROTECTED]
off? The fill option worked in my case. Use the
option with care and double check the dataset.
HTH
Matthew McIntosh
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of I.Szentirmai
Sent: Wednesday, February 22, 2006 7:04 AM
To: r-help
Subject: Re: [R
Diethelm Wuertz wrote:
Thanks a lot that works fine!
Next problem, if I would have my own package, and the file test.csv
would be located in the data directory
How to use the function data to get
data(test)
Also put in the data subdirectory the file test.R
with the commands to read
?scan is much faser. Also, read.table has a colClasses optional argument
which can be used to speed up the reading of large files significantly.
read.table has a pretty good help section well worth reading.
read.table(file, header = FALSE, sep = , quote = \', dec = .,
?read.table
The documentation has the parameter 'check.names'.
On 2/13/06, Diethelm Wuertz [EMAIL PROTECTED] wrote:
I have a file named test.csv with the following 3 lines:
%y-%m-%d;VALUE
1999-01-01;100
2000-12-31;999
read.table(test.csv, header = TRUE, sep = ;)
delivers:
You can do it manually by reading in the headers separately:
headers - read.table(test, header = FALSE, nrow = 1, sep = ;, as.is = TRUE)
read.table(test, header = FALSE, skip = 1, sep = ;, col.names = headers)
On 2/13/06, Diethelm Wuertz [EMAIL PROTECTED] wrote:
I have a file named test.csv
Thanks a lot that works fine!
Next problem, if I would have my own package, and the file test.csv
would be located in the data directory
How to use the function data to get
data(test)
resulting in:
test
%y-%m-%d VALUE
1 1999-01-01 100
2 2000-12-31 999
Again Thanks in advance
On Tue, 14 Feb 2006, Diethelm Wuertz wrote:
Thanks a lot that works fine!
Next problem, if I would have my own package, and the file test.csv
would be located in the data directory
How to use the function data to get
data(test)
resulting in:
test
%y-%m-%d VALUE
1 1999-01-01
Andrej Kastrin [EMAIL PROTECTED] writes:
Dear R useRs,
I have big (23000 rows), vertical bar delimited file:
e.g.
A1|Text a,Text b, Text c|345
A2|Text bla|456
...
..
.
Try using
A - read.table('filename.txt', header=FALSE,sep='\|')
process stop at line 11975 with
Hello,
Well... the error message is explicit enough: number of items read is
not a multiple of the number of columns means that you do not have the
right number of items around line 11975 (not the same number as in the
11974 previous lines)! This is an error in you file.
Best,
Philippe
By the way, you might find this sed one-liner useful:
sed -n '11981q;11970,11980p' filename.txt
It will print the offending line and its neighbors. If you're on
Windows you need to install Windows Services For Unix or Cygwin.
-Original Message-
From: [EMAIL PROTECTED]
Vasu,
You have a lot of problems here.
1. How was your file generated? Excel? You have trailing tabs on
all but row 1 which is why your read.table call with sep=\t
gives you columns that don't seem to agree with what you expect.
See the argument row.names in ?read.table.
2. It's never a good
On 11/9/2005 10:07 AM, Florence Combes wrote:
Dear all,
I just upgraded version of R to R 2.2.0, and I have a problem with a script
that did not happen with my previous version.
Here is the error :
-
param-read.table(file=param.dat,sep
Thanks a lot for your answer.
In fact I found the solution, it's seems strange to me so I put it here if
it could bu useful for other people ...
I have the same as you
getAnywhere(read.table)$where
[1] package:base namespace:base
getAnywhere(read.table.default)$where
character(0)
when I run it
Florence Combes [EMAIL PROTECTED] writes:
Dear all,
I just upgraded version of R to R 2.2.0, and I have a problem with a script
that did not happen with my previous version.
Here is the error :
-
param-read.table(file=param.dat,sep
Florence Combes wrote:
Thanks a lot for your answer.
In fact I found the solution, it's seems strange to me so I put it here if
it could bu useful for other people ...
I have the same as you
getAnywhere(read.table)$where
[1] package:base namespace:base
add:
I used
trn-matrix(scan('train1.dat', sep='|', na.string='.'), nrow=273529, ncol=195)
it is done.
so it seems that I just have no patience to wait for half an hour :)
but i still have that question:
is there a way to track the process if it takes too long. Could we
stop in the middle to
You could use the nlines= argument to scan to read in a
portion at a time.
On 7/13/05, Weiwei Shi [EMAIL PROTECTED] wrote:
add:
I used
trn-matrix(scan('train1.dat', sep='|', na.string='.'), nrow=273529,
ncol=195)
it is done.
so it seems that I just have no patience to wait for half
[I had some email problems and am sending this again. Sorry
if you get it twice.]
You could use the nlines= argument to scan to read in a
portion at a time.
On 7/13/05, Weiwei Shi [EMAIL PROTECTED] wrote:
add:
I used
trn-matrix(scan('train1.dat', sep='|', na.string='.'),
that sort of works for my purpose.
btw, is there a bettter way to get data.frame by passing around
matrix(). Since I could not find data.frame() with nrow or ncol
arguments. so i have to use matrix first and then as.data.frame to
convert it.
is there any other (better) way?
weiwei
On 7/13/05,
Maybe you don't really need a data frame in the first place?
You were concerned with speed and matrices tend to
have higher performance than data frames.
On 7/13/05, Weiwei Shi [EMAIL PROTECTED] wrote:
that sort of works for my purpose.
btw, is there a bettter way to get data.frame by
there is another problem since last time i forgot byrow :(
trn-matrix(scan('train1.dat', sep='|', na.string='.'), nrow=273529,
ncol=195, byrow=T)
Read 53338155 items
Error: cannot allocate vector of size 416704 Kb
please help with this 'simple' reading task.
weiwei
On 7/13/05, Weiwei Shi
Try reading it into and transposing the matrix afterwards. Don't know if
that would work but its worth a try. Actually if you
are having problems read it into a vector, check that its of the required
size, just in case, and then turn it into a matrix and transpose it.
On 7/13/05, Weiwei Shi
i think what you meant is
trn-matrix(scan('train1.dat', sep='|', na.string='.'), nrow=195,
ncol=273529)
and then transpose it. However:
Error: cannot allocate vector of size 512000 Kb
the answer is no :(
I think i am going to write my own function to split the result from
scan but not
Sorry for last post.
I don't know why i got the error message last time.
but if i did in the following way:
t-scan('train1.dat', sep='|', na.string='.')
t2-matrix(t, nrow=195, ncol=273529)
t3-t(t2)
t4-as.data.frame(t3)
now I got what i needed.
Thanks a lot for Gabor's prompt help.
weiwei
On
See ?read.table, especially the argument as.is.
Cheers,
Rich
On Apr 7, 2005 9:55 AM, Laura Holt [EMAIL PROTECTED] wrote:
Hi R!
I am reading in a text file which has one column of alpha data and 5 columns
of numeric data.
There is a header row.
I would like the alpha data column to
Tilo Blenk wrote:
Maybe argument 'fill' of read.table is the solution.
The default value is FALSE in read.table and, therefore, any line not
having the same number of fields as the first line (not skipped) will
make problems. If set to TRUE, as in read.delim and read.csv, lines with
less number
?readLines
I'm sure Perl will do nicely, but you can also use readLines and grep() or
regexpr() the result in R as you would in Perl to find where the problem
lies. ?nchar can also help to find a non-printing character that may be
messing you up. It's no fun, I know. Excel files can be a
On 25-Feb-05 Sean Davis wrote:
I have a commonly recurring problem and wondered if folks
would share tips. I routinely get tab-delimited text files
that I need to read in.
In very many cases, I get:
a - read.table('junk.txt.txt',header=T,skip=10,sep=\t)
Error in scan(file = file, what
On 25-Feb-05 Ted Harding wrote:
On 25-Feb-05 Sean Davis wrote:
I have a commonly recurring problem and wondered if folks
would share tips. I routinely get tab-delimited text files
that I need to read in.
In very many cases, I get:
a - read.table('junk.txt.txt',header=T,skip=10,sep=\t)
Berton Gunter [EMAIL PROTECTED] writes:
?readLines
I'm sure Perl will do nicely, but you can also use readLines and grep() or
regexpr() the result in R as you would in Perl to find where the problem
lies. ?nchar can also help to find a non-printing character that may be
messing you up.
Peter Dalgaard [EMAIL PROTECTED] writes:
You might also try read.delim() which has options set specifically to
be able to read Excel-generated CSV files.
Blah.
*TAB-delimited* files of course. read.csv() for the other ones.
--
O__ Peter Dalgaard Blegdamsvej 3
c/ /'_
The solution is in section 7.21 of the R FAQ. BTW, `rf' is a built-in R
function for generating random numbers from an F distribution, so better use
some other name.
Andy
From: thomas hills
I am wondering if it is possible to read.table repeatedly from a list
of file names into a new list
On Tue, 28 Dec 2004, thomas hills wrote:
I am wondering if it is possible to read.table repeatedly from a list
of file names into a new list of table names.
For example:
filenames - list.files()
then with a function like
rf - function(i) {
word??(filename[i]) - read.table(filenames[i]) }
thomas hills [EMAIL PROTECTED] writes:
I am wondering if it is possible to read.table repeatedly from a list
of file names into a new list of table names.
For example:
filenames - list.files()
then with a function like
rf - function(i) {
word??(filename[i]) -
On 7 Oct 2004 at 20:18, Kunal Shetty wrote:
Dear R users and Helpers
I am beginner with using R and interested in carrying out certain task
for my statistical research. I am reading data for a text file, which
could contain data in following pattern
x y
8 10
1114
16
Hi
you really should spend some time to go through introductory
documentation and do some examples provided.
snip
On 8 Oct 2004 at 3:15, Kunal Shetty wrote:
you probably read it by read.table without saying/specifying
header=TRUE so your X and y is included to your data not as
names but as
James
Thank you for response. I am working on treatment for missing data for both
bivariate and multivariate normal data. Coming back to example. My problem was that
once we do execute this command
x.1 - read.table('/tempxx.txt', fill=T)
How can access the particular column say X8
PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Kunal Shetty
Sent: Thursday, October 07, 2004 18:44 PM
To: [EMAIL PROTECTED]
Cc: R-help
Subject: Re: [R] Read.Table Reading a Text file
James
Thank you for response. I am working on treatment for missing
data for both bivariate
I don't know read.data function, it is
a function that you have defined?
A.S.
Alessandro Semeria
Models and Simulations Laboratory
Montecatini Environmental Research Center (Edison Group),
Via Ciro Menotti 48,
48023 Marina di Ravenna (RA), Italy
Tel. +39 544
You should make your missing value indicator something other than your
separator indicator:
1. Use a text editor to indicate all missing values as NA or
2. Use a text editor to replace the 3 separator spaces with, for example, a
comma or semicolon and use the argument sep=, or sep=; which
On Thu, 20 Nov 2003, forkusam wrote:
Hi;
Thanks for the quick reply. I am presently not sittinh infront of my computer so I
can't tell you the exact error message but.
I have read through the documentation and have found nothing of help.
Yes. the columns are separated by semicolons
On Wed, Nov 19, 2003 at 11:11:27PM -0800, forkusam wrote:
p-read.table(file=FILENAME , header=TRUE,sep=;)
and later used the data.Frame() function.
It functions when the file has only a row of
variables.
It is not at all clear to me what you are doing and what is going wrong.
Please provide
Vadim == Vadim Ogranovich [EMAIL PROTECTED]
on Wed, 3 Sep 2003 14:29:25 -0700 writes:
Vadim Hi, I thought it would be convenient if the
Vadim check.names argument to read.table, which currently
Vadim can only be TRUE/FALSE, could take a function value
Vadim as well. If the
Ogranovich
Cc: R-Help (E-mail)
Subject: Re: [R] read.table: check.names arg - feature request
Vadim == Vadim Ogranovich [EMAIL PROTECTED]
on Wed, 3 Sep 2003 14:29:25 -0700 writes:
Vadim Hi, I thought it would be convenient if the
Vadim check.names argument to read.table, which
On Thu, 2003-09-04 at 12:00, Vadim Ogranovich wrote:
I admit I should have been more clear in my original posting. Let me
try again (and I do know that by deafulat read.table discards
everything after '#' which is why I use comment.char=, my bad not to
mention this).
Here is a typical
[EMAIL PROTECTED] wrote:
Group members,
I am using read.table() to read in ASCII data into a data
frame. The file has multiple columns that are not the
same length. The function gives me errors, or I get 'NA'
characters in the blank fields. I want to read these values
in to, e.g., perform a
On Wed, 2 Apr 2003, Prof Brian Ripley wrote:
On Tue, 1 Apr 2003 [EMAIL PROTECTED] wrote:
I am using read.table() to read in ASCII data into a data
frame. The file has multiple columns that are not the
same length. The function gives me errors, or I get 'NA'
characters in the blank
- Original Message -
From: ptremb17 [EMAIL PROTECTED]
length(varnames) = 9
length(c(F,T,F,F,F,F,F,F,F,F))) = 10
To: R-HELP [EMAIL PROTECTED]
Sent: Saturday, February 01, 2003 3:24 AM
Subject: [R] Read.table problem
Hi !
I am new to R, and using the MAC version onto Mac OS 9.1. My
Let's try to scotch this one.
That is what happens with an unpatched build of R 1.6.2 on classic MacOS,
which has CR line endings in text files and the OS is not treating as
text-mode files (as say Windows does and many Mac applications do). It
happens only with such files and only with R 1.6.2.
I agree with you. For the same purpose I use Text-Edit Plus,
which is also free and in my opinion is the best all-purpose
text editor on any platform (but sorrowly not for programming).
Best regards
Christian Stratowa
Paul Pynsent wrote:
I detect an anti Mac theme, I do not wish to attribute
Mikkel
As mentioned earlier it's a known, (now fixed) bug.
Last night I compiled a new copy of the R-1.6.2 source with the current
patch set installed first and it works fine under Darwin/X11 on my
(excellent) G4/400 Mac.
I just tried reading in a dummy file and it seems to read the file
I detect an anti Mac theme, I do not wish to attribute blame but
suggest that Excel does funny things when it dumps tab separated text
files, like adding unprintable characters and trailing spaces.
My approach is to use BBedit (which is free) to:
1) zap gremlins
2) globally substitute \ \t for
Hamish,
I usually save Excel files as CSV, and then use read.csv() to get them into R.
Also, there are variants of read.table() that seem more successful at reading
in delimited files (see read.delim, read.delim2).
Regards,
Andrew C. Ward
CAPE Centre
Department of Chemical Engineering
The
It should be the same, but then I know nothing about R or Excel for Mac.
Obvious things to check is if it is Excel or R that is the problem, i.e.
have you tested to save your Excel data on a Mac and then tried to
import it into R on a Windows machine and vice versa?
When Europe wakes up they
This is a known problem in R 1.6.2, the Darwin port reading MacOS
CR-delimited files.
Just use the patched version, R-patched, or R 1.6.1.
On Wed, 22 Jan 2003, Henrik Bengtsson wrote:
It should be the same, but then I know nothing about R or Excel for Mac.
Obvious things to check is if it is
On Mon, 20 Jan 2003, Prof Brian D Ripley wrote:
On Mon, 20 Jan 2003, David Parkhurst wrote:
I use read.table(file=clipboard,...) a lot in s-plus (under windows 2000), but it
does not seem to work in R (and is not in the help screen for read.table). Am I
missing something? Would this
88 matches
Mail list logo