Skip to content

Instantly share code, notes, and snippets.

@jlehtoma
Last active December 14, 2015 08:19
Show Gist options
  • Save jlehtoma/5057376 to your computer and use it in GitHub Desktop.
Save jlehtoma/5057376 to your computer and use it in GitHub Desktop.
How big a fraction of wind directions fall into South-East direction
# Read in the data
dat <- read.csv("...", sep=";", header=T)
# Calculate the percentage values for each 10° category
# Divide each row n value with the sum of all n's
# Round to precision 3, this will cause a slight
# rounding error
dat$percent <- round(dat$n / sum(dat$n) * 100, 3)
# Get just the South-East [90°, 180°]
dat.SE <- subset(dat, Wd_10min >= 90 & Wd_10min <= 180)
# Sum the percentages and print
perc.SE <- sum(dat.SE$percent)
perc.SE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment