Advanced Biosurveillance- Activity Solutions

Jarad Niemi

2016-11-29

Advanced R - Solutions

Activity - exporting tables

# Summarize data by facility and age category
fa_l <- GI %>%
  group_by(facility, ageC) %>%
  summarize(count = n())

# Reshape data from long to wide format
fa_w <- fa_l %>%
  spread(ageC, count)

# Create HTML table
tab = xtable(fa_w,
             caption = "Total GI cases by Facility and Age Category",
             label   = "myHTMLanchor",
             align   = "ll|rrrrr") # rownames gets a column

# Save HTML to file
print(tab, file="table.html", type="html", include.rownames=FALSE)

# Copy-and-paste table into Word

Activity - Install the surveillance package

install.packages("surveillance")
help(package=surveillance)