search for: colclasses

Displaying 20 results from an estimated 499 matches for "colclasses".

2004 Oct 11
4
colClasses
Hi I am trying to read a data frame from a text editor in to R. I want some of the columns to be read in as "character" not numeric. I figured that I can do that by using "colClasses" in "read.table" command. However, I couldn't find out how to use "colClasses". e.g. say I have 5 column in the data file. I want 1st and 3rd column to be read in as character. How can I define this using colClasses? (or is there a better way to do what I want?) Th...
2017 Oct 24
2
read.table(..., header == FALSE, colClasses = <vector with names attribute>)
...argument points 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"), header = FALSE, colClasses = c(x = "character", y = "numeric"), sep="\t") ? ?? V1?? V2 ?? 1? a 3.14 (with no warning). As of version 3.3.0, ?? > read.table(file = textConnection("a\t3.14"), header = FALSE, colClasses = c(x = "character", y = "numeric"), sep...
2017 Oct 24
0
read.table(..., header == FALSE, colClasses = <vector with names attribute>)
...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"), header = FALSE, > colClasses = c(x = "character", y = "numeric"), sep="\t") > ? ?? V1?? V2 > ?? 1? a 3.14 > (with no warning). As of version 3.3.0, > ?? > read.table(file = textConnection("a\t3.14"), header = FALSE, > colClasses = c(x = "char...
2006 Jun 21
5
colClasses
Hi Folks! I'm reading in some data from a .csv file that has a date column. How do I use colClasses to get read.csv to recognize the date column? The documentation on this seems to be nil - And yes, I've read help and R Data Import/Export and can't figure out what the colClasses syntax is. Thanks, john [[alternative HTML version deleted]]
2009 Jun 14
2
read.csv
If read.csv's colClasses= argument is NOT used then read.csv accepts double quoted numerics: 1: > read.csv(stdin()) 0: A,B 1: "1",1 2: "2",2 3: A B 1 1 1 2 2 2 However, if colClasses is used then it seems that it does not: > read.csv(stdin(), colClasses = "numeric") 0: A,B 1: "...
2006 Sep 26
2
colClasses: supressed 'NA'
Hi, The colClasses seem to be supressing 'NA' vlaues. How do I fix this? R script and first 5 lines of output is below. File "test2.dat" has blanks that are read as "NA" when I do not use 'colClasses', but as blanks when I use 'colClasses'. temp.df <- read.fwf("t...
2012 Sep 14
1
Any way to get read.table.ffdf() (in the ff package) to pass colClasses or comment.char parameters through to read.fwf() ?
Hi everyone, my apologies if I'm overlooking something obvious in the documentation. I'm relatively inexperienced with the (awesome) ff package. My goal is to use the read.table.ffdf() function to call the read.fwf() function and pass through the colClasses and comment.char arguments. The code below shows exactly what doesn't work for me. If the colClasses and comment.char parameters cannot be passed to read.fwf() through read.table.ffdf(), I'd love to hear any ideas for a workaround? :) Passing the comment.char parameter isn't critica...
2004 Sep 08
1
A couple of issues with colClasses/setAs
Consider this: $ cat test.dat 1 a 2 b Now, we want to read the 2nd column as a factor and ignore the first (since it's just a sequential ID). We can't just put "factor" among the colClasses (would have been nice), so let's try this instead > setAs("character","factor",as.factor) Arguments in definition changed from (x) to (from) > read.table("test.dat",colClasses=c("numeric","factor")) Error in inherits(x, "factor"...
2011 Nov 21
1
extending the colClasses argument in read.table
...tc ... files. I have this function that wraps a call to read.csv to: - read the "int64" and "uint64" columns as "character" - converts them afterwards to the appropriate type read.csv.int64 <- function (file, ...){ dots <- list( file, ... ) if( "colClasses" %in% names(dots) ){ colClasses <- dots[["colClasses"]] idx.int64 <- colClasses == "int64" idx.uint64 <- colClasses == "uint64" colClasses[ idx.int64 | idx.uint64 ] <- "character" dots[["colC...
2010 Feb 11
2
trouble with read.table and colClasses='raw'
...there are no examples of how to use read.table() under ?read.table ! I am trying to read in a flat file of type 'raw'. It has 1000 rows and 600K columns. I have the RAM to accomplish this, but can't get the data into R using read.table: x <- read.table("data",header=TRUE,colClasses=rep(,600000)) #returns error: no method or default for coercing "character" to "raw" Then I thought that maybe the colClasses vector needed to actually *be* the mode needed (here's where an example under ?read.table would help): x <- read.table("data",header=...
2013 Sep 30
4
read.table() with quoted integers
Hi! It seems that read.table() in R 3.0.1 (Linux 64-bit) does not consider quoted integers as an acceptable value for columns for which colClasses="integer". But when colClasses is omitted, these columns are read as integer anyway. For example, let's consider a file named file.dat, containing: "1" "2" > read.table("file.dat", colClasses="integer") Error in scan(file, what, nmax, sep,...
2008 Feb 21
0
Feedback on a colClasses() generator function in progress?
I'm working on colClasses() function that generates "colClasses" vectors for read.table() using a compact format string (see below). The below is what I got right now. Before adding it to R.utils, I would like to check with you if I'm missing something obvious such as certain column classes, if there are use...
2004 Jul 28
1
read.table() and NULL for colClasses
Hi, is there are reason for not supporting NULL or "NULL" values for argument colClasses in read.table(), much like you can use NULL values for argument 'what' in scan()? This would help quite a bit when reading large data files where only a few columns are of interest. I've modfied read.table() to so it calls scan(what=...) also with NULLs for the fields to be skipped. H...
2008 Feb 26
3
using eval-parse-paste in a loop
...about a better approach would also be v. welcome. I haven't included the data because my failed attempt is data-independent (and probably more basic). Michael Anyadike-Danes ############# show that read.xls works > test <- read.xls("Book1.xls",sheet=1,from=4,colClasses="numeric") > str(test) 'data.frame': 23 obs. of 13 variables: $ Off.Flows..Thousands.: num 117.19 NaN NA 1.43 2.26 ... $ Off.Flows..Thousands.: num 8.42 NaN NA 0.08 0.11 0.01 0.11 1.59 0.16 0.04 ... $ Off.Flows..Thousands.: num 20 NaN NA 0.2 0.3 0.02 0....
2017 Oct 23
2
read.table(..., header == FALSE, colClasses = <vector with names attribute>)
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 guess the change was made in response to this? ?? https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16478 Regardless, I am wondering whether this is...
2009 Sep 26
1
questions on csv reading
Hi, Is there any official way to determine the colClasses of a data.frame? Why has POSIXct such a strange class structure? Why is colClasses "ordered" not allowed (and doesn't work)? Background ========== I am writing a chunked csv reader that provides the functionality of read.table for large files (in the next version of package ff). In c...
2005 Apr 18
2
colClasses = "Date" in read.delim, how to pass date-format?
...as "factor" and then convert it later to dates, using: sws.bezuege$FaktDat <- dates(as.character(sws.bezuege$FaktDat), format = c(dates = "d.m.y")) But the conversion requires a huge amount of memory (and time), therefore I would like to use colClasses = c("Date"). My question is: since I have format = c(dates = "d.m.y"), how can I pass this option to read.delim(..., colClasses = c("Date")) ? thanks for a hint cheers christoph
2007 Oct 09
1
Read in date fomat while colClasses="character"
...the columns I have dates ( say col=5). Now date column is read by default as numeric. So I used dateTimeAs= "isodatetime". This enables reading in the date format. However in the earlier column (say col=1) I have data which however starts from row 10. So to read data from column one I use colClasses="character". But this overrules the isodatetime. Now is there someway I can read in date format while keeping colClasses="character" Thanks for your help Ravi [[alternative HTML version deleted]]
2010 Jan 19
2
Memory usage in read.csv()
...mem.colnames <- c("time","total","used","free","shared","buffers","cached"); mem.colclass <- c("character",rep("integer",length(mem.colnames)-1)); vmsdf <- (read.csv(infile.vms,header=FALSE,colClasses=vms.colclass,col.names=vms.colnames)); memdf <- (read.csv(infile.mem,header=FALSE,colClasses=mem.colclass,col.names=mem.colnames)); I am running R v2.10.0 on a 64-bit machine with Fedora 10 (Linux version 2.6.27.41-170.2.117.fc10.x86_64 ) with 6Gb of memory. There are no other significant p...
2017 Oct 24
0
read.table(..., header == FALSE, colClasses = <vector with names attribute>)
...2:53:21 PM PDT, Benjamin Tyner <btyner at gmail.com> wrote: >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 >guess >the change was made in response to this? > > ?? https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16478 > >Regard...