Displaying 20 results from an estimated 30000 matches similar to: "x[1,], x[1,,], x[1,,,], ..."
2006 Oct 19
2
arraytake for extracting subarrays from multidimensional arrays
Hi,
I recently encountered a problem with array subsetting and came up with a
fix. Given an array of arbitrary dimensions, in which the number of
dimensions is only known at runtime, I wanted to extract a subarray. The
main issue with doing this is that in order to extract a subarray from an
array of (say) 4 dimensions you usually specify something like this
a.subarray <- a[,c(4,2),1:5,]
2016 Sep 25
3
withAutoprint({ .... }) ?
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com>
>>>>> on Sat, 24 Sep 2016 11:31:49 -0700 writes:
> Martin, did you post your code for withAutoprint() anywhere?
> Building withAutoprint() on top of source() definitely makes sense,
> unless, as Bill says, source() itself could provide the same feature.
I was really mainly asking
2016 Oct 19
2
How to assign NULL value to pairlist element while keeping it a pairlist?
On Sat, Oct 15, 2016 at 2:00 AM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
>>>>>> Michael Lawrence <lawrence.michael at gene.com>
>>>>>> on Wed, 12 Oct 2016 15:21:13 -0700 writes:
>
> > Thanks, this was what I expected. There is a desire to
> > eliminate the usage of pairlist from user code, which
> >
2016 Oct 12
2
How to assign NULL value to pairlist element while keeping it a pairlist?
Thanks, this was what I expected. There is a desire to eliminate the
usage of pairlist from user code, which suggests the alternative of
allowing for function arguments to be stored in lists. That's a much
deeper change though.
On Wed, Oct 12, 2016 at 12:31 PM, Henrik Bengtsson
<henrik.bengtsson at gmail.com> wrote:
> Michael, thanks for this info.
>
> I've stumbled upon
2016 Oct 12
2
How to assign NULL value to pairlist element while keeping it a pairlist?
Hi Henrik,
It would help to understand your use case for pairlists.
Thanks,
Michael
On Wed, Oct 12, 2016 at 9:40 AM, Michael Lawrence <michafla at gene.com> wrote:
> The coercion is probably the most viable workaround for now, as it's
> consistent with what happens internally for calls. All pairlists/calls
> are converted to list for subassignment, but only calls are
2018 Jul 02
1
MARGIN in base::unique.matrix() and base::unique.array()
Hi,
The man page for base::unique.matrix() and base::unique.array() says
that MARGIN is expected to be a single integer. OTOH the code in charge
of checking the user supplied MARGIN is:
if (length(MARGIN) > ndim || any(MARGIN > ndim))
stop(gettextf("MARGIN = %d is invalid for dim = %d",
MARGIN, dx), domain = NA)
which doesn't really make sense.
As
2002 May 30
1
problem of compile fortran program
I want to call dll from R but encounter problem in compiling the fortran
program.
First I try "Rcmd shlib prog.f", it failed and warning:
make[1]: `libR.a' is up to date.
make: *** No rule to make target `'prog.o', needed by `prog.a'. stop.
Then I try to compile it by absoft fortran compiler, it works and produces
prog.dll.
But when this routine is called in R, it
2014 May 01
3
How to test if an object/argument is "parse tree" - without evaluating it?
This may have been asked before, but is there an elegant way to check
whether an variable/argument passed to a function is a "parse tree"
for an (unevaluated) expression or not, *without* evaluating it if
not?
Currently, I do various rather ad hoc eval()+substitute() tricks for
this that most likely only work under certain circumstances. Ideally,
I'm looking for a isParseTree()
2004 May 27
1
R-1.9.0: Error in paste(ncomp, "LV's") : Argument "ncomp" is missing, with no default
Is it just my installation or bug in 1.9.0 ?
The same thing works fine in 1.8.1
Best regards,
Ryszard
# R-1.9.0
library(pls.pcr)
nr <- 8; ndim <- 2
x <- matrix(rnorm(nr*ndim), nrow=nr)
y <- as.matrix(x[,1])
for (i in 2:ndim) y <- y + x[,i]
y <- y + rnorm(length(y))
m <- pls(x,y,validation='CV')
# Error in paste(ncomp, "LV's") : Argument
2011 Mar 27
1
run function on subsets of matrix
I was wondering if it is possible to do the following in a smarter way.
I want get the mean value across the columns of a matrix, but I want
to do this on subrows of the matrix, given by some vector(same length
as the the number of rows). Something like
nObs<- 6
nDim <- 4
m <- matrix(rnorm(nObs*nDim),ncol=nDim)
fac<-sample(1:(nObs/2),nObs,rep=T)
##loop trough different
2018 Aug 13
2
substitute() on arguments in ellipsis ("dot dot dot")?
Interestingly,
as.list(substitute(...()))
also works.
On Sun, Aug 12, 2018 at 1:16 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 12/08/2018 4:00 PM, Henrik Bengtsson wrote:
>>
>> Hi. For any number of *known* arguments, we can do:
>>
>> one <- function(a) list(a = substitute(a))
>> two <- function(a, b) list(a = substitute(a), b =
2019 Jun 22
2
methods package: A _R_CHECK_LENGTH_1_LOGIC2_=true error
DISCLAIMER: I can not get this error with R --vanilla, so it only
occurs when some other package is also loaded. I don't have time to
find to narrow that down for a reproducible example, but I believe the
following error in R 3.6.0:
> Sys.setenv("_R_CHECK_LENGTH_1_LOGIC2_" = "true")
> library(oligo)
Error in omittedSig && (signature[omittedSig] !=
2014 Nov 24
1
Error "promise already under evaluation ..." with function(x, dim=dim(x))
On Sat, Nov 15, 2014 at 1:47 AM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
>
> On 14/11/2014, 9:06 PM, Henrik Bengtsson wrote:
> > I've meant to ask the following for several years now. I understand why:
> >
> >> foo <- function(x, dim=dim) { dim }
> >> foo(1)
> > Error in foo(1) :
> > promise already under evaluation:
2007 Oct 29
1
meaning of lenwrk value in adapt function
R-listers,
In using the adapt function, I am getting the following warning:
Ifail=2, lenwrk was too small. -- fix adapt() !
Check the returned relerr! in: adapt(ndim = 2, lower = lower.limit,
upper = upper.limit, functn = pr.set,
Would someone explain what the 'lenwrk' value indicates in order to help
diagnose this issue.
Also, what are the possible codes for Ifail, so I can set
2019 Jun 23
2
methods package: A _R_CHECK_LENGTH_1_LOGIC2_=true error
Thank you.
To correct myself, I can indeed reproduce this with R --vanilla too.
A reproducible example is:
$ R --vanilla
R version 3.6.0 Patched (2019-05-31 r76629) -- "Planting of a Tree"
...
> Sys.setenv("_R_CHECK_LENGTH_1_LOGIC2_" = "true")
> loadNamespace("oligo")
Error in omittedSig && (signature[omittedSig] != "missing") :
2007 Mar 28
1
warnings on adapt
Hi all
I was wondering if someone could help me.
I have to estimate some parameters, so I am using the function nlm. Inside
this function I have to integrate, hence
I am using the function adapt.
I don't understand why it is giving the following warnings:
At the beginning:
Warning: a final empty element has been omitted
the part of the args list of 'c' being evaluated was:
2018 Aug 13
1
substitute() on arguments in ellipsis ("dot dot dot")?
Since you're already using bang-bang ;)
library(rlang)
dots1 <- function(...) as.list(substitute(list(...)))[-1L]
dots2 <- function(...) as.list(substitute(...()))
dots3 <- function(...) match.call(expand.dots = FALSE)[["..."]]
dots4 <- function(...) exprs(...)
bench::mark(
dots1(1+2, "a", rnorm(3), stop("bang!")),
dots2(1+2, "a",
2019 Jun 25
3
methods package: A _R_CHECK_LENGTH_1_LOGIC2_=true error
**Maybe this bug needs to be understood further before applying the
patch because patch is most likely also wrong**
Because, from just looking at the expressions, I think neither the R
3.6.0 version:
omittedSig <- omittedSig && (signature[omittedSig] != "missing")
nor the patched version (I proposed):
omittedSig <- omittedSig & (signature[omittedSig] !=
2007 Nov 02
0
applying duplicated, unique and match to lists?
Dear R developers,
While improving duplicated.array() and friends and developing equivalents for the new ff package for large datasets I came across two questions:
1) is it safe to use duplicated.default(), unique.default() and match() on arbitrary lists? If so, we can speed up duplicated.array and friends considerably by using list() instead of paste(collapse="\r")
2) while
2023 Mar 11
2
Multiple Assignment built into the R Interpreter?
FWIW, it's possible to get fairly close to your proposed semantics
using the existing metaprogramming facilities in R. I put together a
prototype package here to demonstrate:
https://github.com/kevinushey/dotty
The package exports an object called `.`, with a special `[<-.dot` S3
method which enables destructuring assignments. This means you can
write code like:
.[nr, nc] <-