<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000'>Bom dia pessoal,<br><br>Dentro da mesma análise de dados (abaixo) é possível obter as médias de valores (Variável "Nivel<b></b>") utilizando o comando "rle" para cada execução do Status e guardar estas informações (lengths, values, timediff, meanNivel ) em outro banco?<br><br><font face="courier new,courier,monaco,monospace,sans-serif">### <code r><br>dat <- read.table(text='Horario Nivel Status<br>"<span class="Object" id="OBJ_PREFIX_DWT135_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT136_com_zimbra_date">01/01/2011</span></span> 00:00" 29 0<br>"<span class="Object" id="OBJ_PREFIX_DWT137_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT138_com_zimbra_date">01/01/2011</span></span> 00:01" 29 0<br>"<span class="Object" id="OBJ_PREFIX_DWT139_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT140_com_zimbra_date">01/01/2011</span></span> 00:02" 30 1<br>"<span class="Object" id="OBJ_PREFIX_DWT141_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT142_com_zimbra_date">01/01/2011</span></span> 00:03" 31 1<br>"<span class="Object" id="OBJ_PREFIX_DWT143_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT144_com_zimbra_date">01/01/2011</span></span> 00:04" 29 0<br>"<span class="Object" id="OBJ_PREFIX_DWT145_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT146_com_zimbra_date">01/01/2011</span></span> 00:05" 29 0<br>"<span class="Object" id="OBJ_PREFIX_DWT147_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT148_com_zimbra_date">01/01/2011</span></span> 00:06" 29 0<br>"<span class="Object" id="OBJ_PREFIX_DWT149_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT150_com_zimbra_date">01/01/2011</span></span> 00:07" 29 0<br>"<span class="Object" id="OBJ_PREFIX_DWT151_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT152_com_zimbra_date">01/01/2011</span></span> 00:08" 30 1<br>"<span class="Object" id="OBJ_PREFIX_DWT153_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT154_com_zimbra_date">01/01/2011</span></span> 00:09" 32 1<br>"<span class="Object" id="OBJ_PREFIX_DWT155_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT156_com_zimbra_date">01/01/2011</span></span> 00:10" 34 1<br>"<span class="Object" id="OBJ_PREFIX_DWT157_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT158_com_zimbra_date">01/01/2011</span></span> 00:11" 35 1<br>"<span class="Object" id="OBJ_PREFIX_DWT159_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT160_com_zimbra_date">01/01/2011</span></span> 00:12" 35 1<br>"<span class="Object" id="OBJ_PREFIX_DWT161_com_zimbra_date"><span class="Object" id="OBJ_PREFIX_DWT162_com_zimbra_date">01/01/2011</span></span> 00:13" 25 0', head=T, as.is=T)<br><br>dat$Horario <- as.POSIXlt(dat$Horario, format = '%d/%m/%Y %H:%M')<br>head(dat)<br><br>res <- do.call(data.frame, rle(dat$Status))<br>n <- nrow(res)<br>res$ini <- c(1, cumsum(res$lengths[-n])+1)<br>res$fim <- cumsum(res$lengths)<br>res$timeDiff <- with(res, dat[fim,1]-dat[ini,1])<br><br>res<br><br><br># lengths values ini fim timeDiff<br># 1 2 0 1 2 60 secs<br># 2 2 1 3 4 60 secs<br># 3 4 0 5 8 180 secs<br># 4 5 1 9 13 240 secs<br># 5 1 0 14 14 0 secs</font><br><br><br><br>Grata,<br><br>Silvia Patricia<br><br></div></body></html>