1
Hello!
I have a little problem in R.... I have a file called dados_dia
with different weather variables: Índice de claridade (I.Cla),
Wind speed (speed), Umidade relativa (hH)
and Temperatura do ar (Tai)
. I need to find the dates when a series of combinations of these variables occur (144 combinations, to be more exact). For that I have a script in which I use a "for
" to generate these combinations and to find the dates. Because each combination results in quantities of different dates, I’m not able to write these dates in one vector or another file, just make one print
.
follows the script:
I.Cla <- c(0,0.3,0.6,0.9)
speed <- c(0,2,4,8)
Tair <- c(0,14,19,24,40)
rH <- c(0,70,80,90,100)
combinacao = NULL
m=1
for(i in 2:4){
for(j in 2:4){
for(l in 2:5){
for(k in 2:5){
######################################################################
############# condições das variáveis ################################
combinacao[m] <- paste('I.Cla > ',I.Cla[i-1],' e I.Cla <= ',I.Cla[i],
'speed > ', speed[j-1],' e speed <= ',speed[j],
'Tair > ',Tair[l-1],' e Tair <= ',Tair[l],
'rH > ',rH[k-1],' e rH <= ',rH[k] )
m=m+1
#####################################################################
############# datas em que ocorrem cada condição das variáveis ######
print(c(dados_dia$date[dados_dia$I.Cla > I.Cla[i-1] &
dados_dia$I.Cla <= I.Cla[i] &
dados_dia$speed > speed[j-1] &
dados_dia$speed <= speed[j] &
dados_dia$Tair > Tair[l-1] &
dados_dia$Tair <= Tair[l] &
dados_dia$rH > rH[k-1] &
dados_dia$rH <= rH[k]] ) )
}
}
}
}
I need the conditions of the variables (combination) to be the columns of my data.frame
and the dates generated in the print are arranged in the columns that match it. NOTE: The results range from zero to 20 dates.
Unfortunately, this question cannot be reproduced by anyone trying to answer it. Information about what is
dados_dia
. Please, take a look at this link and see how to ask a reproducible question in R. So, people who wish to help you will be able to do this in the best possible way.– Marcus Nunes
I updated the question
– Cristiano
The question is still not reproducible.
– Marcus Nunes
The problem is variable
dados_dia
. I suggest using thedput
and post here the result.– Flavio Silva
Thank you for your attention !!!!
– Cristiano