Re: [Rd] [External] Re: Segfault when parsing UTF-8 text with srcrefs

2024-05-30 Thread Barry Rowlingson
I get an R error and no segfault:

> parse(textConnection(text), srcfile = srcfile)
Error in parse(textConnection(text), srcfile = srcfile) :
  test.r:1:1: unexpected $end
1: ×
^

This is R 4.3.0, so maybe the bug has been introduced since then...

Version and system info:

> version
   _
platform   x86_64-pc-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status
major  4
minor  3.0
year   2023
month  04
day21
svn rev84292
language   R
version.string R version 4.3.0 (2023-04-21)
nickname   Already Tomorrow

> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;
 LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8
 [5] LC_MONETARY=en_GB.UTF-8LC_MESSAGES=en_GB.UTF-8
 [7] LC_PAPER=en_GB.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

time zone: Europe/London
tzcode source: system (glibc)

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

loaded via a namespace (and not attached):
[1] compiler_4.3.0

On Tue, May 28, 2024 at 7:42 PM Tomas Kalibera 
wrote:

> This email originated outside the University. Check before clicking links
> or attachments.
>
> On 5/28/24 19:35, Hadley Wickham wrote:
> > Hi all,
> >
> > When I run the following code, R segfaults:
> >
> > text <- "×"
> > srcfile <- srcfilecopy("test.r", text)
> > parse(textConnection(text), srcfile = srcfile)
> >
> > It doesn't segfault if text is ASCII, or it's not wrapped in
> > textConnection, or srcfile isn't set.
>
> Thanks, this is because R parser doesn't support non-ASCII UTF-8 outside
> string literals and comments, plus a missing bounds check. The "correct"
> result should be an R error, which I get in a debug build.
>
> The tokenizer ends up with a negative token and then when the parse data
> are being finalized, creating a table of token names, there is an out of
> bounds access (yytname array). Probably the check should go right away
> into the tokenizer.
>
> Tomas
>
> >
> > Hadley
> >
>
> __
> 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] [External] Re: R for the US Air Force

2024-05-18 Thread Barry Rowlingson
>  that's not strictly true though is it? Anyone can form a company and
> supply R, as long as everyone complies with the license. You are also free
> to download R from public services and do it without any corporate
> wrappings and trappings, which is what Posit (ex-RStudio) do, right?
>
>
[correction for clarity: I mean Posit *do* supply R with corporate
"wrappings and trappings" (whatever they are), the logic may have got
twisted there in edits]

B

[[alternative HTML version deleted]]

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


Re: [Rd] [External] Re: R for the US Air Force

2024-05-18 Thread Barry Rowlingson
R is not a product that is provided by a company or any vendor that can be
> procured through a vendor e.g. something on a GSA schedule.
>
>
 that's not strictly true though is it? Anyone can form a company and
supply R, as long as everyone complies with the license. You are also free
to download R from public services and do it without any corporate
wrappings and trappings, which is what Posit (ex-RStudio) do, right?


> Seems like you're caught in the bureaucracy hell hole. I used to help the
> USAF, and other DoD members use R when I was at RStudio (now Posit).
>

I don't see anything in the PDF posted that links the software to the
company details required. Does it have to be the copyright holder of the
software? Or anyone free to distribute it by license? Does the USAF use
other open source systems, eg Linux, in which case are they going through a
licensed reseller to tick these boxes?

Barry


>
> On Thu, May 16, 2024 at 2:57 PM ADAMS, DOUGLAS L CIV USAF AFMC OO-ALC/OBWA
> via R-devel  wrote:
>
> > Hello,
> >
> >
> >
> > The US Air Force used to have R available on our main network, but now
> > those who need to accept it back are
> > being very particular about what they're accepting in terms of official
> > documentation.
> >
> >
> >
> > Would you be able to help me with this endeavor?  I'm attaching a pdf
> that
> > shows what documentation they'd
> > require for us to re-establish R as being acceptable on the network here.
> > I understand if you're too busy or
> > if it's a pain.  Haha
> >
> >
> >
> > Thank you so much for your help and consideration!
> >
> >
> >
> > Doug Adams
> >
> > United States Air Force
> >
> > Hill AFB, Utah
> >
> >
> >
> > __
> > 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
>

[[alternative HTML version deleted]]

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


[Rd] R6 "classname" and generator name

2024-03-11 Thread Barry Rowlingson
I'm writing some code that does a bit of introspection of R6 classes and am
wondering about the "classname" parameter. Its the first parameter to the
"R6Class" class generator generator function, and the few examples I've
looked at on CRAN set it the same as the name of the generator function,
for example, from the docs:

Queue <- R6Class("Queue", .)

but this isn't mandatory, it can be anything. Or NULL. (side quest: do
linters exist that flag this as bad style?).

Does anyone have an example of a CRAN package where this isn't the case? Or
even where an R6 class generator uses the default "NULL" for its classname
parameter? My introspection code is in two minds whether to use the
classname to label diagrams of classes, or to use the names of the actual
generator functions (which are what the package users should be using), or
show both if different, or flag up NULL values etc...

Never should have opened this can of worms. I don't even like worms.

Barry

[[alternative HTML version deleted]]

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


Re: [Rd] [External] Re: capture "->"

2024-03-04 Thread Barry Rowlingson
It seems like you want to use -> and <- as arrows with different meanings
to "A gets the value of B" in your package, as a means of writing
expressions in your package language.

Another possibility would be to use different symbols instead of the
problematic -> and <-, for example you could use <.~ and ~.> which are not
at all flipped or changed before you get a chance to parse your expression.
It might make your language parser a bit trickier though. Let's see how
these things turn into R's AST using `lobstr`:

 > library(lobstr)
 > ast(A ~.> B)
█─`~`
├─A
└─█─`>`
  ├─.
  └─B
 > ast(A <.~ B)
█─`~`
├─█─`<`
│ ├─A
│ └─.
└─B

You'd have to unpick that tree to figure out you've got A and B on either
side of your expression, and that the direction of the expression is L-R or
R-L.

You could also use -.> and <.- symbols, leading to a different tree

 > ast(A -.> B)
█─`>`
├─█─`-`
│ ├─A
│ └─.
└─B
 > ast(A <.- B)
█─`<`
├─A
└─█─`-`
  ├─.
  └─B

Without knowing the complexity of your language expressions (especially if
it allows dots and minus signs with special meanings) I'm not sure if A)
this will work or B) this will bend your brain in horrible directions in
order to make it work... Although you don't need to parse the AST as above,
you can always deparse to get the text version of it:

 > textex = function(x){deparse(substitute(x))}
 > textex(A <.~ B)
[1] "A < . ~ B"

The <.~ form has an advantage over the <.- form if you want to do complex
expressions with more than one arrow, since the ~ form is syntactically
correct but the - form isnt:

 > textex(A <.~ B ~.> C)
[1] "A < . ~ B ~ . > C"
 > textex(A <.- B -.> C)
Error: unexpected '>' in "textex(A <.- B -.>"


Barry


On Sun, Mar 3, 2024 at 12:25 PM Dmitri Popavenko 
wrote:

> This email originated outside the University. Check before clicking links
> or attachments.
>
> On Sat, Mar 2, 2024 at 7:58 PM Gabor Grothendieck  >
> wrote:
>
> > Would it be good enough to pass it as a formula?  Using your definition
> of
> > foo
> >
> >   foo(~ A -> result)
> >   ## result <- ~A
> >
> >   foo(~ result <- A)
> >   ## ~result <- A
> >
>
> Yes, to pass as a formula would be the idea.
> It's just that the parser inverses "~A -> result" into "result <- ~A".
> We are seeking for any way possible to flag this inversion.
>
> Avi, thank you for your efforts too. Wrapping symbols into percent signs is
> an option, but as Duncan says it is much more intuitive to just quote the
> expression.
> The challenge is to somehow flag the parser inversion, otherwise a quoted
> expression seems to be the only solution possible.
>
> Regards,
> Dmitri
>
> [[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] [External] Re: zapsmall(x) for scalar x

2023-12-17 Thread Barry Rowlingson
I think what's been missed is that zapsmall works relative to the absolute
largest value in the vector. Hence if there's only one
item in the vector, it is the largest, so its not zapped. The function's
raison d'etre isn't to replace absolutely small values,
but small values relative to the largest. Hence a vector of similar tiny
values doesn't get zapped.

Maybe the line in the docs:

" (compared with the maximal absolute value)"

needs to read:

" (compared with the maximal absolute value in the vector)"

Barry





On Sun, Dec 17, 2023 at 2:17 PM Duncan Murdoch 
wrote:

> This email originated outside the University. Check before clicking links
> or attachments.
>
> I'm really confused.  Steve's example wasn't a scalar x, it was a
> vector.  Your zapsmall() proposal wouldn't zap it to zero, and I don't
> see why summary() would if it was using your proposal.
>
> Duncan Murdoch
>
> On 17/12/2023 8:43 a.m., Gregory R. Warnes wrote:
> > Isn’t that the correct outcome?  The user can change the number of
> digits if they want to see small values…
> >
> >
> > --
> > Change your thoughts and you change the world.
> > --Dr. Norman Vincent Peale
> >
> >> On Dec 17, 2023, at 12:11 AM, Steve Martin 
> wrote:
> >>
> >> Zapping a vector of small numbers to zero would cause problems when
> >> printing the results of summary(). For example, if
> >> zapsmall(c(2.220446e-16, ..., 2.220446e-16)) == c(0, ..., 0) then
> >> print(summary(2.220446e-16), digits = 7) would print
> >>Min. 1st Qu.  MedianMean 3rd Qu.Max.
> >> 0  00   0   0  0
> >>
> >> The same problem can also appear when printing the results of
> >> summary.glm() with show.residuals = TRUE if there's little dispersion
> >> in the residuals.
> >>
> >> Steve
> >>
> >>> On Sat, 16 Dec 2023 at 17:34, Gregory Warnes  wrote:
> >>>
> >>> I was quite suprised to discover that applying `zapsmall` to a scalar
> value has no apparent effect.  For example:
> >>>
>  y <- 2.220446e-16
>  zapsmall(y,)
> >>> [1] 2.2204e-16
> >>>
> >>> I was expecting zapsmall(x)` to act like
> >>>
>  round(y, digits=getOption('digits'))
> >>> [1] 0
> >>>
> >>> Looking at the current source code, indicates that `zapsmall` is
> expecting a vector:
> >>>
> >>> zapsmall <-
> >>> function (x, digits = getOption("digits"))
> >>> {
> >>> if (length(digits) == 0L)
> >>> stop("invalid 'digits'")
> >>> if (all(ina <- is.na(x)))
> >>> return(x)
> >>> mx <- max(abs(x[!ina]))
> >>> round(x, digits = if (mx > 0) max(0L, digits -
> as.numeric(log10(mx))) else digits)
> >>> }
> >>>
> >>> If `x` is a non-zero scalar, zapsmall will never perform rounding.
> >>>
> >>> The man page simply states:
> >>> zapsmall determines a digits argument dr for calling round(x, digits =
> dr) such that values close to zero (compared with the maximal absolute
> value) are ‘zapped’, i.e., replaced by 0.
> >>>
> >>> and doesn’t provide any details about how ‘close to zero’ is defined.
> >>>
> >>> Perhaps handling the special when `x` is a scalar (or only contains a
> single non-NA value)  would make sense:
> >>>
> >>> zapsmall <-
> >>> function (x, digits = getOption("digits"))
> >>> {
> >>> if (length(digits) == 0L)
> >>> stop("invalid 'digits'")
> >>> if (all(ina <- is.na(x)))
> >>> return(x)
> >>> mx <- max(abs(x[!ina]))
> >>> round(x, digits = if (mx > 0 && (length(x)-sum(ina))>1 ) max(0L,
> digits - as.numeric(log10(mx))) else digits)
> >>> }
> >>>
> >>> Yielding:
> >>>
>  y <- 2.220446e-16
>  zapsmall(y)
> >>> [1] 0
> >>>
> >>> Another edge case would be when all of the non-na values are the same:
> >>>
>  y <- 2.220446e-16
>  zapsmall(c(y,y))
> >>> [1] 2.220446e-16 2.220446e-16
> >>>
> >>> Thoughts?
> >>>
> >>>
> >>> Gregory R. Warnes, Ph.D.
> >>> g...@warnes.net
> >>> Eternity is a long time, take a friend!
> >>>
> >>>
> >>>
> >>> [[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
>
> __
> 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] [External] subfolders in the R folder

2023-03-28 Thread Barry Rowlingson
The "good reason" is all the tooling in R doesn't work with subfolders and
would have to be rewritten. All the package check and build stuff. And
that's assuming you don't want to change the basic flat package structure -
for example to allow something like `library(foo)` to attach a package and
`library(foo.bar)` to attach some subset of package `foo`. That would
require more changes of core R package and namespace code.

As a workaround, you could implement a hierarchical structure in your file
*names*. That's what `ggplot2` does with its (...downloads tarball...) 192
files in its R folder. Well mostly, there's a load of files called
annotation- and geom- and plot- and position- and stat- etc etc. No reason
why you can't have multiple "levels" separated with "-" as you would have
multiple folder levels separated with "/". You can then do `ls geom-*` to
see the `geom` "folder" and so on (on a unix shell).

And then when R Core receive a patch that implements subfolders, a quick
shell script will be able to create the hierarchy for you and drop all the
files in the right place.

One reason for the flat folder structure may be that R's packages
themselves have no structure to the functions - compare with Python where
modules can have subfolders and functions in subfolders can be access with
module.subfolder.subsub.foo(x), and module subfolders can be imported etc.
The whole module ecosystem was designed with structure in mind.

I don't think there's any restriction on subfolders in the "inst" folder of
a package so if you have scripts you can arrange them there.

Given that most of my students seem to keep all their 23,420 files in one
folder called "Stuff" I think we can manage like this for a bit longer.

B



On Tue, Mar 28, 2023 at 4:43 PM Antoine Fabri 
wrote:

> This email originated outside the University. Check before clicking links
> or attachments.
>
> Dear R-devel,
>
> Packages don't allow for subfolders in R with a couple exceptions. We find
> in "Writing R extensions" :
>
> > The R and man subdirectories may contain OS-specific subdirectories named
> unix or windows.
>
> This is something I've seen discussed outside of the mailing list numerous
> times, and thanks to this SO question
>
> https://stackoverflow.com/questions/14902199/using-source-subdirectories-within-r-packages-with-roxygen2
> I could find a couple instances where this was discussed here as well,
> apologies if I missed later discussions :
>
> * https://stat.ethz.ch/pipermail/r-devel/2009-December/056022.html
> * https://stat.ethz.ch/pipermail/r-devel/2010-February/056513.html
>
> I don't see a very compelling conclusion, nor a justification for the
> behavior, and I see that it makes some users snarky (second link is an
> example), so let me make a case.
>
> This limitation is an annoyance for bigger projects where we must choose
> between having fewer files with too many objects defined (less structure,
> more scrolling), or to have too many scripts, often with long prefixed
> names to emulate essentially what folders would do. In my experience this
> creates confusion, slows down the workflow, makes onboarding or open source
> contributions on a new project harder (where do we start ?), makes dead
> code easier to happen, makes it harder to test the rights things etc...
>
> It would seem to me, but I might be naive, that it'd be a quick enough fix
> to flatten the R folders not named "unix" or "windows"  when building the
> package. Is there a good reason why we can't do that ?
>
> Thanks,
>
> Antoine
>
> PS:
> Other SO Q:
> https://stackoverflow.com/questions/33776643/subdirectory-in-r-package
>
> https://stackoverflow.com/questions/18584807/code-organisation-in-r-package-development
>
> [[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] attach "warning" is a message

2021-08-09 Thread Barry Rowlingson
If I mask something via `attach`:

> d = data.frame(x=1:10)
> x=1
> attach(d)
The following object is masked _by_ .GlobalEnv:

x
>

I get that message. The documentation for `attach` uses the phrase
"warnings", although the message isn't coming from `warning()`:

warn.conflicts: logical.  If ‘TRUE’, warnings are printed about
  ‘conflicts’ from attaching the database, unless that database
  contains an object ‘.conflicts.OK’.  A conflict is a function
  masking a function, or a non-function masking a non-function.

and so you can't trap them with options(warn=...) and so on. This sent me
briefly down the wrong track while trying to figure out why R was showing a
masking error in one context but not another - I wondered if I'd supressed
warning()s in the other context.

Personally I'd like these messages to be coming from warning() since that
seems the appropriate way to warn someone they've done something which
might have unwanted effects. But fixing the documentation to say "If
‘TRUE’, *messages* are printed" is probably less likely to break existing
code.

Happy to add something to bugzilla if anyone thinks I'm not being overly
pedantic here.

Barry

[[alternative HTML version deleted]]

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


Re: [Rd] Making R CMD nicer

2019-07-01 Thread Barry Rowlingson
If you write a lot of R code to run as command line scripts then look at
Dirk E's "littler":

$ r --help

Usage: r [options] [-|file]

Launch GNU R to execute the R commands supplied in the specified file, or
from stdin if '-' is used. Suitable for so-called shebang '#!/'-line
scripts.

Options:
  -h, --help   Give this help list
  --usage  Give a short usage message
  -V, --versionShow the version number
  -v, --vanillaPass the '--vanilla' option to R
  -t, --rtemp  Use per-session temporary directory as R does
  -i, --interactiveLet interactive() return 'true' rather than 'false'
  -q, --quick  Skip autoload / delayed assign of default libraries
  -p, --verbosePrint the value of expressions to the console
  -l, --packages list  Load the R packages from the comma-separated 'list'
  -d, --datastdin  Prepend command to load 'X' as csv from stdin
  -L, --libpath dirAdd directory to library path via '.libPaths(dir)'
  -e, --eval expr  Let R evaluate 'expr'

available from an archive near you...


On Mon, Jul 1, 2019 at 8:58 AM Jason Xu  wrote:

> In my humble personal opinion, I try to avoid bash scripts longer than a
> couple lines because I find the syntax so obtuse and unintuitive it's
> difficult to maintain and write less buggy code. But that is mostly a
> reflection of my personal inexperience.
> I think the only time a bash script is really needed is for maximum
> portability in systems _with bash_.
> (I would use python for a wrapper in personal projects, given python comes
> pre-installed on many linux systems and OS X, but I completely understand
> not wanting to burden Windows users with an extra python dependency to
> install.)
>
>
>
>
>
> On Sun, Jun 30, 2019 at 8:08 PM Abby Spurdle  wrote:
>
> > In that case, I was wrong.
> > And I must apologize...
> >
> > In saying that, good to see Windows out performing Linux on the command
> > line...
> >
> >
> > On Mon, Jul 1, 2019 at 11:30 AM Gábor Csárdi 
> > wrote:
> > >
> > > For the record, this is Linux R-devel:
> > >
> > > root@4bef68c16864:~# R CMD
> > > /opt/R-devel/lib/R/bin/Rcmd: 60: shift: can't shift that many
> > > root@4bef68c16864:~# R CMD -h
> > > /opt/R-devel/lib/R/bin/Rcmd: 62: exec: -h: not found
> > > root@4bef68c16864:~# R CMD --help
> > > /opt/R-devel/lib/R/bin/Rcmd: 62: exec: --help: not found
> > >
> > > This is R-release on macOS:
> > >
> > > ❯ R CMD
> > > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62:
> > > /Library/Frameworks/R.framework/Resources/bin/: is a directory
> > > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec:
> > > /Library/Frameworks/R.framework/Resources/bin/: cannot execute:
> > > Undefined error: 0
> > > ❯ R CMD -h
> > > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: -h:
> > > invalid option
> > > exec: usage: exec [-cl] [-a name] file [redirection ...]
> > > ❯ R CMD --help
> > > /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: --:
> > > invalid option
> > > exec: usage: exec [-cl] [-a name] file [redirection ...]
> > >
> > > On Windows you indeed get a useful list of commands and more helpful
> > tips.
> > >
> > > Gabor
> > >
> > >
> > > On Sun, Jun 30, 2019 at 11:36 PM Abby Spurdle 
> > wrote:
> > > >
> > > > > First time posting in the R mailing lists so hopefully this works
> > well.
> > > > > I noticed when I type `R CMD` I get this unhelpful message:
> > > > > /usr/lib/R/bin/Rcmd: 60: shift: can't shift that many
> > > >
> > > > I wasn't able to reproduce this.
> > > > Maybe it's a Linux thing.
> > > > But then, I suspect you've omitted some of your input.
> > > >
> > > > > I also think it would be nice if `R CMD help` showed the usable
> > commands.
> > > >
> > > > What do you mean...
> > > > All of the following give you the "usable commands":
> > > >
> > > > > R CMD
> > > > > R CMD -h
> > > > > R CMD --help
> > > >
> > > > [[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
>

[[alternative HTML version deleted]]

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


Re: [Rd] bugs in head() and tail()

2019-03-28 Thread Barry Rowlingson
On Wed, Mar 27, 2019 at 1:52 AM Abs Spurdle  wrote:

>
> In the case of head.default(), it assumes that the object is a vector, or
> something similar.
>

No it doesn't. It assumes (ultimately) that x[seq_len(n)] is the correct
way to generate a "head" of something. Which is reasonable. That's
dependent on the implementation of the `[` method on object `x`.


> Resulting in the error above, which fails to recognize that the input was
> unsuitable.
>
> Because the object you fed it didn't have a method for `head` or for `[`.
Its the object designer's responsibility to do that. And by creating a
function that doesn't have the "function" class - that means *you*.

There's no way that head.default can inspect everything it might get fed,
including classes that have yet to be made, to see if it can do anything
meaningful with it. So it uses what looks like a reasonable approach -
apply `[` on the object with the first `n` elements. Let the class decide
what to do with it.

You might think generics should trap errors and give meaningful errors, but
the error isn't in the generic here - its in the `[` method of the class it
was fed. `head` doesn't know or care about that - again, its the class
designers responsibility to handle that, and the users responsibility to
*not* call generics on objects for which there's no meaningful behaviour.
It's really the error message of `[.default` seeming obscure to you that is
your issue here. If it said "cannot create subsets of this object with ["
would that please you? Again, that's not a bug in `head` or anything to do
with method dispatch.

So lets take a look at your choices here:

 "If a generic has a default method, then that default method should be
guaranteed to work."

 - as demonstrated, the default here does its job. it does "work".

"Or at least, provide a useful error message, that makes it obvious to the
user, what he or she has done wrong."

 and that error message is the responsibility of methods of the object, in
this case `[`.

therefore its not a bug.

Barry





> [[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] Runnable R packages

2019-02-02 Thread Barry Rowlingson
I don't think anyone denies that you *could* make an EXE to do all
that. The discussion is on *how easy* it should be to create a single
file that contains an initial "main" function plus a set of bundled
code (potentially as a package) and which when run will install its
package code (which is contained in itself, its not in a repo),
install dependencies, and run the main() function.

Now, I could build a self-executable shar file that bundled a package
together with a script to do all the above. But if there was a "RUN"
command in R, and a convention that a function called "foo::main"
would be run by `R CMD RUN foo_1.1.1.tar.gz` then it would be so much
easier to develop and test.

If people think this adds value, then if they want to offer that value
to me as $ or £, I'd consider writing it if their total value was more
than my cost

Barry


On Sat, Feb 2, 2019 at 12:54 AM Abs Spurdle  wrote:
>
> Further to my previous post,
> it would be possible to create an .exe file, say:
>
> my_r_application.exe
>
> That starts R, loads your R package(s), calls the R function of your choice
> and does whatever else you want.
>
> However, I don't think that it would add much value.
> But feel free to correct me if you think that I'm wrong.
>
> [[alternative HTML version deleted]]
>
> __
> 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


Re: [Rd] Runnable R packages

2019-02-01 Thread Barry Rowlingson
Ummm oops. Magic pixies? It assumed all of CRAN was installed?

Maybe I'll write something that could go in /usr/lib/R/bin/RUN that
checks and gets deps, installs the package, and runs package::main,
which I think is what the OP wants - you could do R CMD RUN
foo_1.0.0.tar.gz and away it goes...

B


On Thu, Jan 31, 2019 at 3:56 PM David Lindelof  wrote:
>
> Would you care to share how your package installs its own dependencies? I 
> assume this is done during the call to `main()`? (Last time I checked, R CMD 
> INSTALL would not install a package's dependencies...)
>
>
> On Thu, Jan 31, 2019 at 4:38 PM Barry Rowlingson 
>  wrote:
>>
>>
>>
>> On Thu, Jan 31, 2019 at 3:14 PM David Lindelof  wrote:
>>>
>>>
>>> In summary, I'm convinced R would benefit from something similar to Java's
>>> `Main-Class` header or Python's `__main__()` function. A new R CMD command
>>> would take a package, install its dependencies, and run its "main"
>>> function.
>>
>>
>>
>> I just created and built a very boilerplate R package called "runme". I can 
>> install its dependencies and run its "main" function with:
>>
>>  $ R CMD INSTALL runme_0.0.0.9000.tar.gz
>>  $ R -e 'runme::main()'
>>
>> No new R CMDs needed. Now my choice of "main" is arbitrary, whereas with 
>> python and java and C the entrypoint is more tightly specified (__name__ == 
>> "__main__" in python, int main(..) in C and so on). But I don't think that's 
>> much of a problem.
>>
>> Does that not satisfy your requirements close enough? If you want it in one 
>> line then:
>>
>> R CMD INSTALL runme_0.0.0.9000.tar.gz && R -e 'runme::main()'
>>
>> will do the second if the first succeeds (Unix shells).
>>
>> You could write a script for $RHOME/bin/RUN which would be a two-liner and 
>> that could mandate the use of "main" as an entry point. But good luck 
>> getting anything into base R.
>>
>> Barry
>>
>>
>>
>>>
>>> If we have this machinery available, we could even consider
>>> reaching out to Spark (and other tech stacks) developers and make it easier
>>> to develop R applications for those platforms.
>>>
>>
>>

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


Re: [Rd] Runnable R packages

2019-01-31 Thread Barry Rowlingson
On Thu, Jan 31, 2019 at 3:14 PM David Lindelof  wrote:

>
> In summary, I'm convinced R would benefit from something similar to Java's
> `Main-Class` header or Python's `__main__()` function. A new R CMD command
> would take a package, install its dependencies, and run its "main"
> function.



I just created and built a very boilerplate R package called "runme". I can
install its dependencies and run its "main" function with:

 $ R CMD INSTALL runme_0.0.0.9000.tar.gz
 $ R -e 'runme::main()'

No new R CMDs needed. Now my choice of "main" is arbitrary, whereas with
python and java and C the entrypoint is more tightly specified (__name__ ==
"__main__" in python, int main(..) in C and so on). But I don't think
that's much of a problem.

Does that not satisfy your requirements close enough? If you want it in one
line then:

R CMD INSTALL runme_0.0.0.9000.tar.gz && R -e 'runme::main()'

will do the second if the first succeeds (Unix shells).

You could write a script for $RHOME/bin/RUN which would be a two-liner and
that could mandate the use of "main" as an entry point. But good luck
getting anything into base R.

Barry




> If we have this machinery available, we could even consider
> reaching out to Spark (and other tech stacks) developers and make it easier
> to develop R applications for those platforms.
>
>

[[alternative HTML version deleted]]

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


Re: [Rd] sys.call() inside replacement functions incorrectly returns *tmp*

2018-10-16 Thread Barry Rowlingson
On Tue, Oct 16, 2018 at 12:03 AM Abs Spurdle  wrote:

> Probably the best example I can think of is converting cartesian
> coordinates to polar coordinates.
> Then we might have something like (note, untested, written in my email):
> cart2polar = function (x, y)
> list (theta=atan (y / x), r=sqrt (x * x + y * y) )
>
> massign (r, theta) = cart2polar (x, y)
>
> Now, I'm considering a multiple assignment operator, so something like:
> c (theta, r) $<-$ cart2polar (x, y)

This is something that comes up occasionally and as noted by Gabor,
has been implemented in packages.

But I am not keen on unpacking the return from a function into
multiple objects. The reason your `cart2polar` function returns a list
of theta and r is because it is returning a polar coordinate, and that
coordinate needs both. Why unpack them? If you don't need theta, then
do `r = cart2polar(x,y)$r`. If you need theta and r, then keep them
together in a single object. If you need to call a function  that
needs separate theta and r, use `plot(d$r, d$theta)`. Its a bit more
typing but that's a false efficiency when you want code to be tidy and
well-structured, and to convey meaning. `plot(this$r, this$theta)` is
clearly a plot of something to do with `this`, and you can see that
the r and the theta are coming from the same thing, whereas a
`(r,theta) %=% foo(x,y)` some place and then `plot(r, theta)`
somewhere else has broken the connection.

Barry

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


Re: [R-pkg-devel] CRAN Non-Triviality Requirement

2018-09-26 Thread Barry Rowlingson
On Wed, Sep 26, 2018 at 12:04 PM, Joris Meys  wrote:

> Hi Thomas,
>
> I would argue that one dataset - even a new one - could be added to another
> package. The pizzapoll doesn't look like a scientific breakthrough, but it
> might be a nice dataset for teaching and/or testing new models. So I see
> value in making it available on CRAN one way or another.
>
> If you would consider adding your data to another package, there's a list
> of fairly recent packages on this link:
>
> https://rviews.rstudio.com/2017/11/01/r-data-packages/
>
>
I'd suggest putting the data on a public dataverse server like this one
from some obscure institution called "Harvard":

https://dataverse.harvard.edu/

and then it should be accessible via the database R package:

https://cran.r-project.org/web/packages/dataverse/index.html

with the added bonus that it gets a DOI, metadata, access from Python and
any other language with a dataverse API interface.

What don't you get? Visibility on CRAN - but its so crowded now that nobody
can see you anyway.

Barry

[[alternative HTML version deleted]]

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


Re: [Rd] diag(-1) produces weird result

2018-09-17 Thread Barry Rowlingson
On Mon, Sep 17, 2018 at 5:22 PM, Gábor Csárdi 
wrote:

> I would say it is a mis-feature. If the 'x' argument of diag() is a
> vector of length 1, then it creates an identity matrix of that size,
> instead of creating a 1x1 matrix with the given value:
>
> ❯ diag(3)
>  [,1] [,2] [,3]
> [1,]100
> [2,]010
> [3,]001
>
> Of course this makes it cumbersome to use diag() in a package, when
> you are not sure if the input vector is longer than 1. This seems to
> be a good workaround:
>
> ❯ diag(-1, nrow = 1)
>  [,1]
> [1,]   -1
>
> Or, in general if you have vector v:
>
> ❯ v <- -1
> ❯ diag(v, nrow = length(v))
>  [,1]
> [1,]   -1
> >
>

Anyone else getting deja-vu with the `sample` function?

 > sample(5:3)
 [1] 3 5 4

ok...

 > sample(5:4)
 [1] 4 5

fine...

 > sample(5:5)
 [1] 3 1 5 2 4

uh oh. Documented, of course.

B

[[alternative HTML version deleted]]

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


Re: [Rd] Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo

2018-07-26 Thread Barry Rowlingson
On Thu, Jul 26, 2018 at 12:22 AM, Gábor Csárdi  wrote:
> I am trying to control a background R session, connected via a fifo /
> named pipe.

 Is the fifo significant here? If I read the same R code from a file
via `<` I get the input echoed (R 3.4.4, Ubuntu).

Barry

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


Re: [Rd] base::mean not consistent about NA/NaN

2018-07-03 Thread Barry Rowlingson
On Tue, Jul 3, 2018 at 10:12 AM, Jan Gorecki  wrote:
> Thank you for interesting examples.
> I would find useful to document this behavior also in `?mean`, while `+`
> operator is also affected, the `sum` function is not.

`sum` is "affected" on my system, if you mean:

> sum(c(NA,NaN))
[1] NA
> sum(c(NaN,NA))
[1] NaN

oh, maybe you mean:

> sum(NaN, NA)
[1] NA
> sum(NA, NaN)
[1] NA

But whatever, no money back guarantee:

 Computations involving ‘NaN’ will return ‘NaN’ or perhaps ‘NA’:
 which of those two is not guaranteed and may depend on the R
 platform (since compilers may re-order computations).

> For mean, NA / NaN could be handled in loop in summary.c. I assume that
> performance penalty of fix is the reason why this inconsistency still
> exists.
> Jan
>
> On Mon, Jul 2, 2018 at 8:28 PM, Barry Rowlingson
>  wrote:
>>
>> And for a starker example of this (documented) inconsistency,
>> arithmetic addition is not commutative:
>>
>>  > NA + NaN
>>  [1] NA
>>  > NaN + NA
>>  [1] NaN
>>
>>
>>
>> On Mon, Jul 2, 2018 at 5:32 PM, Duncan Murdoch 
>> wrote:
>> > On 02/07/2018 11:25 AM, Jan Gorecki wrote:
>> >> Hi,
>> >> base::mean is not consistent in terms of handling NA/NaN.
>> >> Mean should not depend on order of its arguments while currently it is.
>> >
>> > The result of mean() can depend on the order even with regular numbers.
>> > For example,
>> >
>> >  > x <- rep(c(1, 10^(-15)), 100)
>> >  > mean(sort(x)) - 0.5
>> > [1] 5.551115e-16
>> >  > mean(rev(sort(x))) - 0.5
>> > [1] 0
>> >
>> >
>> >>
>> >>  mean(c(NA, NaN))
>> >>  #[1] NA
>> >>  mean(c(NaN, NA))
>> >>  #[1] NaN
>> >>
>> >> I created issue so in case of no replies here status of it can be
>> >> looked up
>> >> at:
>> >> https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17441
>> >
>> > The help page for ?NaN says,
>> >
>> > "Computations involving NaN will return NaN or perhaps NA: which of
>> > those two is not guaranteed and may depend on the R platform (since
>> > compilers may re-order computations)."
>> >
>> > And ?NA says,
>> >
>> > "Numerical computations using NA will normally result in NA: a possible
>> > exception is where NaN is also involved, in which case either might
>> > result (which may depend on the R platform). "
>> >
>> > So I doubt if this inconsistency will be fixed.
>> >
>> > Duncan Murdoch
>> >
>> >>
>> >> Best,
>> >> Jan
>> >>
>> >>   [[alternative HTML version deleted]]
>> >>
>> >> __
>> >> 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
>
>

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


Re: [Rd] base::mean not consistent about NA/NaN

2018-07-02 Thread Barry Rowlingson
And for a starker example of this (documented) inconsistency,
arithmetic addition is not commutative:

 > NA + NaN
 [1] NA
 > NaN + NA
 [1] NaN



On Mon, Jul 2, 2018 at 5:32 PM, Duncan Murdoch  wrote:
> On 02/07/2018 11:25 AM, Jan Gorecki wrote:
>> Hi,
>> base::mean is not consistent in terms of handling NA/NaN.
>> Mean should not depend on order of its arguments while currently it is.
>
> The result of mean() can depend on the order even with regular numbers.
> For example,
>
>  > x <- rep(c(1, 10^(-15)), 100)
>  > mean(sort(x)) - 0.5
> [1] 5.551115e-16
>  > mean(rev(sort(x))) - 0.5
> [1] 0
>
>
>>
>>  mean(c(NA, NaN))
>>  #[1] NA
>>  mean(c(NaN, NA))
>>  #[1] NaN
>>
>> I created issue so in case of no replies here status of it can be looked up
>> at:
>> https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17441
>
> The help page for ?NaN says,
>
> "Computations involving NaN will return NaN or perhaps NA: which of
> those two is not guaranteed and may depend on the R platform (since
> compilers may re-order computations)."
>
> And ?NA says,
>
> "Numerical computations using NA will normally result in NA: a possible
> exception is where NaN is also involved, in which case either might
> result (which may depend on the R platform). "
>
> So I doubt if this inconsistency will be fixed.
>
> Duncan Murdoch
>
>>
>> Best,
>> Jan
>>
>>   [[alternative HTML version deleted]]
>>
>> __
>> 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

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


Re: [Rd] Why R should never move to git

2018-01-31 Thread Barry Rowlingson
On Tue, Jan 30, 2018 at 11:07 PM, Suzen, Mehmet 
wrote:

> This might be off topic, but if R-core development ever moves to git,
> I think it would make sense to have its own git service hosted by a
> university, rather than using
> github or gitlab. It is possible via https://gogs.io/ project.
>
> Just for the record.
>
>
Let the record also state that *gitlab* is an open source project and can
be downloaded and self-hosted, like gogs, but unlike github.

Barry

PS I've been running a gitlab instance for my group for a couple of years
on a private server.

[[alternative HTML version deleted]]

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


Re: [R-pkg-devel] Licensing of an R package

2018-01-19 Thread Barry Rowlingson
On Fri, Jan 19, 2018 at 10:28 AM, Chris Brien <chris.br...@unisa.edu.au>
wrote:

> Hi Barry,
>
> Ideally, I would prefer that my package remain open source.
>
> However, I have considered MIT and the two BSD licenses and I understand
> that they are permissive. I have not ruled out using one of them.
>
> The thing about those licenses is that I have not been able to find
> anything on the web about linking a proprietary and free package under
> those licenses. The information is not nearly as comprehensive as it is for
> GPL licenses.
>
> You're not distributing the proprietary package, and the MIT license
doesn't restrict use in any way, including linking with proprietary
software. So you can MIT-license your code and it remains open source, can
link with EvilCorps `bar` package, and it guarantees your (c) notice and
the MIT license will be preserved on copies of your code (it can't be
re-licensed under a different license).


> The problem as I see it is that they are GPL compatible and so I do not
> understand how that can be the case and that you can apply the licence in
> my situation.
>
>
GPL-compatible means you can put MIT-license code together with GPL-license
code and distribute the combination *under the GPL license*. This doesn't
work the other way round - you can't bring GPL-licensed code into an
MIT-license codebase and distribute that under MIT-license!

Interestingly GNU doesn't seem to acknowledge the existence of a "MIT
License" although OSI does. To GNU, the "MIT LIcense" is a number of
possible licenses, and this might be why CRAN insist on inclusion of the
license file itself with anything branded "MIT License":

https://www.gnu.org/licenses/license-list.html


Barry



> I agree that to write your own license is rather daunting. I would much
> prefer to use a pre-existing license.
>
> Thanks for your comments.
>
> Cheers,
>
>   Chris
>
>
>
> From: b.rowling...@gmail.com [mailto:b.rowling...@gmail.com] On Behalf Of
> Barry Rowlingson
> Sent: Friday, 19 January 2018 8:00 PM
> To: Chris Brien
> Cc: r-package-devel@r-project.org
> Subject: Re: [R-pkg-devel] Licensing of an R package
>
> Chris,
>
>  you've not said what *you* would like the license for your software to
> do. You could release the software under a "public domain", "no rights
> reserved" style license, and then if people want to link it with
> proprietary materials then nothing can stop them. But it wouldn't stop
> people commercialising (what was) your code, modifying it, re-releasing it
> as binary and without source, and so on.
>
>  Once you've decided which things you want to permit or restrict under
> your license then you can see if there's a pre-existing one that matches
> your requirements, or whether you have to write one yourself! Good luck
> with that option!
>
>  https://opensource.org/license/MIT is one of the more permissive open
> source licenses - check the others on there for more info.
>
> Barry
>
>
>
> On Fri, Jan 19, 2018 at 8:31 AM, Chris Brien <chris.br...@unisa.edu.au<
> mailto:chris.br...@unisa.edu.au>> wrote:
> Dear list members,
>
> I have come to realize that my understanding of free software licensing
> was somewhat naïve. The problem is that I now find that, in spite of
> spending quite a bit of time reading about various licenses on the web, I
> have been unable to identify a suitable license for the situation that I
> have with one of my packages.
>
> I am solely responsible for the development of my package, `foo' say.
> However, most functions in `foo' call functions from a proprietary package,
> `bar' say , the latter not being available from an online software
> repository and consisting of R functions that call routines in a library.
> That is, `foo' enhances `bar'.
>
> I had thought that a GPL licence was appropriate because (1) `foo' is free
> software and (ii) I do not distribute `bar' with `foo'. That is, I am
> distributing only free software.  However, I have come to understand that
> this is not the case because a free software package linked with a
> proprietary package does not satisfy the requirements to be GPL.
>
> I have found it difficult to work out a license that might cover my
> package because much of the discussion online covers cases that are the
> opposite of mine i.e. cases where `foo' is proprietary and `bar' is
> freeware. I can appreciate why this needs to be avoided.
>
> I can also understand that a disadvantage of what I am doing is that it
> tends to entrench the use of such software. While I agree that it is
> desirable that `bar' be replaced with free software, unfortunately `bar'
> has functionality that is currently infeasib

Re: [R-pkg-devel] Licensing of an R package

2018-01-19 Thread Barry Rowlingson
Chris,

 you've not said what *you* would like the license for your software to do.
You could release the software under a "public domain", "no rights
reserved" style license, and then if people want to link it with
proprietary materials then nothing can stop them. But it wouldn't stop
people commercialising (what was) your code, modifying it, re-releasing it
as binary and without source, and so on.

 Once you've decided which things you want to permit or restrict under your
license then you can see if there's a pre-existing one that matches your
requirements, or whether you have to write one yourself! Good luck with
that option!

 https://opensource.org/license/MIT is one of the more permissive open
source licenses - check the others on there for more info.

Barry





On Fri, Jan 19, 2018 at 8:31 AM, Chris Brien 
wrote:

> Dear list members,
>
> I have come to realize that my understanding of free software licensing
> was somewhat naïve. The problem is that I now find that, in spite of
> spending quite a bit of time reading about various licenses on the web, I
> have been unable to identify a suitable license for the situation that I
> have with one of my packages.
>
> I am solely responsible for the development of my package, `foo' say.
> However, most functions in `foo' call functions from a proprietary package,
> `bar' say , the latter not being available from an online software
> repository and consisting of R functions that call routines in a library.
> That is, `foo' enhances `bar'.
>
> I had thought that a GPL licence was appropriate because (1) `foo' is free
> software and (ii) I do not distribute `bar' with `foo'. That is, I am
> distributing only free software.  However, I have come to understand that
> this is not the case because a free software package linked with a
> proprietary package does not satisfy the requirements to be GPL.
>
> I have found it difficult to work out a license that might cover my
> package because much of the discussion online covers cases that are the
> opposite of mine i.e. cases where `foo' is proprietary and `bar' is
> freeware. I can appreciate why this needs to be avoided.
>
> I can also understand that a disadvantage of what I am doing is that it
> tends to entrench the use of such software. While I agree that it is
> desirable that `bar' be replaced with free software, unfortunately `bar'
> has functionality that is currently infeasible to replace with free
> software. At least I am not profiting from the enhancements that I have
> made.
>
> I am hoping that someone more experienced in software development and
> licensing issues can suggest a license type that might be suitable for
> `foo' such that at least the enhancements that it incorporates remain
> `free'?
>
> Cheers,
>
>   Chris Brien
>
> Adjunct Senior Lecturer in Statistics
> -
> Phenomics and Bioinformatics Research Centre
> University of South Australia
> GPO Box 2471
> ADELAIDE  5001  South Australia
> Phone:  +61 8 8302 5535   Fax:  +61 8 8302 5785
> Email:   chris.br...@unisa.edu.au
> WEB page:  
> CRICOS No 00121B
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

[[alternative HTML version deleted]]

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

Re: [R-pkg-devel] creating indelible file during unit test

2017-12-12 Thread Barry Rowlingson
On Tue, Dec 12, 2017 at 12:24 PM, Thierry Onkelinx  wrote:

> Dear all,
>
> Some function I wrote deletes a bunch of files. It is crucial that all
> files get deleted. Hence it should return an error when one or more
> files couldn't be deleted.
>
> I'm writing a unit test for this function. I fail to create a file
> that can't be deleted by the function. I've tried Sys.chmod(file,
> "000") which didn't work.
>
>
On a linux system the ability to remove a file is controlled by the
permissions on the directory that the file is in, so setting a file to any
permission doesn't affect your process's ability to delete it:

$ mkdir foo
$ touch foo/1
$ touch foo/2
$ rm foo/1
$ chmod a-w foo # remove write permission on the folder
$ rm foo/2
rm: cannot remove ‘foo/2’: Permission denied


It might cause `rm` on the command line to warn you though:

 $ touch 000 ; chmod 000 000
 $  rm 000
 rm: remove write-protected regular empty file ‘000’? y

- and its gone.

Depending on how your code is trying to delete things, it might be very
hard to create a file owned by you that it can't delete, since it might try
and change the permissions on non-writable directories.

Even things *not owned by you* can be deleted if you have permission on the
containing directory:

$ touch foo
$ ls -l
total 0
-rw-r--r-- 1 rowlings rowlings 0 Dec 12 14:38 foo
$ sudo chown root.root foo
$ ls -l
total 0
-rw-r--r-- 1 root root 0 Dec 12 14:38 foo
$ rm foo
rm: remove write-protected regular empty file ‘foo’? y
$ ls -l
total 0


I think unix makes it impossible for you to create something that even you
can't delete. You may need higher powers ("root") to change the ownership
of the thing you've created.

There may be some other possibilities involving mount points or pipes that
can't get deleted until their processes die...

[[alternative HTML version deleted]]

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

[Rd] R on OpenHub

2017-04-25 Thread Barry Rowlingson
Does anyone want to manage the record for R on OpenHub?

OpenHub is a site that records metrics for open source projects. At
some point a record for R was created:

https://www.openhub.net/p/r_project

but there's no manager listed.

 OpenHub says:

"""
 * Only someone who works on the project and has a close connection to
it should apply. Ideally the owner, founder, lead developer, or
release manager.
"""

So not me. Sounds more like it needs to be someone in R-core or an R
Foundation luminary.

OpenHub is used by the OSGeo Live DVD to generate metrics for all the
projects on the DVD, and I've just been asked by the OSGeo Live team
to inquire about this.

If nobody wants to do it, no biggie, I think it just means the project
information will be less accurate.

Barry

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


Re: [R-pkg-devel] Interplay between knitr() and View()

2017-04-22 Thread Barry Rowlingson
On Thu, Apr 20, 2017 at 3:41 PM, Roy Mendelssohn - NOAA Federal
 wrote:

> What I liked about View() is often the table is quite big, and View() 
> provides scroll bars and nice headers that make it easy to look over the 
> results.

When I run View(iris) I don't get scrollbars, and the table is
truncated so that only whole cells are visible, so there's no clue
that there's other cells outside the initial view - I never see half a
cell. I'd attach a screenshot but not on this list...

 Maybe this is just View() on Linux, or View() on Ubuntu Linux, or
View() on Ubuntu Linux/Gnome. But View() is very system dependent.



> -Roy
>
>> On Apr 20, 2017, at 12:45 AM, David Hugh-Jones  
>> wrote:
>>
>>
>> Two questions:
>>
>> 1. If your package definitely needs to call View(), and you want to explain 
>> how that will look, then why not show one or more screenshots in your 
>> documentation?
>>
>> 2. Why does your package need to call View? Why can't it return the metadata 
>> as a data frame, and let the user do what he wants with it himself - using 
>> View(), head(), or any other tool?
>>
>> Cheers
>> D
>>
>>
>>
>>
>>
>> > Hi All:
>> >
>> > My package allows the user to search for information about the data
>> > available, and the information is returned in a dataframe. I had long been
>> > looking for a nice way to display the results  (the datasets' metadata),
>> > and wasn't too happy with anything until I tried the View() command,  which
>> > does exactly what I want.
>> >
>> > The problem is I can't seem to find a way to make View() and knitr() work
>> > nice together in creating the vignette. Given the way View() works I doubt
>> > there is a way,  but any suggestions of how I can show what the user will
>> > see when the given the command in the package from within my vignette?
>> >
>> > Thanks,
>> >
>> > -Roy
>> >
>> >
>> >
>> > **
>> > "The contents of this message do not reflect any position of the U.S.
>> > Government or NOAA."
>> > **
>> > Roy Mendelssohn
>> > Supervisory Operations Research Analyst
>> > NOAA/NMFS
>> > Environmental Research Division
>> > Southwest Fisheries Science Center
>> > ***Note new street address***
>> > 110 McAllister Way
>> > Santa Cruz, CA 95060
>> > Phone: (831)-420-3666
>> > Fax: (831) 420-3980
>> > e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/
>> >
>> > "Old age and treachery will overcome youth and skill."
>> > "From those who have been given much, much will be expected"
>> > "the arc of the moral universe is long, but it bends toward justice" -MLK
>> > Jr.
>> >
>> > __
>> > R-package-devel@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
>> >
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-package-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>> --
>> Sent from Gmail Mobile
>
> **
> "The contents of this message do not reflect any position of the U.S. 
> Government or NOAA."
> **
> Roy Mendelssohn
> Supervisory Operations Research Analyst
> NOAA/NMFS
> Environmental Research Division
> Southwest Fisheries Science Center
> ***Note new street address***
> 110 McAllister Way
> Santa Cruz, CA 95060
> Phone: (831)-420-3666
> Fax: (831) 420-3980
> e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/
>
> "Old age and treachery will overcome youth and skill."
> "From those who have been given much, much will be expected"
> "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

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


Re: [Rd] A trap for young players with the lapply() function.

2017-03-27 Thread Barry Rowlingson
On Mon, Mar 27, 2017 at 1:17 AM, Rolf Turner  wrote:
>
> Is there any way to trap/detect the use of an optional argument called
> "X" and thereby issue a more perspicuous error message?
>
> This would be helpful to those users who, like myself, are bears of very
> little brain.
>
> Failing that (it does look impossible)

You can get the names of named arguments:

 > z = function(x,X){cos(x*X)}
 > names(formals(z))
 [1] "x" "X"


> might it not be a good idea to
> add a warning to the help for lapply(), to the effect that if FUN has an
> optional argument named "X" then passing this argument via "..." will
> cause this argument to be taken as the first argument to lapply() and
> thereby induce an error?

Another idea might be to use purrr:map instead, which is quite happy
with X in your function:

 >  xxx <- purrr::map(y,function(x,X){cos(x*X)},X=2*pi)
 > xxx
[[1]]
[1] 0.08419541

[[2]]
[1] 0.6346404

[[3]]
[1] 0.9800506

[[4]]
[1] 0.8686734

[[5]]
[1] -0.9220073

But don't feed `.x` to your puing cats, or fails silently:

 >  xxx <- purrr::map(y,function(x,.x){cos(x*.x)},.x=2*pi)
 > xxx
[[1]]
NULL

But who would have a function with `.x` as an argument?


> __
> 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


Re: [R-pkg-devel] Pkgs with ToS violations

2016-08-04 Thread Barry Rowlingson
ROpenSci's onboarding process has a checkbox for confirming that the
package "does not violate the Terms of Service of any service it
interacts with.":

https://github.com/ropensci/onboarding/blob/master/issue_template.md

I also have a vague memory of this discussion a few years ago on
R-help/-dev where TPTB on CRAN decided that they were just providing
hammers, and if people wanted to break into houses with them then that
wasn't their problem (I'm paraphrasing and vague on the details...).
Can't find that thread right now.




On Thu, Aug 4, 2016 at 11:23 AM, Duncan Murdoch
 wrote:
> On 03/08/2016 10:26 PM, Bob Rudis wrote:
>>
>> I came across https://cran.rstudio.com/web/packages/boxoffice/index.html
>> in CRAN today and while I don't expect CRAN to be a legal authority,
>> should there not be some kind of policy for excluding R packages that
>> deliberately violate (data) site ToS? (I'm asking this here vs sending
>> a note to CRAN folks since I tend to be a bit sensitive to this
>> particular issue).
>>
>> Box Office Mojo - which is really just Amazon - clearly states that
>> the activities this package facilitates are in violation of their ToS.
>> Unlike examples on blogs that also violate BOM ToS, this pkg in CRAN
>> is almost legitimizing the violations.
>>
>> Amazon only goes after a few folks a year and it's unlikely R folks
>> will be their target (for now) but that doesn't make it OK IMO.
>>
>> Is this worth bringing up to CRAN?
>
>
> I'd say the place to start is the package maintainer.  The maintainer has
> certified that the package satisfies the policy "The code and examples
> provided in a package should never do anything which might be regarded as
> malicious or anti-social.".
>
> Duncan Murdoch
>
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

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


Re: [Rd] Source code of early S versions

2016-02-29 Thread Barry Rowlingson
On Mon, Feb 29, 2016 at 6:17 PM, John Chambers  wrote:
> The Wikipedia statement may be a bit misleading.
>
> S was never open source.  Source versions would only have been available with 
> a nondisclosure agreement, and relatively few copies would have been 
> distributed in source.  There was a small but valuable "beta test" network, 
> mainly university statistics departments.

So it was free (or at least distribution cost only), but with a
nondisclosure agreement? Did binaries circulate freely, legally or
otherwise? Okay, guess I'll read the book.

 I'm sure I saw S source early in my career (1990 or so), possibly on
an early Sun 3/60 system or even the on-the-way-out Whitechapel MG-1
workstations.

> And two shameless plugs:
>
> 1.  there is a chapter on the history of all this in my forthcoming book on 
> "Extending R"

 That will sit nicely on the shelf next to "Extending The S System"
that Allan Wilks gave me :)

> PS:  somehow "historical" would be less unnerving than "archeological"

 At least I didn't say palaeontological.

Thanks for the response.

Barry

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


[Rd] Source code of early S versions

2016-02-29 Thread Barry Rowlingson
According to Wikipedia:

"In 1980 the first version of S was distributed outside Bell
Laboratories and in 1981 source versions were made available."

but I've been unable to locate any version of S online. Does anyone
have a copy, somewhere, rusting away on an old hard disk or slowly
flaking off a tape? I've had a rummage round the CMU Statlib on
archive.org but no sign of it, and its hard to search for "S"
generally.

 Obviously this would be for archaeological purposes, but there's
bound to be someone out there who'd like to try and compile it on a
modern system. It might at least be nice to see it in a nice format on
Gitlab, for example. But maybe there's licensing problems.

 Anyone interested in the history of S should read Richard Becker's
article from the mid 90s:

http://sas.uwaterloo.ca/~rwoldfor/software/R-code/historyOfS.pdf

Barry

[apologies if S talk is off-topic. Surprisingly I've just discovered
the S-news mailing list still runs, but looking at the recent archive
I don't think I'd get much success there]

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


Re: [Rd] Multi-line comments in R

2015-08-20 Thread Barry Rowlingson
On Wed, Aug 19, 2015 at 5:16 AM, Nathan Esau ne...@sfu.ca wrote:
 I was wondering why the decision was made long ago to never implement
 multi-line comments in R. I feel there are several argument to be made for
 why the R language should have multi-line comments.

 1. Many programming languages (including some which are commonly used for
 statistics, such as python, matlab and SAS) have this feature.

 Python doesn't have a multi-line comment.

 You can use triple-quoted strings in Python to quote a large chunk of
text, which won't generate any bytecode and so has no executable
effect:

def foo(x)
 y = x * 2
 
 well what now
 lets have a comment
 
 return(y)

A similar thing is possible in R:

 foo = function(x){
this is a test.
where
you can comment
return(x*2)
}

However I don't know if this causes any executable effect - its
possible R evaluates the string in some way Anyone want to test.

Yes, you have to escape any string quote marks in your comment, but in
python you have to escape any triple-quote marks.

Barry

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


Re: [Rd] how useful could be a fast and embedded database for the R community?

2014-12-25 Thread Barry Rowlingson
On Wed, Dec 24, 2014 at 7:37 PM, joanv joan.igles...@live.com wrote:
 I'm sorry, but I cannot show code.

 Then can you stop using the word release. To release means to let
something go, preferably out into the wild. I can't even find a binary
release on that site. Call it the first version if you want, but
not release. I'm sure I'm not the only one wondering where this
release is downloadable in some form.

 For the moment, this project is not open
 source, it has costs a lot of effort, and first of all, I have to find a way
 to recover the investment. If I find a way to recover the investment,
 compatible with an open source way of business, the project will be open
 source, but first of all, I have to find the way.

 You say the Open Spartacus project [http://www.openspartacus.org/]
from which VulcanDB came failed Due to the lack of funding. What was
your personal relationship with that project? In what way, apart from
in name, was that Open? I can't find source code or binary releases.
Just a fancy single-page website with *all* the buzzwords. Does this
failure not teach you anything?

 The R project and its leading lights are very proud of the open
nature of R, and so you will be talking to strong proponents of open
source software here. You've presented a project with no source or
binary release, no documentation, no API or specification, nothing. No
more than vapourware ever gives us. And then

 Please, you can check the benchmark of the first release. There are not a
 lot of information about the benchmark, because as I said before, some
 information is sensitive to be published, for the moment.

 ... you ask *us* to check *your* benchmark? How? We have no idea
exactly what you tested, and benchmark comparisons *depend* on that.

 Of course, I would like this project to be open source, but if has to find
 the way, and ideas are welcome!

 Release early, release often. The only way other R users are going to
be interested is to see the source, or at the very least to see the
proposed API and be able to discuss this. I think you will find few
friends here until you do. Otherwise I suggest you jazz up your
benchmarks into a pseudo-technical paper with some 3d bar graphs and
wave it under the noses of idiot venture capitalists until one of them
throws some money at you. Good luck!

Barry

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


Re: [Rd] SUGGESTION: Force install.packages() to use ASCII encoding when parse():ing code?

2014-12-12 Thread Barry Rowlingson
On Fri, Dec 12, 2014 at 12:34 PM, Jan Kim jtt...@googlemail.com wrote:

 it's just a matter of time that people get characters into their code that
 are different but indistinguishable in the font they use (I've seen this
 with \H{o} rather than a \{o}), and mega-personmonths are wasted puzzling
 over tracking down these problems.

 Then R should ban variable names from having 'l', 'i', '1', '0' and
'O' in them!

Barry

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


Re: [Rd] Intel Fortran compiler returns a -1 TRUE value

2014-10-03 Thread Barry Rowlingson
On Thu, Oct 2, 2014 at 4:25 PM, Ei-ji Nakama nak...@ki.rim.or.jp wrote:

 Hello

  The value generated by Fortran's .TRUE. evaluates as truthy -- as in
  all(z[[1]]) -- but is neither equal to nor identical to TRUE. Its numeric
  conversion to -1 is most unusual, every other system I've tried converts
 to
  +1.

 Please read the -fpscomp logicals option of ifort.


 Wow that's an interesting read, and the line

Intel recommends that you avoid coding practices that
  depend on the internal representation of LOGICAL values

says it all with regard to R and Fortran LOGICALS, I think!

Barry

[[alternative HTML version deleted]]

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


Re: [Rd] Intel Fortran compiler returns a -1 TRUE value

2014-10-01 Thread Barry Rowlingson
On Tue, Sep 30, 2014 at 6:25 PM, William Dunlap wdun...@tibco.com wrote:

 In S+ and S it was valid to pass logicals to .Fortran, where they got
 mapped into the
 appropriate bit pattern.  (The trouble was that 'appropriate' was
 compiled into the program -
 so you were locked into our compiler vendor's choice).   Passing them
 between Fortran
 code and C code has always been a problem (as has passing character
 data between them).


 That makes sense. The code was originally written for S-plus, and the
accompanying R code is still in files with a .S extension

 The maintainer has now fixed it.

Barry

[[alternative HTML version deleted]]

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


[Rd] Intel Fortran compiler returns a -1 TRUE value

2014-09-30 Thread Barry Rowlingson
I have access to a cluster on which I have been supplied with R 3.1.0 which
appears to have been built using the intel compiler tools.

The following minimal Fortran file:

  subroutine truth(lind)
  logical lind
  lind = .TRUE.
  end

Compiles thusly:

arcadia R CMD SHLIB truth.f
ifort   -fpic  -O3 -xHOST -axCORE-AVX-I -fp-model precise  -c truth.f -o
truth.o
ifort: command line warning #10212: -fp-model precise evaluates in source
precision with Fortran.
icc -std=gnu99 -shared -L/usr/local/lib64 -o truth.so truth.o -lifport
-lifcore -limf -lsvml -lm -lipgo -lirc -lpthread -lirc_s -ldl


And runs so:

  dyn.load(truth.so)
  z = .Fortran(truth,as.logical(TRUE))
  z[[1]]
 [1] TRUE
  as.numeric(z[[1]])
 [1] -1
  z[[1]] == TRUE
 [1] FALSE
  all(z[[1]])
 [1] TRUE
  identical(z[[1]],TRUE)
 [1] FALSE

The value generated by Fortran's .TRUE. evaluates as truthy -- as in
all(z[[1]]) -- but is neither equal to nor identical to TRUE. Its numeric
conversion to -1 is most unusual, every other system I've tried converts to
+1.

So wrong compiler flag on build? User error - never try comparing
truthy values, as with the various flavours of NA? Or something else?

If its a compiler/config problem I'll pass it on to the cluster admin -
I've had a good look for stuff on building R on Intel compilers, nothing
stood out. I might try building R myself this afternoon but as I implied I
don't have admin on this cluster so I might have to track down a bunch of
library sources to build R from source.

If its a user error then I'll track down every instance of if(foo==TRUE)
and shoot it, and it would be nice to have a note in ?TRUE

Some useful info:

 sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-unknown-linux-gnu (64-bit)

arcadia ifort -v
ifort version 13.0.0


Thanks

Barry

[[alternative HTML version deleted]]

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


Re: [Rd] Intel Fortran compiler returns a -1 TRUE value

2014-09-30 Thread Barry Rowlingson
On Tue, Sep 30, 2014 at 12:53 PM, Duncan Murdoch murdoch.dun...@gmail.com
wrote:


 This appears to be user error.  According to Writing R Extensions, the
 Fortran type corresponding to R logical is INTEGER, not LOGICAL.


Oh yes, a very old and long-standing user error. I assume the CRAN checks
don't check this. Has it ever been okay to pass logicals to Fortran?

 I shall inform the package maintainer

Thanks

Barry

[[alternative HTML version deleted]]

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


Re: [Rd] Re R CMD check checking in development version of R

2014-08-28 Thread Barry Rowlingson
And if, like me, you always forget which of Depends and Imports is the
one you are supposed to be using, the mnemonic device is DEPends is
DEPrecated[1], IMPorts is IMPortant.

Barry

[1] kinda.



On Thu, Aug 28, 2014 at 4:33 AM, Gavin Simpson ucfa...@gmail.com wrote:
 On Aug 27, 2014 5:24 PM, Hadley Wickham
 snip /
 I'd say: Depends is a historical artefact from ye old days before
 package namespaces. Apart from depending on a specific version of R,
 you should basically never use depends.  (The one exception is, as
 mentioned in R-exts, if you're writing something like latticeExtras
 that doesn't make sense unless lattice is already loaded).

 Keeping this nuance in mind when when discussing Depends vs Imports is
 important so as to not suggest that there isn't any reason to use Depends
 any longer.

 I am in full agreement that its use should be limited to exceptional
 situations, and have modified my packages accordingly.

 Cheers,

 G

  This check (whilst having found some things I should have imported and
  didn't - which is a good thing!) seems to be circumventing the
 intention of
  having something in Depends. Is Depends going to go away?

 I don't think it's going to go away anytime soon, but you should
 consider it to be largely deprecated and you should avoid it wherever
 possible.

  (And really you shouldn't have any packages in depends, they should
  all be in imports)
 
  I disagree with *any*; having say vegan loaded when one is using
 analogue is
  a design decision as the latter borrows heavily from and builds upon
 vegan.
  In general I have moved packages that didn't need to be in Depends into
  Imports; in the version I am currently doing final tweaks on before it
 goes
  to CRAN I have remove all but vegan from Depends.

 I think that is a reasonable use case for depends. Here's the exact
 text from R-exts: Field ‘Depends’ should nowadays be used rarely,
 only for packages which are intended to be put on the search path to
 make their facilities available to the end user (and not to the
 package itself): for example it makes sense that a user of package
 latticeExtra would want the functions of package lattice made
 available.

 Personally I avoid even this use, requiring users of my packages to be
 explicit about exactly what packages are on the search path.  You are
 of course welcome to your own approach, but I think you'll find it
 will become more and more difficult to maintain in time. I recommend
 that you bite the bullet now.

 Put another way, packages should be extremely conservative about
 global side effects (and modifying the search path is such a
 side-effect)

 Hadley

 --
 http://had.co.nz/

 [[alternative HTML version deleted]]

 __
 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


Re: [Rd] Why R-project source code is not on Github

2014-08-21 Thread Barry Rowlingson
On Thu, Aug 21, 2014 at 11:40 AM, Marc Schwartz marc_schwa...@me.com wrote:

 Your suggestion to move to Github is perhaps based upon a false premise, that 
 the R community at large has the ability to directly post code/patches to the 
 official distribution.

That's not the false premise here. This is:

 one simply can't ignore Github ,where collaboration is at it's best
- Gaurav Sehrawat

speaking as someone often labelled a git[hub]-fanboy, even I can find
reasons to debate this statement.

Barry

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


Re: [Rd] Listing Packages in Depends or Imports

2014-06-27 Thread Barry Rowlingson
On Fri, Jun 27, 2014 at 3:00 AM, Dario Strbenac
dstr7...@uni.sydney.edu.au wrote:
 Hello,

 The Writing R Extensions manual gives confusing advice. Compare

 Packages listed in imports or importFrom directives in the NAMESPACE file 
 should almost always be in ‘Imports’ and not ‘Depends’.

 with

 Almost always packages mentioned in ‘Depends’ should also be imported from in 
 the NAMESPACE file

 Why is that confusing? Its perfectly logical.

 First line says that packages imported in the NAMESPACE should
usually be in Imports in the DESCRIPTION. It implies there are
special cases when Depends may be correctly used.

 Second line is that packages that are listed as Depends in
DESCRIPTION should usually be imported in the NAMESPACE file, but
implies there may be exceptions - you might correctly have a Depends
that doesn't have an import in the NAMESPACE.

In themselves, those two statements are perfectly logical and consistent.

As an attempt to explain **when** you'd put a reference in Depends or
Imports or why you'd use one of those get-out exceptions, it makes no
claims!

Barry

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


Re: [Rd] setting environmental variable inside R function to call C function

2014-06-03 Thread Barry Rowlingson
What does c_fun look like? Here's mine:

#include stdio.h
#include stdlib.h
void c_fun(){
  printf(TMP is %s\n, getenv(TMP));
}

and I then do this at the shell prompt:

R CMD SHLIB c_fun.c

and this at the R prompt:

dyn.load(c_fun.so)
wrapper()

and I get:

 wrapper()
[1] A
TMP is A
list()

Is that not what you want?

tldr; works for me.


On Tue, Jun 3, 2014 at 5:55 PM, Bowen Meng bowen@gmail.com wrote:
 wrapper - function(){
   Sys.setenv(TMP=A)
   print(Sys.getenv(TMP))

   .C(c_fun)
 }


 As the example above, I hope to set an env var $TMP inside the R function
 wrapper, which affects the functionality of the C function call c_fun.
 Also the print line shows that $TMP is set to be A, but the function call
 of c_fun was not affected.

 Does anyone know why and how to correctly set the env var for subsequent
 functions?

 Thanks,
 BW

 [[alternative HTML version deleted]]

 __
 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


Re: [Rd] precedence (was 'historical NA question')

2014-05-08 Thread Barry Rowlingson
On Wed, May 7, 2014 at 11:00 PM, Duncan Murdoch
murdoch.dun...@gmail.com wrote:


 Is there a language where - 2^2 gives a different answer than -2^2?
   (Substitute ** or any other exponentiation operator for ^ if you
 like.)  This is important, because I'd like to avoid ever attempting any
 important calculation in that language.


I just checked that with javascript, and it gives the same answer so
that's okay. I tried JS because it has some fun things to do with
numbers (especially if you let it coerce strings):

  2 - 1
1
  2 + 1
21

The Javascript Best Practices Document[1] says you should never use
the plus sign for arithmetic addition, instead use a double negative
and rely on subtract converting to numeric:

  2- -1
 3

Given that web pages written with JS get all their data from web
content as strings, this can happen more often than you think.

This is an example to show to everyone who says Can we use + to
concatenate strings in R please!?.

Barry

[1] A completely fictional publication I invented just now, but hey,
I've seen worse than this.

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


Re: [Rd] RFC: API design of package modules

2014-04-29 Thread Barry Rowlingson
On Mon, Apr 28, 2014 at 2:55 PM, Konrad Rudolph 
konrad.rudolph+r-de...@gmail.com wrote:


 So this is my question: what do other people think? Which is the most
 useful and least confusing alternative from the users’ perspective?


The most useful is alternative is write packages.

 The overhead is minimal (install devtools, create(foo); repeat {
load_all(foo) ; edit; until_bugs==0} ). Reloading a package is a
one-liner, you can't get more minimal.

 And with that you get a structure for documentation, a metadata standard,
a wide range of sanity checks, and the option to push to CRAN or github for
distribution. What you don't get is hierarchies.

 Can we get a hierarchy into base packages? That's the real question, and
if answered I think it makes your module package redundant. I'd love to see
a hierarchy with a colon-separator or something, so if I have a package
with foo/R/thing.R and foo/R/this/thing.R I can do:

 require(foo)
 thing()
 this:thing()

or similar

I do like your approach of returning an object that provides an access to
the functions without side-effects, but the masses are so brainwashed into
thinking that require(foo) can put an unknown number of unknown-named
functions into your search list that I don't think it will ever get into
base R...

Note I did once write a simple file loader to avoid using source - it used
sys.source to load files into an environment on the search path, storing
the folder name so that it could be easily reloaded, but then devtools came
along...

If you want your module package to succeed you are going to have to
duplicate all the good stuff in packages - documentation, metadata,
distribution (trivial: zip/unzip/pull/push), and then another problem -
people will grow out of it - they'll start writing C and Fortran code.
Going to support that? devtools already does.


Barry

[[alternative HTML version deleted]]

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


Re: [Rd] Constructor/extractor.

2014-03-04 Thread Barry Rowlingson
On Tue, Mar 4, 2014 at 1:47 AM, Rolf Turner r.tur...@auckland.ac.nz wrote:



 Questions:
 ==


 (2) Even if there are no such functions, is there anything intrinsically
 *wrong* with having a function possessing this somewhat schizophrenic
 nature?  Is it likely to cause confusion, induce syntactical mistakes,
 create errors, or produce wrong results?

 Any thoughts, comments, insights or suggestions gratefully received.



 I don't see why you can't conceptually think of w = owin(some_ppp_object)
as an owin Constructor rather than an Accessor. Its constructing (and
returning) an owin from an object, it just happens to be as simple as
getting a component from that object.

 The raster package has the 'extent' function - you can create an extent
with extent(xmin,xmax,,,etc), get the extent of a raster with extent(r), or
set the extent of a raster with extent(r1) - extent(r2), so I don't see
any problem with:

w1 = owin(poly=...) # construct polygon owin

ppp1 = ppp(x,y,window=w1)
ppp2 = ppp(x,y, window=owin(ppp1)) # construct window from ppp object

owin(ppp1) = owin(ppp2)  # give ppp1 the owin of ppp2

That all reads pretty nicely. As long as owin(...) returns an observation
window and owin-(...) assigns an observation window to an object that can
validly have one, I don't think you can go wrong. I've probably already
tried to do owin(ppp1)=... a few times...

Barry

[[alternative HTML version deleted]]

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


Re: [Rd] contrib.url in non-interactive mode

2014-02-14 Thread Barry Rowlingson
On Fri, Feb 14, 2014 at 10:54 AM, Prof Brian Ripley
rip...@stats.ox.ac.ukwrote:


 It is up to you to set a default mirror: we have little idea where you
 live (and it may not be where your email address suggests).  Geolocation
 of mirrors had been mooted but not implemented (and in a corporate
 setting is not 100% reliable).  The whole point of mirrors is to spread
 the load: without them there would be no CRAN as the main host would not
 allow the traffic.


The RStudio CRAN mirror uses Amazon's CDN to achieve a degree of geographic
convenience:

http://blog.rstudio.org/2013/06/10/rstudio-cran-mirror/

 As far as I know all the other CRAN mirrors are geographically nailed down
and your data will come out of that server in that data centre wherever you
and it may be.

Barry

[[alternative HTML version deleted]]

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


Re: [Rd] cat with backspace and newline characters

2013-11-07 Thread Barry Rowlingson
On Thu, Nov 7, 2013 at 8:28 AM, Jari Oksanen jari.oksa...@oulu.fi wrote:

 On 07/11/2013, at 09:35 AM, Renaud Gaujoux wrote:

 I agree that the handling of \b is not that strange, once one agrees
 on what \b actually means, i.e. go back one character and not
 delete previous character.

It means, to paraphrase Humpty Dumpty from Alice in Wonderland,
whatever the terminal chooses it to mean. If you want to do something
meaningful and consistent across different terminals, you use termcap
or terminfo:

 http://en.wikipedia.org/wiki/Termcap
 http://en.wikipedia.org/wiki/Terminfo

or other abstractions probably built on that (eg 'ncurses').

 As a user DEC LA120 terminal I expect the following:

 cat(a\b^\n)
 â


 Everything else feels like a bug.

 Oh noes! I don't have a terminfo entry for my DEC LA120!

 I don't know what flavour of 'terminal' RStudio, the Windows GUI or
emacs-ess behave as and whether there's terminfo entries for them

 Do any R packages link with termcap to do controlled screen output? H

Barry

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


Re: [Rd] proposal for new FAQ entry?

2013-08-05 Thread Barry Rowlingson
On Mon, Aug 5, 2013 at 2:53 PM, peter dalgaard pda...@gmail.com wrote:

 Does this seem FAQ-worthy? Should I e-mail the FAQ maintainer and suggest
 it?

 Sure, as long as we never change the numbering of FAQ 7.31...


 Not even to FAQ 7.31+1e-15 ?

Barry

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


Re: [Rd] [R] Internalization of help pages

2013-08-04 Thread Barry Rowlingson
[I've tried to move this back to R-devel, which I think is what Brian
Ripley tried and nobody followed...]

On Sun, Aug 4, 2013 at 4:15 PM, John Kane jrkrid...@inbox.com wrote:
 I tried it in French and there a few hiccups but it's not too bad.

 Personally I'd like to see the help tranlated into English too.l

 John Kane
 Kingston ON Canada

 The problems of getting translations for help pages are many-fold:

1. Giving translators access to current .Rd files, which is tricky
when people are developing with roxygen2.
2. Finding translators to do the work. There are a lot of tools for
helping translate message files, but whole .Rd docs might be too much
for the casual translator.
3. Having a standard way to display help in language X if it exists,
considering the complexity of R's help (plain text, web, PDF
versions). Put it all in help/XX and html/XX and doc/XX for XX in
languages?
4. As (3) but with vignettes. Wouldn't vignette(foo,language=fr)
be nice if foo was available in French? Or vignette(language=de)
to get all German vignettes?
5. Language bloat. Best solved by making language documentation 'add
on' packs. Easier for a package developer to do for one package, hard
for core R with several packages and core documentation.
6. How do you integrate that with CRAN?
7. Does CRAN have to build all the built languages documentation from
the language .Rd files? A standard repository structure on github and
some github_ wrapper functions might help kick this off since there
wouldn't be a need to bother the busy CRAN people with things.

Of all of that I reckon foreign-language vignette support might be the
easiest to implement. It would seem to require a way for an author to
specify the language of a vignette, a standard place for languaged
vignettes (source and built), and a mod to the vignette function to
look in those places.

The comparable translation project I know of is the translation of
documents for the OSGeo Live DVD - this consists of translations of
short project introductions and walkthroughs (with screenshots) for
about 50 pieces of software, which is probably of the order of
difficulty of translating an R package with about 100 well-documented
functions. It works well but it does have a lot of commitment from
everyone every six months at the release points.

However, getting all the R documentation translated is probably easier
than getting everyone to speak english - we started trying to do that
in the 18th century and look how that turned out...

Barry

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


Re: [Rd] Problem with distributing data in package.

2013-07-20 Thread Barry Rowlingson
On Fri, Jul 19, 2013 at 10:33 AM, Simon Knapp sleepingw...@gmail.com wrote:
 Hi List,

 I am building a package for a client to help them create and perform
 analyses against netcdf files which contain 'a temporal stack' of
 grids.

 For my examples and test cases, I create an example dataset in code
 (as this is a lot more space efficient than providing raw data). The
 code creates a netcdf file in tempdir() and an object of class 'ncdf'
 in the global namespace. I have placed the code in a .R file in the
 data directory of my package and 'load' it with a call to data().

 Why not just put the function that generates the data file into the
usual place (/R/ folder) and document it so that the user knows to run
'sampledata=makeSampleNCDF()' before doing things that need it?

 Trying to put executable code into the data folder does seem a bit perverse!

Barry

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


Re: [Rd] should the text for RIGHT_ASSIGN be - in getParseData()?

2013-07-05 Thread Barry Rowlingson
On Fri, Jul 5, 2013 at 12:57 PM, Duncan Murdoch
murdoch.dun...@gmail.com wrote:

 R itself doesn't make use of the text column, it's for display of code
 by highlighters etc.  So if anyone does assume text is a function name,
 it's their bug, not ours.  In fact, the bug is already there, because
 there is actually one other example which was being parsed properly,
 ** is translated to ^.  There's no `**` function, but 2**3 works.

 Is there any reason right-assign with - still exists? How much
code on CRAN uses it, and how trivially could it be excised? Can we
also have 'up assign'  and down assign so I can do:

  3
  x -^
  x -v
  4

 - they make just as much sense.

 Okay, lets see all the edge cases.

Barry

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


Re: [Rd] should the text for RIGHT_ASSIGN be - in getParseData()?

2013-07-05 Thread Barry Rowlingson
On Fri, Jul 5, 2013 at 7:24 PM, peter dalgaard pda...@gmail.com wrote:

 I have used in with multi-line input, occasionally, though. As in

 replicate(1, {
ysim - rbinom(length(p), n, p)
glm(cbind(ysim, n - ysim) ~ x, binomial)$deviance
 })

 ... and then you realize that you probably don't want to look at 1 
 simulated deviances and add - simDev.


 Yes, that's kinda cute, but then you realise you don't want to have
to type all that again and it would really be better off in a
function. Can you do something like:

replicate(1,{
  ysim - rbinom(length(p), n, p)
glm(cbind(ysim, n - ysim) ~ x, binomial)$deviance
}) - function()...

 - I don't think so. Once you've started typing, the only way to get
it into a function is going to involve sticking function() at the
start, at which point you can add the foo -

I guess this is the point where Dirk gets upset and calls me a troll.
I'll shut up. You've convinced me its mostly harmless.

Barry

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


Re: [Rd] Subset of a 'table' divided by a 'table' is a 'table', but printed by 'print.default'

2013-04-30 Thread Barry Rowlingson
On Tue, Apr 30, 2013 at 10:49 AM, Duncan Murdoch
murdoch.dun...@gmail.com wrote:

 So it looks like the bug is in the implementation of /.  Either it
 should drop the class, or it should set the object bit.

 The difference in printing between auto-printing and explicit printing
 may be worth addressing, but really objects like ratio shouldn't exist,
 so it's not surprising that they behave strangely.

 Also happens with *, if LHS is not a scalar:

  c(1,1)*table(x)
x
A B
2 2
attr(,class)
[1] table

  1*table(x)
x
A B
2 2

 - similar with + and -, but not unary + and -.

 Nice to see a bug in arithmetic operators that isn't covered by
everyone screaming FAQ 7.31!!!

Barry

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


[Rd] R CMD INSTALL fail deletes earlier versions

2013-04-18 Thread Barry Rowlingson
Just tried to update devtools for R 2.15.3, and after an error about
it only being available for 3.0.0, I found my previously good-enough
devtools had disappeared. Here's how it happens:

$ R --quiet
 require(devtools)
Loading required package: devtools
pac packageDescription(devtools)$Version
[1] 1.1

$ R CMD INSTALL devtools_1.2.99.tar.gz
* installing to library
‘/nobackup/rowlings/RLibrary/R/i486-pc-linux-gnu-library/2.15’
ERROR: this R is version 2.15.3, package 'devtools' requires R = 3.0
* removing 
‘/nobackup/rowlings/RLibrary/R/i486-pc-linux-gnu-library/2.15/devtools’

Oh well, I'll just carry on with the old...

$ R --quiet
 require(devtools)
Loading required package: devtools
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE,
logical.return = TRUE,  :
  there is no package called ‘devtools’

 Oh gee thanks. 1.2.99 wouldn't install, so you zapped my otherwise
perfectly good 1.1?

 Feature? Bug? Fixed in 3.0.0 (can't see it in NEWS)?

Barry

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


Re: [Rd] Snippets from other packages/ License

2013-03-15 Thread Barry Rowlingson
On Thu, Mar 14, 2013 at 8:34 AM, Felix Schönbrodt nicebr...@gmx.net wrote:
 Hello,

 I want to use a function from another package (which is GPL=3), about 20 
 lines of code, in my own package.
 I somewhat hesitate to depend on the entire package just for this single 
 function, but of course I want to credit the original authors.

 What would be the best way to do that? Where should I put that credit? Or 
 should I proceed completely different?

 Why so shy about the name and location of this function?

 I think I've seen cases like this before, where a package has a handy
little function that has use outside the context of the package. In
that case I think the best thing is often for that function to be
taken out of that package completely, and put in a new package,
because it isn't so tightly coupled to the aims of the package.

 Obviously this is overkill for one function, but its possible there's
a few functions, or that they are handy enough to belong somewhere
else, such as the plotrix package if its a little plotting function,
or in one of Hadley's packages if it has an underscore in the name.

Barry

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


Re: [Rd] Why cannot `Rscript -e` accept an empty line?

2013-03-09 Thread Barry Rowlingson
On Sat, Mar 9, 2013 at 9:32 PM, Yihui Xie x...@yihui.name wrote:
 See the example below (under Ubuntu):

 $ Rscript -e '1' -e '2'
 [1] 1
 [1] 2
 $ Rscript -e '1' -e '' -e '2'
 ERROR: option '-e' requires an argument
 $ uname -a
 Linux xie 3.5.0-25-generic #39-Ubuntu SMP Mon Feb 25 18:26:58 UTC 2013
 x86_64 x86_64 x86_64 GNU/Linux

 Similar problem under Windows:

 Rscript -e 1 -e  -e 2
 [1] 1
 Error: object 'e' not found
 Execution halted

 I can certainly save the code in a script and run Rscript foo.R, but
 I'm curious why Rscript stops when the -e argument is an empty string.

 There's some over-zealous argument parsing in the main R startup
shell script. You didn't try negative numbers, did you?

$ Rscript  -e -1
ERROR: option '-e' requires an argument
$ Rscript  -e +1
[1] 1

The R script strips anything starting with a - from the arg after -e
and throws that error if there's nothing left. The relevant lines are:

-e)
  if test -n `echo ${2} | ${SED} 's/^-.*//'`; then
a=`echo ${2} | ${SED} -e 's/ /~+~/g'`; shift
  else
error option '${1}' requires an argument
  fi

- now at least that's on Unix. The Windows problem looks like its
doing something else, and mashing some quotes up and passing 'e' as an
expression to one of the other -e options.

 Not sure what the fix might be, except maybe for the user to always
wrap their expressions in curly brackets...

Barry

__
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 Barry Rowlingson
On Thu, Jan 31, 2013 at 4:28 PM, Yihui Xie x...@yihui.name wrote:
 See this page by Barry Rowlingson:
 https://stat.ethz.ch/pipermail/r-devel/2012-February/063338.html

 Sadly that page is just the lipstick on a pig. Underneath, its still a pig.

 Given that CRAN maintainers do not even use JavaScript, I bet CSS does
 not matter either; plain text is plain good.

 I think we all know that the whole of www.r-project.org could do with
a revamp and that large chunks of the CRAN infrastructure would
benefit from a redesign. But at the moment, it all kinda works, its
just a bit annoying in places, and we put up with it because the
effort to make it more functional or shiny (no, not package:shiny) is
a bit too much.

 Sometimes putting lipstick on the pig is enough...

Barry

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


Re: [Rd] SystemRequirements’ field

2012-12-12 Thread Barry Rowlingson
I see three references to systemRequirements in Writing R Extensions.
The one you list in your last email, this one:

If your package requires one of these interpreters or an extension
then this should be declared in the ‘SystemRequirements’ field of its
DESCRIPTION file. [for listing interpreters to run scripts]

and

If you really must assume GNU make, declare it in the DESCRIPTON file by

  SystemRequirements: GNU make

A grep of a complete R 2.15-2 source tree doesn't show it being used
either. It's mentioned in the OONEWS file for R 1.7.0

It is now recommended to use the 'SystemRequirements:' field in the
DESCRIPTION file for specifying dependencies external to the R
system.

Grepping all the DESCRIPTION files on my work box shows such values
for that field as:

GRASS (=6.3)
An ODBC3 driver manager and drivers
libxml2 (=2.6.3)
OpenGL, GLU Library, zlib (optional), libpng)
for building from source: GDAL = 1.6.0 library

some of which look pretty free-form descriptive to me.

Hope that's a bit more useful than 'No'.

On Wed, Dec 12, 2012 at 7:55 PM, Paul Gilbert pgilbert...@gmail.com wrote:


 On 12-12-12 02:19 PM, Prof Brian Ripley wrote:
 On 12/12/2012 18:33, Paul Gilbert wrote:
 Am I correct in thinking that the ‘SystemRequirements’ field in a
 package DESCRIPTION file is purely descriptive, there are no standard
 elements that can be extracted by parsing it and used automatically?

 No.


 Where can I find more details?  The section The DESCRIPTION file in
 Writing R Extensions says only:

 Other dependencies (external to the R system) should be listed in
 the ‘SystemRequirements’ field, possibly amplified in a separate
 README file.

 Thanks,
 Paul

 __
 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


Re: [Rd] chown, chgrp?

2012-08-15 Thread Barry Rowlingson
On Tue, Aug 14, 2012 at 9:30 PM, Hadley Wickham had...@rice.edu wrote:
 Hi all,

 Is there an R wrapper for chown/chgrp (a la Sys.chmod)?  I couldn't
 find one with a few minutes of searching, but it seems like a curious
 omission.

 A recursive grep of an R-dev source tree I had lying around couldn't
find one in a few seconds.

 I'm not sure its a 'curious' omission, since its something normal
users[1] can't do, and who runs R as root?

Barry

[1] Or at least normal normal users. There might be special normal
users with certain chown permissions...

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


Re: [Rd] csv version of data in an R object

2012-04-21 Thread Barry Rowlingson
On Sat, Apr 21, 2012 at 3:28 PM, Max Kuhn mxk...@gmail.com wrote:
 For a package, I need to write a csv version of a data set to an R
 object. Right now, I use:

    out - capture.output(
                          write.table(x,
                                      sep = ,,
                                      na = ?,
                                      file = ,
                                      quote = FALSE,
                                      row.names = FALSE,
                                      col.names = FALSE))

 To me, this is fairly slow; 131 seconds for a data frame with 8100
 rows and 1400 columns.

 The data will be in a data frame; I know write.table() would be faster
 with a matrix. I was looking into converting the data frame to a
 character matrix using as.matrix() or, better yet, format() prior to
 the call above. However, I'm not sure what an appropriate value of
 'digits' should be so that the character version of numeric data has
 acceptable fidelity.

 I also tried using a text connection and sink() as shown in
 ?textConnection but there was no speedup.


 You could try a loop over each row, and use 'paste' to join each
element in a row by commas. Then use 'paste' again to join everything
you've got (a vector of rows) by a '\n' character.

something like: paste(apply(x,1,paste,collapse=,),collapse=\n)   # untested

you probably also want to stick a final \n on it.

Is it faster? I don't know!

Barry

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


Re: [Rd] Jazzing up the Task Views index page

2012-02-27 Thread Barry Rowlingson
On Wed, Feb 22, 2012 at 3:34 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:

 Barry, is this a test/example only or would you plan on keeping
 something like that on your site even if it is not adopted for cran
 task views?  If it is not adopted elsewhere and you are willing to
 maintain it, I would like to link to it.

 It's really only a test, partly for fun, partly to try and kick up
some of the dust on the R web pages.

 There's been a few comments about that, for sure. The main R web
pages are becoming secondary to other community sites for information
on R and packages and so on. I know it is essentially maintained by
the developers primarily for the developers (as is R itself) but at
some point the users will take over - as they are with the community
sites springing up. However, it would be nice if www.r-project.org
took you to a lively, engaging web site with twitter feeds and google
+1 buttons and latest news postings. And didn't use framesets.

 There's also the issue of CRAN and its mirrors. Mirror technology is
so last century - the way to do these things now is via CDNs - content
delivery networks. You do magic redirection via http 302 responses, or
metalinks. It enables better logging, better resilience. All it needs
is a running instance of MirrorBrain. Or just stick .nyud.net on the
end of the URL and have everything magically cached and proxied by the
Coral cache network.

 The inertia to all this is 'well, it works okay at the moment'. But
why is 'okay' okay, when 'better' is better?

 Anyway, how many of you played 'Top Trumps' when you were kids? My
Task Views index reminded me of it, so I just spent an hour grabbing
some stats and formatting them:

http://www.maths.lancs.ac.uk/~rowlings/R/TaskViews/card.html

The inaugural Task Views Top Trumps World Championship will be held in
Nashville in June...

Barry

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


[Rd] Jazzing up the Task Views index page

2012-02-21 Thread Barry Rowlingson
A little while ago here we had a short discussion about Task Views - I
think ignited by someone saying 'how many times do I have to say have
you read the Optimisation Task View??' and I poured some fuel on that
fire by saying Task Views was a stupid name.

Anyway, I did say that Task Views were rather brilliant, but were let
down by their hidden position on the R web sites (tucked away as the
third element of a sub-menu of a CRAN mirror site linked to by the
CRAN link from the Download menu on the main R home page). The index
page is rather plain, so I designed a more engaging one. The result of
my effort is now here:

http://www.maths.lancs.ac.uk/~rowlings/R/TaskViews/

Having done that, I even considered that something like that could
replace the R Homepage. Giving new visitors an idea of the vast range
of techniques and application areas available in R would seem to be
better than the current graphic which has been there since perhaps
2004.

Comments, thoughts, flames, etc?

Barry

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


Re: [Rd] Task views (was: Re: [R] Schwefel Function Optimization)

2012-02-12 Thread Barry Rowlingson
On Sat, Feb 11, 2012 at 5:55 PM, Patrick Burns pbu...@pburns.seanet.com wrote:

 Now it could be that people are not trying
 very hard to solve their own problems, but
 to be fair it is a pretty gruelling process
 to find the Task Views.

 May I suggest that there be a Task Views item
 on the left sidebar of the R website in the
 Documentation section?


 I'd go further, and suggest that the list of Task Views appears on
the home page of www.r-project.org under the heading Look at all
these things you can do with R. (Maybe to replace the 8 year old
clustering graphic (or maybe someone could do something in ggplot2
that looks nice n shiny?) )

 Task Views (stupid name, who's idea was that?) are an absolute GEM
and shouldn't be slotted between 'What's New?' and Search on CRAN
mirror sites. The CRAN Task Views page doesn't even say what Task
Views are. Here's some text that might help:

 Task Views are short documents outlining the functionality of R in a
given field or methodology. Since most of R's power comes from add-on
packages downloaded from CRAN, Task Views tend to concentrate on
summarising the packages that are relevant. If you ever find yourself
thinking 'how do I do X in R?' then the list of Task Views should be
your first stop.

Barry

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


Re: [Rd] Saving nothing with save()

2011-12-22 Thread Barry Rowlingson
On Tue, Dec 20, 2011 at 6:40 PM, Martin Maechler
maech...@stat.math.ethz.ch wrote:

 I've now changed the patch to only warn and only in the case
 when the 'list' argument is missing(.).

 Martin

 Thanks Martin, that sounds great.

 This came about from a question on Stack Overflow, where a user was
loading an R Data file and seemingly there was nothing in it, and
there were no warnings. I suspected maybe there really was nothing in
it, and discovered an easy way to create empty R Data files without
really trying.

 Turns out her file was over 400k bytes long and once she reinstalled
R [yikes] it loaded... What was the real problem? Well we never found
out!


Barry

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


Re: [Rd] secure password token management method in R

2011-12-18 Thread Barry Rowlingson
On Sun, Dec 18, 2011 at 1:28 AM, Paul Gilbert pgilbert...@gmail.com wrote:
 One way this is often done is to have this information in a file that only
 the owner can read. For example, mysql uses a file .my.cnf (in Windows it
 may have a different name). The code then just reads the information from
 the file. To guard against user carelessness, I think mysql will not use it
 if anyone other than the user has read permission on the file. Of the
 various options for passing user/password information, I think this is
 general considered one of the better ways.

 If anyone has a large chunk of spare time on their hands they could
implement an R interface to the Gnome Keyring and store credentials in
there.  I think under the hood it uses dbus so first implement dbus in
R. Or just call some code with system()...

 gnome keyring API: http://live.gnome.org/GnomeKeyring/StoringPasswords

 command line interface: https://launchpad.net/gkeyring

Probably getting a bit over the top now.

Barry

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


[Rd] Saving nothing with save()

2011-12-17 Thread Barry Rowlingson
Scenario: Here I am working away in R. I've got results that prove
global warming is anthropogenic and also the solution for producing
limitless carbon-neutral energy from nuclear fusion. Its been a good
day.

So, I want to save my work. I don't want to overwrite my current
.RData, so I save it to another file:

save(file=prize.RData)  # just need to email this to the Nobel committee
q()
  Save workspace image? [y/n/c]: - no I don't want to save the
workspace image, I just saved everything to prize.RData. But gee, it
did seem to do that quite quickly considering the volume of evidential
data in my work. My unix shell prompt returns.

Uh oh. See what I did there? I typed 'save' when I meant 'save.image'.
What does that give me?

 A 42 byte, empty, latest.RData, and because there was no warning or
error I quit without saving it again. Oops. Massive Data Loss.

 Is there any reason why save(file=file.RData) couldn't warn or
error if you try and save nothing? There's no obvious check in the R
code for save.

Barry

PS the above scenario is fictional. When did I last have a good day?

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


Re: [Rd] secure password token management method in R

2011-12-14 Thread Barry Rowlingson
On Wed, Dec 14, 2011 at 9:54 PM, Ni Wang niw...@gmail.com wrote:
 hi, r developers, I am now working on a R function/package to handling
 online request with username and token/password.

 For security reasons, it's not so safe to store the username  token in
 persistent variables, since they'll be saved to disk when
 users save their workspace. Is there a secure way in R to handle the online
 password management? I have searched it online
 but didn't find any good suggestions. So I am trying my luck on this mail
 list.

 If you save something to an environment that isnt the Global
Environment then R won't save it when you quit and save. Suggest you
save credentials in a list. Maybe something like this:

 attach(list(username=mrbluesky,password=s3cr3t),name=credentials)

then you just get user and password from the environment when needed:

 get(username,envir=as.environment(credentials))
 get(password,envir=as.environment(credentials))

saving the R workspace in the usual way (answering 'y' to Save
Workspace Image) won't save this data.

 I have a vague memory of Splus possibly having a temporary
environment which would do what you want, but that doesn't seem to be
present in R...

Barry

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


Re: [Rd] bug in rank(), order(), is.unsorted() on character vector

2011-12-07 Thread Barry Rowlingson
2011/12/7 Hervé Pagès hpa...@fhcrc.org:
 rank(xa)

See help(Comparison), specifically:

Beware of making _any_ assumptions about the
 collation order followed by Collation of
 non-letters (spaces, punctuation signs, hyphens, fractions and so
 on) is even more problematic.

Barry

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


Re: [Rd] bug in rank(), order(), is.unsorted() on character vector

2011-12-07 Thread Barry Rowlingson
2011/12/7 Joris Meys jorism...@gmail.com:
 @Barry : regardless of whether '_' comes before or after '1' , it
 should be consistent. Adding an 'a' shouldn't shift '_' from before
 '1' to between '1' and '2', that's clearly an error. The help files
 are not stating anything about that.

 That's an assumption. The help pages are quite clear about making assumptions.

 The only way this could be a 'bug' is if you can show that the sort
order in R is different from the lexicographic sort order using the
collating sequence of the locale in use. But even my command line
'sort' agrees:

$ sort  f1.txt
_1_
1_9
2_9

 now add the trailing a:

$ sort  f1.txt
1_9a
_1_a
2_9a

[ I had a thought maybe it was because _ is sometimes used to break
thousands in numeric formats, but I can't get any obvious consistency
out of that hypothesis ]

Barry

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


Re: [Rd] how to make a true binary package?

2011-10-11 Thread Barry Rowlingson
On Tue, Oct 11, 2011 at 6:09 PM, A Zege andre.z...@gmail.com wrote:
 OK, gentlemen, i agree with you in general. I was not talking about a general
 purpose, general use package that one prepares for CRAN. I am sure you are
 familiar professionally or can imagine situations where you need to
 demonstrate a solution to a specific task without fully disclosing the
 details -- sometimes even hard core open source adherents need to sacrifice
 desire for openness for some prosaic purposes, like getting paid :).
 Compilable languages give an easy solution of a binary code. It sounds like
 if one wants true binary, he has to recode in C++. I thought it's possible
 in R as well, i thought this was discussed even as a default behavior for
 next version of R to make stuff go faster. Maybe not. Thanks, anyway.


 [deja vu all over again]

 What you seem to want to do is code obfuscation. With C, the
obfuscation is caused by it being turned into machine code
instructions, making exact reconstruction of the C source impossible,
but reconstruction of the code as assembly language and hence reverse
engineering very possible.

 With R, there is no compilation to machine code, so plain R source
code has to be available to the R interpreter [exception: see Simon's
talk of bytecode]. Any encryption you put on has to be decrypted by
the user in order to run it. I've said this a few times on R-help and
maybe R-devel too.

 If someone is offering to pay you, then if you tell them they can see
the source code then they should want to pay you more.

 There's also nothing to stop you putting a restrictive license on
your source code - including clauses like 'if you look at the contents
of any *.R files you are in breach of this license'. These things
might even stand up in court.

 Barry 'Not a lawyer' Rowlingson

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


Re: [Rd] Link between Qt GUI and R

2011-09-12 Thread Barry Rowlingson
On Mon, Sep 12, 2011 at 2:00 AM, typhoong graham...@eurus-energy.com wrote:
 hi everyone, thanks for all the tips.


 Barry, can you tell me why you think PyQT is by far the best way?

 I said that conditional on you knowing or wanting to learn Python.
Python interacts with Qt in much the same way as C++ interacts with
it, but without the annoying compile and link steps of C++ (Python is
an interpreted language). Qt was designed to work with C++, and so
development with Python and C++ should be faster than most other Qt
interfaces.

So if you already know Python, and your R scripts are already in the
can ready to go, there's less point learning, or even constructing,
some R-Qt interface than using the well-established and robust
Python-Qt interface.

Barry

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


Re: [Rd] Link between Qt GUI and R

2011-09-11 Thread Barry Rowlingson
On Sun, Sep 11, 2011 at 11:30 AM, typhoong graham...@eurus-energy.com wrote:
 hi,

 i want to build a Qt front-end GUI which communicates with R, and i am not
 sure what i should use for the interface. There seems to be many ways:
 R.dll, Rinside, Rcpp, RQt, Rtools... . what is the best way? please advice.


Another way is to write the Qt GUI code in Python using the PyQt4
classes, then use RPy to call the required R functionality, get the
results back, slap them into the GUI.

If you can program in Python or want to learn it then its the best way by far :)

Barry

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


Re: [Rd] Please explain your workflow from R code - package - R code - package

2011-09-10 Thread Barry Rowlingson
On Fri, Sep 9, 2011 at 7:41 PM, Hadley Wickham had...@rice.edu wrote:

 It's not the cool kids who are doing this, it's the lazy kids ;)

 laziness being one of the three virtues of a programmer. The other
two being hubris and something else I don't have time to look up at
the moment.

 library(fortunes) fodder: Don't do as I say, do as Hadley does.

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


Re: [Rd] non-R package development

2011-05-21 Thread Barry Rowlingson
On Sat, May 21, 2011 at 2:04 AM, Spencer Graves
spencer.gra...@structuremonitoring.com wrote:

      I routinely use the R CMD check, etc., process with Subversion for
 version control and collaborative development.  I've looked for similar
 capabilities for other languages, so far without success.

 Python has a similar package build system based around a directory
structure with a 'setup.py' at its root - you may have seen this if
youve ever installed a python package from source. This python script
enables you to do things like 'python setup.py build' and 'python
setup.py install' to build and install the package, as well as run
tests, build distributable archives and so on. There's probably a way
to get a boilerplate package structure all ready to start developing
but I cant think what it is off the top of my head.

SVN and most other version control systems will play nicely with
text-based program development, so get checking in your python,
matlab, and unix scripts. If LabVIEW has a binary format then you can
normally check these in but you won't get meaningful 'diffs' out of
the system to see what has changed between revisions.

Barry

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


Re: [Rd] fortan common block

2011-05-08 Thread Barry Rowlingson
On Fri, May 6, 2011 at 4:04 PM, Paul Gilbert
pgilb...@bank-banque-canada.ca wrote:
 Is it possible in R to call a fortran routine that sets variables in a common 
 block and expect the values to persist when a call is made from R to a second 
 routine that uses the common block?

 If not (as I suspect),  is it possible to use a common block in a group of 
 routines that are used together, for as long the routines do not return to R?

Simple test seems to confirm it. Here's some 'tran with a setter and a getter:

comchk.f:

  subroutine bar(n)
  common /c/ i
  i=n
  end

  subroutine geti(j)
  common /c/ i
  j = i
  end

R CMD SHLIB comchk.f
  dyn.load(comchk.so)

  .Fortran(bar,as.integer(9))
 [[1]]
 [1] 9

  .Fortran(geti,as.integer(-1))
 [[1]]
 [1] 9

Barry

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


Re: [Rd] Wish there were a strict mode for R interpreter. What

2011-04-11 Thread Barry Rowlingson
On Sat, Apr 9, 2011 at 10:08 PM, Ted Harding ted.hard...@wlandres.net wrote:

 I'm with Duncan on this one! On the other hand, I can understand the
 issues that Paul's students might encounter.

 I think the right thing to so is to introduce the students to the
 basics of scoping, early in the process of learning R.

 Would that be before or after you introduce them to the basics of
testing? Hint: AFTER!

Barry

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


Re: [Rd] How to disable R's crash prompt

2011-03-09 Thread Barry Rowlingson
On Tue, Mar 8, 2011 at 10:41 PM,  wayne.zh...@barclayscapital.com wrote:
 That did the trick.  Thank you soo much Simon!

 But really you *should* fix the segfault. Either you know why it
happens, in which case you should spot it before it happens and do
something sensible, or you don't know why it happens, in which case it
could be a serious bug in your code.

 Even if you *do* know why it happens, there may be other bugs in your
code that cause segfaults that you *dont* know about, and you'll miss
them because you are stupidly ignoring all segfaults.

 Fix the bugs.

Barry

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


Re: [Rd] How to disable R's crash prompt

2011-03-08 Thread Barry Rowlingson
On Tue, Mar 8, 2011 at 2:24 PM,  wayne.zh...@barclayscapital.com wrote:
 Dear R devel,

 I have a C++ app that calls into embedded R to perform some analytic 
 calculations.  When my app encounters a segmentation fault, R always prints 
 the following crash prompt and asks me to enter an action:


 *** caught segfault ***
 address 0x8, cause 'memory not mapped'

 Possible actions:
 1: abort (with core dump, if enabled)
 2: normal R exit
 3: exit R without saving workspace
 4: exit R saving workspace



 The problem is my app will be run in non-interactive mode, so there is no way 
 for me to enter the action.  Is there a way to disable the crash prompt and 
 have R simply crash the whole app?  I have tried using -file=/dev/null, 
 -slave, -vanilla, and pretty much all other start options, to no avail.

 If someone from Barclays Capital is writing programs that are being
allowed to seg fault and they want to *ignore* the seg fault then I'm
taking all my money away from Barclays Capital and keeping it away.
Barclays Capital, the bank that likes to say seg fault.

 Your code can't possibly seg fault - our governments are always
telling us banks are too big to fail.

 That's enough banker bashing.

Barry

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


[Rd] Easily switchable factor levels

2011-02-23 Thread Barry Rowlingson
I've recently been working with some California county-level data. The
counties can be referred to as either FIPS codes, eg F060102, friendly
names such as Del Norte County, names without 'County' on the end,
names with 'CA' on the end (Del Norte County, CA). Different data
sets use slightly different forms and putting them all together is a
pain.

 So I was wondering about ways to attach multiple sets of level codes
to a factor. It would work something like this:

  foo=multifactor(sample(letters,5),levels=letters,levelname=lower)
  foo
 [1] m u i z b
 Levels: a b c d ... y z
  levels(foo,upper) = LETTERS
  uselevels(foo,upper)
  foo
 [1] M U I Z B
  Levels: A B C D E FZ
  uselevels(foo,lower)
  foo
 [1] m u i z b
  Levels: a b c d z

In this way you could easily switch your levels from M and F to Male
and Female, or Hommes et Dames, without having to do levels(foo) =
something and hope to get the ordering right every time. Just do it
once, keep the multiple sets of level lables in the object.

I'd even throw in a function to print out all the level codes:

  levels(foo,all=TRUE)
   upper  lower
[1] A  a
[2] B  b

etc

I can see assorted problems coding this up to cope with dropping
levels when making subsets... and possibly problems when code does
character matching of levels and expects them to be unchanged...

Has anyone bothered to write anything like this yet? Or is the
application a bit too rare to be worth it?

Barry

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


Re: [Rd] R vs. C

2011-01-17 Thread Barry Rowlingson
On Mon, Jan 17, 2011 at 6:57 PM, David Henderson dnadav...@yahoo.com wrote:
 I think we're also forgetting something, namely testing.  If you write your
 routine in C, you have placed additional burden upon yourself to test your C
 code through unit tests, etc.  If you write your code in R, you still need the
 unit tests, but you can rely on the well tested nature of R to allow you to
 reduce the number of tests of your algorithm.  I routinely tell people at Sage
 Bionetworks where I am working now that your new C code needs to experience at
 least one order of magnitude increase in performance to warrant the effort of
 moving from R to C.

 But, then again, I am working with scientists who are not primarily, or even
 secondarily, coders...

If you write your code in C but interface to it in R, you can use the
same R test harness system. I recently coded something up in R, tested
it on small data, discovered it was waaay too slow on the real data,
rewrote the likelihood calculation in C, and then used the same test
set to make sure it was giving the same answers as the R code. It
wasn't. So I fixed that bug until it was. If I'd written the thing in
C to start with I might not have spotted it.

 Sometimes writing a prototype in R is a useful testing tool even when
you know it'll be too slow - as an interpreted language R gives you a
rapid development cycle and handy interactive debugging possibilities.
Things that do exist in C but require compilation

Barry

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


[Rd] stats, pics etc on CRAN

2010-11-01 Thread Barry Rowlingson
Does anyone have some nice ways of showing what's on CRAN? A
time-series of the number of packages? A clustered graph of packages
by keyword?

I'm just after a more impressive way of saying there's 2600 packages
on CRAN than saying that.

Counts of lines of R and C/Fortran code would be interesting... The
CRANtastic tag cloud is quite handy... Anything else?

Barry

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


Re: [Rd] Check for updates under Windows (Was: a reliable way to check the latest version of R on CRAN?)

2010-09-21 Thread Barry Rowlingson
On Sat, Sep 18, 2010 at 11:17 PM, Yihui Xie x...@yihui.name wrote:
 Dear R developers,

 I asked this question in r-help list but have not got a definite
 solution yet, and I think it might be more appropriate to ask
 developers or CRAN maintainers directly. Many software packages often
 have a menu item like Check for updates under the Help menu, e.g.
 Filezilla and Firefox, and I believe it is also necessary for R (at
 least for R GUI under Windows). Note all users really have to update
 R, but we should make it clearer to them that new versions are
 available. Yes, they can go to R homepage to check by themselves, but
 my experience tells me it is rarely the case. Therefore, I wish RGui
 could gain a new menu to check for updates of R. Thanks very much!

Something like this:

 winMenuAdd(Updates); winMenuAddItem(Updates,R
Version,require(gtools);checkRVersion())

Barry

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


Re: [Rd] Non identical numerical results from R code vs C/C++ code?

2010-09-10 Thread Barry Rowlingson
On Fri, Sep 10, 2010 at 11:46 AM, Renaud Gaujoux
ren...@mancala.cbio.uct.ac.za wrote:
 Hi,

 suppose you have two versions of the same algorithm: one in pure R, the
 other one in C/C++ called via .Call().
 Assuming there is no bug in the implementations (i.e. they both do the same
 thing), is there any well known reason why the C/C++ implementation could
 return numerical results non identical to the one obtained from the pure R
 code? (e.g. could it be rounding errors? please explain.)
 Has anybody had a similar experience?

 By not identical, I mean very small differences ( 2.4 e-14), but enough to
 have identical() returning FALSE. Maybe I should not bother, but I want to
 be sure where the differences come from, at least by mere curiosity.

 Briefly the R code perform multiple matrix product; the C code is an
 optimization of those specific products via custom for loops, where entries
 are not computed in the same order, etc... which improves both memory usage
 and speed. The result is theoretically the same.

 I've had almost exactly this situation recently with an algorithm I
first implemented in R and then in C. Guess what the problem was? Yes,
a bug in the C code.

 At first I thought everything was okay because the returned values
were close-ish, and I thought 'oh, rounding error', but I wasn't happy
about that. So I dug a bit deeper. This is worth doing even if you are
sure there no bugs in the C code (remember: there's always one more
bug).

 First, construct a minimal dataset so you can demonstrate the problem
with a manageable size of matrix. I went down to 7 data points. Then
get the C to print out its inputs. Identical, and as expected? Good.

 Now debug intermediate calculations, printing or saving from C and
checking they are the same as the intermediate calculations from R. If
possible, try returning intermediate calculations in C and checking
identical() with R intermediates.

 Eventually you will find out where the first diverge - and this is
the important bit. It's no use just knowing the final answers come out
different, it's likely your answer has a sensitive dependence on
initial conditions. You need to track down when the first bits are
different.

 Or it could be rounding error...

Barry

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


[Rd] An ls error which is not an error...

2010-09-09 Thread Barry Rowlingson
If I try ls with an unquoted version of something in my search list, I
get an error message but the ls completes successfully. For example:

  attach(x.RData)
  ls(file:x.RData)
 Error in try(name) : object 'x.RData' not found
 [1] x

which seems to be because ls first does: nameValue - try(name) which
raises the error, and then goes on to do some
substitute(deparse(magic)) to get the name and carries on as if I'd
done ls(file:x.RData)

Documentation says (with my enumeration):

The ‘name’ argument can specify the environment from which object
 names are taken in one of several forms:

1. as an integer (the position in the ‘search’ list);
2. as the character string name of an element in the search list;
3.  or as an explicit ‘environment’

Either ls(file:x.RData) is none of these in which case there should be
an error and exit, or it's (2), in which case the error is misleading.
I think try(name,silent=TRUE) might be a better option?

Barry

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


Re: [Rd] No RTFM?

2010-08-24 Thread Barry Rowlingson
On Tue, Aug 24, 2010 at 3:28 PM, Michael Dewey i...@aghmed.fsnet.co.uk wrote:

 The thing I find most rude on the list is not the occasional abrupt postings
 by people who are obviously having a bad day but the number of fairly long
 exchanges which end unresolved as the OP never bothers to post a conclusion
 and we never know whether we solved his/her problem.
 I am not asking for thanks but we would all benefit from knowing how it all
 turned out.

 The elephant in the room is, I think, the idea that maybe mailing
lists have had their day - if R-help was a web-based forum then
threads could be moderated by a group of privileged individuals, or
rated by users. Basically, stackoverflow.com

For anyone who has never visited:

http://stackoverflow.com/questions/tagged/r

Good answers get modded up, bad ones slide off.

 I'm considering unsubbing from r-help, and adding the R feed from
stackoverflow to my RSS reader...

Barry

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


Re: [Rd] small syntax suggestion

2010-08-23 Thread Barry Rowlingson
On Mon, Aug 23, 2010 at 6:06 PM, Davor Cubranic cubra...@stat.ubc.ca wrote:

 The students are trying to *compare* to a negative number, and trip on R's 
 parsing of -. They could use '=' for assignment all they want (which I 
 thought is being discouraged as a code style these days, BTW), and they'll 
 still run into this problem.

 Oops yes, negative logic assumption from me.

 Okay, back to the question...

 Looks tricky, because if(x=2){...} fails because of syntax. There's
stuff in gram.y that makes x=1 a bit special, and only lets it occur
as a top-level expression. However x-1 is allowed anywhere an
expression can be. Both expressions then call the same 'primitive'
function. At that point I'm not sure how the code could find out if
it's being called from a - or an = assignment. And then whether its a
top-level expression or not. And this would need checking on every -
call, which could be a problem...

 Barry

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


Re: [Rd] How do you make a formal feature request?

2010-08-21 Thread Barry Rowlingson
On Sat, Aug 21, 2010 at 4:41 PM, Donald Winston satchwins...@yahoo.com wrote:
 Who decides what features are in R and how they are implemented? If there is 
 someone here who has that authority I have this request:

 A report() function analogous to the plot() function that makes it easy to 
 generate a report from a table of data. This should not be in some auxiliary 
 package, but part of the core R just like plot(). As a long time SAS user I 
 cannot believe R does not have this. Please don't give me any crap about 
 Sweave, LaTex, and the power of R to roll your own. You don't have to roll 
 your own plot do you? Reports are no different. If you don't agree do not 
 bother me. If you agree then please bring this request to the appropriate 
 authorities for consideration or tell me how to do it.

 Okay Donald, let's do this. Together. Because only you seem to know
what you want in this report() function.

 Can you spell out the sort of tables of data that report() will take,
what other options it will have and so on, and what its output will
be. It is quite possible someone out there will go Yeah, I can do
that, and have a go, especially if they also go Yeah, I could *use*
that too.

 If you really want it done, then you can pay money.

 So, spec please. From your earlier postings it sounds like not much
more than summary(d) and a few table(d) outputs.

Barry

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


Re: [Rd] Defining a method that behaves like '$'?

2010-07-10 Thread Barry Rowlingson
On Fri, Jul 9, 2010 at 2:10 PM, Renaud Gaujoux
ren...@mancala.cbio.uct.ac.za wrote:
 I do not want to access the slot itself but its content: a:toto would be
 a...@slot1[['toto']].
 The thing is that I would like to have two different methods: '$' (that I
 already have) and another one to define, ideally that behaves like '$'.
 So in brief:
 - a:toto would be for a...@slot1[['toto']]
 - a$tata would be for a...@slot2[['tata']]

 But apparently it might not be possible.


 Even if possible, definitely not desirable. As already mentioned, a:b
is the sequence a to b (as in 0:10), so it's going to look weird to
anyone who hasn't noticed your definition. Also, it looks fairly
meaningless. By which I mean there's no obvious reason why a colon
should do what you want it to do. There's also no obvious reason why a
dollar sign does what it does (whats it got to do with dollars?) but
we've had it for 20 years so we're stuck with it.

 Write a method for your objects and force your users to do a bit more
typing as a trade-off for legibility:

 slot1(a,toto)

 is a lot more readable than a:toto (assuming you replace 'slot1' with
something meaningful).

 Remember, code is most likely to be written once, and read many times
- so make it easy for readers!

Barry

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


Re: [Rd] require( foo (= 2.1) )

2010-05-31 Thread Barry Rowlingson
On Sun, May 30, 2010 at 5:50 PM, Romain Francois
rom...@r-enthusiasts.com wrote:
 Hi,

 Sure. I could and I would provide a patch. Since this is more of a nice to
 have, I wanted to first find out whether others would find it useful, and
 also if such a patch would have chances to get accepted by one of R-core
 members.

 Sometimes patches I or others provide upfront are not accepted. I'm not
 complaining about it, it is always an opportunity to learn something ...


 For starters you could write a function called requireVersion that
does what you want. That would help you (since you say you often find
yourself using this paradigm) and also it would help anyone else who
does this. And since it wouldn't be a patch to R it wouldn't need
R-gods to approve it. It would also make you think about how you'd
parameterise the call - I wouldn't want to build something that had to
parse foo (=2.1), for example, but having a minimum.version
argument makes more sense. Shouldn't be that difficult, you've written
most of it already!

 It might then get included in one of the packages of miscellany on
CRAN, and then maybe become core R functionality (if you sacrifice the
required animal to the R-gods, of course).

Barry

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


Re: [Rd] Is it valid to do x == Inf?

2010-04-01 Thread Barry Rowlingson
On Thu, Apr 1, 2010 at 11:03 AM, Henrik Bengtsson h...@stat.berkeley.edu 
wrote:
 Hi,

 I found in a bit of code the following test for infinity:

  if (x == Inf) ...

 Is that valid, or should it be (as I always thought):

  if (is.infinite(x)) ...?

 Does it depend on whether 'x' is float or integer?

 My question is related to testing for missing values where is.na(x) is 
 required.

 Well, '-Inf' is infinite too:

  is.infinite(-Inf)
 [1] TRUE

 but is not equal to Inf:

  Inf == -Inf
 [1] FALSE

 Also, ?is.infinite says it is a generic method, so is.infinite(x)
could be doing anything, depending on x. I would say the best way of
testing if x is a numeric value of plus infinity would be to test
x==Inf.

 Also also, is.infinite (on a numeric vector) returns FALSE on NA, and
NaN, whereas x==Inf returns NA values for non nice-number inputs.

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


Re: [Rd] Difference Linux / Windows

2010-04-01 Thread Barry Rowlingson
On Thu, Apr 1, 2010 at 4:37 PM, Simon Urbanek
simon.urba...@r-project.org wrote:

 On Mar 31, 2010, at 18:38 , Seth Falcon wrote:

 On 3/31/10 1:12 PM, Christophe Genolini wrote:

 Hi the list,
 I am writing a package that happen to not be compatible with linux
 because I did not know that the function savePlot was available only
 on windows. Is there a list of incompatible function? How can I get
 this kind of information?

 One way is to obtain a copy of the R sources and then grep the Rd files
 for '#ifdef'.

 I don't claim this is convenient.


 nor sufficient - lot of it is simply in the windows directory (such as
 savePlot).
 The safest approach right now is simply to read the documentation - savePlot
 does tell you that it works only for the Windows device. I'm not aware of an
 automated list (save for dumping the function lists per-package on each
 platform).

 It works only on the windows() device on the Windows platform. The
savePlot function *is* on the Linux platform (contrary to OP message,
modulo whether a mention of 'windows' meant the platform or the
device) but only for Cairo x11() devices.

Clear?

Barry

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


Re: [Rd] Improved Nelder-Mead algorithm - a potential replacement for optim's Nelder-Mead

2010-03-06 Thread Barry Rowlingson
On Fri, Mar 5, 2010 at 8:26 PM, Ravi Varadhan rvarad...@jhmi.edu wrote:
 Hi,

 I have written an R translation of C.T. Kelley's Matlab version of the 
 Nelder-Mead algorithm.  This algorithm is discussed in detail in his book 
 Iterative methods for optimization (SIAM 1999, Chapter 8).  I have tested 
 this relatively extensively on a number of smooth and non-smooth problems.  
 It performs well, in general, and it almost always outperforms optim's 
 implementation of Nelder-Mead.  I have obtained written permissions from both 
 SIAM (publishers of Kelley's text) and from C.T. Kelley himself to make this 
 publicly available in R.

 By 'in R' do you mean 'written in R' or 'in the R package as you get
from CRAN'?

 I think the terms and conditions of that permission would need to be
studied if the code can be redistributed and modified, who holds the
copyright, can it be stuck in with R under an open license and so
on...

   Therefore, speed gains could be achieved if translated into C (I am not 
 proficient in C).

 Not necessarily - if most of the time is spent in the objective
function then even an instantaneous implementation isn't going to
speed things up enough to be worthwhile. More R users know R than C so
the R implementation is always going to be more useful for R users to
study, tweak, and possibly improve!

 Sounds good though!

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


Re: [Rd] CRAN nearly down?

2010-03-06 Thread Barry Rowlingson
On Fri, Mar 5, 2010 at 5:40 PM, Paul Gilbert
pgilb...@bank-banque-canada.ca wrote:
 Is CRAN having trouble or is it just me?  (The web interface is very
 slow and install.packages() is timing out and giving me service not
 available).

Have you ever tried:

http://downforeveryoneorjustme.com/cran.r-project.org

 - I thought it was a joke domain name at first! Obviously it might
not get it right if a site is being slow or inconsistent, but its a
handy check when you get a flat non-response.

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


Re: [Rd] R logo as SVG ?

2010-02-21 Thread Barry Rowlingson
On Sat, Feb 20, 2010 at 7:56 PM, Jens Elkner je...@cs.uni-magdeburg.de wrote:

 Yes and scaling would be too resource consuming as well (very bad for
 menus, etc.). I think, the most challenging part here is all the
 [different type of] shadows. So does anybody know, who made  the
 original pixel based image? If not raytraced and steps for reproduction
 are available (e.g. gimp/psp layers), it should be possible to produce a
 less resource consuming but pretty close svg (at least at the given size

A while ago I played around with creating a new R logo using vector
graphics. I took the current logo as a starting point. Here's some
samples on different coloured backgrounds:

http://www.maths.lancs.ac.uk/~rowlings/Graphics/Logo/R/logos.svg

I figured maybe for R 3.0 it would be cool to have an R made from a 1
and a 2

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


Re: [Rd] Problem with ?Syntax

2010-02-20 Thread Barry Rowlingson
On Sat, Feb 20, 2010 at 9:52 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 In ?Syntax [ is given as higher priority than $ but BOD$demand[3]
 seems to be the same as (BOD$demand)[3] contrary to [ being higher
 priority.

 BOD$demand[3]
 [1] 19
 (BOD$demand)[3]
 [1] 19

 What is the rule being used here?

 I think its the parser rule that defines the syntax of $ on a list. Does:

 BOD$(demand[3]) even work?

 BOD$(demand[3])
Error: unexpected '(' in BOD$(

 - no. The parser sees a $ and then gets the next token (gram.y shows
this to be a symbol or a string constant) as the thing to deal with.
Symbols  I can't think of an example where $ and [ could have
ambiguous precedence that is syntactically correct, so maybe the order
is irrelevant...

 Just for fun:

 x=list(a=1,b=2)
 x$a[1]=2
 x$a[1]
[1] 2
 x$a[1]
[1] 1


Barry

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


Re: [Rd] filenames with special characters in the R/ directory of a package?

2010-02-12 Thread Barry Rowlingson
On Fri, Feb 12, 2010 at 5:35 AM, blue sky bluesky...@gmail.com wrote:
 According to R-exts.pdf (page 3):
 For maximal portability filenames should only
 contain only ASCII characters not excluded already (that is
 A-Za-z0-9._!#$%+,;=...@^(){}’[]

 I have some files with special characters like '[' and '%' e.g.
 '[.set.R'.

That character list in your extract from R-exts.pdf is a list of
non-special characters. And [ and % are in there.

 It's clarification of three sentences previous, which says:

the characters ‘’, ‘*’, ‘:’, ‘/’, ‘’, ‘’, ‘?’, ‘\’, and ‘|’ are
not allowed in file names

 I also have some functions that also have those special
 characters defined in those files exported in NAMESPACE.

 I use the following command to install. And I get no warning or errors.

 R CMD INSTALL -d -l my_custom_dir my.pkg

 I then load the package. I get the following errors and warnings. I
 changed a file to one without these special characters. Then the
 corresponding warning/error disappears. Is it the case that there
 should never be files with special characters as names?

 library(my.pkg)
 Error in namespaceExport(ns, exports) :
  undefined exports: %is%
 In addition: Warning message:
 S3 methods ‘[.set’ were declared in NAMESPACE but not found
 Error: package/namespace load failed for 'my.pkg'

 Have you done an R CMD check on your package? I suspect a problem in
your NAMESPACE file, but it's not related to special characters.

Barry

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


Re: [Rd] R Startup configuration file

2010-02-12 Thread Barry Rowlingson
On Wed, Feb 10, 2010 at 3:06 PM, Barry Rowlingson
b.rowling...@lancaster.ac.uk wrote:

  But I agree that writing a saveable options package is the first step
 - then making that a default in R is the second so people don't have
 to edit profiles and R packages and applications can expect an API for
 savable state.

 More thinking about this has turned it into a problem of being able
to serialize R objects to XML. The most reliable way I can find of
doing that is to use serialize, then rawToChar, and put a big old hex
string in the XML. Hardly the most user-friendly format, but then
users aren't supposed to edit XML anyway. I have also considered
having encoding types for objects, something like:

object encoding=raw name=foo66f6e.a7726/object
object encoding=numeric name=bar3.141/object
object encoding=numeric size=2
name=bazitem3.14/itemitem6.28/item/object

at which point I remembered that R objects can also have attributes
which can be any other R objects too. At which point I realized life's
too short for this...

..and had a rethink. Lots of software these days has a configuration
directory, and runs all the scripts or configs within - think
/etc/cron.daily/ or /etc/init.d on a unix system. This has the
advantage that components of the system can manage their own startup
files there, and not worry about stomping on others. So you'd have a
.Rprofile.d/ folder with, say, a cran.R file that could be sourced by
anything that used CRAN, for example to set the default mirror. I'd
insist that each file in .Rprofile.d/ started with a # do not edit
this file warning...

 I'll think some more over coffee until I realise why this is another
of my dumb ideas...

Barry

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


Re: [Rd] R Startup configuration file

2010-02-12 Thread Barry Rowlingson
On Fri, Feb 12, 2010 at 2:22 PM, Simon Urbanek
simon.urba...@r-project.org wrote:

 This is getting OT, but, please, no XML. It's entirely useless in this
 context IMHO (as it is in others, but that's another story) and we already
 have reliable support for storing R objects (more than one in fact). Despite
 the fact that some used to claim human readability of XML in practice it
 turns out to be false, so I don't see any real benefits of XML in this
 context.

 Yes, I agree. Originally I was hoping to have a nice
human-and-computer readable config.ini file:

[options]
contrasts = structure(list(contrasts = structure(c(contr.treatment,
contr.poly
), .Names = c(unordered, ordered))), .Names = contrasts)

but the lack of an ini parser in R made me think heck, let's do it in
something we do have a parser for

maybe I should use JSON? Yeah, we have a parser and that's what all
the hipster web 3.0 kids are using these days

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


[Rd] R Startup configuration file

2010-02-10 Thread Barry Rowlingson
Currently when R starts up it can be configured by a file of
environment variable specifications and a file of R code. This makes
programmatic modification of startup configuration tricky.

Case in point: I start R, do install.packages(foo), and up pops the
'choose a CRAN mirror' dialog. I'd like to put a 'Save my choice'
button on that dialog. Currently it would have to put
'options(repos=http://example.com/cran;)' into my .Rprofile file. Of
course my .Rprofile file could be full of all sorts of other code, so
there's no easy way to do this and guarantee it will work.

Could we have a .Rconfig file, consisting of key-value pairs in a
standard config file form (or XML?), that is read at startup and
applies the key-value pairs to options(key=value)? Obviously more
detail is needed, such as whether to just have one .Rconfig file in
the users' $HOME or in individual folders, where to put a system
Rconfig file, whether it is applied before or after .Rprofile etc.

Or is it a dumb idea? I can see other ways of doing this, such as
saving the options() as an object and re-loading it at startup, but a
config file has the advantage of being simply read-writable by humans
and computers.

I notice several other package using options-style things that might
benefit from a simple persistence framework. For example the sm
package says in ?sm.options:

 This offers the possibility of customizing the functioning of the
 'sm' library, for instance by insertions of appropriate calls to
 'sm.options' in a load hook for package 'sm'.

To which the average user goes 'huh what?'. With a config file there
could be a save.sm.options() function that wrote a new section to the
user's .RConfig:

[sm]
 whatever = 99
 doSomething = TRUE

which the sm package would read in when it is first attached.

My usual R-devel caveats - yes, I know everyone has day jobs; yes, I'm
sure there are problems with it; no, I don't expect it to get done
unless someone thinks it's a Good Thing because I probably don't have
time for it; yes, R is wonderful and fantastic and you devs do a
fantastic job.

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


Re: [Rd] R Startup configuration file

2010-02-10 Thread Barry Rowlingson
On Wed, Feb 10, 2010 at 11:44 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:

 When I read the ?Startup man page, I find it is too complicated already; I
 don't want to add another kind of file to read.  (Would we have  separate
 user and site versions of this new file?  When would it be handled?)

 However, we could achieve what you are asking for with no changes to base R.
  One way would be to write a small package to handle options.  When you want
 to save a setting, you call a function there that writes it to a private
 file.  Then you manually add a line to your .Rprofile, saying something like
 myOptionPackage::loadMyOptions().  This can do whatever you want, it only
 needs to know how to parse the file that your package wrote.


 Yup, I'd already thought about this. However it does mean that any
other packages or applications that use this feature are going to have
to say make sure you have saveableOptions::loadMyOptions() in your R
profile startup somewhere. Resulting in huh what? from users.

 Actually that's not true if the options are only used in add-on
packages - they can require(saveableIOptions) and load them in their
package .First.lib or .onLoad code. It's only options in the R base
(set by options()) that you need to hack code in order to run at
startup...

 In most modern programs, options and setup state are stored when the
user hits the 'apply' button. Even emacs can handle customisation in a
set of config files these days. Can't remember the last time I hacked
lisp in my .emacs file.

 But I agree that writing a saveable options package is the first step
- then making that a default in R is the second so people don't have
to edit profiles and R packages and applications can expect an API for
savable state.

 As for Startup Overload Syndrome - yes, ?Startup is a bit complicated
already. Maybe a sign it needs simplifying!

Barry

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


Re: [Rd] Package Directory Hierarchy: Recursive inclusion of *.R possible?

2010-02-04 Thread Barry Rowlingson
On Wed, Feb 3, 2010 at 10:40 AM, Johannes Graumann
johannes_graum...@web.de wrote:
 Hello,

 I would like to organize the R directory in my home-grown package into
 sub-directories, but R CMD --build doesn't seem to find *.R files below
 the actual source directory. Is there any way around that?

This was discussed in December:

http://finzi.psych.upenn.edu/R/R-devel/2009-December/056022.html

The conclusion was that if Hadley Wickham can manage 145 files in his
R directory for ggplot2, then so can you. Like we're all superhuman.

It would be nice, but probably need way too many patches to the
various build tools.

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


[Rd] Missing argument error message

2010-01-28 Thread Barry Rowlingson
Back in the days of R 2.6, if you did this, you got this:

 z=function(x){x*2}
 z()
Error in z() : argument x is missing, with no default

 But now in this decade we get (for R 2.9 and 2.10):

 z=function(x){x*2}
 z()
Error in z() :
  element 1 is empty;
   the part of the args list of '*' being evaluated was:
   (x, 2)

Now I can see (after thinking about it) that what is happening is that
because of lazy evaluation or something the 'x' isn't getting spotted
as being empty until R tries to do x*2, which obviously maps to *(x,2)
in functional form. It's perfectly correct to say element 1 of the
args list of '*', being (x,2), is empty.

But which of those two errors above is clearer? I don't suppose much
can be done about this since it is going to the guts of modern R, and
I was surprised my initial searches didn't find hordes of confused
newbies. Just me then. It got me when I was doing a histogram of some
dates:

 hist(cases)
Error in inherits(breaks, POSIXt) :
  element 1 is empty;
   the part of the args list of '.Internal' being evaluated was:
   (x, what, which)

 who what which? If the error had been Error in hist(cases): argument
'breaks' is missing, with no default you wouldn't be wasting your
time reading this now...

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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


  1   2   >