Re: [R] read.table and NaN

2019-10-25 Thread Bert Gunter
--- > *From:* Bert Gunter > *Sent:* Thursday, October 24, 2019 10:39 > *To:* Sebastien Bihorel > *Cc:* r-help@r-project.org > *Subject:* Re: [R] read.table and NaN > > Not so. Read ?read.table carefully. You can use "NA" as a default. > Moreover, you

Re: [R] read.table and NaN

2019-10-25 Thread Sebastien Bihorel via R-help
nter Sent: Thursday, October 24, 2019 10:39 To: Sebastien Bihorel Cc: r-help@r-project.org Subject: Re: [R] read.table and NaN Not so. Read ?read.table carefully. You can use "NA" as a default. Moreover, you **specified** that you want NaN read as character, which means that any c

Re: [R] read.table and NaN

2019-10-24 Thread Bert Gunter
>> read.table call accordingly. I am working on a framework that is meant to >> process data files with unknown structure, so I have to think a bit more >> about that... >> -- >> *From:* Bert Gunter >> *Sent:* Thursday, October 24, 2019 00:08 >> *To:* Se

Re: [R] read.table and NaN

2019-10-24 Thread Bert Gunter
a framework that is meant to > process data files with unknown structure, so I have to think a bit more > about that... > -- > *From:* Bert Gunter > *Sent:* Thursday, October 24, 2019 00:08 > *To:* Sebastien Bihorel > *Cc:* r-help@r-project.org > *Subj

Re: [R] read.table and NaN

2019-10-24 Thread Sebastien Bihorel via R-help
Gunter Sent: Thursday, October 24, 2019 00:08 To: Sebastien Bihorel Cc: r-help@r-project.org Subject: Re: [R] read.table and NaN Like this? con <- textConnection(object = 'A,B\n1,NaN\nNA,2') > tmp <- read.table(con, header = TRUE, sep = ',', na.strings = &#

Re: [R] read.table and NaN

2019-10-23 Thread Bert Gunter
Like this? con <- textConnection(object = 'A,B\n1,NaN\nNA,2') > tmp <- read.table(con, header = TRUE, sep = ',', na.strings = '', stringsAsFactors = FALSE, + colClasses = c("numeric", "character")) > close.connection(con) > tmp A B 1 1 NaN 2 NA 2 > class(tmp[,1]) [1] "num

[R] read.table and NaN

2019-10-23 Thread Sebastien Bihorel via R-help
Hi, Is there a way to make read.table consider NaN as a string of characters rather than the internal NaN? Changing the na.strings argument does not seems to have any effect on how R interprets the NaN string (while is does not the the NA string) con <- textConnection(object = 'A,B\n1,NaN\nNA,

Re: [R] read.table(..., header == FALSE, colClasses = )

2017-10-24 Thread Benjamin Tyner
on Tue, 24 Oct 2017 07:21:33 -0400 writes: > Jeff, > Thank you for your reply. The intent was to construct a minimum > reproducible example. The same warning occurs when the 'file' argument > points to a file on disk with a million lines. But you are correct,

Re: [R] read.table(..., header == FALSE, colClasses = )

2017-10-24 Thread Martin Maechler
ints to a file on disk with a million lines. But you are correct, my > example was slightly malformed and in fact gives an error under R > version 3.2.2. Please allow me to try again; in older versions of R, >    > read.table(file = textConnection("a\t3.14"), head

Re: [R] read.table(..., header == FALSE, colClasses = )

2017-10-24 Thread Benjamin Tyner
sion 3.2.2. Please allow me to try again; in older versions of R,    > read.table(file = textConnection("a\t3.14"), header = FALSE, colClasses = c(x = "character", y = "numeric"), sep="\t")      V1   V2    1  a 3.14 (with no warning). As of version 3

Re: [R] read.table(..., header == FALSE, colClasses = )

2017-10-23 Thread Jeff Newmiller
You are constructing the equivalent of a two-line data file, and complaining that it is not treating it like it was one line. If it did used to accept this silently [skeptical] then I for one am glad it produces a warning now. -- Sent from my phone. Please excuse my brevity. On October 23, 201

[R] read.table(..., header == FALSE, colClasses = )

2017-10-23 Thread Benjamin Tyner
Hello I noticed that starting with R version 3.3.0 onward, this generates a warning:    > txt <- c("a", "3.14")    > read.table(file = textConnection(txt), header = FALSE, colClasses = c(x = "character", y = "numeric")) the warning is "not all columns named in 'colClasses' exist" and I gues

Re: [R] read.table() question

2016-10-19 Thread Rich Shepard
On Wed, 19 Oct 2016, Duncan Murdoch wrote: I don't get that from those 9 observations, so there's likely something else going on further down in the file. Duncan, Sigh. I thought I had removed all 'T's (for trace amounts) from the file, but I hadn't. Yes, this explains it. Many thanks,

Re: [R] read.table() question

2016-10-19 Thread Marc Schwartz
> On Oct 19, 2016, at 4:12 PM, David Winsemius wrote: > > >> On Oct 19, 2016, at 1:54 PM, Rich Shepard wrote: >> >> The file, daily_records.dat, contains these data: >> >> "station","date","amount" >> "0.3E",2014-01-01, >> "0.3E",2014-01-02, >> "0.3E",2014-01-03,0.01 >> "0.3E",2014-01-04,0.0

Re: [R] read.table() question

2016-10-19 Thread David Winsemius
> On Oct 19, 2016, at 1:54 PM, Rich Shepard wrote: > > The file, daily_records.dat, contains these data: > > "station","date","amount" > "0.3E",2014-01-01, > "0.3E",2014-01-02, > "0.3E",2014-01-03,0.01 > "0.3E",2014-01-04,0.00 > "0.3E",2014-01-05,0.00 > "0.3E",2014-01-06,0.00 > "0.3E",2014-01-

Re: [R] read.table() question

2016-10-19 Thread Duncan Murdoch
On 19/10/2016 4:54 PM, Rich Shepard wrote: The file, daily_records.dat, contains these data: "station","date","amount" "0.3E",2014-01-01, "0.3E",2014-01-02, "0.3E",2014-01-03,0.01 "0.3E",2014-01-04,0.00 "0.3E",2014-01-05,0.00 "0.3E",2014-01-06,0.00 "0.3E",2014-01-07,0.10 "0.3E",2014-01-08,0.2

[R] read.table() question

2016-10-19 Thread Rich Shepard
The file, daily_records.dat, contains these data: "station","date","amount" "0.3E",2014-01-01, "0.3E",2014-01-02, "0.3E",2014-01-03,0.01 "0.3E",2014-01-04,0.00 "0.3E",2014-01-05,0.00 "0.3E",2014-01-06,0.00 "0.3E",2014-01-07,0.10 "0.3E",2014-01-08,0.22 "0.3E",2014-01-09,0.49 Using read.table(

Re: [R] read.table with a "memory connection"

2015-04-01 Thread Thomas
On 01/04/2015 11:06, Prof Brian Ripley wrote: On 01/04/2015 09:52, Thomas wrote: Hi, I believe you are looking for 'text connections': see the 'text' argument to read.table() and ?textConnection. Thanks, that's it ! __ R-help@r-project.org maili

Re: [R] read.table with a "memory connection"

2015-04-01 Thread Prof Brian Ripley
On 01/04/2015 09:52, Thomas wrote: Hi, Is there a way to create "memory connections" in R which are valid connections to read.table (and associated function)? By saying "memory connection" I refer to something like a connection created from a simple character object (of length 1) - instead of ha

[R] read.table with a "memory connection"

2015-04-01 Thread Thomas
Hi, Is there a way to create "memory connections" in R which are valid connections to read.table (and associated function)? By saying "memory connection" I refer to something like a connection created from a simple character object (of length 1) - instead of having the content in a physical f

Re: [R] read.table with missing data and consecutive delimiters

2015-02-12 Thread MacQueen, Don
To which I will add, you could have tried count.fields('test.dat', sep='$' ) which I expect would have given you 3,3,2,3, and hence a pointer to where the problem is. count.fields is mentioned in the "See Also" section of ?read.table -- Don MacQueen Lawrence Livermore National Laboratory 70

Re: [R] read.table with missing data and consecutive delimiters

2015-02-11 Thread Rui Barradas
Hello, You're missing a dollar sign: 2$$$5, not 2$$5. Hope this helps, Rui Barradas Em 11-02-2015 14:53, Tim Victor escreveu: All, Assume we have data in an ASCII file that looks like Var1$Var2$Var3$Var4 1$2$3$4 2$$5 $$$6 When I execute read.table( 'test.dat', header=TRUE, sep='$' ) I, o

[R] read.table with missing data and consecutive delimiters

2015-02-11 Thread Tim Victor
All, Assume we have data in an ASCII file that looks like Var1$Var2$Var3$Var4 1$2$3$4 2$$5 $$$6 When I execute read.table( 'test.dat', header=TRUE, sep='$' ) I, of course, receive the following error: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 2 did n

Re: [R] read.table - replaces 'T' with 'TRUE'

2015-01-27 Thread Brian Smith
Thanks!! On Mon, Jan 26, 2015 at 5:23 PM, peter dalgaard wrote: > > > On 26 Jan 2015, at 23:10 , Duncan Murdoch > wrote: > > > > read.table(, colClasses = "character") > > > > (You might want "factor" instead of character.) > > Or maybe not. I'd expect trouble with getting the levels set to > c

Re: [R] read.table - replaces 'T' with 'TRUE'

2015-01-26 Thread peter dalgaard
> On 26 Jan 2015, at 23:10 , Duncan Murdoch wrote: > > read.table(, colClasses = "character") > > (You might want "factor" instead of character.) Or maybe not. I'd expect trouble with getting the levels set to c("C","A","G","T") for all columns. Is this always one single line of CGAT? If so,

Re: [R] read.table - replaces 'T' with 'TRUE'

2015-01-26 Thread Duncan Murdoch
On 26/01/2015 4:52 PM, Brian Smith wrote: > Hi, > > I had a table with 'T's in it. When I try to read the table, it replaces > all the 'T's with TRUE. Is there a way that I can retain the Ts? That only happens for columns which are all T. (You only have one row, so every T gets converted.) The

[R] read.table - replaces 'T' with 'TRUE'

2015-01-26 Thread Brian Smith
Hi, I had a table with 'T's in it. When I try to read the table, it replaces all the 'T's with TRUE. Is there a way that I can retain the Ts? thanks! Sample table (test.txt): xx1 xx2 0 0 2 2 A A G G A G A A C C G G G G G G A G A A A G A G A A G G A A A G G G A G A G G G A G A G G G G G A G G G

Re: [R] read.table() 1Gb text dataframe

2014-09-20 Thread Henrik Bengtsson
much to learn. /Henrik > > Stephen HK Wong > Stanford, California 94305-5324 > > - Original Message - > From: Henrik Bengtsson > To: Stephen HK Wong > Cc: r-help@r-project.org > Sent: Thu, 18 Sep 2014 18:33:15 -0700 (PDT) > Subject: Re: [R] read.table() 1Gb

Re: [R] read.table() 1Gb text dataframe

2014-09-19 Thread Stephen HK Wong
information on documentation. Stephen HK Wong Stanford, California 94305-5324 - Original Message - From: Henrik Bengtsson To: Stephen HK Wong Cc: r-help@r-project.org Sent: Thu, 18 Sep 2014 18:33:15 -0700 (PDT) Subject: Re: [R] read.table() 1Gb text dataframe As a start, make sure

Re: [R] read.table() 1Gb text dataframe

2014-09-19 Thread Greg Snow
When working with datasets too large to fit in memory it is usually best to use an actual database, read the data into the database, then pull the records that you want into R. There are several packages for working with databases, but 2 of the simplest are the RSQLite and sqldf packages (installi

Re: [R] read.table() 1Gb text dataframe

2014-09-18 Thread EMISHIA PERSIOUS
r code for the packages cstmr ,gRain,gRc,gRim,gRbase using probability models, On Friday, September 19, 2014 7:05 AM, Henrik Bengtsson wrote: As a start, make sure you specify the 'colClasses' argument. BTW, using that you can even go to the extreme and read one column at the time, if it c

Re: [R] read.table() 1Gb text dataframe

2014-09-18 Thread Henrik Bengtsson
As a start, make sure you specify the 'colClasses' argument. BTW, using that you can even go to the extreme and read one column at the time, if it comes down to that. To read a 10% subset of the rows, you can use R.filesets as: library(R.filesets) db <- TabularTextFile(pathname) n <- nbrOfRows(d

[R] read.table() 1Gb text dataframe

2014-09-18 Thread Stephen HK Wong
Dear All, I have a table of 4 columns and many millions rows separated by tab-delimited. I don't have enough memory to read.table in that 1 Gb file. And actually I have 12 text files like that. Is there a way that I can just randomly read.table() in 10% of rows ? I was able to do that using col

Re: [R] Read.table mucks up headers

2014-04-26 Thread starter
Hello Uwe & Others Thanks for all your help, I figured out what the problem was. It wasn't working with old R version. Once I updated it to the latest version, it seemed to work. Thank you -- View this message in context: http://r.789695.n4.nabble.com/Read-table-mucks-up-headers-tp4688742p468

Re: [R] Read.table mucks up headers

2014-04-22 Thread Pavneet Arora
ate: 19/04/2014 14:05 Subject: Re: [R] Read.table mucks up headers On 19.04.2014 14:30, starter wrote: > Hello Milan > > It had worked perfectly before, but now I am trying on a different text file > but using the trick you showed I just get the headers in the output and

Re: [R] Read.table mucks up headers

2014-04-21 Thread starter
Hello Uwe I tried both the options you mentioned but all i get as output then is the header line and the headers as "row.names" and "X." -- View this message in context: http://r.789695.n4.nabble.com/Read-table-mucks-up-headers-tp4688742p4689185.html Sent from the R help mailing list archive a

Re: [R] Read.table mucks up headers

2014-04-19 Thread Uwe Ligges
On 19.04.2014 14:30, starter wrote: Hello Milan It had worked perfectly before, but now I am trying on a different text file but using the trick you showed I just get the headers in the output and that too as "row.names" and "X". *code:* corr <- read.table("E:/temp/corrosion data.txt",header=

Re: [R] Read.table mucks up headers

2014-04-19 Thread starter
Hello Milan It had worked perfectly before, but now I am trying on a different text file but using the trick you showed I just get the headers in the output and that too as "row.names" and "X". *code:* corr <- read.table("E:/temp/corrosion data.txt",header=T,fileEncoding="UTF-8-BOM") > dput(corr

Re: [R] Read.table mucks up headers

2014-04-15 Thread Pavneet Arora
Thank you Milan, the fileEncoding bit worked perfectly. From: Milan Bouchet-Valat To: Jeff Newmiller Cc: Pavneet Arora/UK/RoyalSun@RoyalSun, r-help@r-project.org, pavnee...@yahoo.co.uk Date: 14/04/2014 18:03 Subject:Re: [R] Read.table mucks up headers Le lundi 14

Re: [R] Read.table mucks up headers

2014-04-14 Thread Milan Bouchet-Valat
Le lundi 14 avril 2014 à 08:50 -0700, Jeff Newmiller a écrit : > You have not posted the input to your code so it is not reproducible. > Also, you have posted in HTML, which is notorious for corrupting R > code and data in emails. > > If I were to guess, though, it looks to me like you are workin

Re: [R] Read.table mucks up headers

2014-04-14 Thread S Ellison
> But for some reason my first header comes as "?...X. ", instead of just "X". > Can some one please tell me why? And how to fix it? i) What were the separator characters in the original data file header row? ii) Your first character is not being decoded properly; check the file encoding and set

Re: [R] Read.table mucks up headers

2014-04-14 Thread Jeff Newmiller
You have not posted the input to your code so it is not reproducible. Also, you have posted in HTML, which is notorious for corrupting R code and data in emails. If I were to guess, though, it looks to me like you are working with a UTF-8 file with a Byte Order Mark (header). I don't know the "

[R] Read.table mucks up headers

2014-04-14 Thread Pavneet Arora
Hey All I am trying to read in a small text file using read.table. dput(sim) structure(list(ï...X. = 1:7, Y1 = c(2.5501, 4.105, 5.4687, 7.0009, 8.5066, 9.785, 11.5167), Y2 = c(2.5501, 4.105, 5.4687, 11.0009, 8.5066, 9.785, 11.5167), Y3 = c(2.5501, 4.105, 5.4687, 7.0009, 8.5066, 9.785, 15.516

Re: [R] read.table freezes the computer

2013-03-11 Thread S Ellison
> -Original Message- > I have a txt file to read into R. The size of it is about 500MB. > This txt file is produced by calling write.table(M, file = > "xxx.txt"), where M is a large matrix After running MM = > read.table("xxx.txt"), the R gui keeps a cpu core/thread > fully occupied

Re: [R] read.table freezes the computer

2013-03-09 Thread Ben Bolker
Jie gmail.com> writes: [snip] > I have a txt file to read into R. The size of it is about 500MB. > This txt file is produced by calling write.table(M, file = > "xxx.txt"), where M is a large matrix > After running MM = read.table("xxx.txt"), the R gui keeps a cpu > core/thread fully occupied fo

Re: [R] read.table()

2012-12-08 Thread Tanja Vukov
Hi! I think you have problem with "flag_var". I suggest to put just "flagvar". Do not use "_" in variable names. I would suggest not to use both "_" or "-" anywhere in data file. I am just a beginner with R but think that is the problem... Cheers! Tanja. On Sat, Dec 8, 2012 at 8:29 PM, Prof Brian

Re: [R] read.table()

2012-12-08 Thread David L Carlson
ember 08, 2012 1:11 PM > To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org > Subject: [R] read.table() > > > Hi List, > > I have spent more than 30 minutes, but failed to read in this file > using the read.table() function. I could not figure out how to fix the

Re: [R] read.table()

2012-12-08 Thread Prof Brian Ripley
On 08/12/2012 19:10, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: Hi List, I have spent more than 30 minutes, but failed to read in this file using the read.table() function. I could not figure out how to fix the following error. Well, we have a whole manual on this, mentioned on ?read.table (see Se

[R] read.table()

2012-12-08 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi List, I have spent more than 30 minutes, but failed to read in this file using the read.table() function. I could not figure out how to fix the following error. Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1 did not have 6 elements Any help would be

Re: [R] read.table

2012-11-19 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of li1127217ye > Sent: Monday, November 19, 2012 8:08 AM > To: r-help@r-project.org > Subject: Re: [R] read.table > > > read.table("data.

Re: [R] read.table

2012-11-19 Thread Uwe Ligges
On 19.11.2012 08:07, li1127217ye wrote: read.table("data.txt",header=TRUE, colClasses=c("character","character","numeric","character", "numeric","numeric")) a b c d e f 1 SPX LSZ 100 C 0 34.40 2 SPX LSZ 100 P 0 1.30 3 SPX LSZ 105 C 0 30.30 4 SPX LSZ 105 P 0 1.85 5 SPX LSZ 110 C

Re: [R] read.table

2012-11-19 Thread li1127217ye
> read.table("data.txt",header=TRUE, colClasses=c("character","character","numeric","character", "numeric","numeric")) a b c d e f 1 SPX LSZ 100 C 0 34.40 2 SPX LSZ 100 P 0 1.30 3 SPX LSZ 105 C 0 30.30 4 SPX LSZ 105 P 0 1.85 5 SPX LSZ 110 C 0 26.40 It's right result! "header=TRUE",no

Re: [R] read.table() Issue

2012-08-01 Thread Rich Shepard
On Wed, 1 Aug 2012, William Dunlap wrote: An unmatched quote can make read.table run very slowly when there are lots of lines in the file. E.g., Bill, Yes. Turns out that there was no closing quote on a changed header. I found this by an error message on one data file; the other data file

Re: [R] read.table() Issue [RESOLVED]

2012-08-01 Thread Rich Shepard
On Wed, 1 Aug 2012, Rich Shepard wrote: What might cause this? Must be computers acting like computers. Restored files from backup, made changes one at a time, and there are no problems reading them into R data frames. My apologies for taking up space here. Rich __

Re: [R] read.table() Issue

2012-08-01 Thread William Dunlap
te final line found by readTableHeader ...". Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Rich Shepard > Sent: Wednesday, August 01, 2012 10:52 AM >

Re: [R] read.table() Issue [UPDATE]

2012-08-01 Thread Rich Shepard
On Wed, 1 Aug 2012, Rich Shepard wrote: What might cause this? I restored these two files from last Friday and they are read into R with no problems. So, I'll make one change at a time and see where things break. Will post results when I have them. Rich ___

[R] read.table() Issue

2012-08-01 Thread Rich Shepard
Yesterday I changed the headers for a couple of columns in data text files and removed hyphens from within character strings, too. When I tried to re-read these data sources using read.table() I encountered an issue I've not before seen. Both files were read almost instantly until yesterday's wo

Re: [R] read.table with numeric row names

2012-07-15 Thread arun
s. It works very good.Chi" A.K. - Original Message - From: peter dalgaard To: arun Cc: kexinz ; R help Sent: Friday, July 13, 2012 10:27 AM Subject: Re: [R] read.table with numeric row names On Jul 13, 2012, at 04:27 , arun wrote: > Hello, > > I saw your reply in nabble. 

Re: [R] read.table with numeric row names

2012-07-13 Thread peter dalgaard
stood from his email: > ("Thanks. It works very good.Chi" > > A.K. > > > > > - Original Message - > From: peter dalgaard > To: arun > Cc: kexinz ; R help > Sent: Friday, July 13, 2012 10:27 AM > Subject: Re: [R] read.table with nu

Re: [R] read.table with numeric row names

2012-07-13 Thread kexinz
Thanks all you guys' help! -- View this message in context: http://r.789695.n4.nabble.com/read-table-with-numeric-row-names-tp4636342p4636446.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://sta

Re: [R] read.table with numeric row names

2012-07-13 Thread William Dunlap
nlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of kexinz > Sent: Thursday, July 12, 2012 2:59 PM > To: r-help@r-project.org > Subject: Re: [R] read.table with numeric row nam

Re: [R] read.table with numeric row names

2012-07-13 Thread jim holtman
4 > names(x) [1] "2.5" "3.6" "7.1" "7.9" On Thu, Jul 12, 2012 at 2:50 PM, kexinz wrote: > I have a text file like this > 2.5 3.6 7.1 7.9 > 100 3 4 2 3 > 200 3.1 4 3 3 > 300 2.2 3.3 2

Re: [R] read.table with numeric row names

2012-07-13 Thread peter dalgaard
ot;\\1",colnames(dat1)) > dat1 > 2.5 3.6 7.1 7.9 > 100 3.0 4.0 2 3 > 200 3.1 4.0 3 3 > 300 2.2 3.3 2 4 > plot(colMeans(dat1)~as.numeric(names(dat1)),xlab="Column_Name",ylab="Column_Mean") > > A.K. > > > > > -

Re: [R] read.table with numeric row names

2012-07-12 Thread Chi Zhang
_Name",ylab="Column_Mean") > > A.K. > > > > > - Original Message - > From: kexinz > To: r-help@r-project.org > Cc: > Sent: Thursday, July 12, 2012 2:50 PM > Subject: [R] read.table with numeric row names > > I have a text file like

Re: [R] read.table with numeric row names

2012-07-12 Thread arun
  2   3 200 3.1 4.0   3   3 300 2.2 3.3   2   4 plot(colMeans(dat1)~as.numeric(names(dat1)),xlab="Column_Name",ylab="Column_Mean") A.K. - Original Message - From: kexinz To: r-help@r-project.org Cc: Sent: Thursday, July 12, 2012 2:50 PM Subject: [R] read.table with nume

Re: [R] read.table with numeric row names

2012-07-12 Thread kexinz
Thanks Yasir, this helps a lot. BTW, is there an R command to read just the first line of the file? Yasir Kaheil wrote > > just do this: > colnames(r)<-substr(colnames(r),2,nchar(colnames(r))) > > This will remove the X. > Later when you want to use the headed to plot something, cast it as > n

Re: [R] read.table with numeric row names

2012-07-12 Thread kexinz
Thanks, but I don't want to specify the column names by hand, since I have a lot of similar files. arun kirshna wrote > > Hi, > > Try this: > > dat1<-read.table(text=" >  2.5  3.6  7.1  7.9 >  100  3  4  2    3 >  200  3.1  4  3  3 >  300  2.2  3.3  2    4 >  ",sep="",header=TR

Re: [R] read.table with numeric row names

2012-07-12 Thread Yasir Kaheil
just do this: colnames(r)<-substr(colnames(r),2,nchar(colnames(r))) This will remove the X. Later when you want to use the headed to plot something, cast it as numeric: plot(colMeans(r)~as.numeric(colnames(r))) - Yasir Kaheil -- View this message in context: http://r.789695.n4.nabble.com/re

Re: [R] read.table with numeric row names

2012-07-12 Thread arun
colnames(dat1)<-c(2.5,3.6,7.1,7.9) #produce character column names  is.character(colnames(dat1)) [1] TRUE  is.numeric(colnames(dat1)) [1] FALSE dat1     2.5 3.6 7.1 7.9 100 3.0 4.0   2   3 200 3.1 4.0   3   3 300 2.2 3.3   2   4 A.K. - Original Message - From: kexinz To: r-help@r-project.o

[R] read.table with numeric row names

2012-07-12 Thread kexinz
I have a text file like this 2.5 3.6 7.1 7.9 100 3 4 2 3 200 3.1 4 3 3 300 2.2 3.3 2 4 I used "r <- read.table("a.txt", header=T)" The row names becomes X2.5, X3.6... What I need is the row names are numeric, so I c

Re: [R] read.table and variable length of tables

2012-06-14 Thread Halldór Björnsson
Thanks and with datlines <- as.data.frame(inp[( grep("", inp)[1]+5 ):(grep("", inp)[1]-1)]); I get the data as needed. Thanks again H. - Original Message - On Jun 14, 2012, at 10:23 AM, Halldór Björnsson wrote: > Hi, > > I am trying to read in weather balloon data, where each file

Re: [R] read.table and variable length of tables

2012-06-14 Thread Halldór Björnsson
Thanks, even better - Original Message - On Jun 14, 2012, at 12:18 PM, Halldór Björnsson wrote: > Thanks and with > > datlines <- as.data.frame(inp[( grep("", inp)[1]+5 ):(grep(" PRE>", inp)[1]-1)]); > I suggest this instead. > read.fwf(textConnection(datlines), widths=rep(7,11)) V1

Re: [R] read.table and variable length of tables

2012-06-14 Thread David Winsemius
On Jun 14, 2012, at 12:18 PM, Halldór Björnsson wrote: Thanks and with datlines <- as.data.frame(inp[( grep("", inp)[1]+5 ):(grep("PRE>", inp)[1]-1)]); Er, ... are you sure? I got a factorized mess when I did that. > str(datlines) 'data.frame': 98 obs. of 1 variable: $ inp[(grep("", i

Re: [R] read.table and variable length of tables

2012-06-14 Thread David Winsemius
On Jun 14, 2012, at 12:18 PM, Halldór Björnsson wrote: Thanks and with datlines <- as.data.frame(inp[( grep("", inp)[1]+5 ):(grep("PRE>", inp)[1]-1)]); I suggest this instead. > read.fwf(textConnection(datlines), widths=rep(7,11)) V1V2V3V4 V5 V6 V7 V8V9 V10

Re: [R] read.table and variable length of tables

2012-06-14 Thread David Winsemius
On Jun 14, 2012, at 10:23 AM, Halldór Björnsson wrote: Hi, I am trying to read in weather balloon data, where each file has a header of fixed length and a trailing section of a fixed length. The data section (the table) is of variable length. An example of the data is on: http://weather

[R] read.table and variable length of tables

2012-06-14 Thread Halldór Björnsson
Hi, I am trying to read in weather balloon data, where each file has a header of fixed length and a trailing section of a fixed length. The data section (the table) is of variable length. An example of the data is on: http://weather.uwyo.edu/cgi-bin/sounding?region=naconf&TYPE=TEXT%3ALIST&YEAR

Re: [R] read.table() vs read.delim() any difference??

2012-05-04 Thread Rameswara Sashi Kiran Challa
Thanks Peter. In my case specifying the quote="\"" worked out fine with read.table(). -Sashi On Fri, May 4, 2012 at 1:53 PM, peter dalgaard wrote: > > On May 4, 2012, at 08:16 , Rameswara Sashi Kiran Challa wrote: > > > Hi, > > > > I have a tab seperated file with 206 rows and 30 columns. > >

Re: [R] read.table() vs read.delim() any difference??

2012-05-04 Thread peter dalgaard
On May 4, 2012, at 08:16 , Rameswara Sashi Kiran Challa wrote: > Hi, > > I have a tab seperated file with 206 rows and 30 columns. > > I read in the file into R using read.table() function. I checked the dim() > of the data frame created in R, it had only 103 rows (exactly half), 30 > columns.

Re: [R] read.table() vs read.delim() any difference??

2012-05-04 Thread Jan van der Laan
read.delim calls read.table so any differences between the two are caused by differences in the default values of some of the parameters. Take a look at the help file ?read.table read.table uses white space as separator; read.delim tabs read.table uses " and ' as quotes; read.delim just " e

[R] read.table() vs read.delim() any difference??

2012-05-03 Thread Rameswara Sashi Kiran Challa
Hi, I have a tab seperated file with 206 rows and 30 columns. I read in the file into R using read.table() function. I checked the dim() of the data frame created in R, it had only 103 rows (exactly half), 30 columns. Then I tried reading in the file using read.delim() function and this time the

Re: [R] read.table issue with "#"

2012-03-02 Thread Sarah Goslee
The # is the default comment character in read.table(), but that can easily be changed: > tc <- textConnection( + "yes yes yes yes yes + yes yes yes yes yes + yes yes # yes yes" + ) > x <- read.table(tc, comment.char="") > x V1 V2 V3 V4 V5 1 yes yes yes yes yes 2 yes yes yes yes yes 3 yes y

Re: [R] read.table issue with "#"

2012-03-02 Thread Jim Holtman
use the 'comment.char' parameter of read.table Sent from my iPad On Mar 1, 2012, at 17:51, Rui Barradas wrote: > Hello, > >> >> The problem is that I get a the following error bacause anything after the >> # is ignored. >> >> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.

Re: [R] read.table issue with "#"

2012-03-01 Thread Rui Barradas
Hello, > > The problem is that I get a the following error bacause anything after the > # is ignored. > > Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, > : > line 6 did not have 500 elements > > R thinks that line 6 has only 2 elements because of the #. > Use '

Re: [R] read.table: how to ignore errors?

2012-01-24 Thread Sam Steingold
> * William Dunlap [2012-01-24 21:47:39 +]: > >> >> Oh, yeah, a reproducible example: >> >> >> >> read.csv from >> >> = >> >> a,b >> >> 1,2 >> >> 3,4 >> >> 5,,6 >> >> 7,8 >> >> = >> >> I want to be able to extract the data frame >> >> a b >> >> 1 1 1 > The previous line should be '

Re: [R] read.table: how to ignore errors?

2012-01-24 Thread William Dunlap
ith 2 fields only > textLines <- readLines(tf) > counts <- count.fields(textConnection(textLines), sep=",") > read.table(text=textLines[counts == 2], header=TRUE, sep=",") a b 1 1 2 2 3 4 3 7 8 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Ori

Re: [R] read.table: how to ignore errors?

2012-01-24 Thread Sam Steingold
> * Duncan Murdoch [2012-01-24 16:00:14 -0500]: > > On 24/01/2012 3:45 PM, Sam Steingold wrote: >> I get this error from read.table(): >> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : >>line 234 did not have 8 elements >> The error is genuine (an extra field sep

Re: [R] read.table: how to ignore errors?

2012-01-24 Thread Rolf Turner
On 25/01/12 09:45, Sam Steingold wrote: I get this error from read.table(): Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 234 did not have 8 elements The error is genuine (an extra field separator between 1st and 2nd element). 1. is there a way to see this

Re: [R] read.table: how to ignore errors?

2012-01-24 Thread R. Michael Weylandt
Given your domain name, you might also get some use out of the system() and system2() commands which allow the passing of strings to the OS command line (and thus the use of tools like grep/sed/awk within R) E.g., an idiom I use pretty frequently for interactive data analysis: (not really related,

Re: [R] read.table: how to ignore errors?

2012-01-24 Thread Duncan Murdoch
On 24/01/2012 3:45 PM, Sam Steingold wrote: I get this error from read.table(): Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 234 did not have 8 elements The error is genuine (an extra field separator between 1st and 2nd element). 1. is there a way to see

[R] read.table: how to ignore errors?

2012-01-24 Thread Sam Steingold
I get this error from read.table(): Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 234 did not have 8 elements The error is genuine (an extra field separator between 1st and 2nd element). 1. is there a way to see this bad line 234 from R without diving into t

Re: [R] read.table as integer

2012-01-13 Thread Gabor Grothendieck
On Fri, Jan 13, 2012 at 7:02 AM, Francisco wrote: > Hello, > I have a csv file with many variables, both characters and integers. > I would like to load it on R and do some operations on integer variables, > the problem is that R loads the entire dataset considering all variables as > characters,

Re: [R] read.table as integer

2012-01-13 Thread David Winsemius
On Jan 13, 2012, at 7:02 AM, Francisco wrote: Hello, I have a csv file with many variables, both characters and integers. I would like to load it on R and do some operations on integer variables, the problem is that R loads the entire dataset considering all variables as characters, instead

[R] read.table as integer

2012-01-13 Thread Francisco
Hello, I have a csv file with many variables, both characters and integers. I would like to load it on R and do some operations on integer variables, the problem is that R loads the entire dataset considering all variables as characters, instead I would like that R makes the distinction between

Re: [R] read.table question

2011-12-09 Thread Pavan G
Thanks All! On Thu, Dec 8, 2011 at 7:41 PM, Robert Baer wrote: > Hello All, > This works, > results <- read.table("plink.txt",T) > > while this doesn't. > results <- read.table("plink.txt") > > The T is the value for the second parameter which you show from the help > file p

Re: [R] read.table performance

2011-12-09 Thread Petr PIKAL
uot;X..Hydrogen" "Helium" "Lithium" "Beryllium" "Boron" > > [6] "Carbon" > >> tail(names(dat)) > > [1] "Sulfur.32""Chlorine.32" "Argon.32" "Potassium.32" > > "C

Re: [R] read.table performance

2011-12-08 Thread Gene Leynes
Now this is interesting: Here's a list of how long it took to read the same file in various versions of R: R version 2.10.1 (2009-12-14) 3.97 R version 2.12.0 (2010-10-15)24.53 R version 2.13.0 (2011-04-13)24.48 R version 2.14.0 (2011-10-31) 3.75 I think that the even numbered re

Re: [R] read.table question

2011-12-08 Thread Robert Baer
Hello All, This works, results <- read.table("plink.txt",T) while this doesn't. results <- read.table("plink.txt") The T is the value for the second parameter which you show from the help file printout you looked at to be header. Thus, you are writing in short cut: results

Re: [R] read.table question

2011-12-08 Thread Duncan Murdoch
On 08/12/2011 3:28 PM, Pavan G wrote: Hello All, This works, results<- read.table("plink.txt",T) while this doesn't. results<- read.table("plink.txt") Make sure your data frame contains columns CHR, BP, and P What does adding the "T" in read.table do? Which argument does this correspond to?

[R] read.table question

2011-12-08 Thread Pavan G
Hello All, This works, results <- read.table("plink.txt",T) while this doesn't. results <- read.table("plink.txt") Make sure your data frame contains columns CHR, BP, and P What does adding the "T" in read.table do? Which argument does this correspond to? I tried searching for it but didn't fin

Re: [R] read.table performance

2011-12-08 Thread Gene Leynes
t;> head(names(dat)) > > [1] "X..Hydrogen" "Helium" "Lithium" "Beryllium" "Boron" > > [6] "Carbon" > >> tail(names(dat)) > > [1] "Sulfur.32""Chlorine.32" "Argon.32

  1   2   3   >