Re: [Rd] should `data` respect default.stringsAsFactors()?

2016-02-18 Thread Michael Nelson
As Peter pointed out.


data loads data from packages. Various formats are supported. The package 
author(s) will decide how best to ship (and load) any such data. 


When you call `data(iris)`, it loads iris as it is defined in the datasets 
package

The definition can be seen here:

https://github.com/wch/r-source/blob/trunk/src/library/datasets/data/iris.R

You will note that Species is explicitly a factor and it won't have been read 
in by read.table, but by being "source()d" because it is a .R file.


Michael 





From: R-devel [r-devel-boun...@r-project.org] on behalf of Cook, Malcolm 
[m...@stowers.org]
Sent: Friday, 19 February 2016 11:03 AM
To: 'peter dalgaard'
Cc: r-de...@stat.math.ethz.ch
Subject: Re: [Rd] should `data` respect default.stringsAsFactors()?

Hi Peter,

Sorry if I was not clear.  Perhaps an example will make my point:

> data(iris)
> class(iris$Species)
[1] "factor"
> write.table(iris,'data/myiris.tab')
> data(myiris)
> class(myiris$Species)
[1] "factor"
> rm(myiris)
> options(stringsAsFactors = FALSE)
> data(myiris)
> class(myiris$Species)
[1] "factor"
> myiris<-read.table("data/myiris.tab",header=TRUE)
> class(myiris$Species)
[1] "character"

I am surprised to find that in the above
  setting the global option stringsAsFactors = FALSE does NOT effect 
how Species is being read in by the `data` function
whereas
setting the global option stringsAsFactors = FALSE DOES effect how 
Species is being read in by read.table

especially since data is documented as calling read.table.

In my opinion, one or the other should change (the behavior of data, or the 
documentation).

 ,

~ Malcolm


 > -Original Message-
 > From: peter dalgaard [mailto:pda...@gmail.com]
 > Sent: Thursday, February 18, 2016 3:32 PM
 > To: Cook, Malcolm 
 > Cc: r-de...@stat.math.ethz.ch
 > Subject: Re: [Rd] should `data` respect default.stringsAsFactors()?
 >
 > What the  are you on about? data() does many things, only some of
 > which call read.table() et al., and the ones that do have no special 
 > treatment
 > of stringsAsFactors.
 >
 > -pd
 >
 > > On 18 Feb 2016, at 21:25 , Cook, Malcolm  wrote:
 > >
 > > Hiya,
 > >
 > > Probably been debated elsewhere
 > >
 > > I note that R's `data` function does not respect default.stringsAsFactors
 > >
 > > By my lights, it should, especially as it is documented to call read.table,
 > which DOES respect.
 > >
 > > Oh, but:  http://r.789695.n4.nabble.com/stringsAsFactors-FALSE-
 > tp921891p921893.html
 > >
 > > Compelling.  I have to agree.
 > >
 > > So, I change my mind.
 > >
 > > By my lights, `data` should then be documented to NOT respect
 > default.stringsAsFactors.
 > >
 > > Else?
 > >
 > > ~Malcolm Cook
 > >
 > > __
 > > R-devel@r-project.org mailing list
 > > https://stat.ethz.ch/mailman/listinfo/r-devel
 >
 > --
 > Peter Dalgaard, Professor,
 > Center for Statistics, Copenhagen Business School
 > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
 > Phone: (+45)38153501
 > Office: A 4.23
 > Email: pd@cbs.dk  Priv: pda...@gmail.com
 >
 >
 >
 >
 >
 >
 >
 >

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] httpd error with and help_type = 'html', package = NULL

2013-04-23 Thread Michael Nelson
Having loaded a package that masks an object from another package, calling


help(conflictedname, help_type = 'html')


instead of producing a page giving the choices of help page available

The page produced is

Error in httpd("/library/NULL/help/nobs", NULL, NULL, c(48, 6f, 73, 74,  : 
  replacement has length zero


This example is reproduced using

library(gdata)
help(nobs, help_type = 'html')



sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
LC_MONETARY=English_Australia.1252 LC_NUMERIC=C   
LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 

other attached packages:
[1] gdata_2.12.0.2

loaded via a namespace (and not attached):
[1] gtools_2.7.1 tools_3.0.0 


There are no issues when using help_type = 'pdf' or help_type = 'text'


Michael

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel