library(readr)
## Warning: package 'readr' was built under R version 4.0.4
library(tidyr)
## Warning: package 'tidyr' was built under R version 4.0.4
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.0.4
library(Hmisc)
## Warning: package 'Hmisc' was built under R version 4.0.5
## Loading required package: lattice
## Loading required package: survival
## Warning: package 'survival' was built under R version 4.0.4
## Loading required package: Formula
## Warning: package 'Formula' was built under R version 4.0.3
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library(plyr)
## Warning: package 'plyr' was built under R version 4.0.4
## 
## Attaching package: 'plyr'
## The following objects are masked from 'package:Hmisc':
## 
##     is.discrete, summarize
library(RColorBrewer)
## Warning: package 'RColorBrewer' was built under R version 4.0.3
library(reshape2)
## Warning: package 'reshape2' was built under R version 4.0.4
## 
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
## 
##     smiths
library(PupillometryR)
## Warning: package 'PupillometryR' was built under R version 4.0.4
## Loading required package: dplyr
## Warning: package 'dplyr' was built under R version 4.0.5
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## The following objects are masked from 'package:Hmisc':
## 
##     src, summarize
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
## Loading required package: rlang
## Warning: package 'rlang' was built under R version 4.0.4
library(nlme)
## Warning: package 'nlme' was built under R version 4.0.4
## 
## Attaching package: 'nlme'
## The following object is masked from 'package:dplyr':
## 
##     collapse
library(lme4)
## Warning: package 'lme4' was built under R version 4.0.4
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## Attaching package: 'lme4'
## The following object is masked from 'package:nlme':
## 
##     lmList
library(readr)
wd_rv <- read_csv("~/Proposed papers/Weed species/Muoni Weed Analysis/wd_rv.csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   season = col_character(),
##   site = col_character(),
##   sampling_time = col_double(),
##   crop = col_character(),
##   replicate = col_double(),
##   treatment_org = col_character(),
##   treatment = col_character(),
##   species_org = col_character(),
##   species = col_character(),
##   group = col_character(),
##   weed_density = col_double()
## )
names(wd_rv)
##  [1] "season"        "site"          "sampling_time" "crop"         
##  [5] "replicate"     "treatment_org" "treatment"     "species_org"  
##  [9] "species"       "group"         "weed_density"
attach(wd_rv)

species=as.factor(species)
treatment=as.factor(treatment)
crop=as.factor(crop)
group=as.factor(group)
dominant<-subset(wd_rv,group=="Group A")
attach(dominant)
## The following objects are masked _by_ .GlobalEnv:
## 
##     crop, group, species, treatment
## The following objects are masked from wd_rv:
## 
##     crop, group, replicate, sampling_time, season, site, species,
##     species_org, treatment, treatment_org, weed_density
LM <- lm(weed_density ~ sampling_time+season+treatment_org+species_org,data = dominant)
summary(LM)
## 
## Call:
## lm(formula = weed_density ~ sampling_time + season + treatment_org + 
##     species_org, data = dominant)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -36.986 -11.941  -4.812   3.133 311.593 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                   14.8873     2.7467   5.420
## sampling_time                                 -2.5786     0.7845  -3.287
## season2010/11                                 -2.5583     1.9044  -1.343
## season2011/12                                -11.1174     1.6150  -6.884
## season2012/13                                -12.5722     1.9044  -6.602
## treatment_orgAtrazine+Glyphosate              -1.5635     2.1731  -0.719
## treatment_orgAtrazine+Glyphosate+Metalachlor  -2.7698     2.1731  -1.275
## treatment_orgGlyphosate                       -0.4841     2.1731  -0.223
## treatment_orgManual weeding                    4.5397     2.1731   2.089
## treatment_orgParaquat                          2.0595     2.1731   0.948
## species_orggalinsoga parviflora                9.7831     1.7743   5.514
## species_orgleucas martinicensis                5.1720     1.7743   2.915
## species_orgricardia scabra                    20.1376     1.7743  11.349
##                                              Pr(>|t|)    
## (Intercept)                                  6.93e-08 ***
## sampling_time                                 0.00104 ** 
## season2010/11                                 0.17935    
## season2011/12                                8.54e-12 ***
## season2012/13                                5.62e-11 ***
## treatment_orgAtrazine+Glyphosate              0.47196    
## treatment_orgAtrazine+Glyphosate+Metalachlor  0.20265    
## treatment_orgGlyphosate                       0.82374    
## treatment_orgManual weeding                   0.03687 *  
## treatment_orgParaquat                         0.34342    
## species_orggalinsoga parviflora              4.13e-08 ***
## species_orgleucas martinicensis               0.00361 ** 
## species_orgricardia scabra                    < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 24.39 on 1499 degrees of freedom
## Multiple R-squared:  0.134,  Adjusted R-squared:  0.1271 
## F-statistic: 19.34 on 12 and 1499 DF,  p-value: < 2.2e-16
par(mfrow = c(2,2))
plot(LM)

#lmm6 <- lme(weed_density ~ season+sampling_time+treatment_org+sampling_time:treatment_org,
#random = ~1|replicate, method = "ML",data = dominant)

#summary(lmm6)

Graphical Presentation

library(readr)
group_a <- read_csv("~/Proposed papers/Weed species/Muoni Weed Analysis/group_a.csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   season = col_character(),
##   site = col_character(),
##   sampling_time = col_double(),
##   crop = col_character(),
##   replicate = col_double(),
##   treatment_org = col_character(),
##   treatment = col_character(),
##   species_org = col_character(),
##   species = col_character(),
##   group = col_character(),
##   weed_density = col_double()
## )
attach(group_a)
## The following objects are masked _by_ .GlobalEnv:
## 
##     crop, group, species, treatment
## The following objects are masked from dominant:
## 
##     crop, group, replicate, sampling_time, season, site, species,
##     species_org, treatment, treatment_org, weed_density
## The following objects are masked from wd_rv:
## 
##     crop, group, replicate, sampling_time, season, site, species,
##     species_org, treatment, treatment_org, weed_density
group_b <- read_csv("~/Proposed papers/Weed species/Muoni Weed Analysis/group_b.csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   season = col_character(),
##   site = col_character(),
##   sampling_time = col_double(),
##   crop = col_character(),
##   replicate = col_double(),
##   treatment_org = col_character(),
##   treatment = col_character(),
##   species_org = col_character(),
##   species = col_character(),
##   group = col_character(),
##   weed_density = col_double()
## )
attach(group_b)
## The following objects are masked _by_ .GlobalEnv:
## 
##     crop, group, species, treatment
## The following objects are masked from group_a:
## 
##     crop, group, replicate, sampling_time, season, site, species,
##     species_org, treatment, treatment_org, weed_density
## The following objects are masked from dominant:
## 
##     crop, group, replicate, sampling_time, season, site, species,
##     species_org, treatment, treatment_org, weed_density
## The following objects are masked from wd_rv:
## 
##     crop, group, replicate, sampling_time, season, site, species,
##     species_org, treatment, treatment_org, weed_density
group_c <- read_csv("~/Proposed papers/Weed species/Muoni Weed Analysis/group_c.csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   season = col_character(),
##   site = col_character(),
##   sampling_time = col_double(),
##   crop = col_character(),
##   replicate = col_double(),
##   treatment_org = col_character(),
##   treatment = col_character(),
##   species_org = col_character(),
##   species = col_character(),
##   group = col_character(),
##   weed_density = col_double()
## )
attach(group_c)
## The following objects are masked _by_ .GlobalEnv:
## 
##     crop, group, species, treatment
## The following objects are masked from group_b:
## 
##     crop, group, replicate, sampling_time, season, site, species,
##     species_org, treatment, treatment_org, weed_density
## The following objects are masked from group_a:
## 
##     crop, group, replicate, sampling_time, season, site, species,
##     species_org, treatment, treatment_org, weed_density
## The following objects are masked from dominant:
## 
##     crop, group, replicate, sampling_time, season, site, species,
##     species_org, treatment, treatment_org, weed_density
## The following objects are masked from wd_rv:
## 
##     crop, group, replicate, sampling_time, season, site, species,
##     species_org, treatment, treatment_org, weed_density
species=as.factor(species)
treatment=as.factor(treatment)
crop=as.factor(crop)
ggplot(data =wd_rv, 
       aes(x = treatment, 
           y = log(weed_density), 
           fill = treatment,
           colour =treatment)) +
  geom_violin(alpha = 1, 
              position = position_nudge(x = .2, y = 0)) +
  stat_ydensity(geom = "bar", colour = "white", fill = "white", width = .8,
                position = position_nudge(x = -.05, y = 0)) +
  geom_jitter( width = .15, 
               size = .5, 
               alpha = 0.5) +
  geom_boxplot(width = 0.5, 
               outlier.shape = NA, 
               alpha = 0.8,
               color = "black",
               notch=TRUE) +
  theme_bw() +
  theme(legend.position = "none") +
  scale_color_brewer(palette = "Spectral") +
  scale_fill_brewer(palette = "Spectral") +
  theme(axis.text.x  = element_text(angle=75, vjust=0.5, size=10))+
  facet_wrap(~ group)
## Warning: Removed 5779 rows containing non-finite values (stat_ydensity).

## Warning: Removed 5779 rows containing non-finite values (stat_ydensity).
## Warning: Removed 5779 rows containing non-finite values (stat_boxplot).

Group A

ggplot(data =group_a, 
       aes(x = treatment, 
           y = log(weed_density), 
           fill = treatment,
           colour =treatment)) +
  geom_violin(alpha = 1, 
              position = position_nudge(x = .2, y = 0)) +
  stat_ydensity(geom = "bar", colour = "white", fill = "white", width = .8,
                position = position_nudge(x = -.05, y = 0)) +
  geom_jitter( width = .15, 
               size = .5, 
               alpha = 0.5) +
  geom_boxplot(width = 0.5, 
               outlier.shape = NA, 
               alpha = 0.8,
               color = "black",
               notch=TRUE) +
  theme_bw() +
  theme(legend.position = "none") +
  scale_color_brewer(palette = "Spectral") +
  scale_fill_brewer(palette = "Spectral") 
## Warning: Removed 554 rows containing non-finite values (stat_ydensity).

## Warning: Removed 554 rows containing non-finite values (stat_ydensity).
## Warning: Removed 554 rows containing non-finite values (stat_boxplot).

facet wrap by treatment

ggplot(data =group_a, 
       aes(x = species, 
           y = log(weed_density), 
           fill = species,
           colour =species)) +
  geom_violin(alpha = 1, 
              position = position_nudge(x = .2, y = 0)) +
  stat_ydensity(geom = "bar", colour = "white", fill = "white", width = .8,
                position = position_nudge(x = -.05, y = 0)) +
  geom_jitter( width = .15, 
               size = .5, 
               alpha = 0.5) +
  geom_boxplot(width = 0.5, 
               outlier.shape = NA, 
               alpha = 0.8,
               color = "black",
               notch=TRUE) +
  theme_bw() +
  theme(legend.position = "none") +
  scale_color_brewer(palette = "Spectral") +
  scale_fill_brewer(palette = "Spectral")+
  facet_wrap(~treatment,ncol=3)
## Warning: Removed 554 rows containing non-finite values (stat_ydensity).

## Warning: Removed 554 rows containing non-finite values (stat_ydensity).
## Warning: Removed 554 rows containing non-finite values (stat_boxplot).

facet wrap by crop

ggplot(data =group_a, 
       aes(x = species, 
           y = log(weed_density), 
           fill = species,
           colour =species)) +
  geom_violin(alpha = 1, 
              position = position_nudge(x = .2, y = 0)) +
  stat_ydensity(geom = "bar", colour = "white", fill = "white", width = .8,
                position = position_nudge(x = -.05, y = 0)) +
  geom_jitter( width = .15, 
               size = .5, 
               alpha = 0.5) +
  geom_boxplot(width = 0.5, 
               outlier.shape = NA, 
               alpha = 0.8,
               color = "black",
               notch=TRUE) +
  theme_bw() +
  theme(legend.position = "none") +
  scale_color_brewer(palette = "Spectral") +
  scale_fill_brewer(palette = "Spectral")+
  facet_wrap(~crop)
## Warning: Removed 554 rows containing non-finite values (stat_ydensity).

## Warning: Removed 554 rows containing non-finite values (stat_ydensity).
## Warning: Removed 554 rows containing non-finite values (stat_boxplot).

facet wrap site

ggplot(data =group_a, 
       aes(x = species, 
           y = log(weed_density), 
           fill = species,
           colour =species)) +
  geom_violin(alpha = 1, 
              position = position_nudge(x = .2, y = 0)) +
  stat_ydensity(geom = "bar", colour = "white", fill = "white", width = .8,
                position = position_nudge(x = -.05, y = 0)) +
  geom_jitter( width = .15, 
               size = .5, 
               alpha = 0.5) +
  geom_boxplot(width = 0.5, 
               outlier.shape = NA, 
               alpha = 0.8,
               color = "black",
               notch=TRUE) +
  theme_bw() +
  theme(legend.position = "none") +
  scale_color_brewer(palette = "Spectral") +
  scale_fill_brewer(palette = "Spectral")+
  facet_wrap(~site)
## Warning: Removed 554 rows containing non-finite values (stat_ydensity).

## Warning: Removed 554 rows containing non-finite values (stat_ydensity).
## Warning: Removed 554 rows containing non-finite values (stat_boxplot).
## notch went outside hinges. Try setting notch=FALSE.

exploring by season

ggplot(data =group_a, 
       aes(x = species, 
           y = log(weed_density), 
           fill = species,
           colour =species)) +
  geom_violin(alpha = 1, 
              position = position_nudge(x = .2, y = 0)) +
  stat_ydensity(geom = "bar", colour = "white", fill = "white", width = .8,
                position = position_nudge(x = -.05, y = 0)) +
  geom_jitter( width = .15, 
               size = .5, 
               alpha = 0.5) +
  geom_boxplot(width = 0.5, 
               outlier.shape = NA, 
               alpha = 0.8,
               color = "black",
               notch=TRUE) +
  theme_bw() +
  theme(legend.position = "none") +
  scale_color_brewer(palette = "Spectral") +
  scale_fill_brewer(palette = "Spectral")+
  facet_wrap(~season)
## Warning: Removed 554 rows containing non-finite values (stat_ydensity).

## Warning: Removed 554 rows containing non-finite values (stat_ydensity).
## Warning: Removed 554 rows containing non-finite values (stat_boxplot).
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.

Group B

ggplot(data =group_b, 
       aes(x = treatment, 
           y = log(weed_density), 
           fill = treatment,
           colour =treatment)) +
  geom_violin(alpha = 1, 
              position = position_nudge(x = .2, y = 0)) +
  stat_ydensity(geom = "bar", colour = "white", fill = "white", width = .8,
                position = position_nudge(x = -.05, y = 0)) +
  geom_jitter( width = .15, 
               size = .5, 
               alpha = 0.5) +
  geom_boxplot(width = 0.5, 
               outlier.shape = NA, 
               alpha = 0.8,
               color = "black",
               notch=TRUE) +
  theme_bw() +
  theme(legend.position = "none") +
  scale_color_brewer(palette = "Spectral") +
  scale_fill_brewer(palette = "Spectral") 
## Warning: Removed 1680 rows containing non-finite values (stat_ydensity).

## Warning: Removed 1680 rows containing non-finite values (stat_ydensity).
## Warning: Removed 1680 rows containing non-finite values (stat_boxplot).

ggplot(data =group_b, 
       aes(x = species, 
           y = log(weed_density), 
           fill = species,
           colour =species)) +
  geom_violin(alpha = 1, 
              position = position_nudge(x = .2, y = 0)) +
  stat_ydensity(geom = "bar", colour = "white", fill = "white", width = .8,
                position = position_nudge(x = -.05, y = 0)) +
  geom_jitter( width = .15, 
               size = .5, 
               alpha = 0.5) +
  geom_boxplot(width = 0.5, 
               outlier.shape = NA, 
               alpha = 0.8,
               color = "black",
               notch=TRUE) +
  theme_bw() +
  theme(legend.position = "none") +
  scale_color_brewer(palette = "Spectral") +
  scale_fill_brewer(palette = "Spectral")+
  facet_wrap(~treatment,ncol=3)
## Warning: Removed 1680 rows containing non-finite values (stat_ydensity).

## Warning: Removed 1680 rows containing non-finite values (stat_ydensity).
## Warning: Removed 1680 rows containing non-finite values (stat_boxplot).
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.

Group C

ggplot(data =group_c, 
       aes(x = treatment, 
           y = log(weed_density), 
           fill = treatment,
           colour =treatment)) +
  geom_violin(alpha = 1, 
              position = position_nudge(x = .2, y = 0)) +
  stat_ydensity(geom = "bar", colour = "white", fill = "white", width = .8,
                position = position_nudge(x = -.05, y = 0)) +
  geom_jitter( width = .15, 
               size = .5, 
               alpha = 0.5) +
  geom_boxplot(width = 0.5, 
               outlier.shape = NA, 
               alpha = 0.8,
               color = "black",
               notch=TRUE) +
  theme_bw() +
  theme(legend.position = "none") +
  scale_color_brewer(palette = "Spectral") +
  scale_fill_brewer(palette = "Spectral") 
## Warning: Removed 3545 rows containing non-finite values (stat_ydensity).

## Warning: Removed 3545 rows containing non-finite values (stat_ydensity).
## Warning: Removed 3545 rows containing non-finite values (stat_boxplot).

m_group_a<- lm(weed_density ~ sampling_time+season+treatment_org+species_org,data = group_a)
summary(m_group_a)
## 
## Call:
## lm(formula = weed_density ~ sampling_time + season + treatment_org + 
##     species_org, data = group_a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -36.986 -11.941  -4.812   3.133 311.593 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                   14.8873     2.7467   5.420
## sampling_time                                 -2.5786     0.7845  -3.287
## season2010/11                                 -2.5583     1.9044  -1.343
## season2011/12                                -11.1174     1.6150  -6.884
## season2012/13                                -12.5722     1.9044  -6.602
## treatment_orgAtrazine+Glyphosate              -1.5635     2.1731  -0.719
## treatment_orgAtrazine+Glyphosate+Metalachlor  -2.7698     2.1731  -1.275
## treatment_orgGlyphosate                       -0.4841     2.1731  -0.223
## treatment_orgManual weeding                    4.5397     2.1731   2.089
## treatment_orgParaquat                          2.0595     2.1731   0.948
## species_orggalinsoga parviflora                9.7831     1.7743   5.514
## species_orgleucas martinicensis                5.1720     1.7743   2.915
## species_orgricardia scabra                    20.1376     1.7743  11.349
##                                              Pr(>|t|)    
## (Intercept)                                  6.93e-08 ***
## sampling_time                                 0.00104 ** 
## season2010/11                                 0.17935    
## season2011/12                                8.54e-12 ***
## season2012/13                                5.62e-11 ***
## treatment_orgAtrazine+Glyphosate              0.47196    
## treatment_orgAtrazine+Glyphosate+Metalachlor  0.20265    
## treatment_orgGlyphosate                       0.82374    
## treatment_orgManual weeding                   0.03687 *  
## treatment_orgParaquat                         0.34342    
## species_orggalinsoga parviflora              4.13e-08 ***
## species_orgleucas martinicensis               0.00361 ** 
## species_orgricardia scabra                    < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 24.39 on 1499 degrees of freedom
## Multiple R-squared:  0.134,  Adjusted R-squared:  0.1271 
## F-statistic: 19.34 on 12 and 1499 DF,  p-value: < 2.2e-16