[R] Plotting wind direction as arrows with precipitation
DJ L
rhelp10 at gmail.com
Mon Aug 10 06:05:27 CEST 2015
Hello R users!
I am trying to create a time series in R with two variables, precipitation
and wind direction vs Date/Time.
I am looking for suggestions and maybe even sample code.
My workbook is called "Sandy" and has columns with Date/Time, Raindall_cm,
Wind Direction in both degree format (0-359) and in character form (N, NW,
S, SW, SE, E, NE, NW).
I have done some reading for it on stackoverflow and other sites but not
making head way.
I will be graphing with ggplot most likely and am a beginner in R, self
taught from books and online resources.
This is the code I have and a small peak into the data.
Sandy<-read.csv("Sandy.csv", header=TRUE, sep=",",stringsAsFactors=FALSE)
> head(Sandy)
Deal1 Rainfall_cm Wind_Direction1 Wind_Direction2
1 10/22/2012 0:00 0 296 W
2 10/22/2012 0:15 0 317 NW
3 10/22/2012 0:30 0 323 NW
4 10/22/2012 0:45 0 323 NW
5 10/22/2012 1:00 0 326 NW
6 10/22/2012 1:15 0 326 NW
> class(Sandy)
[1] "data.frame"
> str(Sandy)
'data.frame': 1832 obs. of 4 variables:
$ Deal1 : chr "10/22/2012 0:00" "10/22/2012 0:15" "10/22/2012
0:30" "10/22/2012 0:45" ...
$ Rainfall_cm : num 0 0 0 0 0 0 0 0 0 0 ...
$ Wind_Direction: num 296 317 323 323 326 326
$ Wind_Direction: chr "W" "NW" "NW" "NW" ...
> require(ggplot2)
Loading required package: ggplot2
# this graph does the precipitation vs time graph, but not the wind
> ggplot(Sandy, aes(x = Deal1, y = Rainfall_cm, group = 1)) +
geom_line(stat = "identity")
Ideally I want it to have the precipitation graph vs time, then wind vs
time on the same graph. I would like the wind direction to be arrows
pointing in the designated direction (i.e. North points north).
Thank you!
[[alternative HTML version deleted]]
More information about the R-help
mailing list