Boa noite,<br><br>Agora tenho o seguinte problema.<br>Tenho um arquivo de dados como abaixo<br><br>Z <- read.table("/test.txt", sep="\t", stringsAsFactors = FALSE)<br><br>Z:<br><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: arial; font-size: small; "><div>
QW<span class="Apple-tab-span" style="white-space: pre; ">    </span>B<span class="Apple-tab-span" style="white-space: pre; ">1       </span>4<span class="Apple-tab-span" style="white-space: pre; ">        </span>2</div><div>QW<span class="Apple-tab-span" style="white-space: pre; ">       </span>B<span class="Apple-tab-span" style="white-space: pre; ">1       </span>4<span class="Apple-tab-span" style="white-space: pre; ">        </span>2</div>
<div>QW<span class="Apple-tab-span" style="white-space: pre; "> </span>B<span class="Apple-tab-span" style="white-space: pre; ">1       </span>4<span class="Apple-tab-span" style="white-space: pre; ">        </span>2</div><div>QW<span class="Apple-tab-span" style="white-space: pre; ">  </span>D<span class="Apple-tab-span" style="white-space: pre; ">2    </span>2<span class="Apple-tab-span" style="white-space: pre; ">        </span>1</div>
<div>QW<span class="Apple-tab-span" style="white-space: pre; "> D</span><span class="Apple-tab-span" style="white-space: pre; ">2       </span>2<span class="Apple-tab-span" style="white-space: pre; ">        </span>1</div><div>QW<span class="Apple-tab-span" style="white-space: pre; ">  </span>D<span class="Apple-tab-span" style="white-space: pre; ">2    </span>2<span class="Apple-tab-span" style="white-space: pre; ">        </span>1</div>
<div>QW<span class="Apple-tab-span" style="white-space: pre; "> D</span><span class="Apple-tab-span" style="white-space: pre; ">3       </span>1<span class="Apple-tab-span" style="white-space: pre; ">        </span>3</div><div>QW<span class="Apple-tab-span" style="white-space: pre; ">       </span>D<span class="Apple-tab-span" style="white-space: pre; ">3       </span>1<span class="Apple-tab-span" style="white-space: pre; ">        </span>3</div>
<div>QW<span class="Apple-tab-span" style="white-space: pre; "> </span>D<span class="Apple-tab-span" style="white-space: pre; ">3       </span>1<span class="Apple-tab-span" style="white-space: pre; ">        </span>3<br><br>preciso escrever esse arquivo "test.txt" em um outro arquivo, ou seja, SALVAR como "final.txt".<br>
1) Selecionar o elemento da 2a coluna e escrever na 1a linha;<br>2) Escrever todos os elementos da 3a que correspondem ao intem 1, em linha;<br>3) <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: arial; font-size: small; ">Escrever todos os elementos da 4a que correspondem ao intem 1, em linha;</span></span><br>
4) Retorna ao intem 1 (ciclo)<br>Obs. No arquivo test.txt tenho muitas linhas + 500.<br>        A 1a é descartada...<br><br>B1<br>4<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: arial; font-size: small; "><span class="Apple-tab-span" style="white-space: pre; ">   </span></span></span>4<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: arial; font-size: small; "><span class="Apple-tab-span" style="white-space: pre; ">    </span></span></span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: arial; font-size: small; "><span class="Apple-tab-span" style="white-space: pre; "></span></span></span>4<br>
2<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: arial; font-size: small;"><span class="Apple-tab-span" style="white-space: pre;">        2</span></span></span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: arial; font-size: small;"><span class="Apple-tab-span" style="white-space: pre;"> 2<br>
D2<br>2</span></span></span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: arial; font-size: small;"><span class="Apple-tab-span" style="white-space: pre;">     2</span></span></span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: arial; font-size: small;"><span class="Apple-tab-span" style="white-space: pre;"> 2<br>
1</span></span></span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: arial; font-size: small;"><span class="Apple-tab-span" style="white-space: pre;"> 1</span></span></span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: arial; font-size: small;"><span class="Apple-tab-span" style="white-space: pre;"> 1<br>
D3<br>1</span></span></span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: arial; font-size: small;"><span class="Apple-tab-span" style="white-space: pre;">     1</span></span></span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: arial; font-size: small;"><span class="Apple-tab-span" style="white-space: pre;"> 1<br>
3</span></span></span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: arial; font-size: small;"><span class="Apple-tab-span" style="white-space: pre;"> 3</span></span></span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: arial; font-size: small; "><span class="Apple-tab-span" style="white-space: pre; ">    3</span></span></span></div>
</span></span><br><br>Muito obrigado caros amigos da lista.<br><br>Ricardo Pereira<br>