Prof Brian Ripley <[EMAIL PROTECTED]> writes:
> > This *should* be somewhere in the R Language Definition, although I'm
> > not sure it is actually there. Or the blue book, although I suspect
> > that S v.3 actually used positional matching (and jumped through
> > hoops).
>
> It did. This is in
On 7 Apr 2004, Peter Dalgaard wrote:
> Robin Hankin <[EMAIL PROTECTED]> writes:
>
> > Hi again everybody.
> >
> > Yesterday I had a problem with c-style "+=" functions. One suggestion
> > was to define
> >
> > R> "plus<-" <- function(x,value){x+value}
> >
> > Then
> >
> > R> a <- matrix(1:9,
On 07 Apr 2004 13:51:52 +0200, Peter Dalgaard
<[EMAIL PROTECTED]> wrote :
>Duncan Murdoch <[EMAIL PROTECTED]> writes:
>> Wouldn't a clearer syntax to follow be Pascal's? I.e.
>> inc(x[3], 1)
>>
>
>But that's not kosher in functional programming languages where you
>expect function calls not to
Duncan Murdoch <[EMAIL PROTECTED]> writes:
> On Tue, 6 Apr 2004 14:18:42 + (UTC), you wrote:
>
> >Robin Hankin soc.soton.ac.uk> writes:
> >> R> a <- matrix(1:9,3,3)
> >> But the following caught me off-guard:
> >> R> a <- matrix(1:9,3,3)
> >> R> a[a%%2==1] %+=% 1000*(1:5)
> >
> >How about th
On Tue, 6 Apr 2004 14:18:42 + (UTC), you wrote:
>Robin Hankin soc.soton.ac.uk> writes:
>> R> a <- matrix(1:9,3,3)
>> But the following caught me off-guard:
>> R> a <- matrix(1:9,3,3)
>> R> a[a%%2==1] %+=% 1000*(1:5)
>
>How about this way:
>
>> a <- matrix(1:9,3,3)
>> "plus<-" <- function(a,va
Robin Hankin <[EMAIL PROTECTED]> writes:
> Hi again everybody.
>
> Yesterday I had a problem with c-style "+=" functions. One suggestion
> was to define
>
> R> "plus<-" <- function(x,value){x+value}
>
> Then
>
> R> a <- matrix(1:9,3,3)
> R> plus(a[a%%2==1]) <- 1000
>
> works as desired.
>
>
Value in an internal variable of a command "function",
have a look on R-help apropos "function".
A.S.
Alessandro Semeria
Models and Simulations Laboratory
Montecatini Environmental Research Center (Edison Group),
Via Ciro Menotti 48,
48023 Marina di Ravenna (RA),
Hi again everybody.
Yesterday I had a problem with c-style "+=" functions. One suggestion
was to define
R> "plus<-" <- function(x,value){x+value}
Then
R> a <- matrix(1:9,3,3)
R> plus(a[a%%2==1]) <- 1000
works as desired.
QUESTION: why does this behave differently:
R> "plus<-" <- function(x,y)
Robin Hankin soc.soton.ac.uk> writes:
> R> a <- matrix(1:9,3,3)
> But the following caught me off-guard:
> R> a <- matrix(1:9,3,3)
> R> a[a%%2==1] %+=% 1000*(1:5)
How about this way:
> a <- matrix(1:9,3,3)
> "plus<-" <- function(a,value) a+value
> plus(a[a%%2==1]) <- 1000*(1:5)
> a
[,1] [,2
Look at Syntax on R-help apropos operators precedence
A.S.
Alessandro Semeria
Models and Simulations Laboratory
Montecatini Environmental Research Center (Edison Group),
Via Ciro Menotti 48,
48023 Marina di Ravenna (RA), Italy
Tel. +39 544 536811
Fax. +39 544 538
On Tue, 6 Apr 2004 13:36:32 +, Robin Hankin <[EMAIL PROTECTED]>
wrote :
> the following caught me off-guard:
>
>
>R> a <- matrix(1:9,3,3)
>R> a[a%%2==1] %+=% 1000*(1:5)
>[1] 1001 2006 3015 4028 5045
>R> a
> [,1] [,2] [,3]
>[1,] 10014 1007
>[2,]2 10058
>[3,] 10036 1009
>R>
Robin Hankin <[EMAIL PROTECTED]> writes:
> Some time ago, Peter Dalgaard made the wonderful suggestion to define
>
> "%+=%" <- function(a,b) {eval.parent(substitute(a <- a + b)) }
...
> R> a <- matrix(1:9,3,3)
> R> a[a%%2==1] %+=% 1000*(1:5)
> [1] 1001 2006 3015 4028 5045
> R> a
> [,1] [,2]
Some time ago, Peter Dalgaard made the wonderful suggestion to define
"%+=%" <- function(a,b) {eval.parent(substitute(a <- a + b)) }
Which I use (R-1.8.1) as follows:
R> a <- matrix(1:9,3,3)
R> a[a%%2==1] %+=% (1000*(1:5))
R> a
[,1] [,2] [,3]
[1,] 10014 4007
[2,]2 30058
[3,] 200
13 matches
Mail list logo