From a7c16c4766670f2843f7be6d189ab56dcfc2f9ce Mon Sep 17 00:00:00 2001 From: eveskew Date: Mon, 27 Jan 2020 10:31:19 -0500 Subject: [PATCH] Adding week 01 lecture and lab materials --- data/ebay_snake_captures.csv | 458 +++++++++++++++++++++++++++++++++++ lab/lab_week_01.Rmd | 104 ++++++++ lecture/lecture_week_01.R | 336 +++++++++++++++++++++++++ 3 files changed, 898 insertions(+) create mode 100644 data/ebay_snake_captures.csv create mode 100644 lab/lab_week_01.Rmd create mode 100644 lecture/lecture_week_01.R diff --git a/data/ebay_snake_captures.csv b/data/ebay_snake_captures.csv new file mode 100644 index 0000000..a15e786 --- /dev/null +++ b/data/ebay_snake_captures.csv @@ -0,0 +1,458 @@ +"Date","Time","TT","Species.","X.","Comments.Observations" +"2-Mar-03",1645,"snake trap","Nerodia fasciata",1,"" +"5-Mar-03",1400,"snake trap","Thamnophis sauritus",1,"" +"5-Mar-03",1730,"snake trap","Agkistrodon piscivorus",1,"" +"6-Mar-03",1045,"snake trap","Agkistrodon piscivorus",1,"" +"6-Mar-03",1045,"snake trap","Agkistrodon piscivorus",1,"" +"10-Mar-03",1030,"snake trap","Nerodia fasciata",1,"" +"10-Mar-03",1715,"snake trap","Agkistrodon piscivorus",1,"" +"12-Mar-03",730,"snake trap","Nerodia fasciata",1,"" +"13-Mar-03",1645,"snake trap","Agkistrodon piscivorus",1,"" +"13-Mar-03",1645,"snake trap","Agkistrodon piscivorus",1,"" +"14-Mar-03",950,"snake trap","Crotalus horridus",1,"" +"14-Mar-03",950,"snake trap","Agkistrodon piscivorus",2,"" +"19-Mar-03",1100,"snake trap","Agkistrodon piscivorus",1,"" +"19-Mar-03",1100,"snake trap","Agkistrodon piscivorus",2,"" +"20-Mar-03",1130,"snake trap","Agkistrodon piscivorus",1,"" +"20-Mar-03",1800,"snake trap","Agkistrodon piscivorus",1,"" +"21-Mar-03",1620,"bucket","Agkistrodon piscivorus",1,"" +"21-Mar-03",1620,"snake trap","Agkistrodon piscivorus",1,"" +"23-Mar-03",1210,"snake trap","Farancia erytrogramma",1,"YEAH!" +"25-Mar-03",1045,"bucket","Agkistrodon piscivorus",1,"" +"25-Mar-03",1545,"snake trap","Agkistrodon piscivorus",1,"" +"25-Mar-03",1045,"snake trap","Nerodia erythrogaster",1,"" +"25-Mar-03",1045,"snake trap","Coluber constrictor",1,"" +"26-Mar-03",1045,"snake trap","Coluber constrictor",1,"" +"26-Mar-03",1610,"snake trap","Coluber constrictor",1,"" +"27-Mar-03",1730,"snake trap","Agkistrodon piscivorus",1,"" +"27-Mar-03",1730,"snake trap","Coluber constrictor",1,"" +"28-Mar-03",1015,"snake trap","Coluber constrictor",1,"" +"28-Mar-03",1625,"snake trap","Coluber constrictor",1,"" +"29-Mar-03",800,"bucket","Farancia erytrogramma",1,"" +"29-Mar-03",800,"snake trap","Farancia erytrogramma",1,"" +"29-Mar-03",1730,"snake trap","Agkistrodon piscivorus",1,"" +"29-Mar-03",1730,"snake trap","Coluber constrictor",1,"" +"29-Mar-03",1730,"snake trap","Coluber constrictor",1,"" +"29-Mar-03",1730,"snake trap","Coluber constrictor",2,"BIT MY FACE" +"30-Mar-03",1030,"snake trap","Agkistrodon piscivorus",1,"" +"1-Apr-03",1230,"snake trap","Nerodia fasciata",1,"" +"3-Apr-03",1730,"snake trap","Nerodia fasciata",1,"" +"3-Apr-03",1730,"snake trap","Heterodon platirhinos",1,"MELANISTIC, PRETTY" +"5-Apr-03",1700,"bucket","Agkistrodon piscivorus",1,"HEAD IN BUCKET" +"6-Apr-03",1800,"snake trap","Heterodon platirhinos",1,"" +"6-Apr-03",1800,"snake trap","Agkistrodon piscivorus",1,"" +"13-Apr-03",1900,"snake trap","Agkistrodon piscivorus",1,"" +"14-Apr-03",1634,"coffee can","Coluber constrictor",1,"COMING OUT OF C" +"15-Apr-03",915,"bucket","Nerodia floridana",1,"" +"15-Apr-03",915,"snake trap","Farancia abacura",1,"" +"15-Apr-03",1730,"snake trap","Coluber constrictor",1,"" +"15-Apr-03",1730,"snake trap","Coluber constrictor",1,"" +"16-Apr-03",1630,"snake trap","Coluber constrictor",2,"" +"17-Apr-03",915,"snake trap","Farancia erytrogramma",1,"" +"17-Apr-03",1720,"snake trap","Agkistrodon piscivorus",1,"" +"17-Apr-03",915,"snake trap","Thamnophis sirtalis",1,"" +"17-Apr-03",1720,"snake trap","Coluber constrictor",1,"" +"18-Apr-03",1115,"bucket","Thamnophis sirtalis",1,"" +"18-Apr-03",1115,"snake trap","Coluber constrictor",1,"" +"19-Apr-03",900,"snake trap","Diadophis punctatus",1,"" +"21-Apr-03",1700,"snake trap","Thamnophis sirtalis",1,"" +"21-Apr-03",1700,"snake trap","Coluber constrictor",1,"" +"22-Apr-03",1700,"snake trap","Coluber constrictor",1,"COVERED IN MAGGETS" +"24-Apr-03",1714,"snake trap","Coluber constrictor",1,"" +"24-Apr-03",1714,"snake trap","Coluber constrictor",1,"" +"26-Apr-03",1715,"snake trap","Coluber constrictor",1,"" +"26-Apr-03",1715,"snake trap","Coluber constrictor",1,"" +"26-Apr-03",1715,"snake trap","Coluber constrictor",1,"" +"26-Apr-03",1715,"snake trap","Coluber constrictor",1,"" +"27-Apr-03",945,"snake trap","Nerodia erythrogaster",1,"" +"27-Apr-03",1710,"snake trap","Coluber constrictor",1,"" +"27-Apr-03",1710,"snake trap","Coluber constrictor",1,"" +"28-Apr-03",940,"snake trap","Agkistrodon piscivorus",1,"JUV" +"28-Apr-03",1745,"snake trap","Coluber constrictor",1,"" +"30-Apr-03",1045,"snake trap","Nerodia erythrogaster",1,"" +"30-Apr-03",1900,"snake trap","Coluber constrictor",1,"" +"1-May-03",1715,"bucket","Coluber constrictor",1,"" +"2-May-03",1050,"snake trap","Coluber constrictor",1,"" +"3-May-03",930,"snake trap","Agkistrodon contortrix",1,"" +"3-May-03",930,"snake trap","Farancia abacura",1,"" +"3-May-03",1800,"snake trap","Nerodia erythrogaster",1,"" +"4-May-03",1700,"bucket","Coluber constrictor",1,"JUVENILE" +"4-May-03",1700,"snake trap","Farancia abacura",1,"" +"4-May-03",1700,"snake trap","Coluber constrictor",1,"" +"4-May-03",1700,"snake trap","Coluber constrictor",1,"" +"6-May-03",850,"bucket","Seminatrix pygaea",1,"" +"6-May-03",850,"snake trap","Coluber constrictor",1,"BEAT UP" +"7-May-03",1520,"snake trap","Coluber constrictor",1,"" +"8-May-03",850,"snake trap","Nerodia fasciata",1,"" +"8-May-03",850,"snake trap","Coluber constrictor",1,"" +"8-May-03",1735,"snake trap","Coluber constrictor",2,"NEITHER MRKD" +"9-May-03",815,"snake trap","Coluber constrictor",2,"" +"9-May-03",1545,"snake trap","Coluber constrictor",1,"" +"10-May-03",624,"snake trap","Agkistrodon piscivorus",1,"" +"10-May-03",1800,"snake trap","Nerodia erythrogaster",1,"" +"10-May-03",1800,"snake trap","Coluber constrictor",1,"" +"10-May-03",1800,"snake trap","Coluber constrictor",1,"RELEASED" +"11-May-03",905,"bucket","Farancia erytrogramma",1,"HATCHLING" +"11-May-03",1815,"snake trap","Coluber constrictor",1,"MRKD " +"13-May-03",945,"snake trap","Coluber constrictor",1,"" +"14-May-03",800,"snake trap","Nerodia fasciata",1,"" +"14-May-03",800,"snake trap","Pantherophis guttatus",1,"JUVENILE" +"18-May-03",2245,"bucket","Seminatrix pygaea",1,"" +"19-May-03",740,"bucket","Nerodia fasciata",1,"JUV" +"20-May-03",830,"bucket","Storeria dekayii",1,"" +"21-May-03",30,"bucket","Seminatrix pygaea",1,"" +"21-May-03",1740,"snake trap","Seminatrix pygaea",1,"" +"21-May-03",1740,"snake trap","Farancia abacura",1,"" +"24-May-03",2330,"bucket","Nerodia fasciata",1,"" +"28-May-03",1615,"snake trap","Nerodia erythrogaster",1,"" +"28-May-03",1615,"snake trap","Nerodia erythrogaster",1,"" +"28-May-03",1615,"snake trap","Coluber constrictor",1,"" +"29-May-03",1645,"snake trap","Heterodon platirhinos",1,"" +"29-May-03",1645,"snake trap","Agkistrodon piscivorus",1,"" +"29-May-03",1645,"snake trap","Coluber constrictor",1,"" +"30-May-03",825,"snake trap","Pantherophis guttatus",1,"" +"30-May-03",1645,"snake trap","Coluber constrictor",1,"" +"31-May-03",1730,"snake trap","Mastocophis flagellum",1,"" +"2-Jun-03",1800,"snake trap","Coluber constrictor",1,"" +"5-Jun-03",730,"bucket","Seminatrix pygaea",1,"" +"5-Jun-03",730,"bucket","Diadophis punctatus",1,"" +"8-Jun-03",1840,"bucket","Nerodia floridana",1,"" +"16-Jun-03",855,"bucket","Seminatrix pygaea",1,"" +"18-Jun-03",824,"bucket","Seminatrix pygaea",1,"" +"19-Jun-03",830,"bucket","Seminatrix pygaea",1,"" +"20-Jun-03",830,"bucket","Seminatrix pygaea",1,"" +"20-Jun-03",830,"bucket","Seminatrix pygaea",1,"" +"20-Jun-03",830,"bucket","Nerodia floridana",1,"DROWNED" +"20-Jun-03",1830,"snake trap","Coluber constrictor",1,"" +"20-Jun-03",1830,"snake trap","Coluber constrictor",1,"" +"21-Jun-03",1700,"snake trap","Coluber constrictor",1,"" +"21-Jun-03",1700,"snake trap","Coluber constrictor",1,"" +"22-Jun-03",909,"bucket","Seminatrix pygaea",1,"NEW" +"22-Jun-03",909,"bucket","Diadophis punctatus",1,"" +"22-Jun-03",1700,"snake trap","Agkistrodon piscivorus",1,"" +"22-Jun-03",1700,"snake trap","Coluber constrictor",1,"" +"22-Jun-03",1700,"snake trap","Coluber constrictor",1,"" +"22-Jun-03",1700,"snake trap","Coluber constrictor",1,"" +"24-Jun-03",1820,"snake trap","Coluber constrictor",1,"" +"26-Jun-03",823,"bucket","Storeria occipitomaculata",1,"ADULT M" +"26-Jun-03",1625,"snake trap","Coluber constrictor",1,"" +"26-Jun-03",1625,"snake trap","Coluber constrictor",1,"" +"27-Jun-03",835,"snake trap","Thamnophis sauritus",1,"JUV" +"27-Jun-03",835,"snake trap","Coluber constrictor",1,"UNMRKD" +"27-Jun-03",1630,"snake trap","Coluber constrictor",1,"" +"28-Jun-03",900,"snake trap","Coluber constrictor",1,"BRAND LOOKS HEALTHY" +"30-Jun-03",1715,"snake trap","Coluber constrictor",1,"" +"1-Jul-03",845,"bucket","Seminatrix pygaea",1,"F" +"1-Jul-03",1715,"snake trap","Agkistrodon piscivorus",1,"" +"2-Jul-03",830,"bucket","Seminatrix pygaea",1,"" +"2-Jul-03",1800,"snake trap","Thamnophis sauritus",1,"JUV" +"2-Jul-03",1800,"snake trap","Agkistrodon piscivorus",1,"" +"3-Jul-03",1825,"snake trap","Coluber constrictor",1,"NEMACIATED" +"5-Jul-03",1730,"snake trap","Agkistrodon piscivorus",1,"" +"6-Jul-03",826,"bucket","Seminatrix pygaea",1,"" +"6-Jul-03",1730,"snake trap","Agkistrodon piscivorus",1,"" +"6-Jul-03",1730,"snake trap","Coluber constrictor",1,"" +"6-Jul-03",1730,"snake trap","Coluber constrictor",1,"" +"7-Jul-03",906,"bucket","Seminatrix pygaea",1,"DIED IN TRANSIT WHILE RTL" +"8-Jul-03",1800,"bucket","Agkistrodon piscivorus",1,"" +"9-Jul-03",1830,"bucket","Seminatrix pygaea",1,"" +"9-Jul-03",1830,"snake trap","Agkistrodon piscivorus",1,"" +"11-Jul-03",1733,"snake trap","Coluber constrictor",1,"" +"13-Jul-03",2000,"bucket","Diadophis punctatus",1,"" +"14-Jul-03",1745,"bucket","Seminatrix pygaea",1,"" +"15-Jul-03",1630,"snake trap","Agkistrodon piscivorus",1,"" +"16-Jul-03",1720,"snake trap","Coluber constrictor",1,"" +"16-Jul-03",1720,"snake trap","Coluber constrictor",1,"" +"17-Jul-03",830,"bucket","Nerodia floridana",1,"" +"19-Jul-03",1855,"snake trap","Thamnophis sauritus",1,"" +"19-Jul-03",1855,"snake trap","Coluber constrictor",1,"" +"21-Jul-03",1745,"snake trap","Agkistrodon piscivorus",1,"" +"22-Jul-03",830,"bucket","Cemophora coccinea",1,"" +"25-Jul-03",830,"bucket","Storeria occipitomaculata",1,"" +"27-Jul-03",1850,"snake trap","Thamnophis sauritus",1,"" +"28-Jul-03",826,"bucket","Nerodia fasciata",1,"" +"28-Jul-03",826,"bucket","Nerodia fasciata",1,"" +"28-Jul-03",826,"snake trap","Agkistrodon piscivorus",1,"" +"28-Jul-03",1910,"snake trap","Agkistrodon piscivorus",1,"" +"30-Jul-03",845,"bucket","Seminatrix pygaea",1,"" +"30-Jul-03",1815,"snake trap","Nerodia fasciata",1,"" +"30-Jul-03",845,"snake trap","Thamnophis sauritus",1,"" +"31-Jul-03",838,"bucket","Seminatrix pygaea",1,"YOTY" +"31-Jul-03",1945,"snake trap","Agkistrodon piscivorus",1,"" +"1-Aug-03",830,"snake trap","Thamnophis sauritus",1,"" +"2-Aug-03",1930,"bucket","Seminatrix pygaea",1,"" +"4-Aug-03",1845,"bucket","Thamnophis sauritus",1,"" +"4-Aug-03",845,"bucket","Diadophis punctatus",1,"" +"5-Aug-03",1800,"coffee can","Seminatrix pygaea",1,"JUV" +"5-Aug-03",1800,"coffee can","Seminatrix pygaea",1,"JUV" +"5-Aug-03",1800,"snake trap","Agkistrodon piscivorus",1,"" +"6-Aug-03",847,"bucket","Seminatrix pygaea",1,"NEONATE" +"6-Aug-03",847,"bucket","Seminatrix pygaea",1,"NEONATE" +"6-Aug-03",1825,"bucket","Nerodia fasciata",1,"" +"6-Aug-03",1825,"bucket","Thamnophis sauritus",1,"" +"6-Aug-03",1825,"snake trap","Opheodrys aestivus",1,"" +"7-Aug-03",830,"coffee can","Seminatrix pygaea",1,"NEONATE" +"7-Aug-03",1830,"snake trap","Thamnophis sauritus",1,"" +"8-Aug-03",845,"bucket","Seminatrix pygaea",1,"" +"8-Aug-03",845,"bucket","Seminatrix pygaea",1,"Y OF YEAR" +"9-Aug-03",940,"bucket","Seminatrix pygaea",1,"NEONATE" +"9-Aug-03",940,"coffee can","Seminatrix pygaea",1,"NEONATE" +"10-Aug-03",830,"bucket","Seminatrix pygaea",1,"" +"10-Aug-03",830,"bucket","Seminatrix pygaea",1,"" +"10-Aug-03",1806,"bucket","Seminatrix pygaea",1,"" +"11-Aug-03",1015,"coffee can","Seminatrix pygaea",1,"NEONATE" +"11-Aug-03",1800,"coffee can","Seminatrix pygaea",1,"NEONATE" +"12-Aug-03",955,"bucket","Seminatrix pygaea",1,"NEONATE" +"12-Aug-03",955,"bucket","Seminatrix pygaea",1,"NEONATE" +"12-Aug-03",955,"bucket","Seminatrix pygaea",1,"NEONATE" +"12-Aug-03",1830,"bucket","Seminatrix pygaea",1,"NEONATE" +"12-Aug-03",1830,"bucket","Seminatrix pygaea",1,"NEONATE" +"12-Aug-03",1830,"bucket","Seminatrix pygaea",1,"NEONATE" +"12-Aug-03",955,"bucket","Nerodia fasciata",1,"NEONATE" +"12-Aug-03",955,"coffee can","Seminatrix pygaea",1,"NEONATE" +"12-Aug-03",1830,"coffee can","Seminatrix pygaea",1,"NEONATE" +"13-Aug-03",1830,"bucket","Seminatrix pygaea",1,"" +"13-Aug-03",1830,"bucket","Seminatrix pygaea",1,"" +"13-Aug-03",1830,"bucket","Seminatrix pygaea",1,"" +"13-Aug-03",1830,"coffee can","Seminatrix pygaea",1,"" +"13-Aug-03",1830,"snake trap","Coluber constrictor",1,"" +"14-Aug-03",823,"bucket","Seminatrix pygaea",1,"NEONATE" +"14-Aug-03",823,"bucket","Seminatrix pygaea",1,"NEONATE" +"14-Aug-03",823,"bucket","Seminatrix pygaea",1,"NEONATE" +"14-Aug-03",823,"bucket","Seminatrix pygaea",1,"NEONATE" +"14-Aug-03",823,"bucket","Seminatrix pygaea",2,"NEONATE" +"14-Aug-03",1930,"bucket","Seminatrix pygaea",1,"" +"14-Aug-03",1930,"bucket","Cemophora coccinea",1,"" +"14-Aug-03",823,"coffee can","Seminatrix pygaea",1,"NEONATE" +"14-Aug-03",823,"coffee can","Seminatrix pygaea",2,"NEONATE" +"14-Aug-03",823,"snake trap","Nerodia fasciata",1,"NEONATE" +"15-Aug-03",1010,"bucket","Seminatrix pygaea",1,"NEONATE" +"15-Aug-03",1010,"bucket","Seminatrix pygaea",1,"NEONATE" +"15-Aug-03",1010,"bucket","Seminatrix pygaea",1,"NEONATE" +"15-Aug-03",1010,"bucket","Seminatrix pygaea",1,"NEONATE" +"15-Aug-03",1800,"bucket","Seminatrix pygaea",1,"NEONATE" +"15-Aug-03",1800,"bucket","Seminatrix pygaea",1,"NEONATE" +"15-Aug-03",1010,"coffee can","Seminatrix pygaea",1,"" +"15-Aug-03",1010,"coffee can","Seminatrix pygaea",1,"NEONATE" +"16-Aug-03",1845,"snake trap","Nerodia fasciata",1,"" +"17-Aug-03",1000,"bucket","Seminatrix pygaea",1,"" +"17-Aug-03",1900,"bucket","Seminatrix pygaea",1,"" +"17-Aug-03",1000,"bucket","Thamnophis sauritus",1,"" +"17-Aug-03",1000,"coffee can","Seminatrix pygaea",1,"" +"18-Aug-03",843,"bucket","Seminatrix pygaea",1,"NEONATE" +"18-Aug-03",843,"bucket","Seminatrix pygaea",1,"NEONATE" +"18-Aug-03",843,"bucket","Seminatrix pygaea",2,"NEONATE" +"18-Aug-03",1830,"bucket","Seminatrix pygaea",1,"" +"18-Aug-03",1830,"bucket","Seminatrix pygaea",1,"JUV" +"19-Aug-03",1810,"bucket","Seminatrix pygaea",1,"NEONATE" +"19-Aug-03",741,"bucket","Diadophis punctatus",1,"" +"19-Aug-03",1810,"snake trap","Nerodia fasciata",1,"" +"20-Aug-03",903,"bucket","Seminatrix pygaea",1,"" +"20-Aug-03",903,"bucket","Seminatrix pygaea",1,"" +"20-Aug-03",903,"bucket","Seminatrix pygaea",1,"" +"20-Aug-03",903,"bucket","Seminatrix pygaea",1,"" +"20-Aug-03",1755,"bucket","Seminatrix pygaea",1,"" +"20-Aug-03",903,"bucket","Diadophis punctatus",1,"" +"20-Aug-03",1755,"snake trap","Coluber constrictor",1,"NEONATE" +"21-Aug-03",915,"bucket","Seminatrix pygaea",1,"" +"21-Aug-03",1815,"bucket","Seminatrix pygaea",1,"" +"21-Aug-03",1815,"bucket","Seminatrix pygaea",1,"" +"21-Aug-03",1815,"bucket","Seminatrix pygaea",1,"" +"22-Aug-03",900,"bucket","Seminatrix pygaea",1,"NEONATE" +"22-Aug-03",900,"bucket","Seminatrix pygaea",1,"NEONATE" +"22-Aug-03",900,"bucket","Seminatrix pygaea",1,"NEONATE" +"22-Aug-03",900,"bucket","Seminatrix pygaea",1,"NEONATE" +"22-Aug-03",900,"bucket","Seminatrix pygaea",1,"NEONATE" +"22-Aug-03",900,"bucket","Seminatrix pygaea",1,"NEONATE" +"22-Aug-03",900,"bucket","Seminatrix pygaea",1,"NEONATE" +"22-Aug-03",1815,"bucket","Seminatrix pygaea",1,"NEONATE" +"22-Aug-03",900,"snake trap","Coluber constrictor",1,"" +"23-Aug-03",930,"bucket","Seminatrix pygaea",1,"" +"23-Aug-03",930,"bucket","Seminatrix pygaea",1,"" +"24-Aug-03",920,"bucket","Seminatrix pygaea",1,"" +"24-Aug-03",920,"bucket","Seminatrix pygaea",1,"" +"24-Aug-03",1800,"bucket","Seminatrix pygaea",1,"NEONATE" +"25-Aug-03",841,"bucket","Seminatrix pygaea",1,"NEONATE" +"25-Aug-03",1800,"snake trap","Coluber constrictor",1,"" +"26-Aug-03",842,"bucket","Seminatrix pygaea",1,"NEONATE" +"26-Aug-03",1804,"bucket","Seminatrix pygaea",1,"NEONATE" +"26-Aug-03",1804,"bucket","Seminatrix pygaea",1,"NEONATE" +"26-Aug-03",1804,"bucket","Seminatrix pygaea",1,"NEONATE" +"26-Aug-03",1804,"snake trap","Nerodia fasciata",1,"" +"27-Aug-03",1800,"bucket","Seminatrix pygaea",1,"RECAP TAIL CLIPPED" +"27-Aug-03",1800,"snake trap","Nerodia erythrogaster",1,"RECECNT REC NOT RTL" +"28-Aug-03",1000,"bucket","Seminatrix pygaea",1,"" +"28-Aug-03",1000,"bucket","Seminatrix pygaea",1,"" +"28-Aug-03",1000,"bucket","Seminatrix pygaea",1,"" +"28-Aug-03",1845,"bucket","Seminatrix pygaea",1,"NEONATE" +"28-Aug-03",1845,"bucket","Seminatrix pygaea",1,"NEONATE" +"28-Aug-03",1845,"bucket","Seminatrix pygaea",1,"NEONATE" +"28-Aug-03",1845,"bucket","Seminatrix pygaea",1,"NEONATE" +"28-Aug-03",1845,"coffee can","Seminatrix pygaea",1,"NEONATE" +"28-Aug-03",1845,"coffee can","Seminatrix pygaea",1,"NEONATE" +"28-Aug-03",1845,"snake trap","Coluber constrictor",1,"NEONATE" +"29-Aug-03",930,"bucket","Seminatrix pygaea",1,"HATCHLING" +"29-Aug-03",930,"bucket","Seminatrix pygaea",1,"HATCHLING" +"29-Aug-03",1810,"bucket","Seminatrix pygaea",1,"" +"29-Aug-03",1810,"coffee can","Seminatrix pygaea",1,"" +"29-Aug-03",1810,"snake trap","Thamnophis sirtalis",1,"" +"29-Aug-03",1810,"snake trap","Coluber constrictor",1,"" +"29-Aug-03",1810,"snake trap","Coluber constrictor",1,"" +"29-Aug-03",1810,"snake trap","Coluber constrictor",1,"" +"30-Aug-03",930,"bucket","Seminatrix pygaea",1,"NEONATE" +"30-Aug-03",930,"bucket","Seminatrix pygaea",1,"DIB " +"30-Aug-03",930,"bucket","Seminatrix pygaea",1,"NEONATE" +"30-Aug-03",1800,"bucket","Seminatrix pygaea",1,"" +"30-Aug-03",1800,"snake trap","Heterodon platirhinos",1,"" +"30-Aug-03",1800,"snake trap","Coluber constrictor",1,"" +"31-Aug-03",930,"bucket","Seminatrix pygaea",1,"NEONATE" +"31-Aug-03",1730,"bucket","Seminatrix pygaea",1,"NEONATE" +"31-Aug-03",1730,"bucket","Seminatrix pygaea",1,"NEONATE" +"31-Aug-03",930,"bucket","Nerodia fasciata",1,"NEONATE" +"1-Sep-03",1830,"bucket","Seminatrix pygaea",1,"" +"2-Sep-03",748,"bucket","Seminatrix pygaea",1,"NEONATE" +"2-Sep-03",1730,"snake trap","Nerodia fasciata",1,"NEONATE" +"3-Sep-03",845,"coffee can","Seminatrix pygaea",1,"" +"3-Sep-03",1745,"snake trap","Coluber constrictor",1,"NEONATE" +"4-Sep-03",1725,"bucket","Seminatrix pygaea",1,"NEONATE" +"4-Sep-03",830,"snake trap","Farancia erytrogramma",1,"" +"4-Sep-03",1725,"snake trap","Coluber constrictor",1,"NEONATE" +"4-Sep-03",1725,"snake trap","Coluber constrictor",1,"ADULT" +"5-Sep-03",1800,"snake trap","Diadophis punctatus",1,"" +"9-Sep-03",1645,"snake trap","Thamnophis sauritus",1,"" +"9-Sep-03",1645,"snake trap","Coluber constrictor",1,"JUV" +"9-Sep-03",1645,"snake trap","Coluber constrictor",1,"JUV" +"10-Sep-03",915,"bucket","Seminatrix pygaea",1,"NEONATE" +"10-Sep-03",1810,"snake trap","Coluber constrictor",1,"" +"11-Sep-03",1630,"snake trap","Coluber constrictor",1,"" +"12-Sep-03",1730,"snake trap","Coluber constrictor",1,"NEONATE" +"12-Sep-03",1730,"snake trap","Coluber constrictor",1,"NEONATE" +"13-Sep-03",1630,"snake trap","Coluber constrictor",1,"" +"13-Sep-03",1630,"snake trap","Coluber constrictor",1,"" +"13-Sep-03",1630,"snake trap","Coluber constrictor",1,"REGURGITATED NEONATE" +"15-Sep-03",840,"bucket","Seminatrix pygaea",1,"" +"15-Sep-03",840,"bucket","Thamnophis sauritus",1,"" +"15-Sep-03",1700,"coffee can","Seminatrix pygaea",1,"REC NEONATE LET GO" +"16-Sep-03",1745,"bucket","Thamnophis sauritus",1,"NEONATE " +"16-Sep-03",1745,"bucket","Agkistrodon piscivorus",1,"YOUNG OF YEAR?" +"16-Sep-03",1745,"bucket","Thamnophis sirtalis",1,"YOUNG OF YEAR?" +"16-Sep-03",1745,"snake trap","Mastocophis flagellum",1,"NEONATE" +"16-Sep-03",850,"snake trap","Coluber constrictor",1,"NEONATE WITH BELLY SCAR" +"16-Sep-03",1745,"snake trap","Coluber constrictor",1,"" +"17-Sep-03",1745,"bucket","Seminatrix pygaea",1,"NEONATE, ANTS ATE" +"17-Sep-03",1745,"bucket","Nerodia floridana",1,"" +"17-Sep-03",1745,"bucket","Coluber constrictor",1,"NEONATE" +"17-Sep-03",905,"snake trap","Nerodia fasciata",1,"UNMRKD" +"17-Sep-03",905,"snake trap","Farancia abacura",1,"UNMRKD" +"18-Sep-03",1830,"snake trap","Coluber constrictor",1,"" +"18-Sep-03",1830,"snake trap","Coluber constrictor",1,"" +"19-Sep-03",905,"snake trap","Nerodia fasciata",1,"" +"19-Sep-03",905,"snake trap","Coluber constrictor",1,"NEONATE" +"19-Sep-03",1830,"snake trap","Coluber constrictor",1,"" +"20-Sep-03",1730,"snake trap","Coluber constrictor",1,"NEONATE" +"21-Sep-03",1730,"bucket","Heterodon platirhinos",1,"NEONATE" +"21-Sep-03",1730,"coffee can","Diadophis punctatus",1,"NEONATE" +"21-Sep-03",1730,"snake trap","Coluber constrictor",1,"" +"22-Sep-03",920,"bucket","Seminatrix pygaea",1,"NEONATE LET GO " +"23-Sep-03",1700,"snake trap","Coluber constrictor",1,"" +"24-Sep-03",850,"snake trap","Farancia abacura",1,"" +"24-Sep-03",1625,"snake trap","Coluber constrictor",1,"" +"25-Sep-03",1745,"snake trap","Heterodon platirhinos",1,"NEONATE" +"26-Sep-03",900,"bucket","Thamnophis sirtalis",1,"" +"26-Sep-03",1710,"snake trap","Coluber constrictor",1,"NEONATE" +"26-Sep-03",1710,"snake trap","Coluber constrictor",1,"NEONATE" +"27-Sep-03",1030,"bucket","Seminatrix pygaea",1,"NEONATE" +"27-Sep-03",1830,"bucket","Thamnophis sauritus",1,"NEONATE" +"28-Sep-03",1730,"snake trap","Coluber constrictor",1,"NEONATE UNMRKD" +"29-Sep-03",930,"snake trap","Nerodia fasciata",1,"" +"29-Sep-03",1700,"snake trap","Coluber constrictor",1,"SUBADULT " +"30-Sep-03",1745,"snake trap","Heterodon platirhinos",1,"ADULT " +"30-Sep-03",1745,"snake trap","Coluber constrictor",1,"NEONATE UNMRKD" +"30-Sep-03",1745,"snake trap","Coluber constrictor",1,"NEONATE UNMRKD" +"30-Sep-03",1745,"snake trap","Coluber constrictor",1,"ADULT MRKD" +"1-Oct-03",915,"bucket","Thamnophis sauritus",1,"NEONATE" +"1-Oct-03",1740,"snake trap","Heterodon platirhinos",1,"" +"1-Oct-03",1740,"snake trap","Coluber constrictor",1,"" +"1-Oct-03",1740,"snake trap","Coluber constrictor",1,"" +"2-Oct-03",850,"snake trap","Coluber constrictor",1,"NEONATE UNMRKD" +"2-Oct-03",850,"snake trap","Coluber constrictor",1,"NEONATE UNMRKD" +"3-Oct-03",1630,"snake trap","Heterodon platirhinos",1,"" +"4-Oct-03",1900,"snake trap","Thamnophis sirtalis",1,"" +"4-Oct-03",1900,"snake trap","Coluber constrictor",1,"NEONATE" +"4-Oct-03",1900,"snake trap","Coluber constrictor",1,"" +"5-Oct-03",1635,"snake trap","Coluber constrictor",1,"NEONATE UNMRKD" +"13-Oct-03",1840,"snake trap","Agkistrodon piscivorus",1,"JUV" +"13-Oct-03",1840,"snake trap","Agkistrodon piscivorus",1,"" +"13-Oct-03",1840,"snake trap","Coluber constrictor",1,"REPTILE RUN ONLY" +"14-Oct-03",1055,"snake trap","Farancia erytrogramma",1,"UNDER TRAP" +"14-Oct-03",1055,"snake trap","Agkistrodon piscivorus",1,"JUV" +"14-Oct-03",1800,"snake trap","Coluber constrictor",1,"" +"15-Oct-03",1645,"snake trap","Thamnophis sauritus",1,"ADULT NEW CAPTURE" +"16-Oct-03",930,"coffee can","Seminatrix pygaea",1,"" +"17-Oct-03",1800,"snake trap","Agkistrodon piscivorus",1,"" +"17-Oct-03",1800,"snake trap","Agkistrodon piscivorus",1,"" +"17-Oct-03",920,"snake trap","Coluber constrictor",1,"" +"20-Oct-03",1710,"snake trap","Heterodon platirhinos",1,"ADULT MARKED" +"20-Oct-03",1710,"snake trap","Coluber constrictor",1,"NEONATE UNMRKD" +"21-Oct-03",1715,"snake trap","Heterodon platirhinos",1,"UNMRKD" +"21-Oct-03",1715,"snake trap","Agkistrodon piscivorus",1,"" +"22-Oct-03",940,"bucket","Thamnophis sirtalis",1,"NEONATE" +"22-Oct-03",940,"snake trap","Coluber constrictor",1,"NEONATE" +"23-Oct-03",1725,"snake trap","Thamnophis sauritus",1,"" +"23-Oct-03",915,"snake trap","Agkistrodon piscivorus",1,"" +"23-Oct-03",915,"snake trap","Thamnophis sirtalis",1,"" +"24-Oct-03",1705,"bucket","Thamnophis sirtalis",1,"NEONATE" +"25-Oct-03",1450,"snake trap","Agkistrodon piscivorus",1,"" +"26-Oct-03",1635,"snake trap","Agkistrodon piscivorus",1,"" +"26-Oct-03",1635,"snake trap","Agkistrodon piscivorus",2,"" +"28-Oct-03",1030,"bucket","Agkistrodon piscivorus",1,"" +"29-Oct-03",1300,"bucket","Agkistrodon piscivorus",1,"" +"30-Oct-03",1730,"snake trap","Thamnophis sauritus",1,"" +"30-Oct-03",1730,"snake trap","Agkistrodon piscivorus",1,"JUV UNDER TRAP" +"30-Oct-03",1730,"snake trap","Agkistrodon piscivorus",1,"" +"31-Oct-03",1735,"snake trap","Coluber constrictor",1,"" +"1-Nov-03",1215,"snake trap","Agkistrodon piscivorus",1,"" +"2-Nov-03",1545,"snake trap","Agkistrodon piscivorus",1,"" +"2-Nov-03",1545,"snake trap","Agkistrodon piscivorus",1,"" +"2-Nov-03",1545,"snake trap","Agkistrodon piscivorus",2,"" +"3-Nov-03",1020,"snake trap","Agkistrodon piscivorus",1,"" +"4-Nov-03",1115,"coffee can","Storeria occipitomaculata",1,"" +"4-Nov-03",1115,"snake trap","Agkistrodon piscivorus",1,"" +"4-Nov-03",1115,"snake trap","Agkistrodon piscivorus",1,"" +"4-Nov-03",1115,"snake trap","Agkistrodon piscivorus",1,"NEONATE" +"4-Nov-03",1115,"snake trap","Agkistrodon piscivorus",3,"" +"4-Nov-03",1700,"snake trap","Agkistrodon piscivorus",1,"" +"5-Nov-03",945,"snake trap","Nerodia fasciata",1,"" +"5-Nov-03",945,"snake trap","Nerodia fasciata",1,"" +"5-Nov-03",945,"snake trap","Nerodia fasciata",1,"" +"6-Nov-03",1724,"snake trap","Agkistrodon piscivorus",2,"2 IN ONE!" +"7-Nov-03",900,"snake trap","Nerodia fasciata",1,"" +"8-Nov-03",1035,"snake trap","Agkistrodon piscivorus",1,"" +"11-Nov-03",1655,"bucket","Coluber constrictor",1,"" +"11-Nov-03",1655,"snake trap","Coluber constrictor",1,"" +"12-Nov-03",946,"snake trap","Thamnophis sauritus",1,"" +"12-Nov-03",946,"snake trap","Agkistrodon piscivorus",1,"" +"13-Nov-03",940,"snake trap","Agkistrodon piscivorus",1,"YOUNG" +"15-Nov-03",1130,"bucket","Thamnophis sauritus",1,"NEONATE" +"16-Nov-03",1115,"snake trap","Coluber constrictor",1,"NEONATE" +"17-Nov-03",1655,"snake trap","Agkistrodon piscivorus",1,"" +"17-Nov-03",1655,"snake trap","Agkistrodon piscivorus",1,"" +"19-Nov-03",930,"snake trap","Nerodia fasciata",1,"" +"19-Nov-03",930,"snake trap","Nerodia fasciata",1,"" +"19-Nov-03",930,"snake trap","Nerodia fasciata",2,"" +"21-Nov-03",1513,"snake trap","Pantherophis alleghaniensis",1,"" +"21-Nov-03",945,"snake trap","Heterodon platirhinos",1,"" +"21-Nov-03",1513,"snake trap","Coluber constrictor",1,"" +"22-Nov-03",1100,"snake trap","Coluber constrictor",1,"NEONATE" +"26-Nov-03",855,"snake trap","Coluber constrictor",1,"MRKD" +"28-Nov-03",1615,"snake trap","Nerodia fasciata",1,"" +"10-Dec-03",1015,"snake trap","Nerodia fasciata",1,"" +"26-Dec-03",1400,"snake trap","Nerodia fasciata",1,"" +"26-Dec-03",1400,"snake trap","Thamnophis sauritus",1,"" +"31-Dec-03",1115,"snake trap","Thamnophis sauritus",1,"" +"3-Jan-04",1200,"snake trap","Nerodia fasciata",1,"" +"4-Jan-04",1530,"snake trap","Nerodia fasciata",1,"" +"4-Jan-04",1530,"snake trap","Thamnophis sauritus",1,"" +"5-Jan-04",1510,"snake trap","Nerodia fasciata",1,"" +"6-Jan-04",1030,"snake trap","Nerodia fasciata",1,"" +"6-Jan-04",1030,"snake trap","Nerodia fasciata",1,"" diff --git a/lab/lab_week_01.Rmd b/lab/lab_week_01.Rmd new file mode 100644 index 0000000..ac8b9ce --- /dev/null +++ b/lab/lab_week_01.Rmd @@ -0,0 +1,104 @@ +--- +title: "| EEEB UN3005/GR5005\n| Lab - Week 01 - 27 and 29 January 2020" +author: "USE YOUR NAME HERE" +output: pdf_document +fontsize: 12pt +--- + +```{r setup, include = FALSE} + +knitr::opts_chunk$set(echo = TRUE) +``` + + +# Introduction to R, RStudio, and R Markdown + +All lab and homework assignments in this course will be distributed as R Markdown files. You can think of R Markdown files as text documents that also feature portions of R code in specially designated areas called "chunks." R Markdown documents can be "knit" into other document types, such as an HTML or PDF file. During the knitting process, the R code within the R Markdown document is executed and both text and code output is woven together (knitted) to make a final document. This is incredibly useful for our course purposes since you will be able to write both R code and text in response to assignment prompts and generate a nicely formatted PDF file as your final product for submission. + +This lab is meant to reinforce some basic concepts in R and demonstrate how you use R Markdown documents. + + +## Exercise 1: Code Chunks and Simple Calculations + +A primary difference between R Markdown files and regular R scripts is that in R Markdown files, the R code itself is confined to what are known as code chunks. Code chunks are created by entering three back ticks, followed by an "r" in braces, and another three back ticks. Within this code chunk, you can write normal R code. Within a code chunk, you can run code line by line, as you would with any R script, or you can run the entire chunk of code with the "Run Current Chunk" button at the right of the chunk (green "play button"). + +To get familiar with coding within R Markdown files, first, add the numbers 3 and 7 using R code in the chunk below. Next, put a new line in the chunk that multiplies the numbers 5 and 6. Make sure you can get R output running the code line by line and as an entire chunk. + +```{r} + +``` + +Next, create a vector named `x` that contains the numbers 1, 5, and 9. Remember that you can create vectors using the `c()` function. Note that if you simply assign a vector to `x`, there will be no immediate output. In order to see the values contained within `x`, you'll have to type `x` on a separate line of the chunk. Make sure you do that as well. + +```{r} + +``` + +Now, assign `x` the values of 1 through 10 using the colon operator (`:`) which will create an integer series between a starting and ending value. Type `x` again to confirm that the vector `x` has taken on a new set of values. + +```{r} + +``` + +Using an R operation, return the cubed values of every element in `x`. + +```{r} + +``` + +Generate a variable `y` that is equal to the sum of all elements in `x`. Show the value of `y`. + +```{r} + +``` + +Make a vector called `panda_name` with two text elements. The first element should read "Ailuropoda". The second element should read "melanoleuca". + +```{r} + +``` + +Use bracket subsetting (`[ ]`) to return only the second element of `panda_name`. + +```{r} + +``` + + +## Exercise 2: Examining Working Directories + +In R scripts or R Markdown files, the working directory describes where on your computer R is "looking" to find and save files. Consequently, R will usually be trying to retrieve files from and save files into your working directory unless you specify other file locations within function calls. + +Because we always have to be mindful of our working directory when using R, it will benefit you to organize your course files in a very specific structure. More specifically, it probably makes sense to have something like a "Statistics for Ecology and Evolution" folder on the computer you plan to use for all class-related work. Within this folder, you should have, among others, `homework`, `lab`, and `data` folders to hold relevant files. This will make your scripting more consistent throughout the semester since you'll be using similar filepaths the whole time. Note that you can create new file folders from your operating system itself (i.e., "Finder" on Mac operating systems) or via the file browser in RStudio. + +To get your current working directory location, use the function `getwd()`. + +```{r} + +``` + +Your working directory should be identical to the location of this R Markdown file on your computer. Assuming this R Markdown file is located within your `lab` folder, this means your working directory should also be the `lab` folder. Therefore, R will assume by default that all files you reference within the script are located in your working directory unless you specifically state otherwise through the use of appropriate filepaths. When referencing external files in other folders, you'll need to be sure to input the correct filepath such that R knows where to look for those files. The concept of directory structure and filepaths should make more sense following the next exercise. + +With a typical R script, we can change the working directory with the function `setwd()` (short for "set working directory"). Unfortunately, modifying working directories is a bit more complicated with R Markdown files. For our purposes, it will be much easier to situate data and other files you may want to reference in your R Markdown script in a consistent location rather than altering your working directory. + + +## Exercise 3: Importing Data + +Often, we'll want to import external data into R. There are a number of functions that can be used for this purpose, but for files containing comma separated values (CSVs), `read.csv()` is an easy option. If you're unfamiliar with CSV files, they're a file type that serve similar purposes as XLS or XLSX files (and they can also be opened with Microsoft Excel), but they're also much simpler than Excel files. The primary argument needed for the `read.csv()` function is the filepath to the relevant file, input as a character string. For example, `read.csv("path/to/my_file.csv")` would read in a file called `my_file.csv` located in this particular filepath (but not assign it to an object). + +The file `ebay_snake_captures.csv` can be found on CourseWorks or on the course [GitHub repository](https://github.com/eveskew/stats_eco_evo_spring2020). Download this file, move it into the folder called `data` that is in your course file folder, and import it into R, using the `read.csv()` function. Note you'll probably need to manually move `ebay_snake_captures.csv` into your `data` folder depending on where the file downloads to your computer by default. + +Once you import the data, can you report the column names of the resulting data frame? What functions might be used to inspect the data? + +```{r} + +``` + + +## Exercise 4: Knit To PDF + +Now, we'd like to output the work we've done into a PDF file. Thankfully, all you need to do is click the "Knit" button in RStudio. Before you do so, make sure to change the `author` field at the top of this document to your name. + +RStudio should pop up a preview of the resulting PDF file, but a copy will also be saved to your computer. Can you find it? Where was the file saved? What was it named? + +The R code `knitr::opts_chunk$set(echo = TRUE)` appears in the first code chunk of this document. Do you see it in your resulting PDF output? Can you figure out why or why not? diff --git a/lecture/lecture_week_01.R b/lecture/lecture_week_01.R new file mode 100644 index 0000000..77577bf --- /dev/null +++ b/lecture/lecture_week_01.R @@ -0,0 +1,336 @@ + + +# Explain relationship between R and RStudio, scripts, etc. + +#========================================================== + + +# Basic mathematical operations in R + +# All work pretty much as you'd expect, given the core +# mathematical operators + +2+2 # addition + +2-1 # subtraction + +2*3 # multiplication + +2/4 # division + +2^4 # exponents + +#========================================================== + + +# Assignment + +# In R, as in programming languages generally, we often +# want to "assign" certain values to objects in order to +# reference those objects (and associated values) later + +# In R, you can assign using the "=" operator + +x = 2 + 2 + +# In other words, you're saying that "x" should equal +# what is placed on the right side of the equals sign + +x # then type the name of the object to see the value(s) + +# You can also see existing objects in your "Environment" +# tab within RStudio + +# Alternatively, and preferably, you can use the "<-" +# operator for assignment + +y <- 3 + 3 + +y + +x <- y + +# This is clearer than "x = y", so the "<-" operator is +# often preferred. With the "<-" operator, we see +# intuitively that "x" takes on the value of "y". +# In contrast, the "=" operator may seem ambiguous + +x # "x" now has the value previously assigned to "y" + +y # "y" retains its value + +#========================================================== + + +# Commenting + +# You can use the "#" character to write portions of your +# script that will NOT be interpreted as code, and +# therefore effectively ignored. You should comment +# liberally to remind yourself of code purpose and to +# document your ideas for any other readers + +#========================================================== + + +# Get and set working directories + +getwd() + +# Anything followed by parentheses are functions in R. +# A function usually takes a series of arguments and +# performs some operation, but sometimes they don't need +# any arguments. Function names often state pretty +# clearly what they do + +setwd() + +# Why didn't this work? + +# Get help in R using the "?" operator preceding the +# function in question + +?setwd() + +# The "Help" tab in RStudio can also be navigated +# interactively + +setwd("~/Desktop/") + +?list.files() + +list.files() # lists all files in the working directory + +setwd("~/Documents/Statistics and Coding/stats_eco_evo_spring2020/") + +list.files() + +#========================================================== + + +# Vectors (with numeric data types) + +# A vector in R is a collection of values of the same data +# type + +c(5.9, 7.2, 6.3) + +weights <- c(5.9, 7.2, 6.3) + +weights + +# What is "c()" doing? + +?c() # concatenates values into a vector or list + +sum(weights) # sum all values in "weights" + +mean(weights) # find the mean of all values in "weights" + +# Note that many operations in R, including some +# mathematical operations, are vectorized, meaning that the +# operation indicated will be performed on EACH element +# of a vector + +weights + 10 # all elements of "weights" with 10 added + +#========================================================== + + +# Vectors (with character data types) + +# We are not limited to using numbers. R also supports +# character data (i.e., text) + +frogs <- + c("Hyla avivoca", "Hyla gratiosa", "Hyla versicolor") + +frogs + +sum(frogs) +# this function doesn't make any sense with character data + +mean(frogs) +# this function doesn't make any sense with character data + +#========================================================== + + +# Key functions to inspect objects in R + +str(weights) # structure of the data + +summary(weights) # summary of the data + +View(weights) # view the data in a new RStudio tab + +# Note, you can't use "View()" in an R Markdown document + +str(frogs) + +summary(frogs) + +View(frogs) + +#========================================================== + + +# Sequences + +# Use the ":" operator to generate a sequence of +# consecutive integers + +1:3 # generates a sequence 1 through 3 + +1:10 # generates a sequence 1 through 10 + +1:(3^6) # generates a sequence 1 through 729 (i.e., 3^6) + +# Use "seq()" to generate more complex sequences + +?seq() + +# This function takes more than one argument, as many +# functions do + +seq(from = 1, to = 3, by = 1) +# within functions, argument values must be assigned +# with the "=" operator + +seq(from = 1, to = 4, by = 1.5) + +my.seq <- seq(from = 0, to = 100, by = 0.5) + +str(my.seq) + +summary(my.seq) + +length(my.seq) # how many values are in the object? + +View(my.seq) + +#========================================================== + + +# Indexing + +# Indexing is the process of subsetting your data to +# obtain only specific values. In R, we index by using +# bracket notation + +my.seq[1] # returns the first value of the vector + +my.seq[1, 2] +# invalid because the vector only has one dimension + +my.seq[c(1, 2)] # returns the first and second values + +my.seq[1:20] # returns the first twenty values + +my.seq[101] + +my.seq[500] # invalid index value; only 201 "my.seq" values + +my.short.seq <- my.seq[1:101] + +#========================================================== + + +# What happens if we try to combine data types into +# one vector? + +mashup <- c(16.9, "Hyla gratiosa") + +str(mashup) # the number has been coerced into a character + +# This can cause confusion and frustration down the road +# if you're unaware this is what's happening + +summary(mashup) + +# Vectors can only support one data type + +#========================================================== + + +# Data frames + +# Data frames can hold collections of different data types + +d <- data.frame(frogs, weights, stringsAsFactors = FALSE) + +str(d) + +summary(d) + +View(d) + +# Inspect and change column names in a data frame + +?colnames() + +colnames(d) + +colnames(d)[1] + +colnames(d)[1] <- "species" + +colnames(d) + +View(d) + +# You can refer to specific columns within a data frame +# using the "$" operator + +d$species + +d$weights + +# Indexing with data frames + +d[1, 1] +# refers to row and column values, separated by a comma + +d[1, 2] # first row, second column + +d[1, 3] # first row, third column (doesn't exist) + +d[1, ] +# if you leave the value blank for a given dimension, +# you'll get all available values + +d[ , 2] # all rows, second column + +d[3, 2] # third row, second column + +# Another way to do this is to call the second column +# directly and then index + +d$weights[3] + +# What if we want to add data to the data frame? + +frogs <- c(frogs, "Hyla chrysoscelis") + +frogs + +d <- data.frame(frogs, weights, stringsAsFactors = FALSE) +# Nope! Every column of the data frame must have the same +# number of observations + +weights <- c(weights, NA) +# add a value to the "weights" vector indicating +# missingness + +mean(weights) +# our weights vector now has NA values, so mean() +# returns NA + +# We need an additional argument telling "mean()" to +# remove NA values when doing its calculation + +mean(weights, na.rm = TRUE) + +d <- data.frame(frogs, weights) + +View(d)