05:00
Write a function that takes two vectors as arguments (inputs) and does the following:
Takes the difference of the vectors’ means. In other words, take the mean() of each input and subtract the first input’s mean() from the second input’s mean(). Make sure to handle NA values that might exist in the vectors. Name this function diff_in_means().
Bonus: (only do if you have time) add a requirement that a and b are the same length vector.
05:00
R and many other programming languages.R: while and for loopswhile loopswhile loops look as follows:while loopsfor loopsfor loops look as follows:for loopsfor loopsfor loop in a function
Basal area in square feet per acre: \[ \text{BA} = \frac{\pi}{144} \cdot \left( \frac{\text{DBH}}{2} \right)^2 = \frac{\pi}{4\cdot 144} \cdot \text{DBH}^2 \] Basal area in square meters per hectare: \[ \text{BA} = \frac{\pi}{10000} \cdot \left( \frac{\text{DBH}}{2} \right)^2 = \frac{\pi}{4\cdot 10000} \cdot \text{DBH}^2 \] Basal area is of the form:
\(\text{forester's constant} \times \text{DBH}^2\)
RWhat we want: A function that
RHow we’ll do it:
Basal area in square feet per acre: \[ \text{BA} = \frac{\pi}{144} \cdot \left( \frac{\text{DBH}}{2} \right)^2 = \frac{\pi}{4\cdot 144} \cdot \text{DBH}^2 \] Basal area in square meters per hectare: \[ \text{BA} = \frac{\pi}{10000} \cdot \left( \frac{\text{DBH}}{2} \right)^2 = \frac{\pi}{4\cdot 10000} \cdot \text{DBH}^2 \] There are 2.54 centimeters in an inch.
tidyverse