Skip to content
Prev 51263 / 63435 Next

Small request of a feature improvement in the next version of R

On Mon, 2015-11-16 at 20:11 -0500, Paul Grosu wrote:
Your example combines two nested calls to the replacement function
"[[<-". It is a lot easier to understand what is going wrong if you
break this down into two separate function calls.

First, the element of m that you want to modify is NULL:
NULL

So the expression
is equivalent to:
Inspecting the result:
$A3V
profile 
      3
[1] "numeric"

So m$A3V is a numeric vector and not, as you expected, a list. This
behaviour of "[[<-" when applied to NULL objects is documented on the
help page: See help("[[<-")

The solution is to create m[["A3V"]] as a list before modifying its
elements:
...

Martyn
-----------------------------------------------------------------------
This message and its attachments are strictly confidenti...{{dropped:8}}