This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

plot(cars)

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.

#Install
install.packages("tidyverse")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/sys_3.4.3.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/bit_4.6.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/ps_1.9.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/farver_2.1.2.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/labeling_0.4.3.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/RColorBrewer_1.1-3.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/viridisLite_0.4.2.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/askpass_1.2.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/bit64_4.6.0-1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/processx_3.8.6.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/backports_1.5.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/generics_0.1.4.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/blob_1.2.4.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/DBI_1.2.3.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/tidyselect_1.2.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/withr_3.0.2.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/data.table_1.17.8.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/gtable_0.3.6.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/isoband_0.2.7.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/S7_0.2.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/scales_1.4.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/gargle_1.6.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/uuid_1.2-1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/curl_7.0.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/ids_1.0.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/rematch2_2.1.2.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/openssl_2.3.3.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/timechange_0.3.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/systemfonts_1.2.3.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/textshaping_1.0.3.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/clipr_0.8.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/vroom_1.6.6.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/tzdb_0.5.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/callr_3.7.6.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/selectr_0.4-2.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/broom_1.0.10.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/conflicted_1.2.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/dbplyr_2.5.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/dplyr_1.1.4.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/dtplyr_1.3.2.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/forcats_1.0.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/ggplot2_4.0.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/googledrive_2.1.2.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/googlesheets4_1.1.2.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/haven_2.5.5.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/httr_1.4.7.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/lubridate_1.9.4.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/modelr_0.1.11.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/purrr_1.1.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/ragg_1.5.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/readr_2.1.5.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/reprex_2.1.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/rstudioapi_0.17.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/rvest_1.0.5.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/tidyr_1.3.1.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/xml2_1.4.0.zip'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/tidyverse_2.0.0.zip'
package ‘sys’ successfully unpacked and MD5 sums checked
package ‘bit’ successfully unpacked and MD5 sums checked
package ‘ps’ successfully unpacked and MD5 sums checked
package ‘farver’ successfully unpacked and MD5 sums checked
package ‘labeling’ successfully unpacked and MD5 sums checked
package ‘RColorBrewer’ successfully unpacked and MD5 sums checked
package ‘viridisLite’ successfully unpacked and MD5 sums checked
package ‘askpass’ successfully unpacked and MD5 sums checked
package ‘bit64’ successfully unpacked and MD5 sums checked
package ‘processx’ successfully unpacked and MD5 sums checked
package ‘backports’ successfully unpacked and MD5 sums checked
package ‘generics’ successfully unpacked and MD5 sums checked
package ‘blob’ successfully unpacked and MD5 sums checked
package ‘DBI’ successfully unpacked and MD5 sums checked
package ‘tidyselect’ successfully unpacked and MD5 sums checked
package ‘withr’ successfully unpacked and MD5 sums checked
package ‘data.table’ successfully unpacked and MD5 sums checked
package ‘gtable’ successfully unpacked and MD5 sums checked
package ‘isoband’ successfully unpacked and MD5 sums checked
package ‘S7’ successfully unpacked and MD5 sums checked
package ‘scales’ successfully unpacked and MD5 sums checked
package ‘gargle’ successfully unpacked and MD5 sums checked
package ‘uuid’ successfully unpacked and MD5 sums checked
package ‘curl’ successfully unpacked and MD5 sums checked
package ‘ids’ successfully unpacked and MD5 sums checked
package ‘rematch2’ successfully unpacked and MD5 sums checked
package ‘openssl’ successfully unpacked and MD5 sums checked
package ‘timechange’ successfully unpacked and MD5 sums checked
package ‘systemfonts’ successfully unpacked and MD5 sums checked
package ‘textshaping’ successfully unpacked and MD5 sums checked
package ‘clipr’ successfully unpacked and MD5 sums checked
package ‘vroom’ successfully unpacked and MD5 sums checked
package ‘tzdb’ successfully unpacked and MD5 sums checked
package ‘callr’ successfully unpacked and MD5 sums checked
package ‘selectr’ successfully unpacked and MD5 sums checked
package ‘broom’ successfully unpacked and MD5 sums checked
package ‘conflicted’ successfully unpacked and MD5 sums checked
package ‘dbplyr’ successfully unpacked and MD5 sums checked
package ‘dplyr’ successfully unpacked and MD5 sums checked
package ‘dtplyr’ successfully unpacked and MD5 sums checked
package ‘forcats’ successfully unpacked and MD5 sums checked
package ‘ggplot2’ successfully unpacked and MD5 sums checked
package ‘googledrive’ successfully unpacked and MD5 sums checked
package ‘googlesheets4’ successfully unpacked and MD5 sums checked
package ‘haven’ successfully unpacked and MD5 sums checked
package ‘httr’ successfully unpacked and MD5 sums checked
package ‘lubridate’ successfully unpacked and MD5 sums checked
package ‘modelr’ successfully unpacked and MD5 sums checked
package ‘purrr’ successfully unpacked and MD5 sums checked
package ‘ragg’ successfully unpacked and MD5 sums checked
package ‘readr’ successfully unpacked and MD5 sums checked
package ‘reprex’ successfully unpacked and MD5 sums checked
package ‘rstudioapi’ successfully unpacked and MD5 sums checked
package ‘rvest’ successfully unpacked and MD5 sums checked
package ‘tidyr’ successfully unpacked and MD5 sums checked
package ‘xml2’ successfully unpacked and MD5 sums checked
package ‘tidyverse’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\abiga\AppData\Local\Temp\RtmpM9GGeb\downloaded_packages
install.packages("lme4")
#Setup
library(readxl)
library(lme4)
library(ggplot2)
RStudio.Version()
$citation
To cite RStudio in publications
use:

  Posit team (2025). RStudio:
  Integrated Development
  Environment for R. Posit
  Software, PBC, Boston, MA.
  URL http://www.posit.co/.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {RStudio: Integrated Development Environment for R},
    author = {{Posit team}},
    organization = {Posit Software, PBC},
    address = {Boston, MA},
    year = {2025},
    url = {http://www.posit.co/},
  }

$mode
[1] "desktop"

$version
[1] ‘2025.9.0.387’

$long_version
[1] "2025.09.0+387"

$release_name
[1] "Cucumberleaf Sunflower"
#Remove Missing Values
na.omit(LMM_Spreadsheet_AMS$Spot_Count)
  [1] 49 40 16 17 40 52 12 17 39 42 21 28 27 14  8 30 10 17 28 31 10 12 30 46  6 11 32
 [28] 25 11 24 33 46 15 11 38 39  9 20 41 32 10 16 29 27  6 40 27  7  8 13 41 28 12 13
 [55] 25 40 12 20 22 26 12 11 40 31 14 12 33 40 20  8 41 41 16 20 41 41 16 20 33 40 20
 [82]  8 22 36 21 29 25 30 10 14 47 30  9 13 37 30 14 11 31 22 12 20 30 40 12 19 43 30
[109] 12  8 27 42  9  8 38 32 12 12 27 31 15  8
attr(,"na.action")
[1] 12 17 45
attr(,"class")
[1] "omit"
#Practice Plot
point_graph <- ggplot(LMM_Spreadsheet_AMS, aes(x = Treatment, y = Spot_Count, color = Sex)) + geom_point(na.rm = TRUE)

point_graph

#Boxplot!
box_plot <- ggplot(LMM_Spreadsheet_AMS, aes(x = Treatment, y = Spot_Count, main = "Average PNN Count per Slice", ylab = "PNN Count")) + geom_boxplot(na.rm = TRUE)

box_plot

#simple linear regression
model <- lm(LMM_Spreadsheet_AMS$Spot_Count ~ LMM_Spreadsheet_AMS$Treatment + LMM_Spreadsheet_AMS$`Brain Region`, data = train)
Error in eval(mf, parent.frame()) : object 'train' not found
#Summary of LM
summary(model)

Call:
lm(formula = LMM_Spreadsheet_AMS$Spot_Count ~ LMM_Spreadsheet_AMS$Treatment + 
    LMM_Spreadsheet_AMS$`Brain Region`, data = LMM_Spreadsheet_AMS)

Residuals:
    Min      1Q  Median      3Q 
-13.522  -4.516  -1.237   4.797 
    Max 
 16.194 

Coefficients:
                                       Estimate
(Intercept)                             33.3780
LMM_Spreadsheet_AMS$TreatmentSaline      2.4284
LMM_Spreadsheet_AMS$`Brain Region`ACCR  -0.2843
LMM_Spreadsheet_AMS$`Brain Region`ICL  -20.7097
LMM_Spreadsheet_AMS$`Brain Region`ICR  -21.2903
                                       Std. Error
(Intercept)                                1.2729
LMM_Spreadsheet_AMS$TreatmentSaline        1.1292
LMM_Spreadsheet_AMS$`Brain Region`ACCR     1.6002
LMM_Spreadsheet_AMS$`Brain Region`ICL      1.5728
LMM_Spreadsheet_AMS$`Brain Region`ICR      1.5728
                                       t value
(Intercept)                             26.222
LMM_Spreadsheet_AMS$TreatmentSaline      2.150
LMM_Spreadsheet_AMS$`Brain Region`ACCR  -0.178
LMM_Spreadsheet_AMS$`Brain Region`ICL  -13.168
LMM_Spreadsheet_AMS$`Brain Region`ICR  -13.537
                                       Pr(>|t|)
(Intercept)                              <2e-16
LMM_Spreadsheet_AMS$TreatmentSaline      0.0336
LMM_Spreadsheet_AMS$`Brain Region`ACCR   0.8593
LMM_Spreadsheet_AMS$`Brain Region`ICL    <2e-16
LMM_Spreadsheet_AMS$`Brain Region`ICR    <2e-16
                                          
(Intercept)                            ***
LMM_Spreadsheet_AMS$TreatmentSaline    *  
LMM_Spreadsheet_AMS$`Brain Region`ACCR    
LMM_Spreadsheet_AMS$`Brain Region`ICL  ***
LMM_Spreadsheet_AMS$`Brain Region`ICR  ***
---
Signif. codes:  
  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’
  0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 6.192 on 117 degrees of freedom
  (3 observations deleted due to missingness)
Multiple R-squared:  0.7507,    Adjusted R-squared:  0.7422 
F-statistic:  88.1 on 4 and 117 DF,  p-value: < 2.2e-16
#Plot LM
ggplotRegression(lm(LMM_Spreadsheet_AMS$Treatment ~ LMM_Spreadsheet_AMS$Spot_Count))
LS0tDQp0aXRsZTogIlIgTm90ZWJvb2siDQpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sNCi0tLQ0KDQpUaGlzIGlzIGFuIFtSIE1hcmtkb3duXShodHRwOi8vcm1hcmtkb3duLnJzdHVkaW8uY29tKSBOb3RlYm9vay4gV2hlbiB5b3UgZXhlY3V0ZSBjb2RlIHdpdGhpbiB0aGUgbm90ZWJvb2ssIHRoZSByZXN1bHRzIGFwcGVhciBiZW5lYXRoIHRoZSBjb2RlLiANCg0KVHJ5IGV4ZWN1dGluZyB0aGlzIGNodW5rIGJ5IGNsaWNraW5nIHRoZSAqUnVuKiBidXR0b24gd2l0aGluIHRoZSBjaHVuayBvciBieSBwbGFjaW5nIHlvdXIgY3Vyc29yIGluc2lkZSBpdCBhbmQgcHJlc3NpbmcgKkN0cmwrU2hpZnQrRW50ZXIqLiANCg0KYGBge3J9DQpwbG90KGNhcnMpDQpgYGANCg0KQWRkIGEgbmV3IGNodW5rIGJ5IGNsaWNraW5nIHRoZSAqSW5zZXJ0IENodW5rKiBidXR0b24gb24gdGhlIHRvb2xiYXIgb3IgYnkgcHJlc3N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