Questions tagged [variable-names]
256 questions
0
votes
1 answer
array_combine with same key names
I am trying to save some information from an email to an array.
The email contents are html tables and i am using the DOMDocument method getElementsByTagName('td') to receive all the td's.
In an for loop i iterate through all emails in an mail…

carboneum
- 21
- 1
- 6
0
votes
2 answers
How can I convert a string which contains a variable name into a variable which can be referenced?
I am creating a function which scans files for a certain function and determines which variables (all are already initialized) are used as parameters for the function. Currently, I am able to derive a cell array with strings for each individual…

Ak K
- 1
- 1
0
votes
1 answer
Python: Add value of iteration variable to variable name within for loop
I have a pandas df with a column (let's say col3) containing a number. These numbers are used in multiple rows and I want to run a function for rows of each number separatly.
So I wrote each number once into an array like this:
l =…

MaMo
- 569
- 1
- 10
- 27
0
votes
0 answers
Variable renaming with Closure compiler in scala.js
I want to store a class into localstorage and therefor stringify it,
and parse it back later, but scala.js (0.6.22) with the "builtin (?)" Closure compiler renames the class variables.
If I use the external Google closure compiler to optimize the…

Joe
- 85
- 6
0
votes
0 answers
Are the rules for variable names in PHP changed?
Previously I knew that "A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores".
But, today I read the following line in the PHP manual :
Note: For our purposes here, a letter is a-z,…

PHPLover
- 1
- 51
- 158
- 311
0
votes
0 answers
Using names() and make.names() inside a loop
I am reading some files into R with a "for loop" and naming them based on the looping index. I have used the assign fucntion to dynamically name one data frame for each file being read as follows:
for (i in 1:10){
…

Mario Reyes
- 385
- 1
- 2
- 13
0
votes
0 answers
executing a command while looping through variable name fragments in R
I have recently switched from STATA to R, and am stuck on some mechanisms of looping (I know looping is considered bad form here in lieu of writing a function, but my feeling is if I can figure out how to get a loop to do this, I can apply that to a…

Babette
- 1
- 1
0
votes
2 answers
how to save output-file with variable name passed to a function?
I need to save the output of the function to a file with a name of the variable passed to that function.
I have tried using a function from a stackoverflow user.
def var_name(**variables):
return [x for x in variables]
My code as…

Yash
- 1
- 2
0
votes
3 answers
How do global and local variables behave in this case?
This is saved in my file function_local.py:
x = 50
def func(x):
print('x is', x)
x = 2
print('Changed local x to', x)
func(x)
print('x is still', x)
Output:
$ python function_local.py
x is 50
Changed local x to 2
x is still…

Nika Chkadua
- 11
- 1
0
votes
1 answer
C++ Access numbered variables
We have numbered variables like:
float my_float_0;
float my_float_1;
float my_float_2;
Is there any form of template / macro magic that would let us access these variables by index in a for loop?

jonnie
- 101
- 1
- 10
0
votes
1 answer
Retrieving all variables (references names) pointing to the same object
Just for curiosity.. python "variables" are references to objects. Each has a name or "accesser label" so I can refer to them while scripting.
Does each python object keep a list of all "variable names" refering to itself? How would I access it?
# A…

iago-lito
- 3,098
- 3
- 29
- 54
0
votes
1 answer
Input variable name handling in R
I would like to learn about how to handle an input of a variable name in a function. For example, I have written a function like this:
bin_multi <- function(y, dataframe, sel = NULL){
if(!is.null(sel)) {
dataframe <- dataframe[,sel]}
else…

user95902
- 149
- 2
- 3
- 13
0
votes
1 answer
Matlab's 'VariableNames' not accepting mix of numerical & non-numerical entries
Suppose we have a 1x3 table A=table(1,2,3);
whose header names should contain a mix of numericals and non-numericals:
A.Properties.VariableNames={'from 1st-5th' 'from 6th-10th' ... 'from 11th-15th'};
and generates the following error:
from 1st-5th'…

John
- 71
- 7
0
votes
1 answer
Creating numbered variable names using the foreach command
I have a list of variables for which I want to create a list of numbered variables. The intent is to use these with the reshape command to create a stacked data set. How do I keep them in order? For instance, with this code
local ct = 1
foreach x…

Steve
- 25
- 1
- 5
0
votes
2 answers
Create and use different tables in for-loops in R in a shorter way
I’m looking for a short solution to create and use different tables in for loops where the loop variable is part of the name.
I found the following solutions:
If I want to create tables in a loop I may use assign together with paste. E.g.:
for (f in…

Thomas R
- 1,067
- 11
- 17