3
I need to exclude empty lines from the df of a 30-year time series, with three daily measurements for each variable. I have already used the function subset(x, ...)
that solves part of the problem. However, in some cases there is no recorded measurement, as noted in the "Prec" column for the date "1961-08-21". In this case, I need to keep a line indicating that no measurement was performed that day, i.e., that it remains with NA. How can I do this?
date id prec tair tw tmax tmin
1961-08-21 83377 NA 22.6 14.1 27.9 NA
1961-08-21 83377 NA 23.8 15.2 NA 13.8
1961-08-21 83377 NA 24.2 15.4 NA NA
1961-08-22 83377 NA 22.6 14.1 29.7 NA
1961-08-22 83377 0 24.8 14.6 NA 13.9
1961-08-22 83377 NA 27 16 NA NA
1961-08-23 83377 NA 24.6 14 28.8 NA
1961-08-23 83377 1 19.8 14.6 NA 13.8
1961-08-23 83377 2 18.8 14.7 NA 13.6
I don’t understand the problem. You need to keep only one line for the day
"1961-08-21"
instead of three rows? If yes, what do we do with the other columns? You can give an example of the output corresponding to this data?– Rui Barradas
I need a continuous time series, no duplicate or missing dates. If I apply subset(x, ...) in the Prec column, for example, I will lose information from that day for this variable, while for the other columns I will have an average value between the three measurements (which I also could not automate). So my dataset will be different for each column.
– Andreia Almeida