[Rd] MiKTeX's withdrawal of texi2dvi.exe

2015-10-09 Thread Prof Brian Ripley
MiKTeX has abruptly removed texi2dvi.exe from its distribution.  (MiKTeX 
broke its updating process earlier and an attempted update trashed the 
updater on my installation so I was forced to make a fresh install of 
the current distribution.  I do not know if updates remove a currently 
installed texi2dvi.exe.)


This has two consequences:

1) It is used by tools::texi2dvi() if found.  As far as I can tell 
texify.exe is a sufficient replacement there, so you can set 
options(texi2dvi = "texify") (and R-patched/R-devel have been changed to 
try that).  Otherwise emulation will be used and does work, less robustly.


2) It was used to make manuals when building R from sources.  This has 
been worked around in R-patched/R-devel.  If you need to build an 
earlier version of R, edit doc/manuals/Makefile.win from


ifeq "$(MIKTEX)" "TRUE"
R_TEXOPTS = --include-directory=../../share/texmf/tex/latex
TEXI2DVI = texi2dvi
else
R_TEXOPTS =
TEXI2DVI =
endif

setting the first TEXI2DVI line to

TEXI2DVI = TEXINDEX=/Rtools/bin/texindex.exe texify

altering the full path to texindex.exe as required (being on the PATH is 
not sufficient).  (For current versions, set this in MkRules.local.)



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

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


[Rd] A where() functions that does what exists() does but return the environment when object lives?

2015-10-09 Thread Henrik Bengtsson
Hi,

exists("foo", inherits=TRUE) check whether an object named "foo"
exists, and get("foo", inherits=TRUE) retrieves it.  I'm looking for a
similar function to exists() that returns the environment where the
object "foo" exists, iff at all.  If not found, NULL is returned.
Does that exist?

EXAMPLE #1:

> sample2 <- base::sample
> env <- where("sample2", inherits=TRUE)
> env


Note the difference to:

> obj <- get("sample2", inherits=TRUE)
> environment(obj)



EXAMPLE #2:

> a <- 1
> foo <- function() { b <- 2; list(a=where("a", inherits=TRUE), b=where("b", 
> inherits=TRUE)) }
> foo()
$a

$b


> foo()
$a

$b



I do understand that I can implement such a function myself, but I
prefer not to.

Thanks,

Henrik

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


Re: [Rd] reverse object creation

2015-10-09 Thread Gabriel Becker
Bo,

More philosophically, the dput output is more idiomatically appropriate for
R.

Data.frames are emphatically column-major data structures in R, by (very
good) design.

Best,
~G
On Oct 9, 2015 3:55 AM, "Thierry Onkelinx"  wrote:

> Dear Bo,
>
> Please keep the mailing list in cc.
>
> Your function only works properly with a data.frame in which all variables
> are characters. dput() will preserve the structure of the object and works
> with all R objects.
>
> Best regards,
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> 2015-10-09 12:32 GMT+02:00 Bo Werth :
>
> > Dear Thierry,
> >
> > many thanks for the hint - indeed, I wasn't aware of dput() - it is doing
> > something close to what I was looking for -
> > the only issue with the result for data frames is that it becomes
> > difficult to see the row association:
> >
> > dput returns
> >
> > structure(list(sheet = c("output cup", "output coppy", "gross value added
> > cup",
> > "gross value added coppy", "GFCF cup", "GFCF vol", "empl jobs",
> > "empl FTE", "employees jobs", "employees FTE", "D1", "D11", "D29-D39",
> > "D29 nom", "D39 nom", "P51c nom", "B2n+B3n", "total hours worked",
> > "hours worked employees"), var = c("PROD", "PKPY", "VALU", "VKPY",
> > "GFCF", "GKPY", "EMPN", "FTEN", "EMPE", "FTEE", "LABR", "WAGE",
> > "OTXS", "D29 nom", "D39 nom", "CFCC", "NOPS", "HRNS", "HRSE")), .Names =
> > c("sheet",
> > "var"), row.names = c(NA, -19L), class = "data.frame")
> > >
> >
> > df_rev returns
> >
> > rbind.data.frame(c("output cup", "PROD"),
> > c("output coppy", "PKPY"),
> > c("gross value added cup", "VALU"),
> > c("gross value added coppy", "VKPY"),
> > c("GFCF cup", "GFCF"),
> > c("GFCF vol", "GKPY"),
> > c("empl jobs", "EMPN"),
> > c("empl FTE", "FTEN"),
> > c("employees jobs", "EMPE"),
> > c("employees FTE", "FTEE"),
> > c("D1", "LABR"),
> > c("D11", "WAGE"),
> > c("D29-D39", "OTXS"),
> > c("D29 nom", "D29 nom"),
> > c("D39 nom", "D39 nom"),
> > c("P51c nom", "CFCC"),
> > c("B2n+B3n", "NOPS"),
> > c("total hours worked", "HRNS"),
> > c("hours worked employees", "HRSE"))
> >
> > Thanks again,
> > best,
> > Bo
> >
> > On Fri, Oct 9, 2015 at 12:22 PM, Thierry Onkelinx <
> > thierry.onkel...@inbo.be> wrote:
> >
> >> Dear Bo,
> >>
> >> I think that you are looking for dput()
> >>
> >> Best regards,
> >>
> >> ir. Thierry Onkelinx
> >> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> >> and Forest
> >> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> >> Kliniekstraat 25
> >> 1070 Anderlecht
> >> Belgium
> >>
> >> To call in the statistician after the experiment is done may be no more
> >> than asking him to perform a post-mortem examination: he may be able to
> say
> >> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> >> The plural of anecdote is not data. ~ Roger Brinner
> >> The combination of some data and an aching desire for an answer does not
> >> ensure that a reasonable answer can be extracted from a given body of
> data.
> >> ~ John Tukey
> >>
> >> 2015-10-09 11:55 GMT+02:00 Bo Werth :
> >>
> >>> Dear all,
> >>>
> >>> this is my first message to this mailing list - please advise if it is
> >>> not
> >>> the right place for the subject
> >>>
> >>> I've been using R very intensively the last 3-4 years and one of the
> most
> >>> tedious tasks is modification of lookup or conversion tables
> >>>
> >>> So far, I have not found functions that create the commands for
> creating
> >>> objects (vectors, data frames) based on the objects themselves - i.e.
> to
> >>> reverse-engineer them.
> >>>
> >>> Here are my suggestions:
> >>>
> >>> c_rev <- function(x) cat(paste0('c("', gsub(', ', '", "', toString(x)),
> >>> '")\n'))
> >>>
> >>> df_rev <- function(x) {
> >>> X <- apply(x, 1,
> >>>function(x) {
> >>>paste0('c(',
> >>>   paste0(shQuote(x), collapse = ", "),
> >>>   ')'
> >>>   )
> >>>}
> >>>)
> >>> command <- paste0(
> >>> 'rbind.data.frame(',
> >>> paste0(
> >>> X,
> >>> collapse = ",\n"),
> >>> ')')
> >>> return(cat(command, "\n"))
> >>> }
> >>>
> >>> Bo
> >>>
> >>> ---
> >>> bowerth.github.io
> >>>
> >>> [[alternative HTML version deleted]]
> >>>
> >>> 

Re: [Rd] R 3.2.2 64 bit compilation error on AIX

2015-10-09 Thread Vinh Nguyen
On Oct 8, 2015 11:36 PM, "Martin Maechler" 
wrote:
>
> > Vinh Nguyen 
> > on Thu, 8 Oct 2015 20:21:32 -0700 writes:
>
> > Ahh, sorry for not googling the error message.  Found
> > [this](
http://r.789695.n4.nabble.com/Error-compiling-R-2-10-1-on-AIX-td1017862.html
)
> > post that suggests modifying /src/extra/tre/tre-internal.h
> > (
https://r-forge.r-project.org/scm/viewvc.php/patches/aix_R210_tre.patch?view=markup&root=aix
)
> > for AIX 64 bit.
>
> > Is it possible to add this information to the AIX section
> > of the R-admin manual?  Thanks.
>
> Actually, I think we (R Core) should just apply that patch to the
>  R/src/extras/tre/ sources.

That sould be even better!

>
> But this does not seem to be related to your original problem
> where compilation stopped during tools package building,
> or does it ?

Yes, the patch did fix the error where the tools package was building. It
also fixed it for [others](
http://r.789695.n4.nabble.com/Error-compiling-R-2-10-1-on-AIX-td1017862.html
).

Thanks.

[[alternative HTML version deleted]]

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


[Rd] Improvement of R_orderVector() via orderVector1()

2015-10-09 Thread Marius Hofert
Hi,

I think R_orderVector() can be improved by calling orderVector1() if
possible. In a problem we had, this gave us a run time improvement
factor of 4 so my hope is that this can be included. Below is the
suggested change, I'm just not 100% sure if the test "CDR(arglist) ==
R_NilValue" is good...

Cheers,
Marius

void R_orderVector(int *indx, // must be pre-allocated to length >= n
   int n,
   SEXP arglist, // <- e.g.  Rf_lang2(x,y)
   Rboolean nalast, Rboolean decreasing)
{
// idx[] <- 0:(n-1) :
for(int i = 0; i < n; i++) indx[i] = i;
if(CDR(arglist) == R_NilValue) {
orderVector1(indx, n, CAR(arglist), nalast, decreasing, R_NilValue);
} else {
orderVector(indx, n, arglist, nalast, decreasing, listgreater);
}
return;
}

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


Re: [Rd] reverse object creation

2015-10-09 Thread Thierry Onkelinx
Dear Bo,

Please keep the mailing list in cc.

Your function only works properly with a data.frame in which all variables
are characters. dput() will preserve the structure of the object and works
with all R objects.

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-10-09 12:32 GMT+02:00 Bo Werth :

> Dear Thierry,
>
> many thanks for the hint - indeed, I wasn't aware of dput() - it is doing
> something close to what I was looking for -
> the only issue with the result for data frames is that it becomes
> difficult to see the row association:
>
> dput returns
>
> structure(list(sheet = c("output cup", "output coppy", "gross value added
> cup",
> "gross value added coppy", "GFCF cup", "GFCF vol", "empl jobs",
> "empl FTE", "employees jobs", "employees FTE", "D1", "D11", "D29-D39",
> "D29 nom", "D39 nom", "P51c nom", "B2n+B3n", "total hours worked",
> "hours worked employees"), var = c("PROD", "PKPY", "VALU", "VKPY",
> "GFCF", "GKPY", "EMPN", "FTEN", "EMPE", "FTEE", "LABR", "WAGE",
> "OTXS", "D29 nom", "D39 nom", "CFCC", "NOPS", "HRNS", "HRSE")), .Names =
> c("sheet",
> "var"), row.names = c(NA, -19L), class = "data.frame")
> >
>
> df_rev returns
>
> rbind.data.frame(c("output cup", "PROD"),
> c("output coppy", "PKPY"),
> c("gross value added cup", "VALU"),
> c("gross value added coppy", "VKPY"),
> c("GFCF cup", "GFCF"),
> c("GFCF vol", "GKPY"),
> c("empl jobs", "EMPN"),
> c("empl FTE", "FTEN"),
> c("employees jobs", "EMPE"),
> c("employees FTE", "FTEE"),
> c("D1", "LABR"),
> c("D11", "WAGE"),
> c("D29-D39", "OTXS"),
> c("D29 nom", "D29 nom"),
> c("D39 nom", "D39 nom"),
> c("P51c nom", "CFCC"),
> c("B2n+B3n", "NOPS"),
> c("total hours worked", "HRNS"),
> c("hours worked employees", "HRSE"))
>
> Thanks again,
> best,
> Bo
>
> On Fri, Oct 9, 2015 at 12:22 PM, Thierry Onkelinx <
> thierry.onkel...@inbo.be> wrote:
>
>> Dear Bo,
>>
>> I think that you are looking for dput()
>>
>> Best regards,
>>
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
>> and Forest
>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>> Kliniekstraat 25
>> 1070 Anderlecht
>> Belgium
>>
>> To call in the statistician after the experiment is done may be no more
>> than asking him to perform a post-mortem examination: he may be able to say
>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>> The plural of anecdote is not data. ~ Roger Brinner
>> The combination of some data and an aching desire for an answer does not
>> ensure that a reasonable answer can be extracted from a given body of data.
>> ~ John Tukey
>>
>> 2015-10-09 11:55 GMT+02:00 Bo Werth :
>>
>>> Dear all,
>>>
>>> this is my first message to this mailing list - please advise if it is
>>> not
>>> the right place for the subject
>>>
>>> I've been using R very intensively the last 3-4 years and one of the most
>>> tedious tasks is modification of lookup or conversion tables
>>>
>>> So far, I have not found functions that create the commands for creating
>>> objects (vectors, data frames) based on the objects themselves - i.e. to
>>> reverse-engineer them.
>>>
>>> Here are my suggestions:
>>>
>>> c_rev <- function(x) cat(paste0('c("', gsub(', ', '", "', toString(x)),
>>> '")\n'))
>>>
>>> df_rev <- function(x) {
>>> X <- apply(x, 1,
>>>function(x) {
>>>paste0('c(',
>>>   paste0(shQuote(x), collapse = ", "),
>>>   ')'
>>>   )
>>>}
>>>)
>>> command <- paste0(
>>> 'rbind.data.frame(',
>>> paste0(
>>> X,
>>> collapse = ",\n"),
>>> ')')
>>> return(cat(command, "\n"))
>>> }
>>>
>>> Bo
>>>
>>> ---
>>> bowerth.github.io
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-devel@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>
>>
>

[[alternative HTML version deleted]]

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


Re: [Rd] reverse object creation

2015-10-09 Thread Thierry Onkelinx
Dear Bo,

I think that you are looking for dput()

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-10-09 11:55 GMT+02:00 Bo Werth :

> Dear all,
>
> this is my first message to this mailing list - please advise if it is not
> the right place for the subject
>
> I've been using R very intensively the last 3-4 years and one of the most
> tedious tasks is modification of lookup or conversion tables
>
> So far, I have not found functions that create the commands for creating
> objects (vectors, data frames) based on the objects themselves - i.e. to
> reverse-engineer them.
>
> Here are my suggestions:
>
> c_rev <- function(x) cat(paste0('c("', gsub(', ', '", "', toString(x)),
> '")\n'))
>
> df_rev <- function(x) {
> X <- apply(x, 1,
>function(x) {
>paste0('c(',
>   paste0(shQuote(x), collapse = ", "),
>   ')'
>   )
>}
>)
> command <- paste0(
> 'rbind.data.frame(',
> paste0(
> X,
> collapse = ",\n"),
> ')')
> return(cat(command, "\n"))
> }
>
> Bo
>
> ---
> bowerth.github.io
>
> [[alternative HTML version deleted]]
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

[[alternative HTML version deleted]]

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


[Rd] reverse object creation

2015-10-09 Thread Bo Werth
Dear all,

this is my first message to this mailing list - please advise if it is not
the right place for the subject

I've been using R very intensively the last 3-4 years and one of the most
tedious tasks is modification of lookup or conversion tables

So far, I have not found functions that create the commands for creating
objects (vectors, data frames) based on the objects themselves - i.e. to
reverse-engineer them.

Here are my suggestions:

c_rev <- function(x) cat(paste0('c("', gsub(', ', '", "', toString(x)),
'")\n'))

df_rev <- function(x) {
X <- apply(x, 1,
   function(x) {
   paste0('c(',
  paste0(shQuote(x), collapse = ", "),
  ')'
  )
   }
   )
command <- paste0(
'rbind.data.frame(',
paste0(
X,
collapse = ",\n"),
')')
return(cat(command, "\n"))
}

Bo

---
bowerth.github.io

[[alternative HTML version deleted]]

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


Re: [Rd] rank(, ties.method="last")

2015-10-09 Thread Martin Maechler

> I ran into a problem where I actually need rank(, ties.method="last"). It 
> would
> be great to have this feature in base and it's also simple to get (see below).

> Thanks & cheers,
> Marius


> rank2 <- function (x, na.last = TRUE, ties.method = c("average",
> "first", "last", # new "last"
> "random", "max", "min"))
> {
> nas <- is.na(x)
> nm <- names(x)
> ties.method <- match.arg(ties.method)
> if (is.factor(x))
> x <- as.integer(x)
> x <- x[!nas]
> y <- switch(ties.method, average = , min = , max = .Internal(rank(x,
> length(x), ties.method)), first = sort.list(sort.list(x)),
> last = sort.list(sort.list(x, decreasing=TRUE), decreasing=TRUE), # 
> change
> random = sort.list(order(x, stats::runif(sum(!nas)
> if (!is.na(na.last) && any(nas)) {
> yy <- NA
> NAkeep <- (na.last == "keep")
> if (NAkeep || na.last) {
> yy[!nas] <- y
> if (!NAkeep)
> yy[nas] <- (length(y) + 1L):length(yy)
> }
> else {
> len <- sum(nas)
> yy[!nas] <- y + len
> yy[nas] <- seq_len(len)
> }
> y <- yy
> names(y) <- nm
> }
> else names(y) <- nm[!nas]
> y
> }

> ## MWE
> x <- c(10, 11, 11, 12, 12, 13)
> rank(x, ties.method="first")
> rank2(x, ties.method="last")

Indeed, this makes sense to me, and is easy enough to document
and maintain, and preferable to asking useRs to use  rev(.) and
similar "easy" (but somewhat costly for large data!)
transformations to get the same

Or have (Marius Hofert and I) overlooked something obvious ?

Martin Maechler,
ETH Zurich

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