[R-br] Dados em uma tabela

Elias T. Krainski eliaskrainski em yahoo.com.br
Quarta Agosto 27 04:28:14 BRT 2014


solucao "rustica"...suponha que seu arquivo e' "dados.txt"

a <- readLines("dados.txt")
id.a <- which(substr(a,1,2)=='A.')
nch <- nchar(a)
tab <- sapply(0:6, function(j)
   as.integer(substring(a[id.a+j], nch[id.a+j])))
dimnames(tab) <- list(a[id.a-1], LETTERS[1:7])
tab

aT+,
Elias.

On 27/08/14 05:26, jose gomes de souza filho Gomes wrote:
> Boa Noite,
>
> Tenho o seguinte banco de dados em txt( em anexo):
>
> JOSÉ
> A................................. 2
> B.....................................0
> C...................................0
> D.................................... 6
> E.......................0
> F............................. 1
> G................................ 13
> MARIA
> A................................. 3
> B.....................................0
> C...................................0
> D.................................... 1
> E.......................0
> F............................. 1
> G................................ 6
> PEDRO
> A.................................0
> B.....................................
> C...................................0
> D...................................0
> E.......................0
> F.............................0
> G................................ 3
>
> Gostaria que ficasse assim:
> Nome     A     B     C     D     E     G     F
> JOSÉ      2     0     0     6     0     1     13
> MARIA     3     0     0     1     0     1     6
> PEDRO     0     0     0     0     0     0     3
>
> Como fazer isso?
>
>
> Att,
> Gomes
>
>
> _______________________________________________
> R-br mailing list
> R-br em listas.c3sl.ufpr.br
> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça código mínimo reproduzível.

-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20140827/93b43b69/attachment.html>


Mais detalhes sobre a lista de discussão R-br