1 Arquivos

#Retirando um data frame da memoria
hospay <- NULL

#Lendo o arquivo no padrão csv com separador ; e criando o data frame nf
# hospay <- read.csv(file="./dados/Hospital.csv", sep=";",stringsAsFactors = FALSE, na.strings = c(""," "))  

hospay <- read.csv(file="https://raw.githubusercontent.com/flaviobrito/dataudit/master/dados/Hospital.csv", sep=";",stringsAsFactors = FALSE, na.strings = c(""," "))  


#Estrutura do Arquivo
str(hospay)
## 'data.frame':    14454 obs. of  23 variables:
##  $ Provider.ID               : int  10005 10005 10005 10032 10032 10032 10131 10131 10131 20001 ...
##  $ Hospital.name             : chr  "MARSHALL MEDICAL CENTER SOUTH" "MARSHALL MEDICAL CENTER SOUTH" "MARSHALL MEDICAL CENTER SOUTH" "WEDOWEE HOSPITAL" ...
##  $ Address                   : chr  "2505 U S HIGHWAY 431 NORTH" "2505 U S HIGHWAY 431 NORTH" "2505 U S HIGHWAY 431 NORTH" "209 NORTH MAIN STREET" ...
##  $ City                      : chr  "BOAZ" "BOAZ" "BOAZ" "WEDOWEE" ...
##  $ State                     : chr  "AL" "AL" "AL" "AL" ...
##  $ ZIP.Code                  : int  35957 35957 35957 36278 36278 36278 35801 35801 35801 99508 ...
##  $ County.name               : chr  "MARSHALL" "MARSHALL" "MARSHALL" "RANDOLPH" ...
##  $ Phone.number              : num  2.57e+09 2.57e+09 2.57e+09 2.56e+09 2.56e+09 ...
##  $ Payment.measure.name      : chr  "Payment for heart attack patients" "Payment for heart failure patients" "Payment for pneumonia patients" "Payment for heart attack patients" ...
##  $ Payment.measure.ID        : chr  "PAYM_30_AMI" "PAYM_30_HF" "PAYM_30_PN" "PAYM_30_AMI" ...
##  $ Payment.category          : chr  "No Different than the National Average Payment" "No Different than the National Average Payment" "No Different than the National Average Payment" "Number of Cases Too Small" ...
##  $ Denominator               : chr  "53" "347" "646" "Not Available" ...
##  $ Payment                   : chr  "$23171.00" "$16376.00" "$14384.00" NA ...
##  $ Lower.estimate            : chr  "$20,404" "$15,237" "$13,642" "Not Available" ...
##  $ Higher.estimate           : chr  "$26,226" "$17,547" "$15,118" "Not Available" ...
##  $ Payment.footnote          : chr  NA NA NA "1 - The number of cases/patients is too few to report." ...
##  $ Value.of.care.display.name: chr  "Value of Care Heart Attack measure" "Value of Care Heart Failure measure" "Value of Care Pneumonia measure" "Value of Care Heart Attack measure" ...
##  $ Value.of.care.display.ID  : chr  "MORT_PAYM_30_AMI" "MORT_PAYM_30_HF" "MORT_PAYM_30_PN" "MORT_PAYM_30_AMI" ...
##  $ Value.of.care.category    : chr  "Average mortality and average payment" "Worse mortality and average payment" "Worse mortality and average payment" "Not Available" ...
##  $ Value.of.care.footnote    : chr  NA NA NA "13 - Results cannot be calculated for this reporting period." ...
##  $ Measure.start.date        : chr  "07/01/2012" "07/01/2012" "07/01/2012" "07/01/2012" ...
##  $ Measure.End.Date          : chr  "06/30/2015" "06/30/2015" "06/30/2015" "06/30/2015" ...
##  $ Location                  : chr  "2505 U S HIGHWAY 431 NORTH\nBOAZ, AL 35957\n" "2505 U S HIGHWAY 431 NORTH\nBOAZ, AL 35957\n" "2505 U S HIGHWAY 431 NORTH\nBOAZ, AL 35957\n" "209 NORTH MAIN STREET\nWEDOWEE, AL 36278\n" ...
#Resumo dos Dados
summary(hospay$Measure.start.date)
##    Length     Class      Mode 
##     14454 character character
summary(hospay$Measure.End.Date)
##    Length     Class      Mode 
##     14454 character character
#Lista as categorias em um 
unique(hospay$Measure.start.date)  %>% head
## Error in eval(expr, envir, enclos): não foi possível encontrar a função "%>%"
levels(hospay$Measure.End.Date) %>% head
## Error in eval(expr, envir, enclos): não foi possível encontrar a função "%>%"
#Checando
hospay$Measure.start.date <- trimws(hospay$Measure.start.date, which = "both")
hospay$Measure.End.Date <- trimws(hospay$Measure.End.Date, which = "both")

#Datas com Missing
any(is.na(as.character(hospay$Measure.start.date)))
## [1] FALSE
any(is.na(as.character(hospay$Measure.End.Date)))
## [1] FALSE
#Pagamentos com Missing
any(is.na(as.numeric(hospay$Payment)))
## Warning: NAs introduzidos por coerção
## [1] TRUE
#Tratando data
hospay$Measure.start.date <- as.Date(hospay$Measure.start.date,"%m/%d/%Y" )
hospay$Measure.End.Date <- as.Date(hospay$Measure.End.Date,"%m/%d/%Y" )

class(hospay$Measure.start.date)
## [1] "Date"
class(hospay$Measure.End.Date)
## [1] "Date"
str(hospay$Measure.start.date)
##  Date[1:14454], format: "2012-07-01" "2012-07-01" "2012-07-01" "2012-07-01" ...
str(hospay$Measure.End.Date)
##  Date[1:14454], format: "2015-06-30" "2015-06-30" "2015-06-30" "2015-06-30" ...
# Tratamento de valores em Strings
# Remover sinal de dollar e vírgula

hospay$Payment <- as.numeric(gsub("[$,]", "", hospay$Payment))
hospay$Lower.estimate <- as.numeric(gsub("[$,]", "", hospay$Lower.estimate))
## Warning: NAs introduzidos por coerção
hospay$Higher.estimate <-as.numeric(gsub("[$,]", "", hospay$Lower.estimate))

#Limpa os brancos 
hospay$Hospital.name<- gsub("[ ]", "", hospay$Hospital.name)

#Qual o total de hospitais prentes na lista
length(hospay$Hospital.name) 
## [1] 14454
#Quantos hospitais
length((unique(hospay$Hospital.name)))
## [1] 4615
#Quais os hostitais
unique(hospay$Hospital.name)  %>% head
## Error in eval(expr, envir, enclos): não foi possível encontrar a função "%>%"
#Pivot
# Contagem de casos por Hospital

pv1 <-data.frame(table(hospay$City, hospay$Value.of.care.category, hospay$State))
table(hospay$City, hospay$State)  %>% head
## Error in eval(expr, envir, enclos): não foi possível encontrar a função "%>%"
#Frequencia
pv1 <- NULL
pv1 <- with(hospay,table(hospay$State))
pv1.freq <- table(hospay$State)
pv1.prob <- prop.table(pv1.freq)
pv1.out <- cbind(pv1.freq, pv1.prob)

#Mudando o nome das colunas
colnames(pv1.out) <-c("Freq","Perc(%)") 

#Frequencia por faixa - dados numéricos
faixa1 <-cut(hospay$Payment, breaks = 10,dig.lab = 10,include.lowest = TRUE)
stack(table(faixa1)) #transpoe
##    values                 ind
## 1      34  [9481.168,11585.2]
## 2     856   (11585.2,13668.4]
## 3    3861   (13668.4,15751.6]
## 4    2314   (15751.6,17834.8]
## 5     475     (17834.8,19918]
## 6     650     (19918,22001.2]
## 7    1130   (22001.2,24084.4]
## 8     490   (24084.4,26167.6]
## 9      64   (26167.6,28250.8]
## 10      6 (28250.8,30354.832]
faixa1 <-cut(hospay$Payment, seq(from = 1000, to = 40000, by = 5000),dig.lab = 10,include.lowest = TRUE,right = TRUE)
stack(table(faixa1)) #transpoe
##   values           ind
## 1      0   [1000,6000]
## 2      6  (6000,11000]
## 3   5211 (11000,16000]
## 4   2539 (16000,21000]
## 5   2043 (21000,26000]
## 6     81 (26000,31000]
## 7      0 (31000,36000]
faixa1 <-cut(hospay$Payment, seq(1000, 40000, 5000),dig.lab = 10,right = FALSE)
stack(table(faixa1)) #transpoe
##   values           ind
## 1      0   [1000,6000)
## 2      6  [6000,11000)
## 3   5211 [11000,16000)
## 4   2539 [16000,21000)
## 5   2043 [21000,26000)
## 6     81 [26000,31000)
## 7      0 [31000,36000)
#include.lowest = TRUE inclui o menor
faixa2 <-cut(hospay$Payment, breaks = 10, dig.lab = 10,labels=c("A","B", "C", "D", "E", "F", "G", "H", "I", "J")) # força os labels
summary(faixa2)
##    A    B    C    D    E    F    G    H    I    J NA's 
##   34  856 3861 2314  475  650 1130  490   64    6 4574
stack(summary(faixa2))
##    values  ind
## 1      34    A
## 2     856    B
## 3    3861    C
## 4    2314    D
## 5     475    E
## 6     650    F
## 7    1130    G
## 8     490    H
## 9      64    I
## 10      6    J
## 11   4574 NA's
faixa2 <-cut(hospay$Payment, breaks = 10, dig.lab = 10,labels=c(1:10)) # força os labels
summary(faixa2)
##    1    2    3    4    5    6    7    8    9   10 NA's 
##   34  856 3861 2314  475  650 1130  490   64    6 4574
stack(summary(faixa2)) 
##    values  ind
## 1      34    1
## 2     856    2
## 3    3861    3
## 4    2314    4
## 5     475    5
## 6     650    6
## 7    1130    7
## 8     490    8
## 9      64    9
## 10      6   10
## 11   4574 NA's
faixa <-cut(hospay$Payment, breaks = c(100,10000,20000, 30000), labels=c("medio", "maior", "avaliar"))
stack(table(faixa)) #transpoe
##   values     ind
## 1      1   medio
## 2   7554   maior
## 3   2324 avaliar
#Steam and Leaf - dados num?ricos
stem(hospay$Payment)
## 
##   The decimal point is 3 digit(s) to the right of the |
## 
##    9 | 5
##   10 | 22478
##   11 | 01112222233344444444555555566666666677788888888889999999999999
##   12 | 00000000000000001111111111111111122222222222222222222333333333333333+194
##   13 | 00000000000000000000000000000000000000000000000000011111111111111111+861
##   14 | 00000000000000000000000000000000000000000000000000000000000000000000+1712
##   15 | 00000000000000000000000000000000000000000000000000000000000000000000+1972
##   16 | 00000000000000000000000000000000000000000000000000000000000000000000+1258
##   17 | 00000000000000000000000000000000000000000000000000000000000000000000+578
##   18 | 00000000000000000000000000000000000000000000011111111111111111111111+208
##   19 | 00000000000000000001111111111112222222222222333333333333344444444444+59
##   20 | 00000000011111111111111111111111111222222222222222223333333333333333+113
##   21 | 00000000000000000000000000000111111111111111111111111111111111222222+343
##   22 | 00000000000000000000000000000000000000000000000000000000111111111111+484
##   23 | 00000000000000000000000000000000000000000000000000000000111111111111+460
##   24 | 00000000000000000000000000000000000000011111111111111111111111111111+280
##   25 | 00000000000000000000000111111111111111111111111122222222222222222222+83
##   26 | 00000000001111122222222333333333344444444555566666666777788999
##   27 | 0000222345567778889
##   28 | 555
##   29 | 25
##   30 | 3
plot(density(na.omit(hospay$Payment)))

#Boxplot
bl <-boxplot(na.omit(hospay$Payment))

which(hospay$Payment %in% bl$out)
##   [1]    95   133   260   300   399   494   500   506   509   515   661
##  [12]   831   976  1041  1267  1348  1403  1449  1501  1572  1716  1772
##  [23]  1808  1857  1991  2065  2086  2114  2154  2210  2213  2215  2259
##  [34]  2295  2310  2338  2390  2478  2566  2580  2582  2875  3072  3099
##  [45]  3156  3270  3282  3330  3589  3796  3983  4132  4148  4159  4166
##  [56]  4336  4377  4411  4424  4603  4613  4677  4763  4937  5238  5306
##  [67]  5532  5617  5938  6404  6709  6755  7092  7303  7488  7518  7553
##  [78]  7603  7614  7783  7869  7988  8178  8191  8287  8521  8567  8570
##  [89]  8578  8584  8625  8645  8649  8658  8661  8691  8694  8714  8756
## [100]  8791  8838  8853  8871  8950  8972  9073  9172  9207  9224  9269
## [111]  9270  9273  9318  9324  9376  9405  9541  9583  9698  9732  9811
## [122] 10069 10137 10271 10404 10636 10694 11373 12168 12285 12296 12319
## [133] 12350 12376 12378 12779 12848 12912 12913 12947 12978 12996 13048
## [144] 13085 13171 13310 13644 13699 13837 13860 13953 13990 14030
hospay$Payment[95]
## [1] 25411
bl$out
##   [1] 25411 27718 25586 25429 26241 25674 25718 26316 26043 25795 27835
##  [12] 25556 26159 25489 25466 25878 25941 25690 26166 25530 26186 26619
##  [23] 26060 25464 30334 25656 27770 27042 25510 26674 25521 25635 26266
##  [34] 27547 27152 25450 27758 27347 26395 25606 25913 27004 26731 25917
##  [45] 26642 26325 25635 25408 26880 28451 26995 26044 25807 26473 25751
##  [56] 26346 25455 26375 25654 26850 26278 26583 26913 28468 25579 26433
##  [67] 27360 25692 25756 25985 25987 26184 27236 26014 27220 25928 26317
##  [78] 26280 25856 26427 25756 26106 26200 27480 25966 25515 25582 25895
##  [89] 25933 25979 25581 25529 26654 25507 26183 25428 27683 25869 26184
## [100] 25799 25527 27931 25662 25458 26999 26810 26604 25932 26459 26101
## [111] 26562 26438 26379 26110 25829 25978 26112 25720 25907 26332 25988
## [122] 25941 25624 25893 25910 25545 25704 26415 25391 26539 27743 26260
## [133] 26347 26596 26726 25932 26483 29548 25385 28454 25495 25457 25790
## [144] 26406 25701 29193 26759 25400 25625 26565 26001 26614 27616
hospay$Payment[which(hospay$Payment %in% bl$out)]
##   [1] 25411 27718 25586 25429 26241 25674 25718 26316 26043 25795 27835
##  [12] 25556 26159 25489 25466 25878 25941 25690 26166 25530 26186 26619
##  [23] 26060 25464 30334 25656 27770 27042 25510 26674 25521 25635 26266
##  [34] 27547 27152 25450 27758 27347 26395 25606 25913 27004 26731 25917
##  [45] 26642 26325 25635 25408 26880 28451 26995 26044 25807 26473 25751
##  [56] 26346 25455 26375 25654 26850 26278 26583 26913 28468 25579 26433
##  [67] 27360 25692 25756 25985 25987 26184 27236 26014 27220 25928 26317
##  [78] 26280 25856 26427 25756 26106 26200 27480 25966 25515 25582 25895
##  [89] 25933 25979 25581 25529 26654 25507 26183 25428 27683 25869 26184
## [100] 25799 25527 27931 25662 25458 26999 26810 26604 25932 26459 26101
## [111] 26562 26438 26379 26110 25829 25978 26112 25720 25907 26332 25988
## [122] 25941 25624 25893 25910 25545 25704 26415 25391 26539 27743 26260
## [133] 26347 26596 26726 25932 26483 29548 25385 28454 25495 25457 25790
## [144] 26406 25701 29193 26759 25400 25625 26565 26001 26614 27616
#Agregação
with(hospay, by(hospay$Payment, list(hospay$Payment.category,hospay$State), mean))
## : Greater than the National Average Payment
## : AK
## [1] NA
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : AK
## [1] 12421.77
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : AK
## [1] 18001.92
## -------------------------------------------------------- 
## : Not Available
## : AK
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : AK
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : AL
## [1] 17285.4
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : AL
## [1] 14089.67
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : AL
## [1] 16991.26
## -------------------------------------------------------- 
## : Not Available
## : AL
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : AL
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : AR
## [1] 18900
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : AR
## [1] 13911.93
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : AR
## [1] 16608.69
## -------------------------------------------------------- 
## : Not Available
## : AR
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : AR
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : AS
## [1] NA
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : AS
## [1] NA
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : AS
## [1] NA
## -------------------------------------------------------- 
## : Not Available
## : AS
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : AS
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : AZ
## [1] 19012.15
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : AZ
## [1] 13673.56
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : AZ
## [1] 17926.23
## -------------------------------------------------------- 
## : Not Available
## : AZ
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : AZ
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : CA
## [1] 19526.76
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : CA
## [1] 14102.07
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : CA
## [1] 17927.4
## -------------------------------------------------------- 
## : Not Available
## : CA
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : CA
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : CO
## [1] 19856.8
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : CO
## [1] 14245.82
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : CO
## [1] 16897.44
## -------------------------------------------------------- 
## : Not Available
## : CO
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : CO
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : CT
## [1] 18467.96
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : CT
## [1] 13376
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : CT
## [1] 18478.34
## -------------------------------------------------------- 
## : Not Available
## : CT
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : CT
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : DC
## [1] 19980
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : DC
## [1] 14614
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : DC
## [1] 17993.81
## -------------------------------------------------------- 
## : Not Available
## : DC
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : DC
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : DE
## [1] 19066.43
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : DE
## [1] 14277
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : DE
## [1] 18641
## -------------------------------------------------------- 
## : Not Available
## : DE
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : DE
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : FL
## [1] 18734.56
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : FL
## [1] 15144.15
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : FL
## [1] 18339.71
## -------------------------------------------------------- 
## : Not Available
## : FL
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : FL
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : GA
## [1] 17076
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : GA
## [1] 14434.22
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : GA
## [1] 17038.91
## -------------------------------------------------------- 
## : Not Available
## : GA
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : GA
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : GU
## [1] NA
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : GU
## [1] 12149.67
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : GU
## [1] NA
## -------------------------------------------------------- 
## : Not Available
## : GU
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : GU
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : HI
## [1] NA
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : HI
## [1] 15432.78
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : HI
## [1] 16613.5
## -------------------------------------------------------- 
## : Not Available
## : HI
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : HI
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : IA
## [1] 18486.14
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : IA
## [1] 14022.19
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : IA
## [1] 16551.7
## -------------------------------------------------------- 
## : Not Available
## : IA
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : IA
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : ID
## [1] 18422.67
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : ID
## [1] 13592.5
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : ID
## [1] 16271.21
## -------------------------------------------------------- 
## : Not Available
## : ID
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : ID
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : IL
## [1] 19709.63
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : IL
## [1] 13980.79
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : IL
## [1] 17290.41
## -------------------------------------------------------- 
## : Not Available
## : IL
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : IL
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : IN
## [1] 18901.9
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : IN
## [1] 15603.47
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : IN
## [1] 17187.11
## -------------------------------------------------------- 
## : Not Available
## : IN
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : IN
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : KS
## [1] 18664.09
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : KS
## [1] 13865.12
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : KS
## [1] 16484.98
## -------------------------------------------------------- 
## : Not Available
## : KS
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : KS
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : KY
## [1] 18545.82
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : KY
## [1] 13187.05
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : KY
## [1] 17354.3
## -------------------------------------------------------- 
## : Not Available
## : KY
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : KY
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : LA
## [1] 17996.38
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : LA
## [1] 15541.38
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : LA
## [1] 17134.23
## -------------------------------------------------------- 
## : Not Available
## : LA
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : LA
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : MA
## [1] 19177.19
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : MA
## [1] 16682.38
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : MA
## [1] 17873.73
## -------------------------------------------------------- 
## : Not Available
## : MA
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : MA
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : MD
## [1] NA
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : MD
## [1] NA
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : MD
## [1] NA
## -------------------------------------------------------- 
## : Not Available
## : MD
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : MD
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : ME
## [1] 20552
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : ME
## [1] 15176.4
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : ME
## [1] 17161.68
## -------------------------------------------------------- 
## : Not Available
## : ME
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : ME
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : MI
## [1] 18154.17
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : MI
## [1] 14686.7
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : MI
## [1] 17030.3
## -------------------------------------------------------- 
## : Not Available
## : MI
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : MI
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : MN
## [1] 19346.8
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : MN
## [1] 14003.88
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : MN
## [1] 16028.23
## -------------------------------------------------------- 
## : Not Available
## : MN
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : MN
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : MO
## [1] 18579.87
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : MO
## [1] 14045.55
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : MO
## [1] 17288.05
## -------------------------------------------------------- 
## : Not Available
## : MO
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : MO
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : MP
## [1] NA
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : MP
## [1] 13827
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : MP
## [1] NA
## -------------------------------------------------------- 
## : Not Available
## : MP
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : MP
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : MS
## [1] 20148.77
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : MS
## [1] 14244
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : MS
## [1] 16124.33
## -------------------------------------------------------- 
## : Not Available
## : MS
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : MS
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : MT
## [1] NA
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : MT
## [1] 12893.35
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : MT
## [1] 16188.4
## -------------------------------------------------------- 
## : Not Available
## : MT
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : MT
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : NC
## [1] 16522.43
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : NC
## [1] 15710.36
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : NC
## [1] 17070.78
## -------------------------------------------------------- 
## : Not Available
## : NC
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : NC
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : ND
## [1] 17798
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : ND
## [1] 12913.4
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : ND
## [1] 16295.76
## -------------------------------------------------------- 
## : Not Available
## : ND
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : ND
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : NE
## [1] 20016.38
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : NE
## [1] 13288.14
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : NE
## [1] 16508.75
## -------------------------------------------------------- 
## : Not Available
## : NE
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : NE
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : NH
## [1] 19609.62
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : NH
## [1] 13108
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : NH
## [1] 17455.17
## -------------------------------------------------------- 
## : Not Available
## : NH
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : NH
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : NJ
## [1] 20405.62
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : NJ
## [1] 14790
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : NJ
## [1] 18241.14
## -------------------------------------------------------- 
## : Not Available
## : NJ
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : NJ
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : NM
## [1] 17426.5
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : NM
## [1] 13022.43
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : NM
## [1] 16578.12
## -------------------------------------------------------- 
## : Not Available
## : NM
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : NM
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : NV
## [1] 19818.52
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : NV
## [1] 14664.91
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : NV
## [1] 18621.17
## -------------------------------------------------------- 
## : Not Available
## : NV
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : NV
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : NY
## [1] 19564.24
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : NY
## [1] 14285.02
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : NY
## [1] 17861.65
## -------------------------------------------------------- 
## : Not Available
## : NY
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : NY
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : OH
## [1] 18643.94
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : OH
## [1] 14489.12
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : OH
## [1] 17596.61
## -------------------------------------------------------- 
## : Not Available
## : OH
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : OH
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : OK
## [1] 17866.17
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : OK
## [1] 14104.3
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : OK
## [1] 16377.65
## -------------------------------------------------------- 
## : Not Available
## : OK
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : OK
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : OR
## [1] NA
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : OR
## [1] 13935.4
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : OR
## [1] 16347.31
## -------------------------------------------------------- 
## : Not Available
## : OR
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : OR
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : PA
## [1] 18843.46
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : PA
## [1] 15068.27
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : PA
## [1] 17942.4
## -------------------------------------------------------- 
## : Not Available
## : PA
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : PA
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : PR
## [1] NA
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : PR
## [1] 14970.08
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : PR
## [1] 15669.31
## -------------------------------------------------------- 
## : Not Available
## : PR
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : PR
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : RI
## [1] 21401.75
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : RI
## [1] 17751
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : RI
## [1] 17813.67
## -------------------------------------------------------- 
## : Not Available
## : RI
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : RI
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : SC
## [1] 18163.12
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : SC
## [1] 15075.52
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : SC
## [1] 17068.56
## -------------------------------------------------------- 
## : Not Available
## : SC
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : SC
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : SD
## [1] 20059
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : SD
## [1] 13424.73
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : SD
## [1] 16392.89
## -------------------------------------------------------- 
## : Not Available
## : SD
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : SD
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : TN
## [1] 17335.92
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : TN
## [1] 14710.6
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : TN
## [1] 16950.76
## -------------------------------------------------------- 
## : Not Available
## : TN
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : TN
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : TX
## [1] 18977.61
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : TX
## [1] 14723.82
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : TX
## [1] 17670.5
## -------------------------------------------------------- 
## : Not Available
## : TX
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : TX
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : UT
## [1] 20331.2
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : UT
## [1] 12094.86
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : UT
## [1] 16891.07
## -------------------------------------------------------- 
## : Not Available
## : UT
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : UT
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : VA
## [1] 18996.94
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : VA
## [1] 15724.21
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : VA
## [1] 17360.43
## -------------------------------------------------------- 
## : Not Available
## : VA
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : VA
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : VI
## [1] 17791
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : VI
## [1] NA
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : VI
## [1] 16387
## -------------------------------------------------------- 
## : Not Available
## : VI
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : VI
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : VT
## [1] 18970
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : VT
## [1] 13326.33
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : VT
## [1] 17343.29
## -------------------------------------------------------- 
## : Not Available
## : VT
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : VT
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : WA
## [1] 21047.18
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : WA
## [1] 15127.11
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : WA
## [1] 16767.32
## -------------------------------------------------------- 
## : Not Available
## : WA
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : WA
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : WI
## [1] 20329.8
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : WI
## [1] 13277.52
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : WI
## [1] 16720.6
## -------------------------------------------------------- 
## : Not Available
## : WI
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : WI
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : WV
## [1] 21015.4
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : WV
## [1] 14734.67
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : WV
## [1] 16638.51
## -------------------------------------------------------- 
## : Not Available
## : WV
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : WV
## [1] NA
## -------------------------------------------------------- 
## : Greater than the National Average Payment
## : WY
## [1] 18226
## -------------------------------------------------------- 
## : Less than the National Average Payment
## : WY
## [1] 12828.78
## -------------------------------------------------------- 
## : No Different than the National Average Payment
## : WY
## [1] 15584.72
## -------------------------------------------------------- 
## : Not Available
## : WY
## [1] NA
## -------------------------------------------------------- 
## : Number of Cases Too Small
## : WY
## [1] NA
with(hospay, table(hospay$Payment.category,hospay$State))
##                                                 
##                                                   AK  AL  AR  AS  AZ  CA
##   Greater than the National Average Payment        0   5  18   0  26 176
##   Less than the National Average Payment          13  48  15   0  16  59
##   No Different than the National Average Payment  12 144 127   0 117 496
##   Not Available                                    6  12  15   3  42 101
##   Number of Cases Too Small                       32  58  50   0  42 203
##                                                 
##                                                   CO  CT  DC  DE  FL  GA
##   Greater than the National Average Payment        5  24   3   7 135   5
##   Less than the National Average Payment          11   1   2   1  13  58
##   No Different than the National Average Payment 126  59  16  10 356 230
##   Not Available                                   20   7   3   3  26  21
##   Number of Cases Too Small                       72   2   0   0  31  88
##                                                 
##                                                   GU  HI  IA  ID  IL  IN
##   Greater than the National Average Payment        0   0  21   3  67  29
##   Less than the National Average Payment           3   9  32  10  39  17
##   No Different than the National Average Payment   0  26 161  47 339 233
##   Not Available                                    3  24  24  12  13  27
##   Number of Cases Too Small                        0  10 110  51  79  54
##                                                 
##                                                   KS  KY  LA  MA  MD  ME
##   Greater than the National Average Payment       34  17  32  32   0   3
##   Less than the National Average Payment          17  37  29   8   0  20
##   No Different than the National Average Payment 147 166 158 124   0  68
##   Not Available                                   61   7  82  17 147   0
##   Number of Cases Too Small                      152  55  68  11   0   8
##                                                 
##                                                   MI  MN  MO  MP  MS  MT
##   Greater than the National Average Payment       30   5  31   0  22   0
##   Less than the National Average Payment          33  16  29   3  28  17
##   No Different than the National Average Payment 236 166 184   0 129  48
##   Not Available                                   27  31  41   0  40  38
##   Number of Cases Too Small                       67 175  57   0  69  80
##                                                 
##                                                   NC  ND  NE  NH  NJ  NM
##   Greater than the National Average Payment        7   5  21   8 111   2
##   Less than the National Average Payment          61   5   7   1   1  30
##   No Different than the National Average Payment 199  51 102  59  78  48
##   Not Available                                   16   8  32   0   6   5
##   Number of Cases Too Small                       35  63 108  10   2  38
##                                                 
##                                                   NV  NY  OH  OK  OR  PA
##   Greater than the National Average Payment       25  62  71  12   0  68
##   Less than the National Average Payment          11  88   8  44  40  30
##   No Different than the National Average Payment  36 301 302 154  89 317
##   Not Available                                   10  31  61  54   5  57
##   Number of Cases Too Small                       20  40  62 111  46  38
##                                                 
##                                                   PR  RI  SC  SD  TN  TX
##   Greater than the National Average Payment        0   4   8   1  13 182
##   Less than the National Average Payment          24   2  27  11  25  50
##   No Different than the National Average Payment  36  24 105  55 211 477
##   Not Available                                   18   1  14  53  27 281
##   Number of Cases Too Small                       78   2  26  60  57 231
##                                                 
##                                                   UT  VA  VI  VT  WA  WI
##   Greater than the National Average Payment        5  17   1   1  11  10
##   Less than the National Average Payment          14  28   0   9  28  31
##   No Different than the National Average Payment  56 175   4  28 141 227
##   Not Available                                   21  21   0   0  23  22
##   Number of Cases Too Small                       42  17   1   4  70  88
##                                                 
##                                                   WV  WY
##   Greater than the National Average Payment        5   1
##   Less than the National Average Payment          15   9
##   No Different than the National Average Payment  87  29
##   Not Available                                    3   9
##   Number of Cases Too Small                       37  33
aggregate(hospay$Payment ~ hospay$State, FUN=mean, hospay)
##    hospay$State hospay$Payment
## 1            AK       15100.24
## 2            AL       16291.74
## 3            AR       16613.64
## 4            AZ       17675.86
## 5            CA       18003.73
## 6            CO       16796.23
## 7            CT       18414.63
## 8            DC       17955.67
## 9            DE       18564.00
## 10           FL       18363.05
## 11           GA       16523.94
## 12           GU       12149.67
## 13           HI       16309.89
## 14           IA       16363.29
## 15           ID       15932.33
## 16           IL       17364.60
## 17           IN       17268.85
## 18           KS       16634.23
## 19           KY       16745.51
## 20           LA       17049.28
## 21           MA       18069.95
## 22           ME       16837.12
## 23           MI       16884.40
## 24           MN       15943.76
## 25           MO       17066.80
## 26           MP       13827.00
## 27           MS       16324.82
## 28           MT       15326.62
## 29           NC       16745.60
## 30           ND       16141.66
## 31           NE       16901.95
## 32           NH       17644.71
## 33           NJ       19487.49
## 34           NM       15265.95
## 35           NV       18432.49
## 36           NY       17397.83
## 37           OH       17726.53
## 38           OK       15986.39
## 39           OR       15599.43
## 40           PA       17882.27
## 41           PR       15389.62
## 42           RI       18287.90
## 43           SC       16746.74
## 44           SD       15960.30
## 45           TN       16745.95
## 46           TX       17798.23
## 47           UT       16225.12
## 48           VA       17278.64
## 49           VI       16667.80
## 50           VT       16434.71
## 51           WA       16773.72
## 52           WI       16457.01
## 53           WV       16576.14
## 54           WY       15016.46
# Removendo hospitais que apresentam MISSING

hospay<-hospay[hospay$Payment.category !="Not Available" & hospay$Payment.category !="Number of Cases Too Small",]

summary(hospay)
##   Provider.ID     Hospital.name        Address              City          
##  Min.   : 10001   Length:9880        Length:9880        Length:9880       
##  1st Qu.:140034   Class :character   Class :character   Class :character  
##  Median :260011   Mode  :character   Mode  :character   Mode  :character  
##  Mean   :263324                                                           
##  3rd Qu.:390080                                                           
##  Max.   :670098                                                           
##     State              ZIP.Code     County.name         Phone.number      
##  Length:9880        Min.   :  603   Length:9880        Min.   :9.369e+08  
##  Class :character   1st Qu.:30342   Class :character   1st Qu.:3.867e+09  
##  Mode  :character   Median :49783   Mode  :character   Median :6.073e+09  
##                     Mean   :51324                      Mean   :5.906e+09  
##                     3rd Qu.:74631                      3rd Qu.:8.025e+09  
##                     Max.   :99901                      Max.   :9.899e+09  
##  Payment.measure.name Payment.measure.ID Payment.category  
##  Length:9880          Length:9880        Length:9880       
##  Class :character     Class :character   Class :character  
##  Mode  :character     Mode  :character   Mode  :character  
##                                                            
##                                                            
##                                                            
##  Denominator           Payment      Lower.estimate  Higher.estimate
##  Length:9880        Min.   : 9502   Min.   : 7661   Min.   : 7661  
##  Class :character   1st Qu.:14650   1st Qu.:13152   1st Qu.:13152  
##  Mode  :character   Median :15845   Median :14420   Median :14420  
##                     Mean   :17167   Mean   :15521   Mean   :15521  
##                     3rd Qu.:18940   3rd Qu.:17415   3rd Qu.:17415  
##                     Max.   :30334   Max.   :28411   Max.   :28411  
##  Payment.footnote   Value.of.care.display.name Value.of.care.display.ID
##  Length:9880        Length:9880                Length:9880             
##  Class :character   Class :character           Class :character        
##  Mode  :character   Mode  :character           Mode  :character        
##                                                                        
##                                                                        
##                                                                        
##  Value.of.care.category Value.of.care.footnote Measure.start.date  
##  Length:9880            Length:9880            Min.   :2012-07-01  
##  Class :character       Class :character       1st Qu.:2012-07-01  
##  Mode  :character       Mode  :character       Median :2012-07-01  
##                                                Mean   :2012-07-01  
##                                                3rd Qu.:2012-07-01  
##                                                Max.   :2012-07-01  
##  Measure.End.Date       Location        
##  Min.   :2015-06-30   Length:9880       
##  1st Qu.:2015-06-30   Class :character  
##  Median :2015-06-30   Mode  :character  
##  Mean   :2015-06-30                     
##  3rd Qu.:2015-06-30                     
##  Max.   :2015-06-30
hospay_pneumo <- NULL


hospay_pneumo <- subset(hospay,  hospay$State == "CA" & grepl("pneumonia",hospay$Payment.measure.name) )

# Contagem de casos por Hospital
library(lubridate)
table(hospay_pneumo$City, hospay_pneumo$Value.of.care.category)  %>% head
## Error in eval(expr, envir, enclos): não foi possível encontrar a função "%>%"
with(hospay_pneumo,
     table(hospay_pneumo$Payment.category=="Greater than the National Average Payment",
           year(hospay_pneumo$Measure.start.date)==2012,
           months(hospay_pneumo$Measure.start.date),
           City,
           useNA = "ifany"))
## , ,  = Julho, City = ALAMEDA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = ALHAMBRA
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = ALTURAS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = ANAHEIM
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     2
## 
## , ,  = Julho, City = ANTIOCH
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = APPLE VALLEY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = ARCADIA
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = ARCATA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = AUBURN
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = BAKERSFIELD
## 
##        
##         TRUE
##   FALSE    3
##   TRUE     2
## 
## , ,  = Julho, City = BANNING
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = BARSTOW
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = BERKELEY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = BISHOP
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = BLYTHE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = BRAWLEY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = BURBANK
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = BURLINGAME
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = CAMARILLO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = CARMICHAEL
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = CASTRO VALLEY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = CHESTER
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = CHICO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = CHULA VISTA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = CLEARLAKE
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = CLOVIS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = COLTON
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = COLUSA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = CONCORD
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = CORONA
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = COVINA
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = CRESCENT CITY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = DALY CITY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = DAVIS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = DELANO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = DOWNEY
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = EL CENTRO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = ENCINITAS
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = ENCINO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = ESCONDIDO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = EUREKA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = FAIRFIELD
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = FALL RIVER MILLS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = FOLSOM
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = FORT BRAGG
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = FORTUNA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = FOUNTAIN VALLEY
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     2
## 
## , ,  = Julho, City = FREMONT
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = FRENCH CAMP
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = FRESNO
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = FULLERTON
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = GARDEN GROVE
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = GARDENA
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = GILROY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = GLENDALE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     2
## 
## , ,  = Julho, City = GLENDORA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     1
## 
## , ,  = Julho, City = GRASS VALLEY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = GREENBRAE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = GRIDLEY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = HANFORD
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = HAWAIIAN GARDENS
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = HAYWARD
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = HEALDSBURG
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = HEMET
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = HOLLISTER
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = HOLLYWOOD
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = HUNTINGTON BEACH
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = HUNTINGTON PARK
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = INDIO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = INGLEWOOD
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = JACKSON
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = JOSHUA TREE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = KING CITY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LA JOLLA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     1
## 
## , ,  = Julho, City = LA MESA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LA PALMA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LAGUNA HILLS
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = LAKE ARROWHEAD
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LAKE ISABELLA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LAKEPORT
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LAKEWOOD
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = LANCASTER
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = LODI
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LOMA LINDA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LOMPOC
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LONG BEACH
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     3
## 
## , ,  = Julho, City = LOS ALAMITOS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LOS ANGELES
## 
##        
##         TRUE
##   FALSE    7
##   TRUE     7
## 
## , ,  = Julho, City = LOS BANOS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = LYNWOOD
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MADERA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MANTECA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MARINA DEL REY
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = MARIPOSA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MARTINEZ
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MARYSVILLE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MERCED
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MISSION HILLS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MISSION VIEJO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MODESTO
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = MONTCLAIR
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MONTEBELLO
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = MONTEREY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MONTEREY PARK
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     1
## 
## , ,  = Julho, City = MORENO VALLEY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MOUNT SHASTA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MOUNTAIN VIEW
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = MURRIETA
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = NAPA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = NATIONAL CITY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = NEWPORT BEACH
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = NORTHRIDGE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = NORWALK
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = NOVATO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = OAKDALE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = OAKLAND
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = OCEANSIDE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = OJAI
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = ORANGE
## 
##        
##         TRUE
##   FALSE    3
##   TRUE     0
## 
## , ,  = Julho, City = OROVILLE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = OXNARD
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = PALM SPRINGS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = PALMDALE
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = PANORAMA CITY
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = PARADISE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = PASADENA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = PETALUMA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = PLACENTIA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = PLACERVILLE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = PLEASANTON
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = POMONA
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = PORTERVILLE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = PORTOLA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = POWAY
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = QUINCY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = RANCHO MIRAGE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = RED BLUFF
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = REDDING
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     2
## 
## , ,  = Julho, City = REDLANDS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = REDWOOD CITY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = REEDLEY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = RIVERSIDE
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     2
## 
## , ,  = Julho, City = ROSEVILLE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SACRAMENTO
## 
##        
##         TRUE
##   FALSE    4
##   TRUE     0
## 
## , ,  = Julho, City = SAINT HELENA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SALINAS
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = SAN ANDREAS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SAN BERNARDINO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     1
## 
## , ,  = Julho, City = SAN DIEGO
## 
##        
##         TRUE
##   FALSE    3
##   TRUE     1
## 
## , ,  = Julho, City = SAN DIMAS
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = SAN FRANCISCO
## 
##        
##         TRUE
##   FALSE    9
##   TRUE     0
## 
## , ,  = Julho, City = SAN GABRIEL
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = SAN JOSE
## 
##        
##         TRUE
##   FALSE    4
##   TRUE     0
## 
## , ,  = Julho, City = SAN LEANDRO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SAN LUIS OBISPO
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = SAN PEDRO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SAN RAMON
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SANTA ANA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     1
## 
## , ,  = Julho, City = SANTA BARBARA
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = SANTA CRUZ
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SANTA MARIA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SANTA MONICA
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = SANTA ROSA
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = SHERMAN OAKS
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = SIMI VALLEY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SOLVANG
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SONOMA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SONORA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SOUTH EL MONTE
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = SOUTH LAKE TAHOE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = STANFORD
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = STOCKTON
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     1
## 
## , ,  = Julho, City = SUN CITY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SUN VALLEY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = SUSANVILLE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = TARZANA
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = TEHACHAPI
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = TEMECULA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = TEMPLETON
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = THOUSAND OAKS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = TORRANCE
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = TRACY
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = TRUCKEE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = TULARE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = TURLOCK
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = UKIAH
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = UPLAND
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = VALENCIA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = VALLEJO
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = VAN NUYS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = VENTURA
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = VICTORVILLE
## 
##        
##         TRUE
##   FALSE    2
##   TRUE     0
## 
## , ,  = Julho, City = VISALIA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = WALNUT CREEK
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = WATSONVILLE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = WEAVERVILLE
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = WEST HILLS
## 
##        
##         TRUE
##   FALSE    0
##   TRUE     1
## 
## , ,  = Julho, City = WHITTIER
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     1
## 
## , ,  = Julho, City = WILLITS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = WILLOWS
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = WOODLAND
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
## 
## , ,  = Julho, City = YREKA
## 
##        
##         TRUE
##   FALSE    1
##   TRUE     0
head(hospay$Payment)
## [1] 23171 16376 14384 16649 13168 20007
library(reshape2)
hosp_melt<-melt(data=hospay,id=c(2,5,9,11), measure=as.numeric(c(13)), value.name='Estimate') 
head(hosp_melt) 
##                Hospital.name State               Payment.measure.name
## 1 MARSHALLMEDICALCENTERSOUTH    AL  Payment for heart attack patients
## 2 MARSHALLMEDICALCENTERSOUTH    AL Payment for heart failure patients
## 3 MARSHALLMEDICALCENTERSOUTH    AL     Payment for pneumonia patients
## 4            WEDOWEEHOSPITAL    AL Payment for heart failure patients
## 5            WEDOWEEHOSPITAL    AL     Payment for pneumonia patients
## 6     CRESTWOODMEDICALCENTER    AL  Payment for heart attack patients
##                                 Payment.category variable Estimate
## 1 No Different than the National Average Payment  Payment    23171
## 2 No Different than the National Average Payment  Payment    16376
## 3 No Different than the National Average Payment  Payment    14384
## 4 No Different than the National Average Payment  Payment    16649
## 5 No Different than the National Average Payment  Payment    13168
## 6         Less than the National Average Payment  Payment    20007
names(hosp_melt)
## [1] "Hospital.name"        "State"                "Payment.measure.name"
## [4] "Payment.category"     "variable"             "Estimate"
library(sqldf)
## Loading required package: gsubfn
## Loading required package: proto
## Loading required package: RSQLite
## Loading required package: DBI
names(hosp_melt) [3] <- "PaymentMeasureName"
hosp_est <- sqldf("SELECT State, AVG(Estimate) AS Estimate 
                  FROM hosp_melt 
                  WHERE paymentmeasurename = 'Payment for heart attack patients' 
                  GROUP BY State")
## Loading required package: tcltk
head(hosp_est)
##   State Estimate
## 1    AK 22678.80
## 2    AL 22540.78
## 3    AR 22806.00
## 4    AZ 23389.11
## 5    CA 23437.82
## 6    CO 22827.00

2 Pacotes instalados e carregados

installed.packages()[names(sessionInfo()$otherPkgs), "Version"]
##     sqldf   RSQLite       DBI    gsubfn     proto  reshape2 lubridate 
##  "0.4-10"   "1.0.0"   "0.3.1"   "0.6-6"  "0.3-10"   "1.4.1"   "1.5.0"