[SOLVED] Problem with operator "<-" for the model-class

If you have problems using RGeostats package or if you simply need some help on an unlisted subject.

[SOLVED] Problem with operator "<-" for the model-class

Postby Nicolas Desassis » Mon Sep 16, 2013 4:00 pm

In the model-class documentation, we can read :
"
[<-

model[i]<-value copies the contents of the value into the i-th basic structure of the model-class
"

When I try the following sequence

mdlt<-model.create(melem.name(2),ndim=2) #Creation of a first model
mdlt<-model.create(melem.name(3),ndim=2,model=mdlt) #Append a second model
value<-model.create(melem.name(4),ndim=2) #Creation of a third model
mdlt[1]<-value #use of the assignment operator
mdlt


R closes and with the following message

terminate called after throwing an instance of 'Rcpp::no_such_slot'
what(): no such slot
Nicolas Desassis
 
Posts: 196
Joined: Thu Sep 20, 2012 4:22 pm

Re: Problem with operator "<-" for the model-class

Postby Didier Renard » Mon Sep 16, 2013 7:29 pm

Dear Nicolas

You probably remember that you model object (mdlt) is composed as the union of basic structures (called "melem").
Therefore, the last sentence:

mdlt[1] <- value

does not make sense as "value" is the result of model.init() and is therefore a model, not a melem.

Instead, you could have done:
value <- melem.init()
mdlt[1] <- value

This would have been meaningfull.

Nevertheless I added the missing safety control to the mentionned operator. It will e active in the next published version (9.1.7)
Didier Renard
 
Posts: 279
Joined: Thu Sep 20, 2012 4:22 pm

Re: Problem with operator "<-" for the model-class

Postby Nicolas Desassis » Mon Sep 16, 2013 7:51 pm

Dear Didier,

thank for your explanations. It is very clear.
I had missed the function melem.init and the fact that melem-class can be instantiated with melem.init.

Nicolas
Nicolas Desassis
 
Posts: 196
Joined: Thu Sep 20, 2012 4:22 pm


Return to Other Troubleshooting

Who is online

Users browsing this forum: No registered users and 1 guest

cron