I know I'm probably just not seeing it, but I can't seem to get this to work or understand why it's doing this on each outcome. What I have is a data frame with several columns that are named percent. So ex. percentone percenttwo...etc. There's quite a few and I need to do several calculations in later steps on each one separately. They are all class numeric. What I would like the outcome to be is a logical, showing list of all the values from each row in the data frame. I did this step on a previous column in a different dataset and it worked just fine, so I'm not sure what I'm doing wrong. Overall I'm trying to identify the values that are greater than 100. I'm using RStudio 2021.09.0 Build 351, R version 4.1.1 (2021-08-10), dplyr 1.0.7. Thank you for any help.
mydf <- data.frame(
"percentone" = as.numeric(c(65, 75, 102)),
"percenttwo" = as.numeric(c(103, 104, 89))
)
mydf
# percentone percenttwo
# 1 65 103
# 2 75 104
# 3 102 89
newmydf <- mydf %>%
mutate(x = percentone > 100)
newmydf
# below is what it should do
# percentone percenttwo x
# 1 65 103 FALSE
# 2 75 104 FALSE
# 3 102 89 TRUE
# but when I set variable to replace it below
percent <- "percentone"
newmydf <- mydf %>%
mutate(x = percent > 100 )
newmydf
# percentone percenttwo x
# 1 65 103 TRUE
# 2 75 104 TRUE
# 3 102 89 TRUE
newmydf <- mydf %>%
mutate(x = paste(percent) > 100 )
newmydf
# percentone percenttwo x
# 1 65 103 TRUE
# 2 75 104 TRUE
# 3 102 89 TRUE
newmydf <- mydf %>%
mutate(x = case_when(
percent > 100 ~ TRUE
))
newmydf
# percentone percenttwo x
# 1 65 103 TRUE
# 2 75 104 TRUE
# 3 102 89 TRUE
newmydf <- mydf$percent > 100
newmydf
# logical(0)
# So what I'd like is an output that gives me class logical with FALSE FALSE TRUE