Displaying 20 results from an estimated 23 matches for "superassignments".
Did you mean:
superassignment
2023 Mar 19
2
WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
Why should it make an exception for cases where the about-to-be-assigned-to
name is present in the global environment? I think it should warn or give
an error if the altered variable is in any environment on the search list.
-Bill
On Sun, Mar 19, 2023 at 10:54?AM Duncan Murdoch <murdoch.duncan at gmail.com>
wrote:
> I think that should be the default behaviour. It's pretty late to
2023 Mar 19
1
WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
I think that should be the default behaviour. It's pretty late to get
that into R 4.3.0, but I think your proposal (with check.superassignment
= FALSE being the default) could make it in, and 4.4.0 could change the
default to TRUE.
Duncan
On 19/03/2023 12:08 p.m., Henrik Bengtsson wrote:
> I'd like to be able to prevent the <<- assignment operator ("super
>
2023 Mar 19
1
WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
I'd like to be able to prevent the <<- assignment operator ("super
assignment") from assigning to the global environment unless the
variable already exists and is not locked. If it does not exist or is
locked, I'd like an error to be produced. This would allow me to
evaluate expressions with this temporarily set to protect against
mistakes.
For example, I'd like to
2023 Mar 19
1
WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
I have to say <<- is a core debugging tool when assigning into the global
environment. I suppose I could use assign but that would be somewhat
annoying.
That said I'm still for this change, the vast overwhelming number of times
that <<- is in my package code - already rare but it does happen - it would
absolutely be a bug (typo most likely) for it to get to the global
environment
2008 Feb 28
0
use of step.gam (from package 'gam') and superassignment inside functions
Hello,
I am using the function step.gam() from the 'gam' package (header info
from library(help=gam) included below) and have come across some
behavior that I cannot understand. In short, I have written a function
that 1) creates a dataframe, 2) calls gam() to create a gam object, then
3) calls step.gam() to run stepwise selection on the output from gam().
When I do this, gam()
2004 Oct 08
2
Evaluating Assignment-Operator R 2.0.0
Dear Helpers,
in which way I have to use the assignment-operator evaluating left to right
with R 2.0.0?
With R 2.0.0 (w2k-installation) the "superassignment" operator '<<-' seems to
have a different behaviour compared with R 1.9.1 :
> x<<-4
> x
[1] 4
> attr(x,'y')<<-5
Error: Object "x" not found
>
Using earlier
2005 Sep 02
2
Superassignment (<<-) and indexing
In a clean environment under R-2.1.0 on Linux:
> x <- 1:5
> x[3] <<- 9
Error: Object "x" not found
Isn't that odd? (Note x <<- 9 works just fine.)
Why am I doing this? Because I'm stepping through code that
normally lives inside a function, where "<<-" is appropriate.
-- David Brahm (brahm at alum.mit.edu)
2007 Mar 21
1
Snow Package and SPRNG: Will it solve my problem?
Hello and thanks in advance for your time. I currently have a
simulation running on my cluster with the help of snow that relies on
global variables being changes regularly to random values. It uses
these values, lets call them x1 x2 and x3, in custom functions for
logliklyhood and score that gets used in the standard optim function.
To get set in the global table on the different
2000 Jun 08
3
Output args?
Hi,
Is there a way to find out if a function was called with an output argument? Or to prevent the printing of large amount of data if the function was called without output argument?
Thanks
YG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20000608/8d7a01ec/attachment.html
2011 Apr 21
6
What does the "<<-" operator mean?
I've been reading some code from an example in a blog post (
http://www.maxdama.com/ here ) and I came across an operator that I hadn't
seen before. The author used a <<- operator to update a variable, like so:
ecov_xy <<- ecov_xy+decay*(x[t]*y[t]-ecov_xy)
At first I thought it was a mistake and tried replacing it with the usual <-
assignment operator, but I didn't
2009 Jun 03
3
Return variable assignments from a function
I'd like to perform return variable assignments like matlab. For example,
the following function would return A, B, and c to the script that called
it.
=================================
function [A,B,c] = simple(m,n)
A=[ 3 2; 3 3]
B=m
c=1:n
=================================
I'd like to do similar assignments in R, but I seem to be able to only
return one variable. I tried to use a
2009 Feb 11
1
Variables captured in closures get copied?
Hi list! I have a data frame called fix and a list of index vectors
called rois:
> head(rois, 3)
[[1]]
[1] 2 1
[[2]]
[1] 3
[[3]]
[1] 6 7 28 26 27 24 25
The part that's causing the issue is the following line:
lapply(rois, function(roi) fix$x[roi] <- 100)
So for every index vector I'd like to set the respective entries in the
data frame (fix) to 100.
I
2001 Jun 11
0
mult.fig() utility [was "margin text mtext"]
Martin,
I have an objection in principle to anything that has the side-effect of
clobbering something in the global environment, even something as innocuous
looking as "old.par". I certainly object to putting something like that
into a public library, however clever and useful the code might be. It just
is not safe.
As a quick way round this I suggest the following (R only) solution:
2008 Sep 02
2
How is the binding for a super assignment made visible?
The statement Globals <<- list() in the body of a function in a package was intended to write an empty list to the R workspace to collect results during the computations of the function. A package name space has not been specified.
The package appears to function correctly, but
during the R CMD check of the package while "checking R code for possible problems ... NOTE",
no
2009 Jul 17
2
Remembering a value in multiple calls of a function
Hello,
I tried this pseudo-generator style experiment (see below). The "<<-"
operator assigns to in the calling environment which would be the
environment of "getN".
Yet when the function incr is returned, isn't this environment lost?
Also the print displays GlobalEnv, yet the globalenv does not have any
mention of startgiven.
This code was inspired from and old
2009 Jul 02
3
Question about <<- assignment
Is this expected behavior?
> z <- 1:5
> z[1] <<- 0
Error in z[1] <<- 0 : object "z" not found
The documentation seems to suggest that z will be found in the global
environment and modified accordingly.
Best,
Hsiu-Khuern.
2010 Nov 01
1
Function not working
Below is the (really basic) script I am creating to call a function that
sets the working directory, determines the number of files it will need to
process in that directory, and creates a mask. A "for" loop will eventually
be added that will loop through the files (arrays) in that directory
performing a baseline/zero correction and apply the mask - that will
probably be a later plea
2007 Apr 02
2
(Newbie)Basic Basic global vs. local variables
My R code has got too complex to have a non-modular approach. Ive done some
coding in other languages before, but I somehow cant figure out R's general
rules for global and local variables. I have put a simple code below, if
anyone can show me what i need to add to make this work, i would greatly
appreciate it!
#----------------------------------------
g_Means<-numeric()
1998 Feb 20
1
R-beta: scoping etc
A non-text attachment was scrubbed...
Name: not available
Type: text
Size: 1538 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/19980220/040a76f5/attachment.pl
2010 Dec 26
2
environment question
Hello, everybody.
I'm putting together some lecture notes and course exercises on R
programming. My plan is to pick some R packages, ask students to read
through code and see why things work, maybe make some changes. As I
look for examples, I'm running up against the problem that packages
use coding idioms that are unfamiliar to me.
A difficult thing for me is explaining scope of