[R-br] função summary quase resolvido
Edson Lira
edinhoestat em yahoo.com.br
Quarta Fevereiro 20 14:33:35 BRT 2013
Faça o seguinte:
tabelas<-function(x){
qtde<-table(x)
perc<-100*prop.table(table(x))
cbind(qtde,perc)
}
apply(bd,2,tabelas)
Essa rotina vai te dar tabelas com quantidades e percentuais de todas as variáveis.
Talvez te ajude.
[. ]'s.
Edson Lira
Estatístico
Ma-Am
Em 20/02/2013, às 13:16, Rodrigo Coster <rcoster em gmail.com> escreveu:
> um print(dados) (ou simplesmente, dados) não faz o que tu quer? O summary() vai fazer descritiva de cada coluna do teu banco de dados. Acredito que o que tu queira é aplicar o summary pra cada clinica, ou seja::
>
> dados <- read.table(text='clinica doismiloito doismilnove doismildez doismilonze doismildoze
> PBarca 0.70 0.72 0.72 0.76 0.77
> Braga 0.74 0.75 0.78 0.76 0.73
> Fafe 0.74 0.75 0.74 0.72 0.76
> Maia 0.70 0.75 0.71 0.76 0.80
> VNGaia 0.80 0.83 0.84 0.84 0.81
> SMFeira 0.73 0.75 0.74 0.78 0.75',header=T)
>
> est <- data.frame(Clinica=dados[,1],apply(dados[,-1],1,summary))
> colnames(est)[-1] <- c('Min.','1st Qu.','Median','Mean','3rd Qu.','Max.')
> est
>
> Clinica Min. 1st Qu. Median Mean 3rd Qu. Max.
> Min. PBarca 0.700 0.730 0.720 0.700 0.800 0.73
> 1st Qu. Braga 0.720 0.740 0.740 0.710 0.810 0.74
> Median Fafe 0.720 0.750 0.740 0.750 0.830 0.75
> Mean Maia 0.734 0.752 0.742 0.744 0.824 0.75
> 3rd Qu. VNGaia 0.760 0.760 0.750 0.760 0.840 0.75
> Max. SMFeira 0.770 0.780 0.760 0.800 0.840 0.78
>
>
> On Wed, Feb 20, 2013 at 12:36 PM, <alanarocha em sapo.pt> wrote:
>> Olá,
>> agora já me aparecem as estatísticas.
>> Mas as clinicas não estão na mesma ordem das que estão no ficheiro.
>> há alguma forma de as coloccar por ordem e em cada linha o nome da clinica e os valores dos 5 anos?
>> setwd("G:/SIN/Users/Ana Rua/indicadores_ano")
>>
>> dados<-read.table("indicadores_08to12.csv",header=TRUE,sep=";")
>> head(dados)
>>
>> Type 'contributors()' for more information and
>> 'citation()' on how to cite R or R packages in publications.
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> 'help.start()' for an HTML browser interface to help.
>> Type 'q()' to quit R.
>>
>> setwd("G:/SIN/Users/Ana Rua/indicadores_ano")
>>
>> dados<-read.table("indicadores_08to12.csv",header=TRUE,sep=";")
>> head(dados)
>> summary(dados)
>>> setwd("G:/SIN/Users/Ana Rua/indicadores_ano")
>>>
>>> dados<-read.table("indicadores_08to12.csv",header=TRUE,sep=";")
>> Warning message:
>> In read.table("indicadores_08to12.csv", header = TRUE, sep = ";") :
>> incomplete final line found by readTableHeader on 'indicadores_08to12.csv'
>>> head(dados)
>> [1] Clinica..2008..2009..2010..2011..2012..PBarca.0.70.0.72.0.72.0.76.0.77.Braga.0.74.0.75.0.78.0.76.0.73.Fafe.0.74.0.75.0.74.0.72.0.76.Maia.0.70.0.75.0.71.0.76.0.80.VNGaia.0.80.0.83.0.84.0.84.0.81.SMFeira.0.73.0.75.0.74.0.78.0.75.Viseu.0.71.0.68.0.78.0.76.0.76.Guarda.0.69.0.64.0.69.0.74.0.81.Covilhã.0.70.0.71.0.77.0.78.0.79.Coimbra.0.80.0.77.0.77.0.77.0.77.Abrantes.0.81.0.83.0.82.0.80.0.81.Entroncamento.0.68.0.74.0.73.0.75.0.75.Santarém.0.76.0.75.0.73.0.82.0.83.TVedras.0.77.0.69.0.75.0.78.0.81.VFXira.0.74.0.71.0.76.0.79.0.79.Alverca.0.79.0.76.0.80.0.84.0.80.Amadora.0.69.0.70.0.73.0.75.0.75.Lumiar.0.69.0.71.0.72.0.75.0.76.DAD.....0.80.Restelo.0.72.0.71.0.70.0.75.0.74.CUF.0.64.0.66.0.68.0.73.0.71.SAMS.0.82.0.80.0.83.0.85.0.81.APDP.....0.57.Montijo.0.74.0.76.0.71.0.74.0.85.Barreiro.0.77.0.78.0.79.0.77.0.78.Almada.0.75.0.75.0.72.0.76.0.79.Seixal.0.76.0.75.0.77.0.81.0.81.Setúbal.0.71.0.76.0.79.0.79.0.77.Portalegre.0.74.0.78.0.81.0.81.0.76.Évora.0.82.0.81.0.81.0.78.0.81.Grãndola.0.76.0.76.0.7
>> 8.0.78.0.80.Beja.0.71.0.76.0.74.0.73.0.69.Tavira.0.63.0.70.0.70.0.65.0.71.Faro.0.61.0.74.0.79.0.77.0.78.Portimão.0.63.0.75.0.79.0.78.0.82.Funchal..0.68.0.74.0.72.0.74.Machico.....0.73..Clinica..2008....2009
>> [2] X2010.2011
>> [3] X2012.PBarca.0.70.0.72.0.72.0.76.0.77.Braga.0.74.0.75.0.78.0.76.0.73.Fafe.0.74.0.75.0.74.0.72.0.76.Maia.0.70.0.75.0.71.0.76.0.80.VNGaia.0.80.0.83.0.84.0.84.0.81.SMFeira.0.73.0.75.0.74.0.78.0.75.Viseu.0.71.0.68.0.78.0.76.0.76.Guarda.0.69.0.64.0.69.0.74.0.81.Covilhã.0.70.0.71.0.77.0.78.0.79.Coimbra.0.80.0.77.0.77.0.77.0.77.Abrantes.0.81.0.83.0.82.0.80.0.81.Entroncamento.0.68.0.74.0.73.0.75.0.75.Santarém.0.76.0.75.0.73.0.82.0.83.TVedras.0.77.0.69.0.75.0.78.0.81.VFXira.0.74.0.71.0.76.0.79.0.79.Alverca.0.79.0.76.0.80.0.84.0.80.Amadora.0.69.0.70.0.73.0.75.0.75.Lumiar.0.69.0.71.0.72.0.75.0.76.DAD.....0.80.Restelo.0.72.0.71.0.70.0.75.0.74.CUF.0.64.0.66.0.68.0.73.0.71.SAMS.0.82.0.80.0.83.0.85.0.81.APDP.....0.57.Montijo.0.74.0.76.0.71.0.74.0.85.Barreiro.0.77.0.78.0.79.0.77.0.78.Almada.0.75.0.75.0.72.0.76.0.79.Seixal.0.76.0.75.0.77.0.81.0.81.Setúbal.0.71.0.76.0.79.0.79.0.77.Portalegre.0.74.0.78.0.81.0.81.0.76.Évora.0.82.0.81.0.81.0.78.0.81.Grãndola.0.76.0.76.0.78.0.78.0.80.Beja.0.71.0.76.0.74.0
>> .73.0.69.Tavira.0.63.0.70.0.70.0.65.0.71.Faro.0.61.0.74.0.79.0.77.0.78.Portimão.0.63.0.75.0.79.0.78.0.82.Funchal..0.68.0.74.0.72.0.74.Machico.....0.73..
>> <0 rows> (or 0-length row.names)
>>>
>>> Type 'contributors()' for more information and
>> Error: unexpected string constant in "Type 'contributors()'"
>>> 'citation()' on how to cite R or R packages in publications.
>> Error: unexpected symbol in "'citation()' on"
>>>
>>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> Error: unexpected string constant in "Type 'demo()'"
>>> 'help.start()' for an HTML browser interface to help.
>> Error: unexpected 'for' in "'help.start()' for"
>>> Type 'q()' to quit R.
>> Error: unexpected string constant in "Type 'q()'"
>> setwd("G:/SIN/Users/Ana Rua/indicadores_ano")
>>
>> dados<-read.table("indicadores_08to12.csv",header=TRUE,sep=";")
>> head(dados)
>> summary(dados)
>>> setwd("G:/SIN/Users/Ana Rua/indicadores_ano")
>>>
>>> dados<-read.table("indicadores_08to12.csv",header=TRUE,sep=";")
>>> head(dados)
>> clinica doismiloito doismilnove doismildez doismilonze doismildoze
>> 1 PBarca 0.70 0.72 0.72 0.76 0.77
>> 2 Braga 0.74 0.75 0.78 0.76 0.73
>> 3 Fafe 0.74 0.75 0.74 0.72 0.76
>> 4 Maia 0.70 0.75 0.71 0.76 0.80
>> 5 VNGaia 0.80 0.83 0.84 0.84 0.81
>> 6 SMFeira 0.73 0.75 0.74 0.78 0.75
>>>
>>> Type 'contributors()' for more information and
>> Error: unexpected string constant in "Type 'contributors()'"
>>> 'citation()' on how to cite R or R packages in publications.
>> Error: unexpected symbol in "'citation()' on"
>>>
>>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> Error: unexpected string constant in "Type 'demo()'"
>>> 'help.start()' for an HTML browser interface to help.
>> Error: unexpected 'for' in "'help.start()' for"
>>> Type 'q()' to quit R.
>> Error: unexpected string constant in "Type 'q()'"
>>>
>>> setwd("G:/SIN/Users/Ana Rua/indicadores_ano")
>>>
>>> dados<-read.table("indicadores_08to12.csv",header=TRUE,sep=";")
>>> head(dados)
>> clinica doismiloito doismilnove doismildez doismilonze doismildoze
>> 1 PBarca 0.70 0.72 0.72 0.76 0.77
>> 2 Braga 0.74 0.75 0.78 0.76 0.73
>> 3 Fafe 0.74 0.75 0.74 0.72 0.76
>> 4 Maia 0.70 0.75 0.71 0.76 0.80
>> 5 VNGaia 0.80 0.83 0.84 0.84 0.81
>> 6 SMFeira 0.73 0.75 0.74 0.78 0.75
>>> summary(dados)
>> clinica doismiloito doismilnove doismildez
>> Abrantes: 1 Min. :0.6100 Min. :0.6400 Min. :0.6800
>> Almada : 1 1st Qu.:0.7000 1st Qu.:0.7100 1st Qu.:0.7225
>> Alverca : 1 Median :0.7400 Median :0.7500 Median :0.7550
>> Amadora : 1 Mean :0.7288 Mean :0.7409 Mean :0.7568
>> APDP : 1 3rd Qu.:0.7600 3rd Qu.:0.7600 3rd Qu.:0.7900
>> Barreiro: 1 Max. :0.8200 Max. :0.8300 Max. :0.8400
>> (Other) :31 NA's :4 NA's :3 NA's :3
>> doismilonze doismildoze
>> Min. :0.6500 Min. :0.5700
>> 1st Qu.:0.7500 1st Qu.:0.7500
>> Median :0.7700 Median :0.7800
>> Mean :0.7697 Mean :0.7708
>> 3rd Qu.:0.7875 3rd Qu.:0.8100
>> Max. :0.8500 Max. :0.8500
>> NA's :3
>>> > setwd("G:/SIN/Users/Ana Rua/indicadores_ano")
>> Error: unexpected '>' in ">"
>>> >
>> Error: unexpected '>' in ">"
>>> > dados<-read.table("indicadores_08to12.csv",header=TRUE,sep=";")
>> Error: unexpected '>' in ">"
>>> Warning message:
>> Error: unexpected symbol in "Warning message"
>>> In read.table("indicadores_08to12.csv", header = TRUE, sep = ";") :
>> Error: unexpected symbol in "In read.table"
>>> incomplete final line found by readTableHeader on 'indicadores_08to12.csv'
>> Error: unexpected symbol in " incomplete final"
>>> > head(dados)
>> Error: unexpected '>' in ">"
>>> [1] Clinica..2008..2009..2010..2011..2012..PBarca.0.70.0.72.0.72.0.76.0.77.Braga.0.74.0.75.0.78.0.76.0.73.Fafe.0.74.0.75.0.74.0.72.0.76.Maia.0.70.0.75.0.71.0.76.0.80.VNGaia.0.80.0.83.0.84.0.84.0.81.SMFeira.0.73.0.75.0.74.0.78.0.75.Viseu.0.71.0.68.0.78.0.76.0.76.Guarda.0.69.0.64.0.69.0.74.0.81.Covilhã.0.70.0.71.0.77.0.78.0.79.Coimbra.0.80.0.77.0.77.0.77.0.77.Abrantes.0.81.0.83.0.82.0.80.0.81.Entroncamento.0.68.0.74.0.73.0.75.0.75.Santarém.0.76.0.75.0.73.0.82.0.83.TVedras.0.77.0.69.0.75.0.78.0.81.VFXira.0.74.0.71.0.76.0.79.0.79.Alverca.0.79.0.76.0.80.0.84.0.80.Amadora.0.69.0.70.0.73.0.75.0.75.Lumiar.0.69.0.71.0.72.0.75.0.76.DAD.....0.80.Restelo.0.72.0.71.0.70.0.75.0.74.CUF.0.64.0.66.0.68.0.73.0.71.SAMS.0.82.0.80.0.83.0.85.0.81.APDP.....0.57.Montijo.0.74.0.76.0.71.0.74.0.85.Barreiro.0.77.0.78.0.79.0.77.0.78.Almada.0.75.0.75.0.72.0.76.0.79.Seixal.0.76.0.75.0.77.0.81.0.81.Setúbal.0.71.0.76.0.79.0.79.0.77.Portalegre.0.74.0.78.0.81.0.81.0.76.Évora.0.82.0.81.0.81.0.78.0.81.Grãndola.0.76.0.76.0
>>> .78.0.78.0.80.Beja.0.71.0.76.0.74.0.73.0.69.Tavira.0.63.0.70.0.70.0.65.0.71.Faro.0.61.0.74.0.79.0.77.0.78.Portimão.0.63.0.75.0.79.0.78.0.82.Funchal..0.68.0.74.0.72.0.74.Machico.....0.73..Clinica..2008....2009
>> Error: unexpected '[' in "["
>>> [2] X2010.2011
>> Error: unexpected '[' in "["
>>> [3] X2012.PBarca.0.70.0.72.0.72.0.76.0.77.Braga.0.74.0.75.0.78.0.76.0.73.Fafe.0.74.0.75.0.74.0.72.0.76.Maia.0.70.0.75.0.71.0.76.0.80.VNGaia.0.80.0.83.0.84.0.84.0.81.SMFeira.0.73.0.75.0.74.0.78.0.75.Viseu.0.71.0.68.0.78.0.76.0.76.Guarda.0.69.0.64.0.69.0.74.0.81.Covilhã.0.70.0.71.0.77.0.78.0.79.Coimbra.0.80.0.77.0.77.0.77.0.77.Abrantes.0.81.0.83.0.82.0.80.0.81.Entroncamento.0.68.0.74.0.73.0.75.0.75.Santarém.0.76.0.75.0.73.0.82.0.83.TVedras.0.77.0.69.0.75.0.78.0.81.VFXira.0.74.0.71.0.76.0.79.0.79.Alverca.0.79.0.76.0.80.0.84.0.80.Amadora.0.69.0.70.0.73.0.75.0.75.Lumiar.0.69.0.71.0.72.0.75.0.76.DAD.....0.80.Restelo.0.72.0.71.0.70.0.75.0.74.CUF.0.64.0.66.0.68.0.73.0.71.SAMS.0.82.0.80.0.83.0.85.0.81.APDP.....0.57.Montijo.0.74.0.76.0.71.0.74.0.85.Barreiro.0.77.0.78.0.79.0.77.0.78.Almada.0.75.0.75.0.72.0.76.0.79.Seixal.0.76.0.75.0.77.0.81.0.81.Setúbal.0.71.0.76.0.79.0.79.0.77.Portalegre.0.74.0.78.0.81.0.81.0.76.Évora.0.82.0.81.0.81.0.78.0.81.Grãndola.0.76.0.76.0.78.0.78.0.80.Beja.0.71.0.76.0.74
>>> .0.73.0.69.Tavira.0.63.0.70.0.70.0.65.0.71.Faro.0.61.0.74.0.79.0.77.0.78.Portimão.0.63.0.75.0.79.0.78.0.82.Funchal..0.68.0.74.0.72.0.74.Machico.....0.73..
>> Error: unexpected '[' in "["
>>> <0 rows> (or 0-length row.names)
>> Error: unexpected '<' in "<"
>>> >
>> Error: unexpected '>' in ">"
>>> > Type 'contributors()' for more information and
>> Error: unexpected '>' in ">"
>>> Error: unexpected string constant in "Type 'contributors()'"
>> Error: unexpected symbol in "Error: unexpected string"
>>> > 'citation()' on how to cite R or R packages in publications.
>> Error: unexpected '>' in ">"
>>> Error: unexpected symbol in "'citation()' on"
>> Error: unexpected symbol in "Error: unexpected symbol"
>>> >
>> Error: unexpected '>' in ">"
>>> > Type 'demo()' for some demos, 'help()' for on-line help, or
>> Error: unexpected '>' in ">"
>>> Error: unexpected string constant in "Type 'demo()'"
>> Error: unexpected symbol in "Error: unexpected string"
>>> > 'help.start()' for an HTML browser interface to help.
>> Error: unexpected '>' in ">"
>>> Error: unexpected 'for' in "'help.start()' for"
>> Error: unexpected string constant in "Error: unexpected 'for'"
>>> > Type 'q()' to quit R.
>> Error: unexpected '>' in ">"
>>> Error: unexpected string constant in "Type 'q()'"
>> Error: unexpected symbol in "Error: unexpected string"
>>> >
>> Error: unexpected '>' in ">"
>> setwd("G:/SIN/Users/Ana Rua/indicadores_ano")
>>
>> dados<-read.table("indicadores_08to12.csv",header=TRUE,sep=";")
>> head(dados)
>> clinica doismiloito doismilnove doismildez doismilonze doismildoze
>> 1 PBarca 0.70 0.72 0.72 0.76 0.77
>> 2 Braga 0.74 0.75 0.78 0.76 0.73
>> 3 Fafe 0.74 0.75 0.74 0.72 0.76
>> 4 Maia 0.70 0.75 0.71 0.76 0.80
>> 5 VNGaia 0.80 0.83 0.84 0.84 0.81
>> 6 SMFeira 0.73 0.75 0.74 0.78 0.75
>> summary(dados)
>> clinica doismiloito doismilnove doismildez
>> Abrantes: 1 Min. :0.6100 Min. :0.6400 Min. :0.6800
>> Almada : 1 1st Qu.:0.7000 1st Qu.:0.7100 1st Qu.:0.7225
>> Alverca : 1 Median :0.7400 Median :0.7500 Median :0.7550
>> Amadora : 1 Mean :0.7288 Mean :0.7409 Mean :0.7568
>> APDP : 1 3rd Qu.:0.7600 3rd Qu.:0.7600 3rd Qu.:0.7900
>> Barreiro: 1 Max. :0.8200 Max. :0.8300 Max. :0.8400
>> (Other) :31 NA's :4 NA's :3 NA's :3
>> doismilonze doismildoze
>> Min. :0.6500 Min. :0.5700
>> 1st Qu.:0.7500 1st Qu.:0.7500
>> Median :0.7700 Median :0.7800
>> Mean :0.7697 Mean :0.7708
>> 3rd Qu.:0.7875 3rd Qu.:0.8100
>> Max. :0.8500 Max. :0.8500
>> NA's :3
>> cumprimentos Ana
>>
>> _______________________________________________
>> 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.
>
> _______________________________________________
> 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/20130220/90260e46/attachment.html>
Mais detalhes sobre a lista de discussão R-br