1. Import dataset: dummydata

(on left: locate correct working directory, click “dummydata.xlsx” and say “import” when promted). OR, as I did here: save the dummydata tab from the excel file as .csv IN YOUR WORKING DIRECTORY (find out what your current working directory is: getwd() ; if you need to change the location: top bar -> session -> set working directory -> browse location [and put it where your R project & script are located])

#dummydata <- read.csv("dummydata.csv")
library(readxl)
dummydata <- read_excel("dummydata.xlsx")
str(dummydata)
## tibble [4 × 6] (S3: tbl_df/tbl/data.frame)
##  $ ClimbS1: num [1:4] 6.36 3.25 12.74 14.13
##  $ ClimbS2: num [1:4] 35.8 34.5 36.4 50.5
##  $ LocS1  : num [1:4] 23.3 20.4 16.4 27
##  $ LocS2  : num [1:4] 31.2 35.8 35.8 25.1
##  $ RestS1 : num [1:4] 70.4 76.4 70.9 58.9
##  $ RestS2 : num [1:4] 33 29.7 27.9 24.4

Other libraries

library(tidyr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)

2. Checking normality

Plotting athe histograms

hist(dummydata$ClimbS1) #ok

hist(dummydata$ClimbS2) # skewed

hist(dummydata$RestS1) #no!!

hist(dummydata$RestS2) #  ok

hist(dummydata$LocS1) # skewed

hist(dummydata$LocS2) # not ok •    shapiro.test(dummydata$locosp1)

## Testing for normality ### Shapiro Wilks test

Please note: “non-significant” means data is normally distributed

shapiro.test(dummydata$ClimbS1) #ns
## 
##  Shapiro-Wilk normality test
## 
## data:  dummydata$ClimbS1
## W = 0.90832, p-value = 0.4736
shapiro.test(dummydata$ClimbS2) # SIG
## 
##  Shapiro-Wilk normality test
## 
## data:  dummydata$ClimbS2
## W = 0.72664, p-value = 0.02276
shapiro.test(dummydata$RestS1) #ns
## 
##  Shapiro-Wilk normality test
## 
## data:  dummydata$RestS1
## W = 0.90439, p-value = 0.4532
shapiro.test(dummydata$RestS2) # ns
## 
##  Shapiro-Wilk normality test
## 
## data:  dummydata$RestS2
## W = 0.99914, p-value = 0.9976
shapiro.test(dummydata$LocS1) # ns
## 
##  Shapiro-Wilk normality test
## 
## data:  dummydata$LocS1
## W = 0.99877, p-value = 0.9963
shapiro.test(dummydata$LocS2) #ns
## 
##  Shapiro-Wilk normality test
## 
## data:  dummydata$LocS2
## W = 0.85675, p-value = 0.2488

Transform the SIG variable

Arcsine transformation: appropriate for % data

dummydata$ClimbS2arc=asin(sqrt(dummydata$ClimbS2/100))

and re-run the above test & hist.

hist(dummydata$ClimbS2arc) # not great

shapiro.test(dummydata$ClimbS2arc) # still SIG
## 
##  Shapiro-Wilk normality test
## 
## data:  dummydata$ClimbS2arc
## W = 0.72949, p-value = 0.02434
str(dummydata)
## tibble [4 × 7] (S3: tbl_df/tbl/data.frame)
##  $ ClimbS1   : num [1:4] 6.36 3.25 12.74 14.13
##  $ ClimbS2   : num [1:4] 35.8 34.5 36.4 50.5
##  $ LocS1     : num [1:4] 23.3 20.4 16.4 27
##  $ LocS2     : num [1:4] 31.2 35.8 35.8 25.1
##  $ RestS1    : num [1:4] 70.4 76.4 70.9 58.9
##  $ RestS2    : num [1:4] 33 29.7 27.9 24.4
##  $ ClimbS2arc: num [1:4] 0.641 0.628 0.647 0.79

Conclusion: transformation didn not improve the outcome.

3. Statistal comparisons

Independent t-test: if normally distributed

Locomotion

t.test(dummydata$LocS1,dummydata$LocS2)
## 
##  Welch Two Sample t-test
## 
## data:  dummydata$LocS1 and dummydata$LocS2
## t = -3.0196, df = 5.9177, p-value = 0.02381
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -18.547777  -1.912213
## sample estimates:
## mean of x mean of y 
##  21.76301  31.99300

Conclusion: Species 2 spent significantly more time moving.

Resting

t.test(dummydata$RestS1,dummydata$RestS2)
## 
##  Welch Two Sample t-test
## 
## data:  dummydata$RestS1 and dummydata$RestS2
## t = 9.8779, df = 4.3444, p-value = 0.0003873
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  29.37293 51.37775
## sample estimates:
## mean of x mean of y 
##  69.11497  28.73963

Conclusion: Species 1 spent significantly more time resting.

Mann Whitney Test

For non-normal data. This means, this test needs to be done if AT LEAST ONE of the datasets you want to compare is not normally distributed:

wilcox.test(dummydata$ClimbS1,dummydata$ClimbS2)
## 
##  Wilcoxon rank sum exact test
## 
## data:  dummydata$ClimbS1 and dummydata$ClimbS2
## W = 0, p-value = 0.02857
## alternative hypothesis: true location shift is not equal to 0

Conclusion: Species 2 spent significantly more time climbing.

# PLOT need to rearrange into “longer format”, want colums Behav, Species, Observation. Needs multiple steps. MAY BE EASIER TO MAIPULATE IN EXCEL (see below whatthe table should look like)

For the brave, who’d like to do it ALL in R (which will require a lot of adjustments regarding your column names):

df_L <- pivot_longer (data = dummydata, cols = c(1:6), names_to = "ID", values_to = "Duration")

str(df_L)
## tibble [24 × 3] (S3: tbl_df/tbl/data.frame)
##  $ ClimbS2arc: num [1:24] 0.641 0.641 0.641 0.641 0.641 ...
##  $ ID        : chr [1:24] "ClimbS1" "ClimbS2" "LocS1" "LocS2" ...
##  $ Duration  : num [1:24] 6.36 35.77 23.29 31.23 70.35 ...
df_Lb <- df_L %>% 
  mutate(Species = case_when(grepl("S1", ID)  ~ "Species1",
    grepl("S2", ID) ~ "Species2"
    ))  %>% 
  mutate(Behaviour = case_when(grepl("Climb", ID)  ~ "Climbing",
    grepl("Loc", ID) ~ "Locomotion",
    grepl("Rest", ID) ~ "Resting",
    )) %>%
  select(., -ID)

THIS is how the table in excel should look like for the code to work:

## tibble [24 × 4] (S3: tbl_df/tbl/data.frame)
##  $ ClimbS2arc: num [1:24] 0.641 0.641 0.641 0.641 0.641 ...
##  $ Duration  : num [1:24] 6.36 35.77 23.29 31.23 70.35 ...
##  $ Species   : chr [1:24] "Species1" "Species2" "Species1" "Species2" ...
##  $ Behaviour : chr [1:24] "Climbing" "Climbing" "Locomotion" "Locomotion" ...
df_Lb
ggplot(df_Lb, aes(x=Behaviour, y=Duration, fill=Species)) + 
    geom_boxplot()

#second alternative
library(ggpubr)
ggboxplot(df_Lb,"Behaviour", "Duration", color = "Species",
          palette = c("#FC4E07", "#00AFBB"))