I am trying to read an ftable using read.ftable, but I get the following error message:> jobSatTable <- read.ftable("definetti.uark.edu/~gpetris/stat5333/jobSatisfaction.dat",skip=2)Error in seek(file, where = 0) : no applicable method for "seek" In addition: Warning messages: 1: no non-missing arguments to max; returning -Inf 2: no non-missing arguments to max; returning -Inf I also tried to play with the argument col.vars, to remove blank lines in the file, to remove the blank in "Not satisfied". Unfortunately nothing worked. Can anybody give me a suggestion on how to read that table? Thanks in advance, Giovanni ps:> version_ platform sparc-sun-solaris2.8 arch sparc os solaris2.8 system sparc, solaris2.8 status major 2 minor 4.1 year 2006 month 12 day 18 svn rev 40228 language R version.string R version 2.4.1 (2006-12-18) -- Giovanni Petris <GPetris at uark.edu> Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) definetti.uark.edu/~gpetris
You cannot seek on a url() connection. Try downloading the file and reading it locally. There's a bug in the function which forgets to open its temporary file: I will attend to that. On Thu, 18 Jan 2007, Giovanni Petris wrote:> > I am trying to read an ftable using read.ftable, but I get the > following error message: > >> jobSatTable <- read.ftable("definetti.uark.edu/~gpetris/stat5333/jobSatisfaction.dat",skip=2) > Error in seek(file, where = 0) : no applicable method for "seek" > In addition: Warning messages: > 1: no non-missing arguments to max; returning -Inf > 2: no non-missing arguments to max; returning -Inf > > > I also tried to play with the argument col.vars, to remove blank > lines in the file, to remove the blank in "Not > satisfied". Unfortunately nothing worked. > > Can anybody give me a suggestion on how to read that table? > > Thanks in advance, > Giovanni > > ps: > >> version > _ > platform sparc-sun-solaris2.8 > arch sparc > os solaris2.8 > system sparc, solaris2.8 > status > major 2 > minor 4.1 > year 2006 > month 12 > day 18 > svn rev 40228 > language R > version.string R version 2.4.1 (2006-12-18) > >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, stats.ox.ac.uk/~ripley University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
You are writing out x rather than ft. If you do: write.ftable(ft, file = stdout()) it looks the same as the input. On 1/19/07, Giovanni Petris <GPetris at uark.edu> wrote:> > Thank you, Prof Ripley. > > However, there is still something unclear to me about read.ftable. I > noticed the following behavior, which I found strange. I expected > read.ftable to be an "inverse" of write.ftable, so to speak. Is there > something I am missing, or is this a problem in read.ftable? > > Thanks, > Giovanni > > > file <- tempfile() > > cat(" Intercourse\n", > + "Race Gender Yes No\n", > + "White Male 43 134\n", > + " Female 26 149\n", > + "Black Male 29 23\n", > + " Female 22 36\n", > + file = file) > > file.show(file) > Intercourse > Race Gender Yes No > White Male 43 134 > Female 26 149 > Black Male 29 23 > Female 22 36 > > > ft <- read.ftable(file) > > ft ## OK so far > Intercourse Yes No > Race Gender > White Male 43 134 > Female 26 149 > Black Male 29 23 > Female 22 36 > > x <- as.table(ft) > > write.ftable(ftable(x, col.vars=2:3), file) > > file.show(file) > "Gender" "Male" "Female" > "Intercourse" "Yes" "No" "Yes" "No" > "Race" > "White" 43 134 26 149 > "Black" 29 23 22 36 > > > ft2 <- read.ftable(file) > > ft2 > Gender Male Female > Intercourse Yes No Yes No Yes No Yes No > Race > White 43 134 26 149 29 23 22 36 > Black 43 134 26 149 29 23 22 36 > > version > _ > platform sparc-sun-solaris2.8 > arch sparc > os solaris2.8 > system sparc, solaris2.8 > status > major 2 > minor 4.1 > year 2006 > month 12 > day 18 > svn rev 40228 > language R > version.string R version 2.4.1 (2006-12-18) > > -- > > Giovanni Petris <GPetris at uark.edu> > Associate Professor > Department of Mathematical Sciences > University of Arkansas - Fayetteville, AR 72701 > Ph: (479) 575-6324, 575-8630 (fax) > definetti.uark.edu/~gpetris > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
> Date: Fri, 19 Jan 2007 11:08:22 -0500 > From: Gabor Grothendieck <ggrothendieck at gmail.com> > Cc: ripley at stats.ox.ac.uk, r-help at stat.math.ethz.ch > DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; > > You are writing out x rather than ft. If you do: > > write.ftable(ft, file = stdout()) > > it looks the same as the input. >You are wright. The point I was trying to make is that read.ftable does not work as (I) expected for an ftable with two column variables. Giovanni> > On 1/19/07, Giovanni Petris <GPetris at uark.edu> wrote: > > > > Thank you, Prof Ripley. > > > > However, there is still something unclear to me about read.ftable. I > > noticed the following behavior, which I found strange. I expected > > read.ftable to be an "inverse" of write.ftable, so to speak. Is there > > something I am missing, or is this a problem in read.ftable? > > > > Thanks, > > Giovanni > > > > > file <- tempfile() > > > cat(" Intercourse\n", > > + "Race Gender Yes No\n", > > + "White Male 43 134\n", > > + " Female 26 149\n", > > + "Black Male 29 23\n", > > + " Female 22 36\n", > > + file = file) > > > file.show(file) > > Intercourse > > Race Gender Yes No > > White Male 43 134 > > Female 26 149 > > Black Male 29 23 > > Female 22 36 > > > > > ft <- read.ftable(file) > > > ft ## OK so far > > Intercourse Yes No > > Race Gender > > White Male 43 134 > > Female 26 149 > > Black Male 29 23 > > Female 22 36 > > > x <- as.table(ft) > > > write.ftable(ftable(x, col.vars=2:3), file) > > > file.show(file) > > "Gender" "Male" "Female" > > "Intercourse" "Yes" "No" "Yes" "No" > > "Race" > > "White" 43 134 26 149 > > "Black" 29 23 22 36 > > > > > ft2 <- read.ftable(file) > > > ft2 > > Gender Male Female > > Intercourse Yes No Yes No Yes No Yes No > > Race > > White 43 134 26 149 29 23 22 36 > > Black 43 134 26 149 29 23 22 36 > > > version > > _ > > platform sparc-sun-solaris2.8 > > arch sparc > > os solaris2.8 > > system sparc, solaris2.8 > > status > > major 2 > > minor 4.1 > > year 2006 > > month 12 > > day 18 > > svn rev 40228 > > language R > > version.string R version 2.4.1 (2006-12-18) > > > > -- > > > > Giovanni Petris <GPetris at uark.edu> > > Associate Professor > > Department of Mathematical Sciences > > University of Arkansas - Fayetteville, AR 72701 > > Ph: (479) 575-6324, 575-8630 (fax) > > definetti.uark.edu/~gpetris > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > >
On 1/19/07, Giovanni Petris <GPetris at uark.edu> wrote:> > > Date: Fri, 19 Jan 2007 11:08:22 -0500 > > From: Gabor Grothendieck <ggrothendieck at gmail.com> > > Cc: ripley at stats.ox.ac.uk, r-help at stat.math.ethz.ch > > DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; > > > > You are writing out x rather than ft. If you do: > > > > write.ftable(ft, file = stdout()) > > > > it looks the same as the input. > > > > You are wright. The point I was trying to make is that read.ftable > does not work as (I) expected for an ftable with two column > variables. >x is not of class "ftable". It is of class "table". It may print with two column variables but it does not intrinsically have two column variables.