Skip to content

Instantly share code, notes, and snippets.

@robwschlegel
Created June 12, 2017 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robwschlegel/0ae1d46368848f3f32488a3ab2202a3e to your computer and use it in GitHub Desktop.
Save robwschlegel/0ae1d46368848f3f32488a3ab2202a3e to your computer and use it in GitHub Desktop.
## Assuming your data frame is called 'my_df'
# First it is necessary to correct any bearings of '0' to '360'
my_df$bearing[my_df$bearing == 0] <- 360
my_df$u <- (1 * my_df$speed) * sin((my_df$bearing * pi / 180.0))
my_df$v <- (1 * my_df$speed) * cos((my_df$bearing * pi / 180.0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment