Basic Analysis

The following code was used to analyze temperature data from 31 locations on the Dutch coastline. We start by reading in the data:

Temperature = read.csv("Temperature.csv")

Followed by calculating the means and standard deviations for temperature and salinity.

mean(Temperature$Temperature,na.rm=TRUE)
## [1] 12.20743
mean(Temperature$Salinity,na.rm=TRUE)
## [1] 29.70221
sd(Temperature$Temperature,na.rm=TRUE)
## [1] 5.412521
sd(Temperature$Salinity, na.rm=TRUE)
## [1] 5.421593

From a data analysis point, I noticed how similar the standard deviations are, despite the subject of measurement being quite different. As a layman in this field, I am going to assume this is a coincidence until told otherwise.

Temp/Salinity by Year and by Station

I then used the tapply function to determine the mean temperatures and salinities 1)as measured at each station 2)over a series of years. I’ll show you the code for each of them, but only the results for one (so you can see an example of what the output looks like).

tapply(Temperature$Temperature, Temperature$Station, mean, na.rm = TRUE)
##     DANT     DREI       G6     GROO     HAMM     HANS     HUIB     LODS 
## 12.05908 12.77160 10.66570 12.25853 12.50000 13.54894 11.85353 12.61192 
##     MARS      N02      N10      N20      N70      R03      R50      R70 
## 12.39607 11.37433 12.45878 12.19753 12.14789 12.80000 13.94911 13.98022 
##     SOEL     T004     T010     T100     T135     T175     T235     VLIS 
## 13.21203 11.28425 12.37517 11.94766 11.75512 11.55431 11.32355 12.79292 
##      W02      W20      W70     WISS     ZIJP     ZUID 
## 10.51829 11.87937 12.18243 12.45090 12.55904 11.83928
tapply(Temperature$Temperature, Temperature$Year, mean, na.rm = TRUE)
tapply(Temperature$Salinity, Temperature$Station, mean, na.rm = TRUE)
tapply(Temperature$Salinity, Temperature$Year, mean, na.rm = TRUE)

Aggregate

The reason why you did not need to see the output of the other three lines is that the aggregate code below will show you all four tapply functions, combined:

YearAndSite = aggregate(Temperature[,14:15], 
                        list(Temperature$Year, Temperature$Station), 
                        mean, na.rm=TRUE)

We can then make the aggregate chart into its own csv file:

write.csv(YearAndSite, file = "YearAndSite.csv")

Tables

Lastly, some quick analysis where the first code tell us how many entries per stations there are, the second tells us how many entries per year there are, and the third gives us a full breakdown based on both:

table(Temperature$Station)
## 
## DANT DREI   G6 GROO HAMM HANS HUIB LODS MARS  N02  N10  N20  N70  R03  R50  R70 
##  300  293  278  296  295  309  296  294  296  402  665  266  268  161  106  106 
## SOEL T004 T010 T100 T135 T175 T235 VLIS  W02  W20  W70 WISS ZIJP ZUID 
##  295  339  261  258  259  258  258  421  272  191  190  296  296  303
table(Temperature$Year)
## 
## 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 
##  367  392  438  436  590  590  583  636  608  570  563  568  545  550  540  552
table(Temperature$Station, Temperature$Year)
##       
##        1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003
##   DANT   12   12   18   19   17   13   19   20   22   21   22   21   21   21
##   DREI   13   13   13   13   19   21   20   20   21   20   20   20   20   20
##   G6     12   16   20   17   21   24   23   28   23   21   13   12   12   12
##   GROO   12   12   18   19   17   12   18   19   21   21   21   21   21   21
##   HAMM   13   13   13   13   20   21   20   21   20   20   21   20   20   20
##   HANS   13   16   13   13   21   24   19   19   18   18   29   29   20   19
##   HUIB   12   11   18   19   17   12   19   19   21   21   21   22   21   21
##   LODS   13   13   13   13   20   21   20   21   20   20   20   20   20   20
##   MARS   12   12   18   18   16   12   19   19   22   21   21   21   21   21
##   N02    12   17   20   17   27   29   31   40   37   29   24   27   23   23
##   N10    47   45   40   46   53   56   43   52   45   43   36   37   30   31
##   N20    12   12   11   11   18   18   18   18   18   18   19   19   19   19
##   N70    12   11   11   11   18   18   18   18   18   19   18   20   20   19
##   R03     0    5    7    7   13   17   17   23   20    9    8    7    7    7
##   R50     0    5    7    7   10    7    7    7    7    7    7    7    7    7
##   R70     0    5    7    7   10    7    7    7    7    7    7    7    7    7
##   SOEL   13   13   13   12   20   22   20   21   20   20   20   20   20   20
##   T004   12   14   20   16   26   27   27   33   28   20   19   19   19   20
##   T010   12   10   11   10   18   18   18   18   18   18   18   18   18   19
##   T100   12   10   10   10   18   18   18   18   18   18   18   18   18   18
##   T135   12   10   10   10   18   18   18   18   18   18   17   19   18   19
##   T175   12   10   10   10   18   18   18   18   18   18   18   18   18   18
##   T235   12   10   10   10   18   18   18   18   18   18   18   18   18   18
##   VLIS   14   18   21   24   35   36   22   23   22   22   30   31   30   32
##   W02    12   17   20   17   21   23   23   28   23   16   12   12   12   12
##   W20    12   12   11   11   12   12   12   12   12   13   12   12   12   12
##   W70    12   12   11   11   12   12   12   12   12   12   12   12   12   12
##   WISS   13   13   13   13   20   21   20   22   20   20   21   20   20   20
##   ZIJP   13   13   13   13   20   21   20   23   20   20   20   20   20   20
##   ZUID   11   12   18   19   17   14   19   21   21   22   21   21   21   22
##       
##        2004 2005
##   DANT   21   21
##   DREI   20   20
##   G6     12   12
##   GROO   21   22
##   HAMM   20   20
##   HANS   19   19
##   HUIB   21   21
##   LODS   20   20
##   MARS   21   22
##   N02    22   24
##   N10    29   32
##   N20    17   19
##   N70    18   19
##   R03     7    7
##   R50     7    7
##   R70     7    7
##   SOEL   20   21
##   T004   19   20
##   T010   18   19
##   T100   18   18
##   T135   18   18
##   T175   18   18
##   T235   18   18
##   VLIS   31   30
##   W02    12   12
##   W20    12   12
##   W70    12   12
##   WISS   20   20
##   ZIJP   20   20
##   ZUID   22   22