I'm assigning values within the output list of a function, like:
nofun = function(sth){
something happening here
metrics = list(
metric1 = value1
metric2 <- value2 )
return(metrics)
}
Once I query metrics
, I noticed that the use of <-
and =
differs: the first ones only assigns the value to a variable with no name (i.e. "x1"= value1
), while the second one applies also the correct name (i.e. metric1 = value1
).
This behaviour is cited also for data.frame
at the bottom of an old more generic question, but there is no explanation of this specific usage case.
It caused me quite many headaches and waste of time before noticing it, but I didn't find any other useful information. thanks in advance!