---
tags: allometry, Rscript
---
# exploring allometry relationships
this is the code for subsetting means for each individual for nights and days.
Takehome is that there is no relationship
```
night <- with(all_animals ,all_animals[ hour( StartTime ) >= 0 & hour( StartTime ) < 6 , ] )
meanEE <- night %>% group_by(Animal_ID) %>% summarise(EE = mean(EE)) %>% select(EE)
```
next i need a vector of weights from the animals that is in the same order.
```
animalweight <- night %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
```
now plotting
```
plot(log(meanEE[[1]]) ~ log(animalweight[[1]]), main = "EE 0000-0600", ylab="EE", xlab="weight")
abline(lm(log(meanEE[[1]]) ~ log(animalweight[[1]])))
```
regression
```
summary(lm(log(meanEE[[1]]) ~ log(animalweight[[1]]))
```
#### All together
```
night <- with(all_animals ,all_animals[ hour( StartTime ) >= 0 & hour( StartTime ) < 6 , ] )
day <- with(all_animals ,all_animals[ hour( StartTime ) >= 13 & hour( StartTime ) < 19 , ] )
animalweight <- night %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
# this is the code to change - when changing the thing you want to plot.
meanVCO2 <- day %>% group_by(Animal_ID) %>% summarise(VCO2 = mean(VO2)) %>% select(VCO2)
plot(meanVCO2[[1]] ~ animalweight[[1]], main = "meanVCO2 1300-1900", ylab="meanVCO2", xlab="weight")
abline(lm(meanVCO2[[1]] ~ animalweight[[1]]))
summary(lm(meanVCO2[[1]] ~ animalweight[[1]]))
```
night




day



