[Rd] stats::screeplot suggestion

2020-06-18 Thread Michael Friendly

 Hi

Here is a suggestion/request for stats::screeplot

* Please allow to change xlab and ylab.  The attached file does that, and maintains current 
behavior. Reason: strictly speaking, ylab should be "Variance" (singular). It would also 
be better to have an explicit label for the X axis: "Component"

In the would-be-nice-if category, I suggest addition of a type="cumulative" chart, a line 
graph of cumulative % of variance, labeled "% Variance" by default.

-Michael

- screeplot.default.R -

screeplot.default <- function (x, npcs = min(10, length(x$sdev)),
   type = c("barplot", "lines"),
   xlab = "",
   ylab = "Variances",
   main = deparse(substitute(x)), ...)
{
    main
    type <- match.arg(type)
    pcs <- x$sdev^2
    xp <- seq_len(npcs)
    dev.hold()
    on.exit(dev.flush())
    if (type == "barplot")
    barplot(pcs[xp], names.arg = names(pcs[xp]), main = main,
    ylab = ylab, ...)
    else {
    plot(xp, pcs[xp], type = "b", axes = FALSE, main = main,
    xlab = xlab, ylab = ylab, ...)
    axis(2)
    axis(1, at = xp, labels = names(pcs[xp]))
    }
    invisible()
}



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, ASA Statistical Graphics Section
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca  |  @datavisFriendly
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] re-submission of package after CRAN-pretest notes

2020-01-08 Thread Michael Friendly
It used to be the case that when I submitted a package and it gave notes 
or warnings in the CRAN checks, I was required to bump the package 
version before re-submission.


I hope this is no longer the case.  I recently submitted a package that 
gave one fairly trivial NOTE, fixed that, and would like to re-submit.


-Michael


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, ASA Statistical Graphics Section
York University  Voice: 416 736-2100 x66249
4700 Keele StreetWeb: http://www.datavis.ca | @datavisFriendly
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] passing extra arguments to devtools::build

2019-09-27 Thread Michael Friendly
This question was posed on SO : 
https://stackoverflow.com/questions/58118495/passing-extra-argumenets-to-devtoolsbuild
 
but there has been no useful reply.

Something seems to have changed in the |devtools|package, so that the 
following commands, that used to run now give an error I can't decipher:

|>Sys.setenv(R_GSCMD="C:/Program 
Files/gs/gs9.21/bin/gswin64c.exe")>devtools::build(args 
=c('--resave-data','--compact-vignettes="gs+qpdf"'))The 
filename,directory name,or volume label syntax is incorrect. Error 
in(function(command =NULL,args =character(),error_on_status 
=TRUE,:System command error|

I've tried other alternatives with other |devtools| commands, like just 
passing a single argument, but still get the same error

|args ='--compact-vignettes="gs+qpdf"'devtools::check_win_devel(args=args)|

I'm using devtools 2.2.0, under R 3.5.2

-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, ASA Statistical Graphics Section
York University  Voice: 416 736-2100 x66249
4700 Keele StreetWeb: http://www.datavis.ca | @datavisFriendly
Toronto, ONT  M3J 1P3 CANADA


[[alternative HTML version deleted]]

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


[Rd] packages: Examples with CPU or elapsed time > 10s

2017-10-04 Thread Michael Friendly
I am perplexed about NOTEs I get from Win Builder on my genridge 
package, https://github.com/friendly/genridge.

It shows, e.g.,

Examples with CPU or elapsed time > 10s
  user system elapsed
plot3d.ridge 12.4   0.05   12.45

However, if I run *exactly the same code* in my console with 
system.time(), I get

user system elapsed
0.95 0.16 1.17

What could be the explanation for this?

Second, the .log file from Win Builder shows only the *first example* 
with > 10s time.
I have been able to reduce the time by wrapping part of the example in 
\donttest{}.
I run Win Builder again, and the NOTE appears for another file. Very 
annoying.

It would be far more helpful to see these all together, rather than 
having to do this incrementally.
-Michael

-- Michael Friendly Email: friendly AT yorku DOT ca Professor, 
Psychology Dept. & Chair, Quantitative Methods York University Voice: 
416 736-2100 x66249 Fax: 416 736-5814 4700 Keele Street 
Web:http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA

[[alternative HTML version deleted]]

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


Re: [Rd] Installing/updating packages on a lab network

2015-07-29 Thread Michael Friendly

On 7/28/2015 1:32 PM, Uwe Ligges wrote:

Just add the line

R_LIBS_SITE=F:/R/library

to the file R_HOME/etc/x64/Renviron.site

Thanks, Uwe

I have no way to test this and our IT people who do the installation 
know nothing of R, so follow-up questions:


*  There is no R_HOME/etc/x64/Renviron.site file, but there is a 
R_HOME/etc/Rprofile.site I can modify and

ask them to install.  Would the equivalent in Rprofile.site be
Sys.setenv(R_LIBS_SITE=F:/R/library)

* Does this require that the R_LIBS_SITE folder exist and be writable by 
the user?


 Here is what I see in the current version:

  .libPaths(), the library trees where R looks for packages gives:
  [1] G:/uitapps/HEBB_R_LIB2/library
  [2] C:/Program Files/R/R/R-3.1.1/library

  If I try to install a new package, e.g.,
  install.packages(rockchalk)

  I get G:/uitapps/HEBB_R_LIB2/library is not writeable.  Use a 
personal library instead?, followed by a popup window,

  Create ~R/library? (y/n)

  This then installs the package, but to 
C:/Users/friendly/Desktop/~R/library.  In the current login session, 
.libPaths() will

  then have this path, so in a new R session, load(rockchalk) will work.

  However, once I logout, all that disappears, so I have to start over 
again to install or update a package.


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] update.packages(checkBuilt=TRUE, ask=FALSE): possible bug

2015-07-29 Thread Michael Friendly

On 7/19/2015 3:50 AM, peter dalgaard wrote:

For some, but not allI repositories I get the error message below:
Error in install.packages(update[instlib == l, Package], l, contriburl =
contriburl,  :
  specifying 'contriburl' or 'available' requires a single type, not type =
both

Is it a bug?


I think that what Jose is referring to is this error message from 
install.packages(), even though he set

options(pkgType='binary')
Isn't that a bug?

Moreover, in a fresh R 3.2.1 session [Platform: x86_64-w64-mingw32/x64 
(64-bit)], I see

 getOption(pkgType)
[1] both

I think this is somehow related to the fact that install.packages() will 
now tell you if a more current source package exists and ask if you want 
to install from source.  But this would require RTools to

be installed to work.

IMHO, I consider this a major infelicity or design flaw, that will cause 
problems for naive and even experienced users.  install.packages(foo) 
should always work unless package foo cannot

cannot be found in getOption(repos)

-Michael

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


[Rd] Installing/updating packages on a lab network

2015-07-28 Thread Michael Friendly
I'm the faculty member in my department who advises our IT staff on the 
details of installing R for
students and faculty on our Windows 7 lab network.  We are about to 
upgrade from R 3.1.1 to
R 3.2.1, and once that is done, this version of R and all installed 
packages will be frozen in the
image that appears in C:/Program Files/R/R-3.2.1/ on every lab computer, 
and this image is

refreshed on each computer at each new login.

Every user has a persistent home directory across all university lab 
computers, typically their
F:/ drive (students) and/or X:/ drive (faculty).  I need to give 
instructions to our IT staff for how to

arrange for a personal library, say
F:/~R/library
to be be set automatically, and included in .libPaths() so that 
install.packages() and update.packages()

will work using that path.

At present, there is no file R_HOME/etc/Renviron.site and 
R_HOME/etc/Rprofile.site is the vanilla

version with everything commented out, including
# set a site library
# .Library.site - file.path(chartr(\\, /, R.home()), site-library)

Environmental variables set for users include
HOMEDRIVE=F:
HOMEPATH=\
HOMESHARE=\\vfadmin.yorku.yorku.ca\HH\HOME\friendly
with the latter mapped to the X: drive

What is the code to be added to Rprofile.site to make this work?

thanks,
-Michael



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] 'library' or 'require' call not declared from: 'rgl'

2014-10-30 Thread Michael Friendly
I'm checking a new release of vcdExtra via win builder with R-devel 
2014-10-29 r66897

and have run into a Warning I don't know how to fix.

I have one S3 generic, mosaic3d() that uses rgl and don't want to have 
rgl always loaded

via Depends:.  Instead, the mosaic3d.default() method includes

  if (!require(rgl)) stop(rgl is required)

This always worked in the past, but in this testing cycle, I got a slew 
of no visible global function definition for ...

all rgl functions.

I revised DESCRIPTION to include:

Imports:  rgl

and NAMESPACE:

import(rgl)

All the no visible global function definition ... went away, but I'm 
stuck with


* checking dependencies in R code ... WARNING
'library' or 'require' call not declared from: 'rgl'
See the information on DESCRIPTION files in the chapter 'Creating R
packages' of the 'Writing R Extensions' manual.

How can I solve this?

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] 'library' or 'require' call not declared from: 'rgl'

2014-10-30 Thread Michael Friendly

On 10/30/2014 4:19 PM, Simon Urbanek wrote:

Did you intend rgl to be optional? If so, then you should use Suggests: 
instead. When you use Imports: it will load rgl automatically so require() 
does't make sense (since it will be always TRUE).

I always had it as Suggests: rgl before.  But R-devel now gave be all 
those no visible global function definition for ...

messages.

Achim suggested using explicitly rgl:: everywhere.  That's quite ugly, 
but seems to work.


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] no visible binding for global variable for data sets in a package

2014-08-27 Thread Michael Friendly

On 8/27/2014 5:24 AM, Martin Maechler wrote:

Michael Friendly frien...@yorku.ca
 on Tue, 26 Aug 2014 17:58:34 -0400 writes:

  I'm updating the Lahman package of baseball statistics to the 2013
  release. In addition to
  the main data sets, the package also contains several convenience
  functions that make use
  of these data sets.  These now trigger the notes below from R CMD check
  run with
  Win builder, R-devel.  How can I avoid these?

  * using R Under development (unstable) (2014-08-25 r66471)
  * using platform: x86_64-w64-mingw32 (64-bit)
  ...
  * checking R code for possible problems ... NOTE
  Label: no visible binding for global variable 'battingLabels'
  Label: no visible binding for global variable 'pitchingLabels'
  Label: no visible binding for global variable 'fieldingLabels'
  battingStats: no visible binding for global variable 'Batting'
  battingStats: no visible global function definition for 'mutate'
  playerInfo: no visible binding for global variable 'Master'
  teamInfo: no visible binding for global variable 'Teams'

  One such function:

  ## function for accessing variable labels

  Label - function(var, labels=rbind(battingLabels, pitchingLabels,
  fieldingLabels)) {
  wanted - which(labels[,1]==var)
  if (length(wanted)) labels[wanted[1],2] else var
  }

and you are using the data sets you mentioned before,
(and the checking has been changed recently here).

This is a bit subtle:
Your data sets are part of your package (thanks to the default
lazyData), but *not* part of the namespace of your package.
Now, the reasoning goes as following: if someone uses a function
from your package, say Label() above,
by
Lahman::Label(..)
and your package has not been attached to the search path,
your user will get an error, as the datasets are not found by
Label().

If you consider something like   Lahman::Label(..)
for a bit and the emphasis we put on R functions being the
primary entities, you can understand the current, i.e. new,
R CMD check warnings.

Thanks for this explicit explanation.  Now I understand why this occurs.


I see the following two options for you:

1) export all these data sets from your NAMESPACE
For this (I thinK), you must define them in  Lahman/R/ possibly via a
Lahman/R/sysdata.rda
Not sure I quite understand how this would work.  My NAMESPACE currently 
exports

the few functions in this package:

# all the rest is data
export(battingStats,
playerInfo,teamInfo,
Label
)

Do you mean to simply add all the data sets ('globals')  that are 
referred to in these functions?


# all the rest is data
export(battingStats,
playerInfo,teamInfo,
Label,
battingLabels, pitchingLabels, fieldingLabels,
Batting, Master, Teams
)

That seems a bit odd.  Can you actually export data?  Maybe there is a 
need for a

separate NAMESPACE declaration, that might be called either of

exportdata()
globaldata()



2) rewrite your functions such that ensure the data sets are
loaded when they are used.


2) actually works by adding
stopifnot(require(Lahman, quietly=TRUE))
   as first line in Label() and other such functions.

It works in the sense that  Lahman::Label(yearID)  will
work even when Lahman is not in the search path,
but   R-devel CMD check   will still give the same NOTE,
though you can argue that that note is actally a false positive.

So, this would be version 1 of 2):

Label - function(var, labels) {
stopifnot(require(Lahman, quietly=TRUE))
if(missing(labels)) labels - rbind(battingLabels, pitchingLabels, 
fieldingLabels)

wanted - which(labels[,1]==var)
if (length(wanted)) labels[wanted[1],2] else var
}

And this would be version 2, using data():

Label - function(var, labels) {
stopifnot(require(Lahman, quietly=TRUE))
if(missing(labels)) {
data(battingLabels); data(pitchingLabels); data(fieldingLabels)
labels - rbind(battingLabels, pitchingLabels, fieldingLabels)
}
wanted - which(labels[,1]==var)
if (length(wanted)) labels[wanted[1],2] else var
}



Not sure about another elegant way to make 2) work, apart from

using  data() on each of the datasets inside the
function.  As I haven't tried it, that may *still* give a
(false) NOTE..

This is a somewhat interesting problem, and I wonder if everyone
else has solved it with '1)' rather than a version of '2)'.

Martin




--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] no visible binding for global variable for data sets in a package

2014-08-27 Thread Michael Friendly

On 8/27/2014 9:29 AM, Michael Friendly wrote:

It works in the sense that  Lahman::Label(yearID)  will
work even when Lahman is not in the search path,
but   R-devel CMD check   will still give the same NOTE,
though you can argue that that note is actally a false positive.

So, this would be version 1 of 2):

Label - function(var, labels) {
 stopifnot(require(Lahman, quietly=TRUE))
 if(missing(labels)) labels - rbind(battingLabels, pitchingLabels,
fieldingLabels)
 wanted - which(labels[,1]==var)
 if (length(wanted)) labels[wanted[1],2] else var
}

And this would be version 2, using data():

Label - function(var, labels) {
 stopifnot(require(Lahman, quietly=TRUE))
 if(missing(labels)) {
 data(battingLabels); data(pitchingLabels); data(fieldingLabels)
 labels - rbind(battingLabels, pitchingLabels, fieldingLabels)
 }
 wanted - which(labels[,1]==var)
 if (length(wanted)) labels[wanted[1],2] else var
}




Just to follow up:  R-devel likes this less than it does my initial 
version.  I still get no visible binding NOTES, and complaint about

using data() in a function:

* checking R code for possible problems ... NOTE
Label: no visible binding for global variable 'battingLabels'
Label: no visible binding for global variable 'pitchingLabels'
Label: no visible binding for global variable 'fieldingLabels'
battingStats: no visible binding for global variable 'Batting'
battingStats: no visible global function definition for 'mutate'
playerInfo: no visible binding for global variable 'Master'
teamInfo: no visible binding for global variable 'Teams'

Found the following calls to data() loading into the global environment:
File 'Lahman/R/Label.R':
  data(battingLabels)
  data(pitchingLabels)
  data(fieldingLabels)
See section 'Good practice' in '?data'.

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


Re: [Rd] no visible binding for global variable for data sets in a package

2014-08-27 Thread Michael Friendly

On 8/27/2014 10:41 AM, peter dalgaard wrote:

Using data() in a package with lazyloaded data seems like asking for trouble to 
me. But you're making me curious (and I'm too lazy[*] to set up for rebuilding 
the package myself):

Did you actually try putting battingLabels  friends in the namespace? What 
happened?

Well, I tried this, with NAMESPACE as

# all the rest is data, except we try to export the data sets used 
globally in these functions

export(battingStats,
playerInfo,teamInfo,
Label,
battingLabels, pitchingLabels, fieldingLabels,
Batting, Master, Teams
)

R CMD check was even more unhappy, failing immediately, so the attempted 
cure was worse than the original disease.


* checking whether package 'Lahman' can be installed ...Warning: running 
command 'C:/R/R-3.0.3/bin/x64/Rcmd.exe INSTALL -l 
C:/eclipse/Lahman2013.Rcheck --no-html 
C:\DOCUME~2\WORKSP~1\LAHMAN~1' had status 1

 ERROR
Installation failed.
See 'C:/eclipse/Lahman2013.Rcheck/00install.out' for details.

00install.out said:

Error in namespaceExport(ns, exports) :
  undefined exports: battingLabels, pitchingLabels, fieldingLabels, 
Batting, Master, Teams

Error: loading failed
Execution halted

My conclusions so far are:

- These are just NOTEs, so I will ignore them for now.  But they will 
probably trigger the CRAN
maintainers to notice them when I resubmit and I will have to plead 
guilty with an explanation.  This makes more useless work for all involved.


- Peter Dalgaard noted the change in R-devel, and nobody so far has 
suggested a working remedy, so a clean solution
seems warranted.  It mentions 'now by default' -- is there a switch for 
this?


The change would seem to be this

  \item \command{R CMD check} now by default checks code usage
  directly on the package namespace without loading and attaching
  the package and its suggests and enhances.

and perhaps the remedies could be stated more clearly?

Alternatively, it isn't common, but it is by no means rare for package 
functions to need to use data sets
in the package, so some mechanism to declare these, perhaps in NAMESPACE 
is needed.


A workaround could be to use rbind(Lahman::battingLabels,) which runs a bit 
against the grain for me.

I think the right answer _is_ to export the lazy data; the question is how to do it. 
There's nothing particularly strange about exporting non-functions (letters 
would be an example, save for the special status of package:base). If you attach the 
package, the lazyloaded data appear in the same environment as the exported function so 
they are de facto already in the namespace for the purposes of library() and `::`. So I 
agree, something like exportData() would be useful. (Or some other mechanism. You might 
want to be able to export data selectively.)

- pd


[*] Burdened with pressing obligations, if you like.


On 27 Aug 2014, at 16:07 , Michael Friendly frien...@yorku.ca wrote:


On 8/27/2014 9:29 AM, Michael Friendly wrote:

It works in the sense that  Lahman::Label(yearID)  will
work even when Lahman is not in the search path,
but   R-devel CMD check   will still give the same NOTE,
though you can argue that that note is actally a false positive.

So, this would be version 1 of 2):

Label - function(var, labels) {
 stopifnot(require(Lahman, quietly=TRUE))
 if(missing(labels)) labels - rbind(battingLabels, pitchingLabels,
fieldingLabels)
 wanted - which(labels[,1]==var)
 if (length(wanted)) labels[wanted[1],2] else var
}

And this would be version 2, using data():

Label - function(var, labels) {
 stopifnot(require(Lahman, quietly=TRUE))
 if(missing(labels)) {
 data(battingLabels); data(pitchingLabels); data(fieldingLabels)
 labels - rbind(battingLabels, pitchingLabels, fieldingLabels)
 }
 wanted - which(labels[,1]==var)
 if (length(wanted)) labels[wanted[1],2] else var
}



Just to follow up:  R-devel likes this less than it does my initial version.  I 
still get no visible binding NOTES, and complaint about
using data() in a function:

* checking R code for possible problems ... NOTE
Label: no visible binding for global variable 'battingLabels'
Label: no visible binding for global variable 'pitchingLabels'
Label: no visible binding for global variable 'fieldingLabels'
battingStats: no visible binding for global variable 'Batting'
battingStats: no visible global function definition for 'mutate'
playerInfo: no visible binding for global variable 'Master'
teamInfo: no visible binding for global variable 'Teams'

Found the following calls to data() loading into the global environment:
File 'Lahman/R/Label.R':
  data(battingLabels)
  data(pitchingLabels)
  data(fieldingLabels)
See section 'Good practice' in '?data'.

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



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept

[Rd] no visible binding for global variable for data sets in a package

2014-08-26 Thread Michael Friendly
I'm updating the Lahman package of baseball statistics to the 2013 
release. In addition to
the main data sets, the package also contains several convenience 
functions that make use
of these data sets.  These now trigger the notes below from R CMD check 
run with

Win builder, R-devel.  How can I avoid these?

* using R Under development (unstable) (2014-08-25 r66471)
* using platform: x86_64-w64-mingw32 (64-bit)
  ...
* checking R code for possible problems ... NOTE
Label: no visible binding for global variable 'battingLabels'
Label: no visible binding for global variable 'pitchingLabels'
Label: no visible binding for global variable 'fieldingLabels'
battingStats: no visible binding for global variable 'Batting'
battingStats: no visible global function definition for 'mutate'
playerInfo: no visible binding for global variable 'Master'
teamInfo: no visible binding for global variable 'Teams'

One such function:

## function for accessing variable labels

Label - function(var, labels=rbind(battingLabels, pitchingLabels, 
fieldingLabels)) {

wanted - which(labels[,1]==var)
if (length(wanted)) labels[wanted[1],2] else var
}


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] listof

2014-08-03 Thread Michael Friendly

An interesting topic, but I'll only respond with my own experience,
and that is, while 'listof' could be usefully extended there was not
enough meat on the bones to want to do so. I think this is a limitation
of the S3 class/method structure, as I see it.

In several packages (effects, heplots, candisc, vcdExtra) I/we
deal with lists of objects of a given class, and want to define
methods for plot(), summary(), print(), etc.  In these cases, the
simplest solution was to designate a new class, e.g., 'efflist'
for a list of effects in a univariate lm/glm/polr/ ... model
or 'candiscList' for a list of candisc objects.  Methods for the
*list class could then use an apply() construct over the list
items.

Most recently,
in the effects package, we implemented some effects plot methods
for multivariate linear models. This is essentially a two-way collection
of effects for terms x responses, but how to represent this in the
class structure to re-use the existing code for a single effect
of a given response variable?

The solution used here was to define a new class, 'mlm.efflist', with 
new methods for this class.  This works within the current S3 class

scheme, but doesn't provide an extendible semantics.

-Michael


On 7/29/2014 11:20 PM, Adrian Baddeley wrote:

Dear R developers

A question about the class 'listof',  defined in package 'stats'.

Other than its definition and use in the code for 'anova',
we can't see that the class 'listof' is used for anything else
(in recommended packages, or elsewhere).

In the spatstat package we have been using a 'listof'
to represent a list of spatial objects of the same class
(such as point patterns, or pixel images)
and we've defined a plot method.

Is it OK for us to hijack an existing class in this way,
or is this a violation of some future plans/ design feature of R ?

We're about to publish a book on spatstat
so I would much appreciate advice if we need to change it.

regards
Adrian

Prof Adrian Baddeley FAA
University of Western Australia



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


[Rd] historical significance of Pr(Chisq) 2.2e-16

2014-05-07 Thread Michael Friendly
Where does the value 2.2e-16 come from in p-values for chisq tests such 
as those

reported below?

 Anova(cm.mod2)
Analysis of Deviance Table (Type II tests)

Response: Freq
LR Chisq Df Pr(Chisq)
B 11026.2 1  2.2e-16 ***
W 7037.5 1  2.2e-16 ***
Age 886.6 8  2.2e-16 ***
B:W 3025.2 1  2.2e-16 ***
B:Age 1130.4 8  2.2e-16 ***
W:Age 332.9 8  2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] Historical NA question

2014-05-04 Thread Michael Friendly

On 03/05/2014 12:39 PM, Hadley Wickham wrote:

Can anyone tell me what the significance of 1954 is in R's NA?



Just ask R:

 2*(1-pnorm(1954))
[1] 0
 2*(1-pnorm(1954)) %in% NA
[1] 0


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


[Rd] version numbers for CRAN submissions that give warnings/notes

2014-03-06 Thread Michael Friendly
It often happens that I submit a new revision of a package, say 
mypkg-1.0-10, from R-Forge
to CRAN after running R CMD check locally and looking at the log files 
on R-Forge.
But R-Forge has the devel checks disabled, and I get an email from CRAN 
pointing out

some new warning or note I'm asked to correct.

OK, I correct this and commit a new rev to R-Forge.  But, is it still 
required to bump the
version number to mypkg-1.0-11 before resubmitting to CRAN, even though 
mypkg-1.0-10

did not make it there?

To do so means also modifying the DESCRIPTION, NEWS and
mypkg-package.Rd files even for a minor warning or note.

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] forking a CRAN project

2014-03-04 Thread Michael Friendly
There is a CRAN package licensed just as GPL, say, XX, I want to use 
in a book.
But I've needed to modify the package to make it do what I need for 
expository purposes.
The package author(s) are amenable to my modifications, but probably 
unlikely to

incorporate them into the CRAN version any time soon.

Am I allowed, under GPL, to create a new version of the package, say 
XX2, in a
public repository such as R-Forge or github?  I would, of course, 
maintain their
authorship, though perhaps take over the maintainer role.  For my 
purposes in
the book, I don't necessarily need to release my version to CRAN; just a 
public repo

a reader could download from.

-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] proposal: stats::as.matrix.ftable method

2014-01-10 Thread Michael Friendly
Following some discussion on R-help, I'd like to propose that an 
as.matrix method be added
to those available for ftable objects.  The reason for this is that 
there are a variety of situations
where one needs to flatten a 3+ way table, but then use that for 
analysis as a matrix, not just for
pretty-printing.  There is an as.table method to turn the result back to 
a table, but an as.matrix

method is missing.

 methods(class=ftable)
[1] as.data.frame.ftable* as.table.ftable* format.ftable*
[4] head.ftable*  print.ftable tail.ftable*

   Non-visible functions are asterisked


The function below was proposed by William Dunlop:

# as.matrix method for flattened tables

# modified from Willaim Dunlop, wdun...@tibco.com, R-Help, 01-09-2014
as.matrix.ftable - function(x, sep=_, ...) {
makeDimNames - function(vars) {
structure(
list(do.call(paste, c(rev(expand.grid(rev(vars))), 
list(sep=sep,

names = paste(collapse=sep, names(vars))
)
}
structure(
unclass(x),
dimnames=c(makeDimNames(attr(x, row.vars)),
   makeDimNames(attr(x, col.vars))),
row.vars=NULL,
col.vars=NULL)
}

Some test cases:

 UCB - UCBAdmissions
 as.matrix(ftable(Dept ~ Admit + Gender, data=UCB))
 Dept
Admit_GenderA   B   C   D   E   F
  Admitted_Male   512 353 120 138  53  22
  Admitted_Female  89  17 202 131  94  24
  Rejected_Male   313 207 205 279 138 351
  Rejected_Female  19   8 391 244 299 317
 as.matrix(ftable(Dept ~ ., data=UCB))
 Dept
Admit_GenderA   B   C   D   E   F
  Admitted_Male   512 353 120 138  53  22
  Admitted_Female  89  17 202 131  94  24
  Rejected_Male   313 207 205 279 138 351
  Rejected_Female  19   8 391 244 299 317
 as.matrix(ftable(Admit + Gender ~ Dept, data=UCB))
Admit_Gender
Dept Admitted_Male Admitted_Female Rejected_Male Rejected_Female
   A   512  89   313  19
   B   353  17   207   8
   C   120 202   205 391
   D   138 131   279 244
   E53  94   138 299
   F22  24   351 317
 as.matrix(ftable(Admit ~ ., data=UCB))
   Admit
Gender_Dept Admitted Rejected
   Male_A512  313
   Male_B353  207
   Male_C120  205
   Male_D138  279
   Male_E 53  138
   Male_F 22  351
   Female_A   89   19
   Female_B   178
   Female_C  202  391
   Female_D  131  244
   Female_E   94  299
   Female_F   24  317


Related functions: The vcd package defines a more extensive suite of 
similar structable functions,
including as.matrix.structable;  however that function doesn't supply 
appropriate dimnames for

the dimensions.  Given as.matrix.ftable(), that is easy to correct:

# use as.matrix.ftable, but
# need to remove other attributes: dnames, split_vertical
library(vcd)
as.matrix.structable - function(x, sep=_, ...) {
structure(
as.matrix.ftable(x, sep, ...),
dnames = NULL,
split_vertical = NULL
)
}

Test:

 as.matrix(structable(Gender ~ Admit + Dept, data=UCB))
Gender
Admit_Dept   Male Female
  Admitted_A  512 89
  Admitted_B  353 17
  Admitted_C  120202
  Admitted_D  138131
  Admitted_E   53 94
  Admitted_F   22 24
  Rejected_A  313 19
  Rejected_B  207  8
  Rejected_C  205391
  Rejected_D  279244
  Rejected_E  138299
  Rejected_F  351317
 as.matrix(structable(Gender + Admit ~ Dept, data=UCB))
Gender_Admit
Dept Male_Admitted Male_Rejected Female_Admitted Female_Rejected
   A   512   313  89  19
   B   353   207  17   8
   C   120   205 202 391
   D   138   279 131 244
   E53   138  94 299
   F22   351  24 317


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] bug/infelicity in citation(base)

2013-10-04 Thread Michael Friendly
utils::citation() offers the option auto=(NULL|TRUE) to obtain the 
citations for a package from the package
DESCRIPTION file or a CITATION file, as described below:

|auto|

a logical indicating whether the default citation auto-generated from 
the package 'DESCRIPTION' metadata should be used or not, or |NULL| 
(default), indicating that a 'CITATION' file is used if it exists, or an 
object of class |packageDescription 
http://127.0.0.1:11936/library/utils/help/packageDescription| with 
package metadata (see below).

This presents a problem when citation() is used in functions such as 
bibtex::write.bib() and
knitr::write_bib(), because the base package is treated specially in 
citation() and does not
allow auto=TRUE

  citation(base,auto=TRUE)
Error in citation(base, auto = TRUE) :
   broken installation, no CITATION file in the base package.
 

This is a strange and misleading message, since the base package, 
presumably by design
has no CITATION file.  It requires a workaround in functions like 
knitr::write_bib when given
a list of packages,

 bib = sapply(x, function(pkg) {
 cite = citation(pkg, auto = if (pkg == base)
 NULL
 else TRUE)
 entry = toBibtex(cite)
 entry[1] = sub(\\{,$, sprintf({R-%s,, pkg), entry[1])
 gsub(, , entry)
 }, simplify = FALSE)


Is there some reason why citation() can't simply ignore auto=TRUE 
(perhaps with a message)
for the base package?


-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA


[[alternative HTML version deleted]]

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


Re: [Rd] declaring package dependencies

2013-09-15 Thread Michael Friendly

On 9/13/2013 12:15 PM, John Fox wrote:

If I understand this thread, Michael's package doesn't use loglm() -- it
provides methods for objects produced by loglm() and hence Enhances the
package.
Well, here's the rub: vcdExtra uses MASS::loglm() in examples, and also 
in R code,
where it provides new S3 methods for loglm objects.  And, this whole 
problem only arose

after vcd (on which I Depend), modified its Imports to:

Imports: utils, MASS, grDevices, colorspace
where, previously, MASS had been a Depends (or Suggests?) there.


For my examples, the old Suggests: MASS worked, but now I've used 
require(MASS) in
each of those examples.  However, the use in R code also triggered an 
error on loglm, even

when I added
Enhances: MASS
to DESCRIPTION.

OK, so I switched to using
Imports: MASS
but even that doesn't cure the problem alone.  I then got:

* checking dependencies in R code ... NOTE
Namespace in Imports field not imported from: 'MASS'
  All declared Imports should be used.
See the information on DESCRIPTION files in the chapter 'Creating R
packages' of the 'Writing R Extensions' manual.

but then an Error when an example using the function which called loglm()
directly was run.


### ** Examples

data(Titanic, package=datasets)
# variables are in the order Class, Sex, Age, Survived
tt - seq_loglm(Titanic)

1   model.string:  = Class
Error in eval(expr, envir, enclos) : could not find function loglm
Calls: seq_loglm - eval - eval
Execution halted


So, as several people have suggested, I changed to use MASS::loglm() in 
code,
though it still perplexes me why this is necessary.  At any rate, this 
now passes R devel.

Whew!


Thanks to a suggestion from Mattew Dowle, I'm now using winbuilder (thx, 
Uwe for this!)
and can get rather quick ( 30 min.) feedback on an R-devel build, 
whereas the

R-Forge build cycle often takes a day.

So, my workflow is  now
- R CMD check on local version in StatET
- If OK, send to winbuilder, http://win-builder.r-project.org/upload.aspx
- If OK, commit to R-Forge, and perhaps submit to CRAN if this is the 
final rev

in a development cycle.

But I still feel like I'm spending too much time on satisfying the 
unknown, new

requirements of CRAN checks.  As Dirk said (also deserving to be a fortune),


Absent a time machine or psychic powers, I do not see how package developers
can reasonably be expected to cope with this.
The effort by R Core members that goes into R and CRAN is certainly 
herculean and I
appreciate it very much.  Like Dirk, I'm just looking for a little more 
predictability as

CRAN evolves.


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] declaring package dependencies

2013-09-12 Thread Michael Friendly

I received the following email note re: the vcdExtra package

A vcd update has shown that packages TIMP and vcdExtra are not 
declaring their dependence on colorspace/MASS: see


http://cran.r-project.org/web/checks/check_results_vcdExtra.html
But, I can't see what to do to avoid this, nor understand what has 
changed in R devel.


Sure enough, CRAN now reports errors in examples using MASS::loglm(), 
using R Under development (unstable) (2013-09-11 r63906)


 Caesar.mod0 - loglm(~Infection + (Risk*Antibiotics*Planned), 
data=Caesar)

Error: could not find function loglm

In DESCRIPTION I have
Depends: R (= 2.10), vcd, gnm (= 1.0.3)
Suggests: 
ca,gmodels,Fahrmeir,effects,VGAM,plyr,rgl,lmtest,MASS,nnet,ggplot2,Sleuth2,car


and the vcd DESCRIPTION has

Depends: R (= 2.4.0), grid, stats
Suggests: KernSmooth, mvtnorm, kernlab, HSAUR, coin
Imports: utils, MASS, grDevices, colorspace

so, in an R 3.0.0 console, library(vcdExtra) loads vcd and its dependencies:

 library(vcdExtra)
Loading required package: vcd
Loading required package: MASS
Loading required package: grid
Loading required package: colorspace
Loading required package: gnm
Warning messages:
1: package ‘vcd’ was built under R version 3.0.1
2: package ‘MASS’ was built under R version 3.0.1


Note: these CRAN errors do not occur on R-Forge, using R version 3.0.1 
Patched (2013-08-21 r63645)

and the latest devel version (0.5-11) of vcdExtra.

-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] packages with Sweave and knitr vignettes?

2013-08-23 Thread Michael Friendly
Now that R 3.0.0+ supports non-Sweave vignettes, R-exts \S 1.4.2 seems 
to imply that
it is possible to include both Sweave and knitr vignettes in a single 
package.


I'm wondering
if anyone has tried this and/or if there are some hidden gotchas putting 
this into practice,

and concerned about creating problems with CRAN checks if I try this.

Consider two vignettes:

pkg/vignettes/vign1.Rnw, containing:
% !Rnw weave = Sweave
%\VignetteEngine{Sweave}
...

pkg/vignettes/vign2.Rnw, containing:
% !Rnw weave = knitr
%\VignetteEngine{knitr::knitr}
...

both are .Rnw files, distinguished only by \VignetteEngine. vign1.Rnw is 
currently in my
package, and vign2.Rnw compiles OK outside it, using knitr in an R 
console or RStudio.


R-exts implies that the DESCRIPTION file must include (minimally):

VignetteBuilder: Sweave, knitr
Suggests: knitr

Is anything more/different required?  Does a package exist that does this?

TIA
-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] Confusion about Depends:, Imports:, Enhances:, import(), inportFrom()

2013-08-22 Thread Michael Friendly
In checking my vcdExtra package, the following NOTE newly appeared 
(R-Forge, using R version 3.0.1 Patched (2013-08-20 r63635))


Package in Depends field not imported from: ‘gnm’
  These packages needs to imported from for the case when
  this namespace is loaded but not attached.

In the DESCRIPTION file, I have

Depends: R (= 2.10), vcd, gnm (= 1.0.3)

In NAMESPACE:

# we are a vcd extension
import(vcd)

I've read 1.1.1 of R-Exts, but it is not clear to me whether I should 
also import gnm or change

the DESCRIPTION file to use

Imports: vcd, gnm (= 1.0.3)

R-Exts says: The ‘Imports’ field lists packages whose namespaces are 
imported from (as specified in the
NAMESPACE file) but which do not need to be attached, but how can I tell 
if gnm needs to be attached?


Also, what is the difference between Imports: in DESCRIPTION and 
imports() in NAMESPACE?


-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] legitimate use of :::

2013-08-22 Thread Michael Friendly

On 8/22/2013 7:45 AM, Uwe Ligges wrote:



On 22.08.2013 07:45, Yihui Xie wrote:

Hi,

So now R CMD check starts to warn against :::, but I believe sometimes
it is legitimate to use it when developing R packages. For example, I
have some utils functions that are not exported but I want to share
them across the packages that I maintain. I do not need to coordinate
with other authors about these internal functions since I'm the only
author and I know clearly what I'm doing, and I want to avoid copying
and pasting the code across packages just to avoid the NOTE in R CMD
check. What should I do in this case?


Nothing. The way you describe above seems to be a reasonable usage, iff
you are the same maintainer who knows what is going on. Other
maintainers should not use one of your not exported (hence non API)
functions, of course.

Uwe Ligges




Related to this is the use of other-package unexported utility functions 
that don't pass Uwe's iff test, but I, as maintainer,

want to use in my package.

Cases in point:  in heplots, I had used stats:::Pillai, stats:::Wilks,
stats:::Roy and stats:::LH for calculation in one of my functions.
Similarly, I had a need to use car:::df.terms, also unexported, but
don't want to ask John Fox to export it just for my use.  Uwe's
reply suggests that I should not be using car:::df.terms, however.

To avoid the NOTEs (which often triggers a 'pls fix' upon submission to
CRAN), I simply copied/pasted these functions to my package, but this 
seems wasteful.


-Michael


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] probable bugs in stats::loglin calculation of pearson chisq

2013-07-09 Thread Michael Friendly

In running the following example of a loglinear model for the Titanic data,
I was surprised to see NaN reported for the
Pearson chisq

 loglin(Titanic, margin=list(1:3, 4))
2 iterations: deviation 2.273737e-13
$lrt
[1] 671.9622

$pearson
[1] NaN

$df
[1] 15

$margin
$margin[[1]]
[1] Class Sex   Age

$margin[[2]]
[1] Survived


Tracing it back, this occurs because there are zeros in the 
fitted/expected frequencies

for children among the Crew.

 # get fitted (expected) values
 fitted - loglin(Titanic, margin=list(1:3, 4), fit=TRUE)$fit
2 iterations: deviation 2.273737e-13
 fitted[Class=Crew,,Age=Child,]
Survived
Sex  No Yes
  Male0   0
  Female  0   0

I certainly understand the difference between sampling
zeros and structural zeros, and this distinction seems properly 
implemented in loglin()
via the start= argument, but only in the calculation of Pearson chisq, 
not for LRT.  I think this is a code
bug, but if there is a reason for the difference, it should be 
documented in the help for

loglin.

Another probable bug is that the calculation of of the LRT chisq also 
takes zero fitted values
into account, while the calculation of the Pearson chisq does not, and 
leads to the NaN

result for my example.
It occurs in the following portion of the code for loglin:

fit - z$fit
attributes(fit) - attributes(table)
observed - as.vector(table[start  0])
expected - as.vector(fit[start  0])
pearson - sum((observed - expected)^2/expected)
observed - as.vector(table[table * fit  0])
expected - as.vector(fit[table * fit  0])
lrt - 2 * sum(observed * log(observed/expected))

I don't understand the reasons for the different calculations of 
observed  expected

for pearson  lrt.

FWIW, below is how I calculate these in my mosaics.sas program

start chisq(obs, fit);
   *-- Find Pearson and likelihood ratio chisquares;
   gf = sum ( (obs - fit)##2 / ( fit + (fit=0) ) );
   lr = 2 # sum ( obs # log ( (obs+(obs=0)) / (fit + (fit=0)) ) );
   return (gf // lr);
   finish;

-Michael




--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] vignettes: problems with PDF compaction

2013-04-23 Thread Michael Friendly

On 4/22/2013 5:51 PM, Uwe Ligges wrote:

But this doesn't do anything, not even changing the timestamp on the
file, because the file size doesn't change enough.


Either you changed it or not, there is no not enough.


I meant that the code in tools::compact compares the sizes of the old
and new files and only replaces the old file if the change in size is 
sufficient:


 if (new/old  0.9  new  old - 1) {
file.copy(tf, p, overwrite = TRUE)
}

At any rate, with R_GSCMD now fixed (Thx: Henrik), tools::compactPDF,
with gs_quality=ebook,
still does not reduce the size of my HE-examples.pdf file.

I tried the same on my Ubuntu system (R 2.15.2 also), and there I get

 tools::compactPDF(HE-examples.pdf, gs_quality=ebook)
  compacted 'HE-examples.pdf' from 739Kb to 366Kb

So, I can now copy the compacted file back to my development tree
on Windows; however, as I understand things, vignettes are re-built
by R CMD build and --compact-vignettes=gs+qpdf has no effect.
So my Ubuntu-compacted file will be overwritten.

It's somewhat maddening to have to spend so much time to save ~373Kb
in order to avoid a CRAN warning.

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] vignettes: problems with PDF compaction

2013-04-22 Thread Michael Friendly

On 4/21/2013 1:28 PM, Michael Friendly wrote:

[Env: OS: Win Xp; R 2.15.2; IDE: eclipse/StatET]

Each time I update my heplots package, I get warnings from R CMD check
on R-Forge,

* checking sizes of PDF files under ‘inst/doc’ ... WARNING
   ‘gs+qpdf’ made some significant size reductions:
  compacted ‘HE-examples.pdf’ from 739Kb to 366Kb


To follow up my own post, I did some more checking of whether/how to
compact PDFs on my own system.  My conclusion is that that I am unable
to comply with the request from CRAN maintainers, even though I would
like to.  Once again, I wonder why this cannot be handled on the CRAN
side automatically.

qpdf: running it from a cmd prompt (using the options from 
tools::compactPDF) doesn't do very much compression


C:\R\testqpdf --stream-data=compress --object-streams=generate 
HE-examples.pdf

HE-examples-comp.pdf

C:\R\testdir HE-examples*
04/22/2013  10:55 AM   699,191 HE-examples-comp.pdf
04/22/2013  10:28 AM   756,624 HE-examples.pdf

gs:  I have gs installed at C:\Program Files\gs\gs9.07\bin\gswin32.exe,
but the gs installer doesn't put itself on the path, so 
tools::compactPDF sees gs_cmd as empty:


 gs_cmd = Sys.getenv(R_GSCMD, )
[1] 

so it can't run gs+qpdf.  OK, so I try to do it manually:

 Sys.setenv(R_GSCMD = C:/Program Files/gs/gs9.07/bin/gswin32.exe)
 setwd(test)

 tools::compactPDF(HE-examples.pdf)
 tools::compactPDF(HE-examples.pdf, gs_quality=ebook)

But this doesn't do anything, not even changing the timestamp on the 
file, because the file size doesn't change enough.


C:\R\testdir HE-examples.pdf
04/22/2013  10:28 AM   756,624 HE-examples.pdf

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] vignettes: problems with PDF compaction

2013-04-21 Thread Michael Friendly

[Env: OS: Win Xp; R 2.15.2; IDE: eclipse/StatET]

Each time I update my heplots package, I get warnings from R CMD check
on R-Forge,

* checking sizes of PDF files under ‘inst/doc’ ... WARNING
  ‘gs+qpdf’ made some significant size reductions:
 compacted ‘HE-examples.pdf’ from 739Kb to 366Kb

and upon submission to CRAN, a message from maintainers:

On CRAN now: but again there were warnings about significant size
reductions in PDF compaction, which should really be fixed on your end.

however, I am unable to find what to do to fix this on my end. In my 
package directory,
I have the vignette sources all under vignettes/, with copies of the 
.pdf and .Rnw
under inst/doc for historical reasons. [Q: can I now safely delete the 
copies under

inst/doc ?]

inst/doc/
HE-examples.pdf
HE-examples.Rnw
vignettes/
HE-examples.pdf
HE-examples.Rnw
HE-examples.bib
fig/
...

I have qpdf installed:
 Sys.which(Sys.getenv(R_QPDF, qpdf))
qpdf
c:\\Rtools\\bin\\qpdf.exe


but, if I try to run it on the vignettes/HE-examples.pdf file, nothing 
happens:


 
tools::compactPDF(C:/Documents/workspace/heplots/vignettes/HE-examples.pdf)



Since vignettes are re-built from sources and then installed into 
inst/doc, I don't see why

PDF compaction cannot be run as part of the build process. That is, if
R CMD check --as-cran detects a problem, shouldn't there be some option for
R CMD build that would run gs+qpdf to correct it?

The idea of vignettes for R packages is a good thing, but, this problem 
(and others with vignettes) discourages me from using vignettes in 
packages, a bad thing.


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] vignettes: problems with PDF compaction

2013-04-21 Thread Michael Friendly
On 4/21/2013 1:47 PM, Uwe Ligges wrote:
 Since vignettes are re-built from sources and then installed into
 inst/doc, I don't see why
 PDF compaction cannot be run as part of the build process. That is, if
 R CMD check --as-cran detects a problem, shouldn't there be some 
 option for
 R CMD build that would run gs+qpdf to correct it?

 Yes, see

 R CMD build --help


 that tells you

   --compact-vignettes=  try to compact PDF files under inst/doc:
 no (default), qpdf, gs, gs+qpdf, both
I meant that perhaps R-Forge and CRAN could *automatically* do the 
compaction.

I *do* run R CMD build on my machine with options
--compact-vignettes=qpdf --keep-empty-dirs --resave-data

giving the log info:

* checking for file 'C:/Documents/workspace/heplots/DESCRIPTION' ... OK
* preparing 'heplots':
* checking DESCRIPTION meta-information ... OK
* installing the package to re-build vignettes
* creating vignettes ... OK
* compacting vignettes and other PDF files
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* looking to see if a 'data/datalist' file should be added
* re-saving image files
* building 'heplots_1.0-9.tar.gz'

However:
(a) the heplots_1.0-9.tar.gz source package is built outside of the 
workspace source tree I sync with R-Forge
(b) when I examine the heplots_1.0-9.tar.gz source package, the file 
heplots/inst/doc/HE-examples has
not been modified in size.
So, I still don't know how to correct this on my end.

-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA


[[alternative HTML version deleted]]

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


Re: [Rd] assignInNamespace to create a setwd() replacement: how to use unlockBinding()?

2013-02-08 Thread Michael Friendly

Thanks, Uwe
Yes, that was evil, but like other evil practices, it worked for many R 
generations.  Your suggestion wasn't hard to implement

and makes my .Rprofile healthier  happier.
-Michael


On 2/8/2013 9:17 AM, Uwe Ligges wrote:


Replacing base functionality is bad practice, since some packages may 
rely on the actual functionality from base. Why not provide such 
functions in a private package that masks the base functionality for 
your interactive work only (and keeps base clean to be used by other 
packages).

Finally, you can load that package in your startup code.

Best,
Uwe Ligges



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] assignInNamespace to create a setwd() replacement: how to use unlockBinding()?

2013-02-07 Thread Michael Friendly
In my .Rprofile for Windows, I had the following functions defined to 
mirror a few features

I miss from linux:

(a) replace setwd() with a version that stashes the current directory so 
it can be easily restored
(b) writes a short version of the current R directory to the Windows 
title bar: I can always see where I am,

with multiple Rgui windows.
(c) creates a cd() shorthand for setwd(), but with the difference that 
cd() acts like cd - under the tcsh shell,

returning to the previously stored directory.

 setwd-new.R ##
# .Rprofile functions to set current directory in WindowTitle

#==
# setwd() replacement functions
#==

oldsetwd - base::setwd
utils::assignInNamespace(setwd,
function(dir) {
.lastdir - oldsetwd(dir)
utils::setWindowTitle( short.path(base::getwd()) )
.lastdir
}, base)

# setwd replacement, allowing cd() to be like 'cd -' on unix (return to 
last dir)

cd - function(dir) {
if(missing(dir)) dir - .lastdir
.lastdir - base::setwd(dir)
utils::setWindowTitle( short.path(base::getwd()) )
}

short.path - function(dir, len=2) {
np -length(parts - unlist(strsplit(dir, '/')))
parts -rev( rev(parts)[1:min(np,len)] )
dots - ifelse (nplen, '...', '')
paste(dots,paste(parts, '/', sep='', collapse=''))
}


These all worked for all R versions up to R 2.15.0, where it began to 
break as follows:


 source(setwd-new.R)
Error in utils::assignInNamespace(setwd, function(dir) { :
locked binding of ‘setwd’ cannot be changed


I understand what the error means, and I think that unlockBinding() 
somewhere in my code gives a solution,

but I don't see where or how.

I should also add that in my actual .Rprofile, I source these functions 
into a local environment  attach

so they are always available, but don't clutter up ls()

.my.env - local({
# all my local definitions
})
attach(.my.env)



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] CRAN task views: markdown? better .CSS?

2013-01-31 Thread Michael Friendly
CRAN task views are useful, but they seem difficult to write and 
maintain because the XML format is rather

limited (no sectioning) and the packagelist must be maintained manually.
They are also difficult to read because the generated html and .css used 
are extremely basic, giving an

overly dense page.

Are there any markdown-like tools for writing a CTV?  Is it possible to 
apply a custom .css to a CTV?


-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] CRAN task views: markdown? better .CSS?

2013-01-31 Thread Michael Friendly

On 1/31/2013 12:01 PM, Achim Zeileis wrote:

Michael:

CRAN task views are useful, but they seem difficult to write and 
maintain because the XML format is rather limited (no sectioning)


What type of sectioning would you like to have? In the HTML part, you 
can use the usual structuring tools like h*, p, etc. It's not
OK. I think you mean the info ... /info section, where I failed to 
read the vignette sufficiently closely, which talks about

using HTML.



and the packagelist must be maintained manually.


Yes, but I recently started adding tools to help checking this. 
Hopefully I'll also get round to add some more convenience features 
for this.
Something simple might be a tool to scan the info ... /info section 
for pkg ... /pkg mentions and just print
a new packagelist section to the console.  This would avoid having to 
remember what you added recently

and manually add to the packagelist

-Michael


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] Declaring/importing non-exported functions [car] in another package

2013-01-16 Thread Michael Friendly
A new function in my heplots package wants to use a non-exported utility 
function in the car package,
df.terms, but this depends on other non-exported functions.
 From the Writing R extensions manual, I thought I could do this via (in 
my NAMESPACE)

importFrom(car, car:::df.terms, car:::df.terms.default, car:::is.aliased)

but I get:
** preparing package for lazy loading
Error : objects 'car:::df.terms', 'car:::df.terms.default', 
'car:::is.aliased' are not exported by 'namespace:car'
ERROR: lazy loading failed for package 'heplots'

\S 1.6.1 of the manual says regarding importFrom():
Using |foo:::f| instead of |foo::f| allows access to unexported objects. 
This is generally not recommended, as the semantics of unexported 
objects may be changed by the package author in routine maintenance.

Questions:
1.  Why doesn't this work?
2.  Is my only alternative to copy these functions to my package, also 
unexported?

thx,
-Michael

-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA


[[alternative HTML version deleted]]

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


Re: [Rd] Declaring/importing non-exported functions [car] in another package

2013-01-16 Thread Michael Friendly
On 1/16/2013 11:40 AM, Duncan Murdoch wrote:

 \S 1.6.1 of the manual says regarding importFrom():
 Using |foo:::f| instead of |foo::f| allows access to unexported objects.
 This is generally not recommended, as the semantics of unexported
 objects may be changed by the package author in routine maintenance.

 Questions:
 1.  Why doesn't this work?

 I think you misread the manual.  It is talking about ways to access 
 functions other than by using importFrom.  You can use car:::df.terms 
 in your functions.
Thanks for the clarification, but I blame the manual. Could I suggest a 
change in the manual to make this clearer:

Using |foo:::f| directly in a function  instead of |foo::f| allows 
access to unexported objects (rather than in importsFrom()). ...


-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA


[[alternative HTML version deleted]]

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


Re: [Rd] Declaring/importing non-exported functions [car] in another package

2013-01-16 Thread Michael Friendly

On 1/16/2013 11:40 AM, Duncan Murdoch wrote:



2.  Is my only alternative to copy these functions to my package, also
unexported?


Using car:::df.terms explicitly is another option.

Another possibility is for the car maintainer (John Fox) to export 
that function from car.


Hmm.  It turns out that this is a bit more complicated, since 
car::df.terms is an S3 generic,

relying on car:::df.terms.default().

In my function, I am now using car::: explicitly--

# determine size of intervals [perhaps need importFrom(car, 
car:::df.terms, ...) in NAMESPACE?]

if(is.null(df)) {
  df - if (Scheffe) sum(car:::df.terms(object)) else 2
  }

However, when I removed the definitions of the subsidiary 
df.terms.default from my package, R CMD check

complains bitterly:

 coefplot(mod, add=TRUE, Scheffe=TRUE, fill=TRUE)
Error in UseMethod(df.terms) :
  no applicable method for 'df.terms' applied to an object of class 
c('mlm', 'lm')

Calls: coefplot - coefplot.mlm - Anonymous
Execution halted

So, the semantics of importFrom() do not allow non-exported functions (I 
still wonder why), and my only direct option is to

copy these functions to my package.

-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] Declaring/importing non-exported functions [car] in another package

2013-01-16 Thread Michael Friendly

On 1/16/2013 12:26 PM, John Fox wrote:

Dear Duncan and Michael,

My initial reaction is that I'd rather not export these functions from the car 
package since the package already has many exported functions and the functions 
in question perform low-level operations that won't be of interest to end 
users. I recognize, however, the functions (and possibly some others) may be 
useful in other packages, such as heplots, so I'll think about this some more.
This is why I wrote directly to R-devel rather than to you.  It is 
low-level, and doesn't need to be exported.
OTOH, it provides an elegant way to provide Sheffe-type intervals  
ellipses as you do in car::confidenceEllipse,

which I copied.

best,
-Michael



Following up on Michael's subsequent message in this thread, I find the current text in 
Sec. 1.6.1 (Specifying imports and exports) of Writing R Extensions 
reasonably clear.

Best,
  John

On Wed, 16 Jan 2013 11:40:37 -0500
  Duncan Murdoch murdoch.dun...@gmail.com wrote:

On 13-01-16 11:25 AM, Michael Friendly wrote:

A new function in my heplots package wants to use a non-exported utility
function in the car package,
df.terms, but this depends on other non-exported functions.
   From the Writing R extensions manual, I thought I could do this via (in
my NAMESPACE)

importFrom(car, car:::df.terms, car:::df.terms.default, car:::is.aliased)

but I get:
** preparing package for lazy loading
Error : objects 'car:::df.terms', 'car:::df.terms.default',
'car:::is.aliased' are not exported by 'namespace:car'
ERROR: lazy loading failed for package 'heplots'

\S 1.6.1 of the manual says regarding importFrom():
Using |foo:::f| instead of |foo::f| allows access to unexported objects.
This is generally not recommended, as the semantics of unexported
objects may be changed by the package author in routine maintenance.

Questions:
1.  Why doesn't this work?

I think you misread the manual.  It is talking about ways to access functions 
other than by using importFrom.  You can use car:::df.terms in your functions.


2.  Is my only alternative to copy these functions to my package, also
unexported?

Using car:::df.terms explicitly is another option.

Another possibility is for the car maintainer (John Fox) to export that 
function from car.

Duncan Murdoch



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] R CMD check: better diagnosis for non-ASCII characters

2012-11-28 Thread Michael Friendly

On 11/28/2012 6:02 AM, Martin Maechler wrote:

In any case, I support your suggestion (replacing ::: by :: !)
and would definitely volunteer to accept patches and then put such an
improvement into R.

Thanks, Martin.
If you can point me to the source where this is carried out, I can 
attempt a patch.


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] stumped on re-building package vignette

2012-06-06 Thread Michael Friendly

[Env: Win Xp / StatET 2.0 / R 2.15.0]

In my heplots package I extended the HE-examples.Rnw vignette under 
inst/doc. The package passes R CMD check

on my machine:

* using log directory 'C:/eclipse-3.7/heplots.Rcheck'
* using R version 2.15.0 (2012-03-30)
* using platform: i386-pc-mingw32 (32-bit)
...
* checking sizes of PDF files under 'inst/doc' ... OK
* checking installed files from 'inst/doc' ... OK
* checking examples ... OK
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in 'inst/doc' ... OK
* checking running R code from vignettes ...
'HE-examples.Rnw' ... OK
'repeated.Rnw' ... OK
...

However, on R-Forge and on CRAN, the following error/warning is generated:

Mon Jun  4 20:18:22 2012: Checking package heplots (SVN revision 136) ...
* using log directory 
‘/mnt/building/build_2012-06-04-20-02/RF_PKG_CHECK/PKGS/heplots.Rcheck’
* using R version 2.15.0 Patched (2012-06-03 r59505)
* using platform: x86_64-unknown-linux-gnu (64-bit)
  ...
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in ‘inst/doc’ ... OK
* checking running R code from vignettes ...
   ‘HE-examples.Rnw’ ... [4s/4s] OK
   ‘repeated.Rnw’ ... [4s/4s] OK
 [9s/9s] OK
* checking re-building of vignette PDFs ... NOTE
Error in re-building vignettes:
  ...
Loading required package: car
Loading required package: MASS
Loading required package: nnet
Error: processing vignette 'HE-examples.Rnw' failed with diagnostics:
cannot open file 'fig/plot-plastic1.pdf'
Execution halted

* checking PDF version of manual ... OK

I am unable to determine why the file fig/plot-plastic1.pdf cannot be 
opened. It is in my inst/doc/fig directory  is regenerated

by the .Rnw file. What could cause this?

Second, I have tried manually running 
tools::compactPDF(HE-examples.pdf) on the .pdf file under inst/doc in 
the package,

but no change is made to the .pdf file. I can't see any way to correct this.

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] setting global options for a package

2012-05-10 Thread Michael Friendly
This may be elementary, but I can't find an answer: How can I set up 
global options for
some specific arguments to functions in a package which can be easily 
changed by the user?


This question relates to the selection of colors used in functions in 
several packages (heplots,
genridge), where I want to provide reasonable default values for plots, 
but allow users to

change those defaults globally for all plots produced with my functions.

One solution is to use palette() for the default, as in

foo - function(x, col=palette(), ...)  {}
but the standard palette is not appropriate for my use, and I'd rather 
not hijack more typical uses


Another is to use an explicit list of colors for default, as in

bar - function(x, col=c('red', 'blue', 'brown', 'darkgreen', ...), ...)  {}
but this must be overridden each time by someone to wants to change the 
defaults.


options() seems like the way to go, but I'm not sure how to implement 
this.  If I use
a .onLoad function to set some options, will these be created in the 
global environment?

If not, how to make them so?

.onLoad - function() {
  options(heplot.colors =
  c(red, blue, black, darkgreen, darkcyan,magenta, 
brown,darkgray))

}

My function could then use

foo - function(x, getOption(heplot.colors), ...)  {}


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] uncompressed saves warning

2012-03-22 Thread Michael Friendly

On 3/21/2012 1:22 PM, Uwe Ligges wrote:

What is the equivalent R command to compress these files in my project
tree?



Michael,

if you use
R CMD build --resave-data
to build the tar archive, the versions therein are recompressed.
But AFAIK, in StatET, R CMD build  builds a separate .tar.gz file under 
c:/eclipse, and does not affect

the project directory where these files are stored and sync'd with R-Forge.


Otherwise, you can also open the files and resave them via save() and 
appropriate arguments.

I exported the .rda files to c:/R/data and ran

 load(gfrance.rda)
 load(gfrance85.rda)
 save(gfrance, file=gfrance.RData, compress=xz)
Error in xzfile(file, wb, compression = 9) : cannot open the connection
In addition: Warning message:
In xzfile(file, wb, compression = 9) :
  cannot initialize lzma encoder, error 5

Why doesn't this work?

 save(gfrance, file=gfrance.RData, compress=TRUE)

The above works, but only compresses a 300K file to 299K


Or use  resaveRdaFiles() in package tools to runn it on a whole folder 
automatically.




 sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United 
States.1252LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C   LC_TIME=English_United 
States.1252


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


other attached packages:
[1] p3d_0.02-4   mgcv_1.7-13  car_2.0-12   nnet_7.3-1   
rgl_0.92.798 vcd_1.2-13   colorspace_1.1-1 MASS_7.3-17


loaded via a namespace (and not attached):
[1] lattice_0.20-6 Matrix_1.0-4   nlme_3.1-103   tools_2.14.1


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] uncompressed saves warning

2012-03-21 Thread Michael Friendly

[Env:  Windows XP Pro / R 2.14.1 / StatET / R-Forge]

A package of mine now generates a Warning under R 2.15.0 beta on CRAN 
checks:


* checking data for ASCII and uncompressed saves ... WARNING

  Note: significantly better compression could be obtained
by using R CMD build --resave-data
old_size new_size compress
  gfrance.rda  300Kb179Kb   xz
  gfrance85.rda295Kb176Kb   xz

What is the equivalent R command to compress these files in my project tree?

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] R-devel now triggers nags on notes from vignettes

2012-01-24 Thread Michael Friendly
I recently submitted a minor update to a CRAN package that passed all 
CRAN checks

~ two weeks ago.

Now, I get the response below from the CRAN-check-daemon

R-devel reports

* checking installed files from ‘inst/doc’ ... NOTE
The following files are already in R: ‘jss.cls’
Please remove them from your package.
The following files should probably not be installed:
‘sfheaders.sty’
The following directories should probably not be installed:
‘fig’

Consider the use of a .Rinstignore file: see ‘Writing R Extensions’,
or move the vignette sources from ‘inst/doc’ to ‘vignettes’.

Please fix.

I added a .Rinstignore file to my project, (at top level, same as 
DESCRIPTION) containing


inst/doc/fig/
inst/doc/jss.cls
inst/doc/sfheaders.sty

and re-submitted to CRAN, but the same nag notes return again. How to fix?

And, why has the CRAN-check-daemon suddenly gotten so picky about NOTEs,
particularly from vignettes?

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] nobs() and logLik()

2012-01-20 Thread Michael Friendly

On 1/20/2012 1:42 AM, Berwin A Turlach wrote:

One reason that I can see for people to use zero weights rather than
'subset' is that fitted() and predict() in the former case readily
produce fitted values for the observations that received a zero weight.

Another is that including the case of zero weights naturally allows a 
variety of simple robust methods via a weight function that descends to 
0.  A discontinuity at 0 in the handling of weights prevents this use.


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] R package BibTex entries: looking for a more general solution

2011-12-19 Thread Michael Friendly

On 12/19/2011 2:02 AM, Renaud Gaujoux wrote:

Hi,

I actually adapted and integrated this feature into Achim's -- nice -- 
function (posted on r-help).
Romain included it a couple of weeks ago into the bibtex package as 
function write.bib, and submitted the update to CRAN, but some NOTEs 
in the check delayed its availability on CRAN.

You can still install and try out the new version with:
install.packages(bibtex, repos=http://R-Forge.R-project.org;)

Keys for multiple citations are generated as pkgname%i, which 
might not be ideal, but works ok though. It might be better not number 
the first (main) citation. Romain, I think I will submit a patch for 
this.

Hope this helps.


Thanks, Renaud

I now have a working function, Rpackages.bib() that is roughly 
equivalent to your write.bib() and other related

material at
http://euclid.psych.yorku.ca/SCS/Private/Rbibs/

Also, see the document
http://euclid.psych.yorku.ca/SCS/Private/Rbibs/Rpkg-test.pdf
which reports some problems  perl fixes for the generated bibentries.  
These might be incorporated into
the functions to make the resulting bibtex files directly usable.  Your 
bibtex package seems the most natural place for

this.

Also, write.bib() doesn't seem to work unless you pass a list of package 
names.


 write.bib()
Error in is(entry, bibentry) :
  argument entry is missing, with no default
 write.bib(NULL)
Error in write.bib(NULL) :
  Invalid argument `entry`: expected a bibentry object or a character 
vector of package names.




best,
-Michael



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] R package BibTex entries: looking for a more general solution

2011-12-16 Thread Michael Friendly
Back in 2010 I raised this issue, and there was some discussion,

https://stat.ethz.ch/pipermail/r-devel/2010-November/058987.html

The goal, then, as now is to have a way to produce a bibtex-clean .bib 
file (i.e., not requiring
manual editing except in unusual circumstances) reflecting installed 
packages
for use in writing where one often needs/wants to cite all packages used 
in a given article.

Achim wrote the function below  which largely does this job, quite 
nicely now that most
DESCRIPTION files now contain Authors@R fields.  However, something 
changed since
R 2.11.1 when I tried this last, so that the function no longer 
generates keys for packages
which contain *more than one citation*.

I've tried debugging with browser(), but can't figure out how to make 
the lines around FIXME
work.  Can someone help?

You can see the result from this at
http://euclid.psych.yorku.ca/SCS/Private/Rbibs/Rpackages-2.14.0.bib
The function is also at:

# Original code by Achim Zeileis, 16 Dec 2009, R-help
# Added: support header and preamble

Rpackages.bib - function(filename = paste(Rpackages-,getRversion(), 
.bib, sep=),
 header=TRUE, preamble=NULL, suppress.warnings=TRUE, verbose = TRUE)
{
   ## installed packages
   pkgs - unique(installed.packages()[,1])
   if (suppress.warnings) warn - options(warn=-1)
   bibs - lapply(pkgs, function(x) try(toBibtex(citation(x
   if (suppress.warnings) options(warn)

   n.installed - length(bibs)

   ## omit failed citation calls
   ok - !(sapply(bibs, class) == try-error)
   pkgs - pkgs[ok]
   bibs - bibs[ok]
   n.converted - sum(ok)
   ## unify to list of Bibtex
   bibs - lapply(bibs, function(x) if(inherits(x, Bibtex)) list(x) 
else x)

   ## FIXME: add bibtex keys to each entry [the line below does not work!!]
   pkgs - lapply(seq_along(pkgs), function(i) if(length(bibs[[i]])  1)
 paste(pkgs[i], 1:length(bibs[[i]]), sep = ) else pkgs[i])
   pkgs - do.call(c, pkgs)
   bibs - do.call(c, bibs)
   for(i in seq_along(pkgs)) bibs[[i]][1] -
 gsub({,, paste({, pkgs[i], ,, sep = ), bibs[[i]][1], fixed 
= TRUE)

 if(header) header - gsub(^, %, toLatex(sessionInfo()))
 output - file(filename, a)
 cat(header, preamble, sep='\n', file=output, append=TRUE)
   ## write everything to a single .bib file
   writeLines(do.call(c, lapply(bibs, as.character)), con=output)
   close(output)
   if(verbose) cat(Converted, n.converted, of, n.installed,
 package citations to BibTeX,
 \nResults written to file, filename, \n)

   ## return Bibtex items invisibly
   invisible(bibs)
}






-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA


[[alternative HTML version deleted]]

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


Re: [Rd] How to deal with package conflicts

2011-11-25 Thread Michael Friendly

On 11/25/2011 9:10 AM, Terry Therneau wrote:

The ridge() function was put into the survival package as a simple
example of what a user could do with penalized functions.  It's not a
serious function, and I'd be open to any suggestions for change.

Actually, for any L2 penalty + Cox model one is now better off using
coxme as the maximization process is much better thought out there.  I'd
be happy to remove ridge from survival -- except that there are bound to
be lots of folks using the function and any such changes (even good
ones) to the survival package are fraught with peril.
Duncan provided one suggestion:  make ridge() an S3 generic, and rename 
ridge()
to ridge.coxph(), but this won't work, since you use ridge() inside 
coxph() and

survreg() to add a penalty term in the model formula.
Another idea might be simply to not export ridge(), but I have the 
feeling this will break

your R CMD checks.

Alternatively, my particular problem (wanting to use car::vif in my 
package documentation) would
be solved if John Fox considered making making survival a Suggests: 
package rather than a
Depends: one.  This might work, since survival is only referenced in car 
by providing Anova()

methods for coxph models.

I think all of this raises a general issue of unintended consequences of 
package bloat, where
(a) Depends: packages are forced to load by require()/library(), whether 
they are really needed or not;

(b) There is nothing like require(car, depends=FALSE) to circumvent this;
(c) Once a require()'d package is loaded, it cannot be unloaded;
(d) AFAIK, there is no way for a package author to override the masking 
of functions or data

provided by other other packages, except by using mypackage::myfun() calls.

To me this seems to be a flaw in the namespace mechanism.

best,
-Michael







--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] How to deal with package conflicts

2011-11-24 Thread Michael Friendly
In my genridge package, I define a function ridge() for ridge 
regression, creating objects of class 'ridge'

that I intend to enhance.

In a documentation example, I want to use some functions from the car 
package. However, that package
requires survival, which also includes a ridge() function, for coxph 
models. So, once I require(car)
my ridge() function is masked, which means I have to use the awkward 
form below in my .Rd files.


ridgemod - genridge::ridge(...)

I tried to detach survival, but that doesn't work:

 detach(package:survival)
Error: package ‘survival’ is required by ‘car’ so will not be detached

I don't see any solution to this, other than
(a) renaming my ridge() to something else -- don't want to do this
(b) use \dontrun{} for the examples that use car

Or, is there some other way?

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] NAMESPACES for data only packages

2011-11-08 Thread Michael Friendly
the NEWS file for R-devel says

  *

Even data-only packages without *R* code need a namespace and so may
need to be installed under *R* 2.14.0 or later.


but what should this contain?  Can it simply be an empty NAMESPACE 
file?  I assume that data does not have to
be exported.

-Michael

-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA


[[alternative HTML version deleted]]

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


Re: [Rd] CRAN: How to list a non-Sweave doc under Vignettes: on package page?

2011-11-07 Thread Michael Friendly

On 11/6/2011 7:41 PM, Henrik Bengtsson wrote:

Hi,

is it possible to have non-Sweave vignettes(*) in inst/doc/ be listed
under 'Downloads' on CRAN package pages?  For instance, in my R.rsp
package I have a inst/doc/report.pdf (part of the source *.tar.gz)
that is not detected/listed.  The PDF is not based on a Sweave
vignette but an *.tex.rsp vignette that is dynamically created via
inst/doc/Makefile.  It is listed

(*) BTW, can the term vignette be used for any inst/doc/ document,
or should it be reserved for Sweave+LaTeX-based documents?



I have a related problem/question and a request to R-Core to consider 
relaxing the requirements for vignettes when, for one reason or another,
they cannot be built entirely via Sweave.  In such cases, perhaps 
package authors can provide alternative metadata in the form of an

00index.html or something similar to allow such vignettes to be
more visible.

Those who face this problem would then be able to figure out a
Makefile or manual way to maintain the metadata file. What would be
required to implement this?

In my case, my Guerry package has a vignette, inst/doc/MultiSpat.pdf, 
originally built entirely with Sweave.  However, the vignette require()d 
a package only on R-Forge, which the author does not wish
to release to CRAN.  At some point, ~ R 2.10, this triggered a 
WARNING/ERROR from the CRAN check daemon, in spite of the fact that the
vignette .Rnw file contained the following hack designed to make sure 
that all necessary packages were available anywhere:


\subsection{Installation and loading of required packages}
Several packages must be installed to run the different analyses:
ni0, fig=F, eval=TRUE, echo=TRUE, debug=TRUE, results=hide, include 
=FALSE, width=7, height=7=

pkg - c(maptools,spdep,ade4,Guerry,spacemakeR)
inst.pkg - row.names(installed.packages())
pkg2inst - pmatch(pkg,inst.pkg)
if(any(is.na(pkg2inst[1:4]))) 
install.packages(pkg[which(is.na(pkg2inst[1:4]))],repos=http://cran.at.r-project.org;)

if(is.na(pkg2inst[5]))
  install.packages(spacemakeR, repos=http://R-Forge.R-project.org;)

library(maptools)
library(ade4)
library(spdep)
library(spacemakeR)
library(Guerry)
@

However, this hack was deemed unacceptable for a CRAN package vignette.
In the end, the only solution that would satisfy the CRAN check daemon 
was to delete the source inst/doc/MultiSpat.Rnw file from the package.


Consequently, the .pdf vignette remains in the package, but it is not 
listed as a vignette on CRAN, nor found via vignette()


best,
-Michael


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] NOTE: unstated dependencies in examples

2011-10-14 Thread Michael Friendly

On 10/13/2011 11:34 AM, Uwe Ligges wrote:

I looked at the code and since this is not that trivial to change, I
think we can well live with typing

grep -r gplots ./man

which is not too hard to run on the source package, I believe.

Best wishes,
Uwe

Yes, that's quite easy, if I wanted to search for files mentioning 
gplots.  However, the NOTE was misleading:


 'library' or 'require' calls not declared from:
 gplots sp

suggesting that I had used a function from those packages somewhere 
without a library() or require().  It turned out that I had just omitted 
those packages from the Suggests: line in DESCRIPTION.  So,

perhaps it would be more informative to say:

 'library' or 'require' calls not declared in Depends: or Suggests: from:
 gplots sp

-Michael





On 13.10.2011 03:00, Yihui Xie wrote:

You have this in Jevons.Rd:

# show as balloonplots

if (require(gplots)) {


and this in Snow.Rd:

%\dontrun{

library(sp)


It will certainly be helpful if R CMD check can provide more
informative messages (in this case, e.g, point out the Rd files).

Regards,
Yihui
--
Yihui Xiexieyi...@gmail.com
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Wed, Oct 12, 2011 at 11:33 AM, Michael Friendlyfrien...@yorku.ca
wrote:

Using R 2.13.1, I am now getting the following NOTE when I run R CMD
check
on my HistData
package

* checking for unstated dependencies in examples ... NOTE
'library' or 'require' calls not declared from:
gplots sp

Under R 2.12.x, I didn't get these notes.

I have ~ 25 .Rd files in this package, and AFAICS, every example uses
library or require for the
functions used; the DESCRIPTION file has the long list of Suggests,
which
previously was sufficient
for packages used in examples.

Suggests: gtools, KernSmooth, maps, ggplot2, proto, grid, reshape, plyr,
lattice, ReadImages, car

But I have no way to find the .Rd file(s) that triggered this note.

What is the tool used in R CMD check to make this diagnosis? It would be
better
if this reported the .Rd file(s) that triggered this note.
Is it possible that this note could be specious?

-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street Web: http://www.datavis.ca
Toronto, ONT M3J 1P3 CANADA

__
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





--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] NOTE: unstated dependencies in examples

2011-10-12 Thread Michael Friendly
Using R 2.13.1, I am now getting the following NOTE when I run R CMD 
check on my HistData

package

* checking for unstated dependencies in examples ... NOTE
'library' or 'require' calls not declared from:
  gplots sp

Under R 2.12.x, I didn't get these notes.

I have ~ 25 .Rd files in this package, and AFAICS, every example uses 
library or require for the
functions used;  the DESCRIPTION file has the long list of Suggests, 
which previously was sufficient

for packages used in examples.

Suggests: gtools, KernSmooth, maps, ggplot2, proto, grid, reshape, plyr, 
lattice, ReadImages, car


But I have no way to find the .Rd file(s) that triggered this note.

 What is the tool used in R CMD check to make this diagnosis?  It would 
be better

if this reported the .Rd file(s) that triggered this note.
Is it possible that this note could be specious?

-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] R license for a derived data-only package

2011-09-16 Thread Michael Friendly
I'm looking for guidance or advice about the R license to use in 
preparing a package containing the

Baseball Database from http://baseball1.com/statistics/
My main purpose is to make it available to students in a course, and to 
develop it with others

I'd like to put it on R-Forge, and then perhaps make it public on CRAN.

However, the page above bears a very restrictive copyright notice and 
limited license:


This database is copyright 1996-2010 by Sean Lahman. A license is granted
for individual use for research purposes. It may not be re-distributed
without permission. Any commercial use, or other dissemination of the
database in part or in whole is prohibited. Use of this database
constitutes acceptance of these terms.

I've written several times to the author asking permission for my 
intended wider use, but have

received no reply.

What makes this perplexing is that I am apparently free to distribute 
this by sending links
in an email or posting them on a web page, so that others actually 
download them for
personal use.  The R package, however would be considered a derived 
work, I think,
since it contains .RData files I created and .Rd documentation.  Does 
the original

limited license apply to this?

AFAICS, none of the R licenses described at: 
http://www.r-project.org/Licenses/
seem to cover this situation, although they seem to apply to the R 
package, not the

data on which it is based.

The TeX archive CTAN defines a wider range of licenses, including a 
bunch of non-free ones,

http://ctan.mirror.rafal.ca/help/Catalogue/licenses.html

But I don't know if any of these are acceptable in R packages (e.g., 
will pass R CMD check).

I'd rather not have to consult a lawyer, so any guidance is welcome.

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] CRAN packages maintained by you

2011-08-22 Thread Michael Friendly
It is A Good Thing to regularize Authors and Maintainers of packages, 
particularly for citation()

and toBibTex().

Could I add a suggested TODO item for the maintainer of package.skeleton 
and friends to

help reinforce this for new packages:

- Please add appropriate templates for Author@R in the skeleton 
DESCRIPTION file generated,
indicating the proper format as well as the use of role= to signal the 
creator and

maintainer.

- a comment to see ?person for descriptions of fields wouldn't hurt either

best,
-Michael


On 8/8/2011 9:46 AM, Kurt Hornik wrote:

Dear maintainers,

This concerns the packages

CITAN ENmisc Formula MSBVAR RExcelInstaller RcmdrPlugin.mosaic
Rd2roxygen Rz SGP betareg expectreg fastcluster glmc gptk heplots pxR
sideChannelAttack sp spacetime trapezoid vcd

maintained by one of you.

I see that you have added Author@R fields providing enhanced information
on package authors to your DESCRIPTION files, which since R 2.12.0 is
used for auto-generating citations.

In current r-devel, we have finally added functionality for also
auto-generating package DESCRIPTION Author and Maintainer fields from
the enhanced information if needed [i.e., existing fields will not be
overwritten].

However, in the process of this the field was renamed to 'Authors@R', so
please change your DESCRIPTION files accordingly.

In doing so, pls note that to auto-generate Maintainer fields the
Authors@R fields need to provide authors with a maintainer (cre) role
and an email address.  Currently, packages

CITAN MSBVAR SGP fastcluster glmc gptk heplots sideChannelAttack sp
spacetime trapezoid

do not specify the package maintainer in their Authors@R field.

(Note that to take advantage of the new auto-generation functionality,
you need to rename to Authors@R, remove the DESCRIPTION Author and
Maintainer fields in the package sources, and then run R CMD build from
a current version of r-devel.)

Best
-k



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] Consistency of messages from R CMD {check,build,install}

2011-04-08 Thread Michael Friendly
A minor gripe/request:  Could all R CMD package tools not at the very 
least be consistent in indicating when

they are done, as in
* DONE (packagename)
or at least
* DONE

R CMD build leaves one hanging, not knowing whether it has completed or 
it is time to get another coffee.


* checking for file 'C:/Documents/workspace/heplots/DESCRIPTION' ... OK
* preparing 'heplots':
* checking DESCRIPTION meta-information ... OK
* installing the package to re-build vignettes
* creating vignettes ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'heplots_0.9-8.tar.gz'

Some checking/building processes take a while, so it would also be nice 
if more of the info lines

ended with ... OK

tia,
-Michael


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] system.file() to read a text file from a vignette

2011-03-23 Thread Michael Friendly

[Env: R 2.12.2, WinXp]

In a vignette for the vcdExtra package, I had a text file, tv.dat under 
data/, that I used in the vignette as


tv1,results=verbatim=
tv.data-read.table(system.file(data,tv.dat,package=vcdExtra))
head(tv.data,5)
@

I was told that this now generates a warning for non-Rdata files in R 
CMD check. But I'm now confused about
where to put this and how to use system.file() in the vignette to read 
it. The R-exts.pdf says


The R working directory for all vignette tests in R CMD
check is the installed version of the ‘doc’ subdirectory. Make sure all 
files needed by the vignette
(data sets, . . . ) are accessible by either placing them in the 
‘inst/doc’ hierarchy of the source

package, or using calls to system.file().

So, I moved this file to inst/doc/extdata/tv.dat, and changed the 
vignette to


tv1,results=verbatim=
tv.data-read.table(system.file(inst,doc,extdata,tv.dat,package=vcdExtra))
head(tv.data,5)
@

But I get the error:
Error: processing vignette 'vcd-tutorial.Rnw' failed with diagnostics:
chunk 23 (label=tv1)
Error in read.table(system.file(inst, doc, extdata, tv.dat, 
package = vcdExtra)) :

no lines available in input

How can I fix this?

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] system.file() to read a text file from a vignette

2011-03-23 Thread Michael Friendly
On 3/23/2011 10:21 AM, Duncan Murdoch wrote:

 Everything in the inst directory is moved up a level when it is 
 installed.  So you shouldn't mention inst in its path.


I discovered this by error-and-trial.  ?system.file is mute on this.  
Perhaps R-ext.pdf could make this explicit by saying

The R working directory for all vignette tests in R CMD
check is the installed version of the ‘doc’ subdirectory. Make sure all 
files needed by the vignette
(data sets, . . . ) are accessible by either placing them in the 
‘inst/doc’ hierarchy of the source
package, or using calls to system.file(),
*noting that the inst directory is moved up a level when it is 
installed and should not be mentioned
in the path used in system.file().*


-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA



[[alternative HTML version deleted]]

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


Re: [Rd] aperm() should retain class of input object

2010-12-29 Thread Michael Friendly
* contourplot.array*  dotplot.array*
[7] duplicated.arraylevelplot.array*unique.array


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] aperm() should retain class of input object

2010-12-27 Thread Michael Friendly
aperm() was designed for multidimensional arrays, but is also useful for 
table objects, particularly
with the lattice, vcd and vcdExtra packages.  But aperm() was designed 
and implemented before other
related object classes were conceived, and I propose a small tune-up to 
make it more generally useful.


The problem is that  aperm() always returns an object of class 'array', 
which causes problems for methods
designed for table objects. It also requires some package writers to 
implement both .array and .table

methods for the same functionality, usually one in terms of the other.
Some examples of unexpected, and initially perplexing results (when only 
methods for one class are implemented)

are shown below.


 library(vcd)
 pairs(UCBAdmissions, shade=TRUE)
 UCB - aperm(UCBAdmissions, c(2, 1, 3))

 # UCB is now an array, not a table
 pairs(UCB, shade=TRUE)
There were 50 or more warnings (use warnings() to see the first 50)

 # fix it, to get pairs.table
 class(UCB) - table
 pairs(UCB, shade=TRUE)




Of course, I can define a new function, tperm() that does what I think 
should be the expected behavior:


# aperm, for table objects

tperm - function(a, perm, resize = TRUE) {
result - aperm(a, per, resize)
class(result) - class(a)
result
}

But I think it is more natural to include this functionality in aperm() 
itself.  Thus, I propose the following

revision of base::aperm(), at the R level:

aperm - function (a, perm, resize = TRUE, keep.class=TRUE)
{
if (missing(perm))
perm - integer(0L)
result - .Internal(aperm(a, perm, resize))
if(keep.class) class(result) - class(a)
result
}


I don't think this would break any existing code, except where someone 
depended on coercion to an array.
The drop-in replacement for aperm would set keep.class=FALSE by default, 
but I think TRUE is  more

natural.

FWIW, here are the methods for table and array objects
from my current (non-representative) session.

 methods(class=table)
 [1] as.data.frame.table barchart.table* cloud.table*
contourplot.table*  dotplot.table*
 [6] head.table* levelplot.table*pairs.table*
plot.table* print.table

[11] summary.table   tail.table*

   Non-visible functions are asterisked

 methods(class=array)
[1] anyDuplicated.array as.data.frame.array as.raster.array*
barchart.array* contourplot.array*  dotplot.array*

[7] duplicated.arraylevelplot.array*unique.array


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] warning creating an as.array method in a package

2010-12-10 Thread Michael Friendly
I found a solution to this problem, but don't understand why it was 
necessary. In a clean workspace, I get:


 methods(as.array)
[1] as.array.default
 showMethods(as.array)

Function as.array:
 not a generic function

So, I just added the generic definition to my package, making with 
warnings go away.


as.array - function(x, ...)
UseMethod(as.array)

as.array.loddsratio - function (x, log=x$log, ...)
drop(array(coef(x, log = log), dim = dim(x), dimnames=dimnames(x)))

Yet, help(as.array) says:

as.array is a generic function for coercing to arrays. The default 
method does so by attaching a dim attribute to it. It also attaches 
dimnames if x has names.   Is this a documentation error?


 sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

loaded via a namespace (and not attached):
[1] tools_2.11.1


On 12/9/2010 10:05 AM, Michael Friendly wrote:

I posted on this topic to r-help, but never got a sufficient answer, so
I'm reposting here.

[Env: R 2.11.1, Win Xp, using Eclipse/StatET]

In a package I'm working on, I want to create as.matrix() and as.array()
methods for a particular kind of
object (log odds ratios). These are returned in a loddsratio object as
the $coefficients component,
a vector, but really reflect an underlying (R-1)x(C-1)xstrata array,
whose attributes are contained in other components.

These are all properly declared in the NAMESPACE as S3 methods,

...
S3method(dim, loddsratio)
S3method(dimnames, loddsratio)
S3method(print, loddsratio)
S3method(vcov, loddsratio)
S3method(as.matrix, loddsratio)
S3method(as.array, loddsratio)

Yet, when I run R CMD check, R CMD build, etc. or even load the package,
I get the warning,

  library(vcdExtra)
Loading required package: vcd
Loading required package: MASS
Loading required package: grid
Loading required package: colorspace
Loading required package: gnm
Warning message:
found an S4 version of ‘as.array’ so it has not been imported correctly

  showMethods(as.array)
Function: as.array (package base)
x=ANY
x=Matrix

But as.array does show up as a method for my class:

  methods(class=loddsratio)
[1] as.array.loddsratio* as.data.frame.loddsratio*
[3] as.matrix.loddsratio* coef.loddsratio*
[5] confint.loddsratio* dim.loddsratio*
[7] dimnames.loddsratio* print.loddsratio*
[9] vcov.loddsratio*

Non-visible functions are asterisked
 

Is there some work-around so I can have an S3 as.array() method in my
package and avoid this warning?






--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] warning creating an as.array method in a package

2010-12-09 Thread Michael Friendly
I posted on this topic to r-help, but never got a sufficient answer, so 
I'm reposting here.


[Env:  R 2.11.1, Win Xp, using Eclipse/StatET]

In a package I'm working on, I want to create as.matrix() and as.array() 
methods for a particular kind of
object (log odds ratios). These are returned in a loddsratio object as 
the $coefficients component,
a vector, but really reflect an underlying (R-1)x(C-1)xstrata array, 
whose attributes are contained in other components.


These are all properly declared in the NAMESPACE as S3 methods,

...
S3method(dim, loddsratio)
S3method(dimnames, loddsratio)
S3method(print, loddsratio)
S3method(vcov, loddsratio)
S3method(as.matrix, loddsratio)
S3method(as.array, loddsratio)

Yet, when I run R CMD check, R CMD build, etc. or even load the package, 
I get the warning,


 library(vcdExtra)
Loading required package: vcd
Loading required package: MASS
Loading required package: grid
Loading required package: colorspace
Loading required package: gnm
Warning message:
found an S4 version of ‘as.array’ so it has not been imported correctly

 showMethods(as.array)
Function: as.array (package base)
x=ANY
x=Matrix

But as.array does show up as a method for my class:

 methods(class=loddsratio)
[1] as.array.loddsratio*  as.data.frame.loddsratio*
[3] as.matrix.loddsratio* coef.loddsratio*
[5] confint.loddsratio*   dim.loddsratio*
[7] dimnames.loddsratio*  print.loddsratio*
[9] vcov.loddsratio*

   Non-visible functions are asterisked


Is there some work-around so I can have an S3 as.array() method in my 
package and avoid this warning?




--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] Request: kronecker to get a sep= argument

2010-11-25 Thread Michael Friendly

kronecker, with make.dimnames=TRUE uses a hardwired sep=: in the line

tmp - outer(dnx[[i]], dny[[i]], FUN = paste, sep = :)

For an application in which dimnames arise from an n-way array, where 
different dimensions have

different roles, and I would like to be able to use kronecker in the form

kronecker(A, B, make.dimnames=TRUE, sep='/')

All this requires is to change the following two lines:

kronecker - function (X, Y, FUN = *, make.dimnames = FALSE, sep=: ...)
{
 ...
tmp - outer(dnx[[i]], dny[[i]], FUN = paste, sep = sep)
}


Otherwise, I have to reproduce the logic inside kronecker() in my 
application function.


-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] R package BibTex entries: looking for a more general solution

2010-11-03 Thread Michael Friendly

== Summary ==
* Problem: BibTeX entries extracted from R packages via citation() 
require too much manual editing to be

of general use.
* Proposal: Date: fields should be made mandatory in package DESCRIPTION 
files, perhaps

beginning with warnings from R CMD check
* Proposal: Package authors should be encouraged to use a (new) 
Contributors: field in the DESCRIPTION file
rather than packing all information into the Author: field, which at 
present cannot often be parsed by BibTeX.

* Files: All test files referred to here can be found at

http://euclid.psych.yorku.ca/SCS/Private/Rbibs/

== Details ==
Around 16 Dec. 2009, I queried R-help about automating the extraction of 
citation()s from R packages. The stimulus
was that some journals, notably JSS, now require a reference and 
citation of every R package mentioned,
and it is a pain to create these manually, no less maintain them for 
current versions.


The result of that query was a function, Rpackage.bibs() by Achim 
Zeileis that I have been using ever since.

Code in: http://euclid.psych.yorku.ca/SCS/Private/Rbibs/Rpackages.bib.R
On one current system I get the following:

 Rpackage.bibs(file=Rpackages-R.2.11.1.bib)
Converted 230 of 230 package citations to BibTex
Results written to file Rpackages-R.2.11.1.bib
Warning messages:
1: In citation(x) :
no date field in DESCRIPTION file of package 'codetools'
2: In citation(x) :
no date field in DESCRIPTION file of package 'gridBase'
3: In citation(x) : no date field in DESCRIPTION file of package 'iplots'

See:
http://euclid.psych.yorku.ca/SCS/Private/Rbibs/Rpkg-test.pdf
for the result of processing this .bib file with latex/bibtex using the 
jss.bst bibliography style


I'm writing to R-Devel because the DESCRIPTION and inst/CITATION files 
in R packages provide the
basic data used in citation() and any methods based on this, and yet the 
information in these files is
often insufficient to generate well-formed BibTeX entries for use in 
vignettes and publications.


One easy case is illustrated above, where 3 packages have no Date: field 
so the BibTeX gets no

year = {},
and references get printed as Murrell, P () for gridBase. (In my 
original test under R 2.9.1, there where
~ 20 such warnings.) Thus, I propose that Date: be a required field in 
DESCRIPTION files, and

R CMD check complain if this is not found.

The more difficult case has to do with the Author: field in the 
DESCRIPTION file (when no CITATION file is present)
People can write whatever they want here, and the result looks sort of 
OK when printed by citation(), but confuses

BibTeX mightly. One example:

 citation(akima)
To cite package ‘akima’ in publications use:

Fortran code by H. Akima R port by Albrecht Gebhardt aspline function
by Thomas Petzoldt petzo...@rcs.urz.tu-dresden.de enhancements and
corrections by Martin Maechler (2009). akima: Interpolation of
irregularly spaced data. R package version 0.5-4.
http://CRAN.R-project.org/package=akima

A BibTeX entry for LaTeX users is

@Manual{,
title = {akima: Interpolation of irregularly spaced data},
author = {Fortran code by H. Akima R port by Albrecht Gebhardt aspline 
function by Thomas Petzoldt petzo...@rcs.urz.tu-dresden.de 
enhancements and corrections by Martin Maechler},

year = {2009},
note = {R package version 0.5-4},
url = {http://CRAN.R-project.org/package=akima},
}

ATTENTION: This citation information has been auto-generated from the
package DESCRIPTION file and may need manual editing, see
‘help(citation)’ .


Yes, the ATTENTION note does say that manual editing may be necessary, 
but I think a worthy goal would be

to try to reduce the need for this.

One simple way to do that would be to support an extra Contributions: 
field in the DESCRIPTION file,
so that Authors: can be more cleanly separated for the purpose of 
creating well-structured BibTeX.

Perhaps others have better ideas.

-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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