[R-pkg-devel] Browser Level for Conditional Function Parameter

2015-08-19 Thread Dario Strbenac
Good day,

Why do I get a debug message and a change in browser level when I inspect the 
title variable ? For the comparison variable, it simply prints its value and 
remains at level 1.

aFunction <- function(comparison = c("within", "classifier", "selection"),
  title = if(comparison[1] == "within") "Internal" else 
"Between")
{
browser()
require(ggplot2)
comparison <- match.arg(comparison)
ggplot(mtcars, aes(wt, mpg)) + geom_point() + ggtitle(title)
}

aFunction()

Browse[1]> title
debug at #4: [1] "Internal"
Browse[3]>

--
Dario Strbenac
PhD Student
University of Sydney
Camperdown NSW 2050
Australia
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Return Value of By Function

2015-09-14 Thread Dario Strbenac
Good day,

I am curious why the by function result has dimensions attached, even when it 
returns a list.

result <- by(warpbreaks[, 1],   warpbreaks[, -1], summary)
str(result)

List of 6
...
- attr(*, "dim")= int [1:2] 2 3
 - attr(*, "dimnames")=List of 2
  ..$ wool   : chr [1:2] "A" "B"
  ..$ tension: chr [1:3] "L" "M" "H"

Also, why does looking at the top of the list remove the names ?

> head(result, 3)
[[1]]
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
  25.00   26.00   51.00   44.56   54.00   70.00 

[[2]]
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
  14.00   20.00   29.00   28.22   31.00   44.00 

[[3]]
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
 12  18  21  24  30  36

Compared to :

> result
wool: A
tension: L
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
  25.00   26.00   51.00   44.56   54.00   70.00 
...

I can't tell which list entry is for which combination of factors, after it is 
accessed. It would be great if it was easier to get the factor levels used for 
each list element, perhaps as a data.frame.

--
Dario Strbenac
PhD Student
University of Sydney
Camperdown NSW 2050
Australia

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


[R-pkg-devel] Formals of S4 Function

2015-09-30 Thread Dario Strbenac
Good day,

Is it still planned that there will be a new method for determining formals 
implemented for R 3.3 or enhancing the current formals method to work 
seamlessly on S4 functions ?  
http://r.789695.n4.nabble.com/Q-Get-formal-arguments-of-my-implemented-S4-method-td4702420.html
 I am currently developing a package and one of my design choices would be 
based on the near-term availability of this feature.

--
Dario Strbenac
PhD Student
University of Sydney
Camperdown NSW 2050
Australia
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Rd File Line Widths Not Suggested in Manual

2017-11-21 Thread Dario Strbenac
Good day,

I often notice that some lines of code in many PDF manuals generated for CRAN 
packages run off the page. Perhaps the maximum number of characters per line 
should be stated in section 2.16 of Writing R Extensions. It would help package 
authors like me write better Rd files.

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia

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


Re: [R-pkg-devel] Problem enhancing a package with a predict method not declared to be an S3 method

2017-12-17 Thread Dario Strbenac
Good day,

It seems that they are not internal functions if they are have user 
documentation written for them. Internal functions usually don't have a help 
page.

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Concise Summary For Any Variety Of R Function

2021-10-19 Thread Dario Strbenac
Good day,

I would like to create a concise show method for an S4 class that I am 
developing. One class slot stores a function specified by the end user. It 
could be a basic function, an S3 function, an S4 function. For S4 functions, I 
can get a concise representation:

> capture.output(showMethods(limmaSelection))[1]
[1] "Function: limmaSelection (package ClassifyR)"

If the user specified the function bdiag from Matrix, how could I generalise 
the show code to describe the function, such that the output would be "Function 
bdiag from package Matrix" and simiarly for an S3 function?

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] S4 Methods and Ellipsis Formals

2021-11-17 Thread Dario Strbenac
Good day,

I read in the documentation of SetMethod that "Roughly, if the generic has ... 
as one of its arguments, then the method may have extra formal arguments, which 
will be matched from the arguments matching ... in the call to f." I was hoping 
that ellipsis could be also part of a method because this explanation doesn't 
explicitly rule it out. What I am hoping to do is:

setGeneric("Example", function(x, ...) standardGeneric("Example"))
setMethod("Example", "numeric", function(x, y, ...) as.list(...))
Example(x = 1, y = 2, z = 3, a = 99) # Error in typeof(x) : argument "x" is 
missing, with no default

So, ellipsis can't be a formal of a method, but only in the generic? May this 
be clarified by the documentation?

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Identify Original Column Names of Model Matrix

2022-10-10 Thread Dario Strbenac
Good day,

I am developing a wrapper around xgboost which does not (yet - I see that it is 
on the developer's version 2.0 task list) support factor variable type. It 
requires input data to be in one-hot encoding, which is created by 
Matrix::sparse.model.matrix. For further analysis, such as variable importance, 
is there a way to identify which original feature each column of a 
sparse.model.matrix result was derived from? Using str(oneHotMatrix), I don't 
see any class slots nor tacked-on attributes which would confidently allow the 
identification of original column names of the expanded input data. Is there an 
alternative way to robustly identify the original variable names?

------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] vapply and More Complex FUN.VALUE

2023-09-26 Thread Dario Strbenac
Good day,

Is it possible to somehow specify more complex return types, such as a 
data.frame with specific columns?

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Alignment of Function Arguments For PDF Manual and HTML

2018-02-28 Thread Dario Strbenac
Good day,

If I have a function definition in the Usage section of an R documentation file 
(file name ending in .Rd) that requires two or more lines to specify, can I 
format it so that the first letter of the first variable on the second and 
subsequent lines is aligned with the opening bracket of the function in the PDF 
manual created by R CMD Rd2pdf and has the same appearance in the HTML page 
shown in RStudio? I notice that if I align the text for a particular output 
format, it doesn't look aligned in the other. The package I am developing is a 
part of Bioconductor, so I can't modify options to Rd2pdf.

------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia

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


Re: [R-pkg-devel] Alignment of Function Arguments For PDF Manual and HTML

2018-03-01 Thread Dario Strbenac
Good day,

The difference in position doesn't change if the HTML page is resized so it 
seems as if the width of the font is different. I agree that alignment would be 
easy in most cases but it's not as simple to align the elements if using 
\S4method{aFunction}{aType}. I suppose I'll ensure that the PDF and terminal 
help appears aligned in favour of the HTML version.

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Warnings if Carriage Returns in Code Elements of R Documentation

2018-03-05 Thread Dario Strbenac
Good day,

The package checking software emits a warning if \cr is used inside \code. The 
reason I'd like to do that is to avoid a S4 constructor specification being 
limited to one line and running off the side of the PDF page of the PDF manual, 
as happens by default. The style of the documentation which I wrote is:

\section{Constructor}{
  \describe{
\item{}{
  \code{DataClass(parameter1, parameter2, parameter3, parameter4,\cr
parameter5, parameter6)
}
}
}  \describe{
\item{\code{parameter1}}{A description of the requirements of the 
first parameter.}
   }
}

How can wrapping be forced without causing a warning during checking?

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia

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


[R-pkg-devel] Documentation Cross-reference Unexpected Warning

2018-05-12 Thread Dario Strbenac
Good day,

If limma has already been installed, such as by

source("https://bioconductor.org/biocLite.R";)
biocLite("limma")

and the attached minimalist R package is built and checked, a warning is 
emitted about the cross-reference in the documentation file. The Writing R 
Extensions manual states that the [packageName] specifier would only be needed 
to "... refer to not-yet-installed packages ..." but in this case, limma is 
already installed and is in the library path. Is the warning a false positive? 
I am using the latest release of R.

* using R version 3.5.0 (2018-04-23)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8

------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia


Tester.tar.gz
Description: Tester.tar.gz
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Documentation Cross-reference Unexpected Warning

2018-05-13 Thread Dario Strbenac
Good day,

That form solves it, but there's nothing in the Cross-references secion of the 
manual which suggests that it is necessary.

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia

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


[R-pkg-devel] Function Overloading of S4 Methods

2019-05-09 Thread Dario Strbenac
Good day,

Some programming languages, such as C++, allow function overloading. Is it 
possible to mimic it when creating S4 methods?

An example from an undergraduate text book is:

int largerInt(int x, int y);
char largerChar(char first, char second);

You can write the previous function prototypes simply as

int larger(int x, int y);
char larger(char first, char second);

Conversely, it does not seen to be possible to use different formal argument 
names for a S4 generic, unless I don't know about some obscure trick to do it.

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia

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


Re: [R-pkg-devel] Function Overloading of S4 Methods

2019-05-18 Thread Dario Strbenac
Good day,

Your conclusion seems to be different to the details you discussed. Don't you 
intend to conclude that it's not possible with an S4 generic to define methods 
with different argument names which is different to a language such as C++?

------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Maintainer a Group

2019-06-25 Thread Dario Strbenac
Good day,

What about the CRAN package Rmixmod? Its contact address is a mailing list and 
its status is Orphaned. It seems that the mailing list e-mail address was not 
detected during review of the recently updated version. I hope that this can 
systematically be prevented in other package submissions.

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel