I'm Trying to add a column to my data set in R with this formula:
Bauer_Units_2020_1$FB_Score <- (((Bauer_Units - 24) * 4) + +
if(Launch_Angle >= 50) {
Launch_Angle - 20} +
if(Launch_Angle <= 4) {
(Launch_Angle * -1) + 10} +
if(Launch_Angle > 4 & Launch_Angle <= 23) {
(Launch_Angle * -1) + 10} +
if(Launch_Angle > 23 & Launch_Angle <= 35) {
Launch_Angle - 26} +
if(Launch_Angle > 35 & Launch_Angle <= 49) {
Launch_Angle - 20})
and getting the error message:
Error in +if (Launch_Angle >= 50) { : invalid argument to unary operator
In addition: Warning message:
In if (Launch_Angle >= 50) { :
the condition has length > 1 and only the first element will be used
I've researched this message but am confused on how it applies to my data frame which looks like this
player_name pitch_type Bauer_Units Velo Spin_Rate Launch_Angle
<chr> <chr> <dbl> <dbl> <dbl> <dbl>
1 Shaun Anderson FT 30.4 94.5 2874 27
2 Trevor Bauer FF 29.8 94.6 2817 36
3 Lucas Sims FF 29.9 93.6 2801 47
4 Dillon Maples FF 30.8 91.3 2792 12
5 Luke Bard FF 29.1 94.6 2747 45
6 Corbin Burnes FF 27.6 96.9 2676 58
7 Nick Burdi FF 27.1 98.3 2665 40
8 Jose Leclerc FF 28.2 94.5 2660 18
9 Carl Edwards Jr. FF 28.3 93.4 2646 13
10 Michael Lorenzen FF 26.9 98.4 2644 32
I've made sure there are no NA's or missing values as well
Aucun commentaire:
Enregistrer un commentaire