Graphing acacia ants.qmd (solution)

Exercise

An experiment in Kenya has been exploring the influence of large herbivores on plants.

Check to see if ACACIA_DREPANOLOBIUM_SURVEY.txt is in your workspace. If not, download it. Read it into R using the following command:

acacia <- read_tsv("ACACIA_DREPANOLOBIUM_SURVEY.txt", na = c("dead"))
  1. Make a scatter plot with CIRC on the x axis and AXIS1 (the maximum canopy width) on the y axis. Label the x axis “Circumference” and the y axis “Canopy Diameter”.
  2. The same plot as (1), but with both axes scaled logarithmically (using scale_x_log10 and scale_y_log10).
  3. The same plot as (1), but with points colored based on the ANT column (the species of ant symbiont living with the acacia)
  4. The same plot as (3), but instead of different colors show different species of ant (values of ANT) each in a separate subplot.
  5. The same plot as (4) but add a simple model of the data by adding geom_smooth.
Output solution

Code solution for Graphing Acacia and Ants

Warning: One or more parsing issues, call `problems()` on your data frame for details,
e.g.:
  dat <- vroom(...)
  problems(dat)
Rows: 157 Columns: 15
── Column specification ────────────────────────────────────────────────────────
Delimiter: "\t"
chr  (4): SITE, TREATMENT, PLOT, ANT
dbl (11): SURVEY, YEAR, BLOCK, ID, HEIGHT, AXIS1, AXIS2, CIRC, FLOWERS, BUDS...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

1

Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).

2

Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).

3

Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).

4

Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).

5

`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Warning: Removed 4 rows containing non-finite outside the scale range
(`stat_smooth()`).
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: span too small.  fewer data values than degrees of freedom.
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: at 9.975
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: radius 0.000625
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: all data on boundary of neighborhood. make span bigger
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: pseudoinverse used at 9.975
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: neighborhood radius 0.025
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: reciprocal condition number 1
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: at 15.025
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: radius 0.000625
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: all data on boundary of neighborhood. make span bigger
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: There are other near singularities as well. 0.000625
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: zero-width neighborhood. make span bigger
Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
: zero-width neighborhood. make span bigger
Warning: Failed to fit group -1.
Caused by error in `predLoess()`:
! NA/NaN/Inf in foreign function call (arg 5)
Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).