Can anyone tell me what I'm doing wrong here. Trying to use a combined if_else statement in R::dplyr based on the values of two columns. Code below doesn't work - only gives X+90?
Link to csv: https://www.dropbox.com/s/nmyiwdazsvs7wko/VideoTrack_ed.csv?dl=0
library(readr)
library(dplyr)
VidTrack <- read_csv("VideoTrack_ed.csv")
x <- VidTrack$course
Perp <- if_else(("R" %in% VidTrack$Side & VidTrack$course<270), x+90, x-270,
if_else(("L" %in% VidTrack$Side & VidTrack$course<90), x+270,
x-90))
Perp_df <- as.data.frame(Perp)
In Excel this would be; =IF(AND(H2="R",Z2<270),Z2+90,IF(AND(H2="R",Z2>=270),Z2+270,IF(AND(H2="L",Z2<90),Z2+270,Z2-90)))
Column H = VidTrack$Side
Column Z = VidTrack$course
Aucun commentaire:
Enregistrer un commentaire