<font face="trebuchet ms,sans-serif">Gerar os intervalos e usar cut() com tapply()<br><br><span style="font-family:courier new,monospace">### Criando o objeto com datas e a variável climática</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">x <- as.Date("1994-01-01")</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">times <- 1:2865</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">datas <- x+times</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">datas <- as.data.frame(datas)##Cria o vetor data de 01/01/1994 a 5/11/2001</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">variavel <- rnorm(2865)## Simula a variável medida no dia</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">dados <- cbind(datas,variavel)##Cria o objeto</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">str(dados)</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"># sequência do dia 1 de cada mês</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">min(dados$data)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">max(dados$data)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">x1 <- seq(from=as.Date("1994-01-01"), to=as.Date("2001-11-30"), "month")</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">str(x1)</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"># sequência do dia 15 de cada mês</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">x2 <- seq(as.Date("1994-01-15"), as.Date("2001-11-30"), "month")</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">str(x2)</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"># sequência de datas para corte</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">x <- sort(c(x1,x2))</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">str(x)</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">xx <- cut(dados$data, x)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">str(xx)</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">tapply(dados$variavel, xx, length)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">tapply(dados$variavel, xx, mean)</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace">À disposição.<br>Walmes.<br><br clear="all"></font><span style="font-family:trebuchet ms,sans-serif">==========================================================================</span><br style="font-family:trebuchet ms,sans-serif">
<span style="font-family:trebuchet ms,sans-serif">Walmes Marques Zeviani</span><br style="font-family:trebuchet ms,sans-serif"><span style="font-family:trebuchet ms,sans-serif">LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)</span><br style="font-family:trebuchet ms,sans-serif">
<span style="font-family:trebuchet ms,sans-serif">Departamento de Estatística - Universidade Federal do Paraná</span><br style="font-family:trebuchet ms,sans-serif"><span style="font-family:trebuchet ms,sans-serif">fone: <a href="tel:%28%2B55%29%2041%203361%203573" value="+554133613573" target="_blank">(+55) 41 3361 3573</a></span><br style="font-family:trebuchet ms,sans-serif">
<span style="font-family:trebuchet ms,sans-serif">VoIP: (3361 3600) 1053 1173</span><br style="font-family:trebuchet ms,sans-serif"><span style="font-family:trebuchet ms,sans-serif">e-mail: <a href="mailto:walmes@ufpr.br" target="_blank">walmes@ufpr.br</a></span><br style="font-family:trebuchet ms,sans-serif">
<span style="font-family:trebuchet ms,sans-serif">twitter: @walmeszeviani</span><br style="font-family:trebuchet ms,sans-serif"><span style="font-family:trebuchet ms,sans-serif">homepage: <a href="http://www.leg.ufpr.br/%7Ewalmes" target="_blank">http://www.leg.ufpr.br/~walmes</a></span><br style="font-family:trebuchet ms,sans-serif">
<span style="font-family:trebuchet ms,sans-serif">linux user number: 531218</span><br style="font-family:trebuchet ms,sans-serif"><span style="font-family:trebuchet ms,sans-serif">==========================================================================</span><br>