Hi,
Say I have
function(aa,bb,cc) { does something }
and I want to go through all (or a subset) of function arguments to check if
they're missing. Of course, I can check each one in turn, ie.
if (missing(aa)) {}
if (missing(bb)) {}, etc.
But is there a construct like the follo
t; > p <- 1:5
> > twoTimes(p)
> Calling twoTimes: x= 1:5
> [1] 2 4 6 8 10
> > twoTimes(p)[1:2] <- c(100,102)
> Calling twoTimes: x= 1:5
> Calling twoTimes<-: x= 1:5
> > p
> [1] 50 51 3 4 5
> >
> > p <- 1:5
>
e a method for "[<-" .
e.g. try:
methods("[<-")
If this is not it ... ??
Cheers,
Bert
On Wed, Jul 10, 2013 at 12:51 PM, David Winsemius
wrote:
>
> On Jul 10, 2013, at 12:17 PM, Harry Mamaysky wrote:
>
>> As I understand it rownames(aa) returns a
d Winsemius wrote:
On Jul 10, 2013, at 11:47 AM, Harry Mamaysky wrote:
> I know how to define replacement functions in R (i.e. ‘foo<-‘ <-
> function(x,value) x<-value, etc.), but how do you define replacement
> functions that operate on subsets of arrays (i.e. how do you pass a
I know how to define replacement functions in R (i.e. âfoo<-â <-
function(x,value) x<-value, etc.), but how do you define replacement functions
that operate on subsets of arrays (i.e. how do you pass an index into foo)?
For example, why does the following use of ârownamesâ work?
> aa <-
R gives you facilities for doing this (using '...' and 'missing') without
passing in a data.frame. For example,
> foo <- function(arg1,arg2,...) { if (missing(arg1)) cat('missing arg1\n');
> print(list(...)) }
> foo(1,2,arg3=3,arg4=4,arg5=5)
$arg3
[1] 3
$arg4
[1] 4
$arg5
[1] 5
> foo(arg2=2
That's a nice solution. Thanks.
Sent from my iPhone
On Apr 9, 2013, at 10:00 AM, Gabor Grothendieck wrote:
On Tue, Apr 9, 2013 at 9:15 AM, Harry Mamaysky wrote:
> That's true. So perhaps there should be a flag that turns on this error
> checking. Often "args"
o have the option of flagging
when one of those list elements (inadvertently) has the same name as an
argument of "what".
Sent from my iPhone
On Apr 9, 2013, at 9:07 AM, Joshua Ulrich wrote:
On Tue, Apr 9, 2013 at 7:31 AM, Harry Mamaysky wrote:
> Thanks for the explanations.
>
>
ing( 'Element of "args" is also an argument for ', callFctn, '.' )
## Do the actual call.
do.call( what, args, ... )
}
Sent from my iPhone
On Apr 8, 2013, at 7:23 PM, Gabor Grothendieck wrote:
On Mon, Apr 8, 2013 at 3:54 PM, Harry Mamaysky wrote:
> Can
Can someone explain why this happens when one of the list elements is named
'all'?
> zz <- list( zoo(1:10,1:10), zoo(101:110,1:10), zoo(201:210,1:10) )
> names(zz)<-c('test','bar','foo')
> do.call(cbind,zz)
test bar foo
1 1 101 201
2 2 102 202
3 3 103 203
4 4 104 204
5 5 1
I am new to R, and I have been running into the following situation
when I mistype a variable name in some code:
> list1 <- list( a=1, b=2 )
> list2 <- list( a=1 )
> list2$b <- list1$c
> list2
$a
[1] 1
I would think at the point where I am trying to reference a field
called "c" -- that does not e
11 matches
Mail list logo