I am trying to write a simple if statement. I have data like this
Number Description Type
1 Snow in road "weather"
2 Ice on Roof "Weather"
3 Dog bite "Not Classified"
Basically trying to do this:
if(data$type == "Not Classified") {sapply(data$description, colcheck)} else "Not Classified"
The desired result would be for the function that I have stated previously in my code to run on row 3, the "Not Classified"
row. For some reason, I keep getting the same error:
"the condition has length > 1 and only the first element will be used".
colcheck
is a function created previously. I have tried IfElse
, taking out the else
at the end, and adding a do
in front of the function, but they aren't working. I am trying to filter the data to only use the function on the rows where type == "Not classified"
. Thank you