<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Desculpa, David!<br>
    Estava lendo seu email junto com o do colega Romero. rsrs<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 06/15/2015 01:49 PM, Vinícius Lionel
      Mateus wrote:<br>
    </div>
    <blockquote cite="mid:557EBBD1.4000005@gmail.com" type="cite">
      <meta content="text/html; charset=windows-1252"
        http-equiv="Content-Type">
      Olá Romero,<br>
      <br>
      Precisei fazer algo similar para uma avaliação de um curso, que me
      inscrevi no Coursera.<br>
      Estou rodando o programa para 322 arquivos.<br>
      <br>
      Dá uma olhada:<br>
      <br>
      pollutantmean <- function(directory, pollutant, id = 1:332) {<br>
        ## 'directory' is a character vector of length 1 indicating<br>
        ## the location of the CSV files<br>
        <br>
        ## 'pollutant' is a character vector of length 1 indicating<br>
        ## the name of the pollutant for which we will calculate the<br>
        ## mean; either "sulfate" or "nitrate".<br>
        <br>
        ## 'id' is an integer vector indicating the monitor ID numbers<br>
        ## to be used<br>
        <br>
        ## Return the mean of the pollutant across all monitors list<br>
        ## in the 'id' vector (ignoring NA values)<br>
        ## NOTE: Do not round the result!  <br>
        <br>
        files_full <- list.files("specdata", full.names = TRUE)<br>
        files_full<br>
        <br>
      #   summary(files_full)<br>
        tmp <- vector(mode = "list", length = length(files_full))<br>
        <br>
        for (i in seq_along(files_full)) {<br>
          tmp[[i]] <- read.csv(files_full[[i]])<br>
        }<br>
        <br>
        output <- do.call(rbind, tmp)<br>
      #   str(output)<br>
        <br>
        output_subset <- subset(output, output[, "ID"] %in% id) #
      subset by any value<br>
        <br>
        <br>
        <br>
        if (pollutant == "sulfate")  {<br>
          mean(output_subset$sulfate, na.rm = TRUE)<br>
        } else if  (pollutant == "nitrate")  {<br>
          mean(output_subset$nitrate, na.rm = TRUE)<br>
        } else {<br>
          print("pollutant can only be nitrate or sulfate!")<br>
        }      <br>
      }<br>
      <br>
      Acho que pode servir a ti!<br>
      <br>
      Abs,<br>
      Vinícius<br>
      <br>
      <br>
      <div class="moz-cite-prefix">On 06/13/2015 04:56 PM, David Feitosa
        wrote:<br>
      </div>
      <blockquote
cite="mid:CAL1rLtpe2mYKdARQ5RKejUmR_Sv2S=0E3eEsSMxUPGcLRjZmtA@mail.gmail.com"
        type="cite">
        <div dir="ltr">João, não sei o quão esse procedimento irá
          escalar,
          <div>mas considere usar um SGBD, como Postgresql/MySQL ou
            outro.</div>
          <div><br>
          </div>
          <div>Há um pacote sqldf que permite trabalhar com consultas à
            bases de dados</div>
          <div>e tratar o resultado como um dataframe.</div>
        </div>
        <div class="gmail_extra"><br clear="all">
          <div>
            <div class="gmail_signature">
              <div dir="ltr">
                <div>
                  <div dir="ltr">
                    <div>
                      <div><br>
                      </div>
                      <div>Atenciosamente,</div>
                      <div><br>
                      </div>
                      David F.</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <br>
          <div class="gmail_quote">Em 8 de junho de 2015 11:19, joão
            Rodrigo Castro <span dir="ltr"><<a
                moz-do-not-send="true"
                href="mailto:joaorodrigo2005@gmail.com" target="_blank">joaorodrigo2005@gmail.com</a>></span>
            escreveu:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir="ltr">Entendi Augusto, vou implementar! Muito
                Obrigado<br>
              </div>
              <div class="HOEnZb">
                <div class="h5">
                  <div class="gmail_extra"><br>
                    <div class="gmail_quote">Em 8 de junho de 2015
                      11:14, Augusto Ribas <span dir="ltr"><<a
                          moz-do-not-send="true"
                          href="mailto:ribas.aca@gmail.com"
                          target="_blank">ribas.aca@gmail.com</a>></span>
                      escreveu:<br>
                      <blockquote class="gmail_quote" style="margin:0 0
                        0 .8ex;border-left:1px #ccc
                        solid;padding-left:1ex">
                        <div dir="ltr">Algo assim:<br>
                          <div><br>
                          </div>
                          <div>#Ve o nome dos arquivos da pasta, use
                            getwd e setwd se precisar mudar de pasta<br>
                          </div>
                          <div>arquivos<-list.files()<br>
                            <br>
                          </div>
                          <div>#pegue os arquivos que são .dat<br>
                          </div>
                          <div>indices<-grep(".dat",arquivos)<br>
                            arquivos[indices]<br>
                            <br>
                          </div>
                          <div>#separe um vetor com eles, podemos
                            reutilizar o vetor aqui<br>
                          </div>
                          <div>arquivos<-arquivos[indices]<br>
                            <br>
                          </div>
                          <div>#Ai você usa alguma estrutura de
                            repetição, um loop por exemplo, para
                            processar um por um<br>
                          </div>
                          <div>for(i in 1:length(arquivos)) {<br>
                                print(paste("Lendo",arquivos[i]))<br>
                                #Seu codigo aqui<br>
                            }<br>
                            <br>
                          </div>
                          <div>#ai insira seu código ali, fazendo as
                            operações que tem que fazer, e juntando os
                            arquivos, salvando, o que for necessário.<br>
                          </div>
                        </div>
                        <div>
                          <div>
                            <div class="gmail_extra"><br>
                              <div class="gmail_quote">Em 8 de junho de
                                2015 10:06, joão Rodrigo Castro <span
                                  dir="ltr"><<a
                                    moz-do-not-send="true"
                                    href="mailto:joaorodrigo2005@gmail.com"
                                    target="_blank">joaorodrigo2005@gmail.com</a>></span>
                                escreveu:<br>
                                <blockquote class="gmail_quote"
                                  style="margin:0 0 0
                                  .8ex;border-left:1px #ccc
                                  solid;padding-left:1ex">
                                  <div dir="ltr">
                                    <div>
                                      <div>
                                        <div>Obrigado Augusto, vou dar
                                          uma olhada nas funções que vc
                                          citou.<br>
                                          <br>
                                        </div>
                                        Um trecho do código:<br>
                                        # Passo A<br>
                                        Teste_SF = read.table("<b>dado1</b>.dat",

                                        dec=".",h=T ,col.names = c(
                                        "ano", "mes",
                                        "jday","Rad","Tmax",
                                        "Tmin","stopo","trans","dt","lat","lon"))<br>
                                        Teste = subset(Teste_SF,
                                        trans<0.81 & Rad>1)<br>
                                        summary(Teste)<br>
                                        <br>
                                        # Passo B<br>
                                        dr = 1 + 0.033 *
                                        cos(0.0172*Teste$jday)<br>
                                        declin = 0.409 *
                                        sin(0.0172*Teste$jday - 1.39)<br>
                                        omega =
                                        acos(-tan(Teste$lat*pi/180) *
                                        tan(declin))<br>
                                        Teste$Rad_Pot =
                                        37.6*dr*(omega*sin(declin)*sin(Teste$lat*pi/180)
                                        +
                                        cos(declin)*cos(Teste$lat*pi/180)*sin(omega))<br>
                                        <br>
                                      </div>
                                      Há ainda outros passos onde os
                                      atributos dos arquivos são lidos e
                                      posteriormente utilizados em
                                      outros cálculos. No final é gerado
                                      um arquivo de saída com o
                                      write.table com os resultados
                                      obtidos.<br>
                                      <br>
                                    </div>
                                    <div>Então como são 38 arquivos
                                      (dado1.dat, dado2.dat,  etc .....
                                      ) a utilização de alguma função
                                      que permita a leitura de todos os
                                      arquivos, e depois fazer um loop
                                      pelos arquivos, tornaria mais
                                      dinâmica a tarefa. <br>
                                    </div>
                                    <div><br>
                                    </div>
                                    <div>Obrigado pelas dicas!<span><font
                                          color="#888888"><br>
                                        </font></span></div>
                                    <span><font color="#888888">
                                        <div>João<br>
                                        </div>
                                        <div><br>
                                          <br>
                                        </div>
                                      </font></span></div>
                                  <div>
                                    <div>
                                      <div class="gmail_extra"><br>
                                        <div class="gmail_quote">Em 8 de
                                          junho de 2015 10:42, Augusto
                                          Ribas <span dir="ltr"><<a
                                              moz-do-not-send="true"
                                              href="mailto:ribas.aca@gmail.com"
                                              target="_blank">ribas.aca@gmail.com</a>></span>
                                          escreveu:<br>
                                          <blockquote
                                            class="gmail_quote"
                                            style="margin:0 0 0
                                            .8ex;border-left:1px #ccc
                                            solid;padding-left:1ex">
                                            <div dir="ltr">
                                              <div>
                                                <div>Não entendi
                                                  exatamente o problema,
                                                  mas os arquivos estão
                                                  em um determinado
                                                  diretorio?<br>
                                                </div>
                                                Não daria para dar um
                                                list.files() para pegar
                                                a lista de arquivos dos
                                                diretorio, usar um
                                                grep() para selecionar
                                                os arquivos que quer ler
                                                e então em um loop ir
                                                ler os arquivos com
                                                read.table, ai você pode
                                                ir dando merge ou
                                                concatenando eles.<br>
                                                <br>
                                              </div>
                                              Da um exemplo de código
                                              como você está fazendo,
                                              talvez alguém tenha uma
                                              ideia melhor.<br>
                                            </div>
                                            <div class="gmail_extra"><br>
                                              <div class="gmail_quote">
                                                <div>
                                                  <div>Em 8 de junho de
                                                    2015 08:45, joão
                                                    Rodrigo Castro <span
                                                      dir="ltr"><<a
                                                        moz-do-not-send="true"
href="mailto:joaorodrigo2005@gmail.com" target="_blank">joaorodrigo2005@gmail.com</a>></span>
                                                    escreveu:<br>
                                                  </div>
                                                </div>
                                                <blockquote
                                                  class="gmail_quote"
                                                  style="margin:0 0 0
                                                  .8ex;border-left:1px
                                                  #ccc
                                                  solid;padding-left:1ex">
                                                  <div>
                                                    <div>
                                                      <div dir="ltr">
                                                        <div>Pessoal,<br>
                                                          <br>
                                                          <br>
                                                        </div>
                                                        <div>Tenho
                                                          utilizado o
                                                          read.table
                                                          para ler
                                                          arquivos e
                                                          realizar
                                                          tarefas
                                                          simples.
                                                          Contudo, agora
                                                          necessito
                                                          rodar 6
                                                          programas para
                                                          38 localidades
                                                          distintas e
                                                          tenho feito
                                                          isso ponto a
                                                          ponto, para
                                                          cada um dos
                                                          modelos... Já
                                                          rodei os
                                                          programas uma
                                                          vez dessa
                                                          maneira
                                                          trabalhosa e
                                                          agora pretendo
                                                          automatizar o
                                                          processo lendo
                                                          todos os 38
                                                          arquivos de
                                                          uma só vez e
                                                          rodar cada um
                                                          dos modelos
                                                          para os 38
                                                          arquivos (um
                                                          modelo por
                                                          vez).<br>
                                                          <br>
                                                        </div>
                                                        <div>Minha
                                                          pergunta é: há
                                                          alguma função
                                                          para leitura
                                                          de vários
                                                          arquivos
                                                          juntos ?<br>
                                                        </div>
                                                        <div><br>
                                                        </div>
                                                        <div>
                                                          <div>Por
                                                          favor, se não
                                                          ficar claro
                                                          posso tentar
                                                          explicar
                                                          melhor! <br>
                                                          </div>
                                                          <div>abs<span><font
color="#888888"><br>
                                                          </font></span></div>
                                                          <span><font
                                                          color="#888888">
                                                          <div>-- <br>
                                                          <div>
                                                          <div dir="ltr">
                                                          <div>
                                                          <div dir="ltr"><font
color="#666666">João Rodrigo de Castro</font>
                                                          <div><font
                                                          color="#666666">Programa

                                                          de
                                                          Pós-Graduação
                                                          em
                                                          Meteorologia</font></div>
                                                          <div><font
                                                          color="#666666">Bolsista

                                                          Laboratório de
                                                          Agrometeorologia

                                                          - Embrapa
                                                          Clima
                                                          Temperado</font></div>
                                                          <div><font
                                                          color="#666666">Universidade

                                                          Federal de
                                                          Pelotas</font></div>
                                                          </div>
                                                          </div>
                                                          </div>
                                                          </div>
                                                          </div>
                                                          </font></span></div>
                                                      </div>
                                                      <br>
                                                    </div>
                                                  </div>
_______________________________________________<br>
                                                  R-br mailing list<br>
                                                  <a
                                                    moz-do-not-send="true"
href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
                                                  <a
                                                    moz-do-not-send="true"
href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br"
                                                    target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
                                                  Leia o guia de
                                                  postagem (<a
                                                    moz-do-not-send="true"
href="http://www.leg.ufpr.br/r-br-guia" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>)
                                                  e forneça código
                                                  mínimo reproduzível.<span><font
                                                      color="#888888"><br>
                                                    </font></span></blockquote>
                                              </div>
                                              <span><font
                                                  color="#888888"><br>
                                                  <br clear="all">
                                                  <br>
                                                  -- <br>
                                                  <div>
                                                    <div dir="ltr">
                                                      <div>Grato<br>
                                                        Augusto C. A.
                                                        Ribas</div>
                                                      <div> </div>
                                                      <div>Site Pessoal:
                                                        <a
                                                          moz-do-not-send="true"
href="http://recologia.com.br/" target="_blank">http://recologia.com.br/</a></div>
                                                      <div>Github: <a
                                                          moz-do-not-send="true"
href="https://github.com/Squiercg" target="_blank">https://github.com/Squiercg</a></div>
                                                      <div>Lattes: <a
                                                          moz-do-not-send="true"
href="http://lattes.cnpq.br/7355685961127056" target="_blank">http://lattes.cnpq.br/7355685961127056</a><br>
                                                      </div>
                                                    </div>
                                                  </div>
                                                </font></span></div>
                                            <br>
_______________________________________________<br>
                                            R-br mailing list<br>
                                            <a moz-do-not-send="true"
                                              href="mailto:R-br@listas.c3sl.ufpr.br"
                                              target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
                                            <a moz-do-not-send="true"
                                              href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br"
                                              target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
                                            Leia o guia de postagem (<a
                                              moz-do-not-send="true"
                                              href="http://www.leg.ufpr.br/r-br-guia"
                                              target="_blank">http://www.leg.ufpr.br/r-br-guia</a>)
                                            e forneça código mínimo
                                            reproduzível.<br>
                                          </blockquote>
                                        </div>
                                        <br>
                                        <br clear="all">
                                        <br>
                                        -- <br>
                                        <div>
                                          <div dir="ltr">
                                            <div>
                                              <div dir="ltr"><font
                                                  color="#666666">João
                                                  Rodrigo de Castro</font>
                                                <div><font
                                                    color="#666666">Programa

                                                    de Pós-Graduação em
                                                    Meteorologia</font></div>
                                                <div><font
                                                    color="#666666">Bolsista

                                                    Laboratório de
                                                    Agrometeorologia -
                                                    Embrapa Clima
                                                    Temperado</font></div>
                                                <div><font
                                                    color="#666666">Universidade

                                                    Federal de Pelotas</font></div>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                  <br>
_______________________________________________<br>
                                  R-br mailing list<br>
                                  <a moz-do-not-send="true"
                                    href="mailto:R-br@listas.c3sl.ufpr.br"
                                    target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
                                  <a moz-do-not-send="true"
                                    href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br"
                                    target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
                                  Leia o guia de postagem (<a
                                    moz-do-not-send="true"
                                    href="http://www.leg.ufpr.br/r-br-guia"
                                    target="_blank">http://www.leg.ufpr.br/r-br-guia</a>)
                                  e forneça código mínimo reproduzível.<br>
                                </blockquote>
                              </div>
                              <br>
                              <br clear="all">
                              <br>
                              -- <br>
                              <div>
                                <div dir="ltr">
                                  <div>Grato<br>
                                    Augusto C. A. Ribas</div>
                                  <div> </div>
                                  <div>Site Pessoal: <a
                                      moz-do-not-send="true"
                                      href="http://recologia.com.br/"
                                      target="_blank">http://recologia.com.br/</a></div>
                                  <div>Github: <a moz-do-not-send="true"
                                      href="https://github.com/Squiercg"
                                      target="_blank">https://github.com/Squiercg</a></div>
                                  <div>Lattes: <a
                                      moz-do-not-send="true"
                                      href="http://lattes.cnpq.br/7355685961127056"
                                      target="_blank">http://lattes.cnpq.br/7355685961127056</a><br>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                        <br>
                        _______________________________________________<br>
                        R-br mailing list<br>
                        <a moz-do-not-send="true"
                          href="mailto:R-br@listas.c3sl.ufpr.br"
                          target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
                        <a moz-do-not-send="true"
                          href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br"
                          target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
                        Leia o guia de postagem (<a
                          moz-do-not-send="true"
                          href="http://www.leg.ufpr.br/r-br-guia"
                          target="_blank">http://www.leg.ufpr.br/r-br-guia</a>)
                        e forneça código mínimo reproduzível.<br>
                      </blockquote>
                    </div>
                    <br>
                    <br clear="all">
                    <br>
                    -- <br>
                    <div>
                      <div dir="ltr">
                        <div>
                          <div dir="ltr"><font color="#666666">João
                              Rodrigo de Castro</font>
                            <div><font color="#666666">Programa de
                                Pós-Graduação em Meteorologia</font></div>
                            <div><font color="#666666">Bolsista
                                Laboratório de Agrometeorologia -
                                Embrapa Clima Temperado</font></div>
                            <div><font color="#666666">Universidade
                                Federal de Pelotas</font></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <br>
              _______________________________________________<br>
              R-br mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br>
              <a moz-do-not-send="true"
                href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br"
                rel="noreferrer" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
              Leia o guia de postagem (<a moz-do-not-send="true"
                href="http://www.leg.ufpr.br/r-br-guia" rel="noreferrer"
                target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e
              forneça código mínimo reproduzível.<br>
            </blockquote>
          </div>
          <br>
        </div>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
R-br mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a>
Leia o guia de postagem (<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.leg.ufpr.br/r-br-guia">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.</pre>
      </blockquote>
      <br>
      <pre class="moz-signature" cols="72">-- 
Best regards,

Vinícius Lionel Mateus, MSc (<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lattes.cnpq.br/6501001637020665">http://lattes.cnpq.br/6501001637020665</a>)
Chemistry PhD Student
Atmospheric Chemistry Laboratory - Dep. Chemistry
PUC-Rio - Pontifical Catholic University of Rio de Janeiro
Marquês de São Vicente, 225, Gávea - Rio de Janeiro, RJ - Brazil CEP: 22451-900
Phone:        (+45) 26 28 28 51
              (+55) (21) 3527-1327
              (+55) (21) 993 - 588 - 051
Skype: vinicius.lionel
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.qui.puc-rio.br/index.html">http://www.qui.puc-rio.br/index.html</a></pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Best regards,

Vinícius Lionel Mateus, MSc (<a class="moz-txt-link-freetext" href="http://lattes.cnpq.br/6501001637020665">http://lattes.cnpq.br/6501001637020665</a>)
Chemistry PhD Student
Atmospheric Chemistry Laboratory - Dep. Chemistry
PUC-Rio - Pontifical Catholic University of Rio de Janeiro
Marquês de São Vicente, 225, Gávea - Rio de Janeiro, RJ - Brazil CEP: 22451-900
Phone:        (+45) 26 28 28 51
              (+55) (21) 3527-1327
              (+55) (21) 993 - 588 - 051
Skype: vinicius.lionel
<a class="moz-txt-link-freetext" href="http://www.qui.puc-rio.br/index.html">http://www.qui.puc-rio.br/index.html</a></pre>
  </body>
</html>