I am trying to take two sets of data in two separate files, add them together, and average them. Some are NaN values which I switched to 0 for the purpose of adding. The values after adding are then averaged and values of zero are changed back to NaN. The problem is I only want to average when there is more than one variable. So, I am trying to do an if statement and say if a value in A and B are not 0 then add. But I am getting an error so I am not sure if I can do that. Is this the appropriate use of if? If not, what shoule be used? Here is the portion of the code with the problem.
if ( i in (A != 0) & x in (B != 0)){
addedozone <- sum(A, B)}
ABBR DATE O3 SWS VWS SWD VWD SDWD TMP RH RNF SOL
HAVO-VC 10/01/1986 00 -999 -999 -999 -999 -999 -999 -999 -999 -999
HAVO-VC 10/01/1986 01 -999 -999 -999 -999 -999 -999 -999 -999 -999
HAVO-VC 10/01/1986 02 -999 -999 -999 -999 -999 -999 -999 -999 -999
Aucun commentaire:
Enregistrer un commentaire