Re: [Rd] Can't install.packages() from local repo in 2.15.2

2012-11-05 Thread Imanuel Costigan

Hi Prof. Ripley,

There is in fact a parallel source repository (see my initial email):

L:/R/src/contrib

I had also run tools:write_PACKAGES() therein, generating an empty PACKAGES 
file as I have chosen not to release source packages.  

I would like to make two comments.

First, I believe the behaviour of install.packages isn't documented in at least 
the case that I found myself in. Namely, when the source package doesn't exist 
(and the src tree does exist), but the binary does, then the binary cannot be 
installed. Unless, of course, you specify the option 
install.packages.check.source = FALSE. I can confirm that this does resolve my 
error.

> For binary installs, the function also checks for the availability of a 
> source package on the same repository, and reports if the source package has 
> a later version, or is available but no binary version is.
  
Second, the error message could be improved to better specify what is causing 
the problem.

> Warning in install.packages : package ‘anRpackage’ is not available (for R 
> version 2.15.2)

This is a bit vague. My suggestion, would be for the error message, in the case 
I found myself in, to read something like:

> Warning in install.packages : package 'anRpackage' is not available in the 
> source tree

The R version number is a red-herring, except to the extent that this check 
didn't (appear to) occur in R 2.15.1. But given that most users will know they 
are using R 2.15.2 and that the repo structure doesn't require you to drill 
down past 2.15, this ending doesn't make much sense to me.  

In any case, thanks for your hard work in giving us such great software to use. 
I really appreciate it.  

On Sunday, 4 November 2012 at 8:32 PM, Prof Brian Ripley wrote:

> Your subject line isn't truthful. At the very least you are talking  
> about binary packages on Windows using a file:// repository ('local'  
> does not usually mean that, and is specified by NULL).
>  
> I think you have not understood the NEWS item: most likely you do not  
> have a parallel source repository.
>  
> * For a Windows or Mac OS X binary package install,
> install.packages() will check if a source package is available on
> the same repositories, and report if it is a later version or
> there is a source package but no binary package available.
>  
> This check can be suppressed: see the help page.
>  
> I guess you did not do so. Try
> options(install.packages.check.source = FALSE)
> which works for me.
>  
> You could also specify contriburl, as you have a partial repository.
>  
>  
>  
> On 02/11/2012 09:28, Imanuel Costigan wrote:
> > Hi guys
> >  
> > I think there's a high chance this is a bug. But I can't rule out that I 
> > can be blamed for this. I've posted this to bugzilla (#15092). Then I read 
> > that I probably should have posted it to R-develop first. Sorry for doing 
> > this in the wrong order.
> >  
> > I've set up a local repo on my local drive (happens to be mapped to L:/). 
> > It has the following structure (as per 
> > http://cran.r-project.org/doc/manuals/R-admin.html#Setting-up-a-package-repository):
> >  
> > L:/R/bin/windows/contrib/
> > 2.11/
> > 2.12/
> > 2.13/
> > 2.14/
> > 2.15/
> > L:/R/src/contrib
> >  
> > I created a bare bones package (`anRpackage`) using `package.skeleton`. I 
> > cleaned it up and added a basic function, checked it and built it from 
> > command line using `R CMD INSTALL --build .`. That generates 
> > `anRpackage_1.0.zip` with no errors. Note:
> >  
> > ```
> > $ R CMD INSTALL --build --version
> > R add-on package installer: 2.15.2 (r61015)
> > ```
> >  
> > I have Rtools 2.16 installed (as this is for R >2.15.1 to R 2.16.x). I have 
> > also followed the instructions here: 
> > http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset
> >  
> > I copy that to L:/R/bin/windows/contrib/2.15 (for example), run 
> > `tools::write_PACKAGES()` in that directory. That successfully generates 
> > the packages file. I also run `tools::write_PACKAGES()` in L:/R/src/contrib 
> > to generate an empty PACKAGES file.
> >  
> > I have the following in my .Rprofile (among other things):
> >  
> > ```
> > .First <- function ()
> > {
> > options( repos = c(CRAN = "http://cran.csiro.au/";,
> > LREPO = "file:///L:/R/"))
> > }
> > ```
> >  
> > I run `install.packages("anRpackage") and I get the following error:
> >  
> > ```
> > Installing package(s) into ‘C:/Program Files/R/R-2.15.2/library’
> > (as ‘lib’ is unspecified)
> > Warning in install.packages : package ‘anRpackage’ is not available (for R 
> > version 2.15.2)
> > ```
> >  
> > Same issue on another Windows machine.
> >  
> > However, if I run 
> > `install.packages("L:/R/bin/windows/contrib/2.15/anRpackage_1.0.zip", 
> > repos=NULL)`, it installs successfully.
> >  
> > I do not have this problem in R 2.15.1.
> >  
> > NB: If I provide full file path to install.packages and set repos=NULL, and 
> > then check the package's DESCRIPTION file in the help, I

[Rd] Ops.data.frame

2012-11-05 Thread Hadley Wickham
Hi all,

Where are the semantics for Ops.data.frame documented?  I've tried
looking in ?Ops.data.frame, ?data.frame, the "R language definition"
(by searching for data frame), and "An Introduction to R" (similarly),
but haven't found anything.  What am I missing?

Hadley

-- 
RStudio / Rice University
http://had.co.nz/

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


[Rd] Another code to drop factor levels

2012-11-05 Thread Suharto Anggono Suharto Anggono

I apologize if this is not appropriate for this mailing list.

In R, there is already functionality to drop unused factor levels. However, I 
am proposing the code below that I wrote. In some occasions, it was faster than 
applying function 'factor'. In any case, there is no restriction for anyone to 
use the code below.

droplevels2 <- function(x) {
if (is.null(levels(x)))
 stop("no 'levels' attribute")
nlev <- length(levels(x))
y <- unclass(x)
tb <- tabulate(y, nlev)
used <- as.logical(tb)
tb[used] <-
 seq(length=sum(used))
y[] <- tb[y]
levels(y) <- levels(x)[used]
attr(y, "class") <-
 attr(x, "class")
y
}

Alternatively, one may use 'levels<-.factor' by assigning NA to unused levels, 
like below.

levels(x)[ tabulate(
unclass(x),
length(levels(x))) == 0 ] <-
NA

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