Skip to content

Instantly share code, notes, and snippets.

@cavedave
Created May 18, 2018 15:11
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 cavedave/7b036d7aab86f2f4267633ed48dbcc99 to your computer and use it in GitHub Desktop.
Save cavedave/7b036d7aab86f2f4267633ed48dbcc99 to your computer and use it in GitHub Desktop.
Year Date
1916 20 April
1917 1 May
1918 8 April
1919 18 April
1920 25 March
1921 20 April
1922 18 April
1923 18 April
1924 14 April
1925 10 April
1926 10 April
1927 20 April
1928 24 April
1929 16 April
1930 12 April
1931 26 April
1932 14 April
1933 16 April
1934 17 April
1935 14 April
1936 22 April
1937 24 April
1938 26 April
1939 13 April
1940 20 April
1941 22 April
1942 22 April
1943 22 April
1944 6 April
1945 12 April
1946 4 April
1947 13 April
1948 14 April
1949 11 April
1950 16 April
1951 14 April
1952 22 April
1953 20 April
1954 22 April
1955 15 April
1956 18 April
1957 19 April
1958 22 April
1959 18 April
1960 15 April
1961 20 April
1962 11 April
1963 22 April
1964 18 April
1965 30 April
1966 26 April
1967 23 April
1968 16 April
1969 18 April
1970 14 April
1971 18 April
1972 2 May
1973 24 April
1974 24 April
1975 26 April
1976 16 April
1977 25 April
1978 2 May
1979 4 May
1980 25 April
1981 4 May
1982 25 April
1983 25 April
1984 20 April
1985 22 April
1986 30 April
1987 25 April
1988 18 April
1989 20 April
1990 30 April
1991 2 May
1992 27 April
1993 25 April
1994 24 April
1995 27 April
1996 28 April
1997 30 April
1998 27 April
1999 25 April
2000 22 April
2001 30 April
2002 1 May
2003 6 May
cuckoo = read.csv("/Users/davidcurran/Documents/cuckoo.csv")
head(cuckoo)
Year
<int>
Date
<fctr>
1 1916 20 April
2 1917 1 May
3 1918 8 April
library(lubridate)
begin <- cuckoo
begin$c <- paste(begin$Date,begin$Year)
head(begin)
Year
<int>
Date
<fctr>
c
<chr>
1 1916 20 April 20 April 1916
2 1917 1 May 1 May 1917
3 1918 8 April 8 April 1918
begin$new <- dmy(begin$c)
begin$e <- strftime(begin$new, format = "%j")
begin$e <- as.numeric(as.character(begin$e))
ggplot(begin, aes(Year, e)) +
theme_update(plot.title = element_text(hjust = 0.5))+
theme_tufte() +
geom_point(color='black') +
geom_smooth(color='darkred',method = 'loess')+
ggtitle("First Cuckoo of Spring in England")+
#theme(plot.title = element_text(hjust = 0.5)+
ylab("Day of Year")+
annotate("segment", x = 1915, xend = 1915, y = 85, yend = 90, colour = "wheat1", size=3) +
annotate("text", x = 1915, y = 87.5, label = "March", size = 3.0,angle = 90)+
annotate("segment", x = 1915, xend = 1915, y = 90.2, yend = 120, colour = "wheat2", size=3) +
annotate("text", x = 1915, y = 105.5, label = "April", size = 3.0,angle = 90)+
annotate("segment", x = 1915, xend = 1915, y = 120.2, yend = 130, colour = "wheat3", size=3) +
annotate("text", x = 1915, y = 125.5, label = "May", size = 3.0,angle = 90)+
#annotate("segment", x = 800, xend = 820, y = 80, yend = 90, colour = "wheat4", size=.5) +
annotate("text", x = 1975, y = 85, label = "@iamreddave http://www.wbrc.org.uk/WORCRECD/Issue11/Cuckoo.htm", size = 3.0)
#> `geom_smooth()` using method = 'loess' and formula 'y ~ x'
ggsave("cuckoo.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment