<div dir="ltr"><div>Roney, boa tarde!</div><div><br></div><div>Há alguns pacotes específicos para tratar de referências no R, como o RefManageR. Com ele é possível importar diretamente diversos formatos de arquivos como Bibtex ou Zotero e é bem provável que irá facilitar suas análises.</div>
<div><br></div><div><a href="http://cran.r-project.org/web/packages/RefManageR/vignettes/manual.pdf">cran.r-project.org/web/packages/RefManageR/vignettes/manual.pdf</a><br></div><div><br></div><div>Embora a solução proposta por Gustavo Carvalho já deva lhe atender, também arrisquei um código pra fins de aprendizado... </div>
<div><br></div>### <code r><br><div><div><font face="courier new, monospace">setwd("C:/LAB/Temp"); getwd()</font></div><div><font face="courier new, monospace">raw <- readLines("savedrecs.txt")</font></div>
<div><font face="courier new, monospace">raw2 <- gsub("(^..)(.*$)", "\\1_\\2", raw)</font></div><div><font face="courier new, monospace">df <- read.table(text=raw2, head=F, sep='_')</font></div>
<div><font face="courier new, monospace">rec <- cumsum(ifelse(df$V1=="PT",1,0))</font></div><div><font face="courier new, monospace">df2 <- cbind(rec, df)</font></div><div><font face="courier new, monospace">df3 <- df2[grep("^AU|^DT|^PY|^VL|^BP", df2$V1),]</font></div>
<div><font face="courier new, monospace">reshape2::dcast(df3, V1~rec, value.var="V2")</font></div><div><font face="courier new, monospace"># V1 1 2</font></div><div><font face="courier new, monospace"># 1 AU Lin, TH Brodeur-Campbell, M</font></div>
<div><font face="courier new, monospace"># 2 BP 314 320</font></div><div><font face="courier new, monospace"># 3 DT Article Article</font></div><div><font face="courier new, monospace"># 4 PY 2012 2012</font></div>
<div><font face="courier new, monospace"># 5 VL 116 116</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">t(reshape2::dcast(df3, V1~rec, value.var="V2"))</font></div>
<div><font face="courier new, monospace"># [,1] [,2] [,3] [,4] [,5] </font></div><div><font face="courier new, monospace"># V1 "AU" "BP" "DT" "PY" "VL" </font></div>
<div><font face="courier new, monospace"># 1 " Lin, TH" " 314" " Article" " 2012" " 116"</font></div><div><font face="courier new, monospace"># 2 " Brodeur-Campbell, M" " 320" " Article" " 2012" " 116"</font></div>
</div><div>### </ code><font face="courier new, monospace"><br></font></div><div><br></div><div>Atte.,</div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">Éder Comunello <<a href="mailto:comunello.eder@gmail.com" target="_blank">c</a><a href="mailto:omunello.eder@gmail.com" target="_blank">omunello.eder@gmail.com</a>> <br>
Dourados, MS - [22 16.5'S, 54 49'W]<br></div></div>
<br><br><div class="gmail_quote">Em 22 de maio de 2014 17:07, Gustavo Carvalho <span dir="ltr"><<a href="mailto:gustavo.bio@gmail.com" target="_blank">gustavo.bio@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>Assim serve?</div><div><br></div>test <- scan("savedrecs.txt", sep = "\n", what = "")<div><div>matrix(test[grep("^AU|^DT|^PY|^VL|^BP", test)], ncol = 5, byrow = TRUE)</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-05-22 17:48 GMT-03:00 Roney Fraga Souza <span dir="ltr"><<a href="mailto:roneyfraga@gmail.com" target="_blank">roneyfraga@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div style="word-wrap:break-word">Caros,<div><br></div><div>Tenho o seguinte arquivo:</div><div><a href="https://gist.github.com/roneyfraga/ca682b6193c75e7be4bf" target="_blank">https://gist.github.com/roneyfraga/ca682b6193c75e7be4bf</a></div>
<div><br></div><div>Quero manter apenas as linhas que começam com AU, DT, PY, VL e BP no arquivo. O resultado seria:</div><div><br></div><div><pre>AU Lin, TH
DT Article
PY 2012
VL 116
BP 314</pre><pre>AU Brodeur-Campbell, M
DT Article
PY 2012
VL 116
BP 320</pre><pre><br></pre><div><pre><div><div><div><div>Agora preciso que a cada 4 linhas estas sejam transpostas, de modo que ficaria assim:</div></div></div><div><br></div><div>
<table cellspacing="0" cols="5" border="0">
<colgroup width="187"></colgroup>
<colgroup width="88"></colgroup>
<colgroup width="78"></colgroup>
<colgroup width="67"></colgroup>
<colgroup width="91"></colgroup>
<tbody><tr>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" height="21" align="LEFT"><font face="Menlo-Regular" size="1">V1</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">V2</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">V3</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">V4</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">V5</font></td>
</tr>
<tr>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" height="21" align="LEFT"><font face="Menlo-Regular" size="1">AU Lin, TH</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">DT Article</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">PY 2012</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">VL 116</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">BP 314</font></td>
</tr>
<tr>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" height="21" align="LEFT"><font face="Menlo-Regular" size="1">AU Brodeur-Campbell, M</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">DT Article</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">PY 2012</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">VL 116</font></td>
<td style="border-top:1px solid #000000;border-bottom:1px solid #000000;border-left:1px solid #000000;border-right:1px solid #000000" align="LEFT"><font face="Menlo-Regular" size="1">BP 320</font></td>
</tr>
</tbody></table>
Qualquer sugestão será bem vinda?</div><div><br></div><div>Atenciosamente,</div><div>Roney
</div></div></pre></div></div></div><br></div></div>_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
<a 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 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></div></div>
<br>_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br>
<a 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 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></div></div>