possible strong mistake using db.sel()

Here you can suggest new features to be added to RGeostats package.

possible strong mistake using db.sel()

Postby bez » Fri Feb 07, 2020 7:00 pm

If a variable exists in the GlobalEnvironment and in a DB, when applying db.sel() using this variable the function does not use the variable of the DB but the variable of the GlobalEnvironment. This may cause severe problems...
bez
 
Posts: 21
Joined: Tue Oct 23, 2012 10:31 am

Re: possible strong mistake using db.sel()

Postby Didier Renard » Thu Feb 13, 2020 12:27 pm

This is probably a consequence of the "attach" statement that is used only in two functions in RGeostats: i.e.
- db.add for adding variables to a Db
- db.sel for performing selections
The "attach" statement makes it easy to manipulate already existing variables of the Db. As an illustration, imagine the Db (named db) contains two variables called A and B. Then the following command is valid:

db = db.add(db,C=A+B)

But the attach statement actually converts the variables of the Db as if they were variables defined in the environment. This is the reason why problem may occur when similar variables already exist in the environment. I do not know if there is any way distinguish between the two.

With the new naming convention, I am not sure we should not suppress this facility, as we can change the previous statement into:

db = db.create(db,C=db$A+db$B)

Still to be discussed.
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm


Return to Global suggestions

Who is online

Users browsing this forum: No registered users and 11 guests

cron