Hi all,
In my df I have a longitude column in which all values must be negative. As I read in my data I make a few adjustments to the df using the read_csv()
call and I pipe(%>%)
a few checks/modifications to it. I would like to check that all values are negative in a column I created and if they're positive to multiply them by -1 else keep them as is by the following:
df <- ifelse(BestLong > 0, BestLong * -1, BestLong)
But I get this error: Error in ifelse(., BestLong > 0, BestLong * -1, BestLong) : unused argument (BestLong)
I'm not sure why because right before I make this call I've called on the sister columnBestLat
without getting an error. This is the full read_csv
call that I make when attempting to bring in a tidier data set:
sightings <- read_csv('OM_SightingsData.csv', na = c("", "NA", "<Null>")) %>%
drop_na(Time1) %>%
mutate(SightDateTime = mdy_hms(paste(SightDate, Time1), tz = "US/Pacific"),
BestLat = coalesce(ActLat, Lat),
BestLong = coalesce(ActLong, Long)) %>%
# Drop sightings with no location data
mutate_at(vars(BestLat, BestLong), na_if, y = 0) %>%
drop_na(BestLat) %>%
ifelse(BestLong > 0, BestLong * -1, BestLong)
View(sightings)
The code above works perfectly without the ifelse
call and I'm not sure why. Any help would be greatly appreciated!
Thank you in advance