reproducible example
library(dplyr)
library(readr)
tf <- tempfile()
download.file( "http://downloads.cms.gov/FILES/HCRIS/HOSP10FY2013.zip" , tf , mode = 'wb' )
z <- unzip( tf , exdir = tempdir() )
nmrc <- read_csv( grep( 'NMRC' , z , value = TRUE ) , col_names = F )
# Warning message:
# In sum(nmrc$X5, na.rm = TRUE) : integer overflow - use sum(as.numeric(.))
sum( nmrc$X5 , na.rm = TRUE )
# now it works
sum( as.numeric( nmrc$X5 ) , na.rm = TRUE )
# this sum is missing despite the na.rm = TRUE
nmrc %>% summarize( mean( X5 , na.rm = TRUE ) , sum( X5 , na.rm = TRUE ) )
# here's the fix for this case
nmrc$X6 <- as.numeric( nmrc$X5 )
nmrc %>% summarize( mean( X6 , na.rm = TRUE ) , sum( X6 , na.rm = TRUE ) )