In a recent SO post this came up (changed example to simplify it
here). It seems that `test` still has the value sin.
test <- sin
environment(test)$test <- cos
test(0)
## [1] 0
It appears to be related to the double use of `test` in `$<-` since if
we break it up it works as expected:
This is discussed in the "Writing R Extensions" manual section 5.9.10:
Named objects and copying.
.Call does not copy its arguments and it is not safe to modify them, as
you have found, since multiple symbols may refer to the same object. If
you are going to modify an argument to .Call you should
Hi All,
i have a problem in understanding what the assignment operator '<-' really is
doing.
If i create two numeric arrays in R and copy one into the other with '<-' and
afterwards change one array by calling a C function, both arrays are changed!
The problem I am facing can easily be seen in
On 07/02/2016 9:15 AM, peter dalgaard wrote:
On 07 Feb 2016, at 14:46 , Duncan Murdoch wrot8[e:
[snippage]
but in fact, this doesn't work:
getValue(fn)[[1]] <- 3
Error in getValue(fn)[[1]] <- 3 : could not find function "getValue"
I suspect this is a parser problem.
Umm, no...
The can
On So, Feb 7, 2016 at 2:46 , Duncan Murdoch
wrote:
An assignment function should return the modified value. So it looks
like you would need
'getValue<-' <- function(x, value) {
environment(x)$mylist <- value
x
}
Thanks. I have not thought of a return value. That makes the differen
> On 07 Feb 2016, at 14:46 , Duncan Murdoch wrot8[e:
>
[snippage]
>
> but in fact, this doesn't work:
>
> getValue(fn)[[1]] <- 3
> Error in getValue(fn)[[1]] <- 3 : could not find function "getValue"
>
> I suspect this is a parser problem.
Umm, no...
The canonical semantics are that
foo(x
On 07/02/2016 8:08 AM, Daniel Kaschek wrote:
Dear all,
I have a function "fn" with its own environment, i.e.
env <- environment(fn)
and env is not .GlobalEnv. And another function
getValue <- function(x) environment(x)$mylist
which returns the list object "mylist" which is in "env". If I wan
Dear all,
I have a function "fn" with its own environment, i.e.
env <- environment(fn)
and env is not .GlobalEnv. And another function
getValue <- function(x) environment(x)$mylist
which returns the list object "mylist" which is in "env". If I want to
modify "mylist", I could write
'getVal
On Thu, 30 Sep 2010, Thomas Lumley wrote:
On Thu, Sep 30, 2010 at 8:15 AM, peter dalgaard wrote:
On Sep 30, 2010, at 16:19 , Niels Richard Hansen wrote:
setClass("A", representation(a = "numeric"))
B <- list()
myA <- new("A", a = 1)
B$otherA <- myA
b$oth...@a <- 2
m...@a
R version 2.12.0
On Thu, Sep 30, 2010 at 8:15 AM, peter dalgaard wrote:
>
> On Sep 30, 2010, at 16:19 , Niels Richard Hansen wrote:
>
>> setClass("A", representation(a = "numeric"))
>> B <- list()
>> myA <- new("A", a = 1)
>> B$otherA <- myA
>> b$oth...@a <- 2
>> m...@a
>
> R version 2.12.0 Under development (unst
On Sep 30, 2010, at 16:19 , Niels Richard Hansen wrote:
> setClass("A", representation(a = "numeric"))
> B <- list()
> myA <- new("A", a = 1)
> B$otherA <- myA
> b$oth...@a <- 2
> m...@a
R version 2.12.0 Under development (unstable) (2010-09-13 r52905)
Platform: i386-apple-darwin9.8.0/i386 (32-b
Dear R-developers
I came across the following issue, which I find strange:
setClass("A", representation(a = "numeric"))
B <- list()
myA <- new("A", a = 1)
B$otherA <- myA
b$oth...@a <- 2
m...@a
Assigning a new value to slot 'a' in the _copy_ of myA stored
in B$otherA changes the original value
On 2010-08-05 12:14, Ulrike Grömping wrote:
Gabor Grothendieck schrieb:
On Thu, Aug 5, 2010 at 12:24 PM, Ulrike Grömping
wrote:
Dear developeRs,
I have just discovered a strange feature when assigning some values to
columns of a data frame: The column is matched by partial matching (as
docu
Ulrike Grömping wrote:
>
>
> However, given the documentation that partial matching is not used on
> the left-hand side, I would have expected even more that the assignment
>
> sw$Fert[1] <- 10
>
> works differently, because I am using it on the left-hand side.
> Probably, extraction ([1])
Gabor Grothendieck schrieb:
On Thu, Aug 5, 2010 at 12:24 PM, Ulrike Grömping
wrote:
Dear developeRs,
I have just discovered a strange feature when assigning some values to
columns of a data frame: The column is matched by partial matching (as
documented), but when assigning a value, a new c
On Thu, Aug 5, 2010 at 12:24 PM, Ulrike Grömping
wrote:
> Dear developeRs,
>
> I have just discovered a strange feature when assigning some values to
> columns of a data frame: The column is matched by partial matching (as
> documented), but when assigning a value, a new column with the partial na
Dear developeRs,
I have just discovered a strange feature when assigning some values to
columns of a data frame: The column is matched by partial matching (as
documented), but when assigning a value, a new column with the partial
name is added to the data frame that is identical to the origina
Stavros Macrakis wrote:
> On Wed, Apr 1, 2009 at 5:11 PM, Wacek Kusnierczyk <
> waclaw.marcin.kusnierc...@idi.ntnu.no> wrote:
>
>
>> Stavros Macrakis wrote:
>> ...
>> i think this concords with the documentation in the sense that in an
>> assignment a string can work as a name. note that
>>
>>
On Wed, Apr 1, 2009 at 5:11 PM, Wacek Kusnierczyk <
waclaw.marcin.kusnierc...@idi.ntnu.no> wrote:
> Stavros Macrakis wrote:
> ...
> i think this concords with the documentation in the sense that in an
> assignment a string can work as a name. note that
>
>`foo bar` = 1
>is.name(`foo`)
>
Stavros Macrakis wrote:
> The documentation for assignment says:
>
> In all the assignment operator expressions, 'x' can be a name or
> an expression defining a part of an object to be replaced (e.g.,
> 'z[[1]]'). A syntactic name does not need to be quoted, though it
> can be
On Wed, Apr 1, 2009 at 4:21 PM, Simon Urbanek
wrote:
>
> On Apr 1, 2009, at 15:49 , Stavros Macrakis wrote:
>
> The documentation for assignment says:
>>
>>In all the assignment operator expressions, 'x' can be a name or
>>an expression defining a part of an object to be replaced (e.g.,
>
On Apr 1, 2009, at 15:49 , Stavros Macrakis wrote:
The documentation for assignment says:
In all the assignment operator expressions, 'x' can be a name or
an expression defining a part of an object to be replaced (e.g.,
'z[[1]]'). A syntactic name does not need to be quoted, thoug
The documentation for assignment says:
In all the assignment operator expressions, 'x' can be a name or
an expression defining a part of an object to be replaced (e.g.,
'z[[1]]'). A syntactic name does not need to be quoted, though it
can be (preferably by backticks).
But the
23 matches
Mail list logo