Advertisement
ansakoy

getdataframe.R

Oct 26th, 2013
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.54 KB | None | 0 0
  1. # This function was written to create a general data frame for the output
  2. # of this function: http://pastebin.com/eTJHsS6A
  3.  
  4. getdataframe <- function (data) {
  5.   data <- readLines("homicides.txt")
  6.   causes <- c("asphyxiation", "blunt force", "shooting",
  7.               "stabbing", "other", "unknown")
  8.   df <- data.frame(Cause = character(),
  9.                    Gender = character(),
  10.                    stringsAsFactors=FALSE)
  11.   for (i in causes) {
  12.     cause <- i
  13.     result <- gendercause(data, cause)
  14.     df <- rbind(result, df)
  15.   }
  16.   return(df)
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement