Open rdstern opened 7 years ago
from your error it seems Water1 is not recognised as a numeric column. Could you check the class of this in the metadata? @lilyclements could try replicate this as well.
I tried this out. I created a water balance column which had it's class as "integer" Then I added 366 to it in calculator and got the error
Error in Water_Balance1 + 366 : non-numeric argument to binary operator
I assume this is the one that Roger is referring to.
This dataset has two variables; Year and Water_Balance1
To test around, I then tried putting "Year + 366" in the receiver and it worked
A difference between Year and Water_Balance1 is that Water_Balance1 has "Dependencies" and "Calculated_by" in the column metadata.
I did some testing on R and found that if I do the line
Water_Balance1 + 366
then I (unsurprisingly) get the same error as in R-Instat.
However, if I run
Water_Balance1 <- InstatDataObject$get_columns_from_data(use_current_filter=FALSE, col_names="Water_Balance1", data_name="Damango_by_Year)"
Then run the line
Water_Balance1 + 366
Then it works. I am unsure why "Year" works by getting the string and not "Water_Balance1"
However, hopefully this makes it a little bit closer to fixing the problem.
@dannyparsons doing calculations through the calculation system?
Solution: When saving the result go through the calculation system so that stored correctly When not saving use attach/detach as is. But need to modify assign to so that extra variables are removed from the global environment to avoid this issue.
This issue should go in release notes for 0.3.
Global environment variables now removed so bug fixed for all dialogs.
The calculator should still go through the calculation system when saving a column. This doesn't cause a bug currently, but should be done anyway.
@dannyparsons I assume this should be done for the next version or do we push it further?
I tried the calculator in a simple way and it seems fine. I then repeated an error from this morning, this time using Dodoma a) Got start of rains b) Got end of the rains - in column called Water1 c) then tried calculation, namely Water1 + 366 putting the result in a column called End
Error running R command(s)
Error in Water1 + 366 : non-numeric argument to binary operator The error occurred in attempting to run the following R command(s): End <- Water1+366 InstatDataObject$add_columns_to_data(col_data=End, col_name="End", data_name="Dodoma_by_Year")
But now I tried to rename the column I just produced and that also gives an error. So I think (logically sensible?) it is more to do with the production of those names by the climatic dialogues, than in the calculator. When I try to rename I get:
Error running R command(s)
Error: object 'new_value' not found The error occurred in attempting to run the following R command(s): InstatDataObject$rename_column_in_data(data_name="Dodoma_by_Year", column_name="Water1", new_val="Water")
OK