ggplot is printing entire function output, please ignore what’s not needed!

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.4     ✓ stringr 1.4.0
## ✓ readr   2.1.1     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
##################################################
# FUNCTION: p_data or plant data
# input: randomly simulated data
# output: simulated plant height data, in a long format for analysis
#------------------------------------------------- 
p_data <- function(size=30, mean1=20, mean2=30, mean3=40, sd13=2,sd2=3) {
  dataFrame <- data.frame(lowN=rnorm(size, mean=mean1,sd=sd13),
                          medN=rnorm(size, mean=mean2, sd=sd2),
                          highN=rnorm(size, mean=mean3, sd=sd13)) # creating the data frames
                          
  dataFrame <- pivot_longer(dataFrame, cols=lowN:highN,
                            names_to = "trtmnt",
                            values_to = "height",
                            values_drop_na = T)
                            # changing orientation
  s1 <- summary(aov(height~trtmnt, data=dataFrame))
  p1 <- ggplot(data=dataFrame, aes(x=trtmnt, y=height)) + geom_point()
  p2 <- ggplot(data=dataFrame, aes(x=trtmnt, y=height)) + geom_boxplot()
  return(c(dataFrame,plot(p1),s1,plot(p2)))
}
# plotting the graph and output, added a boxplot which shows the data better
p_data()

## $trtmnt
##  [1] "lowN"  "medN"  "highN" "lowN"  "medN"  "highN" "lowN"  "medN"  "highN"
## [10] "lowN"  "medN"  "highN" "lowN"  "medN"  "highN" "lowN"  "medN"  "highN"
## [19] "lowN"  "medN"  "highN" "lowN"  "medN"  "highN" "lowN"  "medN"  "highN"
## [28] "lowN"  "medN"  "highN" "lowN"  "medN"  "highN" "lowN"  "medN"  "highN"
## [37] "lowN"  "medN"  "highN" "lowN"  "medN"  "highN" "lowN"  "medN"  "highN"
## [46] "lowN"  "medN"  "highN" "lowN"  "medN"  "highN" "lowN"  "medN"  "highN"
## [55] "lowN"  "medN"  "highN" "lowN"  "medN"  "highN" "lowN"  "medN"  "highN"
## [64] "lowN"  "medN"  "highN" "lowN"  "medN"  "highN" "lowN"  "medN"  "highN"
## [73] "lowN"  "medN"  "highN" "lowN"  "medN"  "highN" "lowN"  "medN"  "highN"
## [82] "lowN"  "medN"  "highN" "lowN"  "medN"  "highN" "lowN"  "medN"  "highN"
## 
## $height
##  [1] 20.88602 30.03792 41.36338 20.32973 26.79656 38.27195 21.68797 30.43452
##  [9] 40.47790 20.42961 33.03116 39.49667 21.49114 25.12161 40.60940 20.58948
## [17] 35.32824 40.21053 21.78411 28.66885 38.53359 21.81345 34.21070 37.23968
## [25] 17.09858 32.07797 40.16988 21.55874 34.21410 40.41877 24.59348 32.03358
## [33] 41.52235 20.83479 36.39295 41.86584 16.17099 30.65231 41.76730 19.81665
## [41] 31.79555 38.69733 22.72046 27.95089 43.97845 21.29391 32.60059 38.90921
## [49] 22.10342 31.22940 42.13530 19.88802 32.66961 38.84360 19.19522 29.98095
## [57] 37.63337 18.88655 34.54289 39.43325 16.98896 26.38165 41.54648 18.69483
## [65] 28.23647 39.30330 22.36766 27.76945 39.84707 18.11721 29.68208 39.93397
## [73] 21.63514 27.40878 39.63990 20.48419 26.31947 39.85326 19.27039 27.32757
## [81] 43.67746 20.43973 36.78144 40.32388 19.45899 26.95220 40.57907 20.67696
## [89] 26.38716 38.49644
## 
## $data
## # A tibble: 90 × 2
##    trtmnt height
##    <chr>   <dbl>
##  1 lowN     20.9
##  2 medN     30.0
##  3 highN    41.4
##  4 lowN     20.3
##  5 medN     26.8
##  6 highN    38.3
##  7 lowN     21.7
##  8 medN     30.4
##  9 highN    40.5
## 10 lowN     20.4
## # … with 80 more rows
## 
## $layers
## $layers[[1]]
## geom_point: na.rm = FALSE
## stat_identity: na.rm = FALSE
## position_identity 
## 
## 
## $scales
## <ggproto object: Class ScalesList, gg>
##     add: function
##     clone: function
##     find: function
##     get_scales: function
##     has_scale: function
##     input: function
##     n: function
##     non_position_scales: function
##     scales: list
##     super:  <ggproto object: Class ScalesList, gg>
## 
## $mapping
## Aesthetic mapping: 
## * `x` -> `trtmnt`
## * `y` -> `height`
## 
## $theme
## list()
## 
## $coordinates
## <ggproto object: Class CoordCartesian, Coord, gg>
##     aspect: function
##     backtransform_range: function
##     clip: on
##     default: TRUE
##     distance: function
##     expand: TRUE
##     is_free: function
##     is_linear: function
##     labels: function
##     limits: list
##     modify_scales: function
##     range: function
##     render_axis_h: function
##     render_axis_v: function
##     render_bg: function
##     render_fg: function
##     setup_data: function
##     setup_layout: function
##     setup_panel_guides: function
##     setup_panel_params: function
##     setup_params: function
##     train_panel_guides: function
##     transform: function
##     super:  <ggproto object: Class CoordCartesian, Coord, gg>
## 
## $facet
## <ggproto object: Class FacetNull, Facet, gg>
##     compute_layout: function
##     draw_back: function
##     draw_front: function
##     draw_labels: function
##     draw_panels: function
##     finish_data: function
##     init_scales: function
##     map_data: function
##     params: list
##     setup_data: function
##     setup_params: function
##     shrink: TRUE
##     train_scales: function
##     vars: function
##     super:  <ggproto object: Class FacetNull, Facet, gg>
## 
## $plot_env
## <environment: 0x1068499e0>
## 
## $labels
## $labels$x
## [1] "trtmnt"
## 
## $labels$y
## [1] "height"
## 
## 
## [[12]]
##             Df Sum Sq Mean Sq F value    Pr(>F)    
## trtmnt       2 5870.7 2935.35  528.61 < 2.2e-16 ***
## Residuals   87  483.1    5.55                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $data
## # A tibble: 90 × 2
##    trtmnt height
##    <chr>   <dbl>
##  1 lowN     20.9
##  2 medN     30.0
##  3 highN    41.4
##  4 lowN     20.3
##  5 medN     26.8
##  6 highN    38.3
##  7 lowN     21.7
##  8 medN     30.4
##  9 highN    40.5
## 10 lowN     20.4
## # … with 80 more rows
## 
## $layers
## $layers[[1]]
## geom_boxplot: outlier.colour = NULL, outlier.fill = NULL, outlier.shape = 19, outlier.size = 1.5, outlier.stroke = 0.5, outlier.alpha = NULL, notch = FALSE, notchwidth = 0.5, varwidth = FALSE, na.rm = FALSE, orientation = NA
## stat_boxplot: na.rm = FALSE, orientation = NA
## position_dodge2 
## 
## 
## $scales
## <ggproto object: Class ScalesList, gg>
##     add: function
##     clone: function
##     find: function
##     get_scales: function
##     has_scale: function
##     input: function
##     n: function
##     non_position_scales: function
##     scales: list
##     super:  <ggproto object: Class ScalesList, gg>
## 
## $mapping
## Aesthetic mapping: 
## * `x` -> `trtmnt`
## * `y` -> `height`
## 
## $theme
## list()
## 
## $coordinates
## <ggproto object: Class CoordCartesian, Coord, gg>
##     aspect: function
##     backtransform_range: function
##     clip: on
##     default: TRUE
##     distance: function
##     expand: TRUE
##     is_free: function
##     is_linear: function
##     labels: function
##     limits: list
##     modify_scales: function
##     range: function
##     render_axis_h: function
##     render_axis_v: function
##     render_bg: function
##     render_fg: function
##     setup_data: function
##     setup_layout: function
##     setup_panel_guides: function
##     setup_panel_params: function
##     setup_params: function
##     train_panel_guides: function
##     transform: function
##     super:  <ggproto object: Class CoordCartesian, Coord, gg>
## 
## $facet
## <ggproto object: Class FacetNull, Facet, gg>
##     compute_layout: function
##     draw_back: function
##     draw_front: function
##     draw_labels: function
##     draw_panels: function
##     finish_data: function
##     init_scales: function
##     map_data: function
##     params: list
##     setup_data: function
##     setup_params: function
##     shrink: TRUE
##     train_scales: function
##     vars: function
##     super:  <ggproto object: Class FacetNull, Facet, gg>
## 
## $plot_env
## <environment: 0x1068499e0>
## 
## $labels
## $labels$x
## [1] "trtmnt"
## 
## $labels$y
## [1] "height"