R/extractWeather.R

#extractWeather
#
#


extractWeather <- function(dataFile,fromColumn,toColumn){
    
    c <- character(nrow(dataFile))

    for(i in 1:nrow(dataFile)) {
    tempStr <- dataFile[i,fromColumn]
    if(grepl("fog$", tolower(tempStr)))
    c[i] <- "Fog"
    if(grepl("wind$", tolower(tempStr)))
    c[i] <- "Wind"
    if(grepl("rain$", tolower(tempStr)))
      c[i] <- "Rain"
    if(grepl("hail$", tolower(tempStr)))
      c[i] <- "Hail"
    if(grepl("snow$", tolower(tempStr)))
      c[i] <- "Snow"
    #if(nchar(c[i]) < 1)
    #   c[i] <- "Normal"
    }
  dataFile[toColumn] <- c
  return(dataFile)
}
aalmasaud/TDW documentation built on May 8, 2019, 1:44 p.m.