Hi! I'm very new to R and I had a quick question and I was hoping someone may know the answer I am trying to create a new column in a data set and I was hoping to look within a different column. For example, if the already existing Date column has "a certain date", I want "Yes" to be printed in my new column. This is what I have so far but I'm getting an error message that the object Date is not found. I've tried a couple of different things but to no avail. Thank you in advance if anyone is able to provide any advice or direction!
You get a boolean variable that can easily be reused for other operations.
EDIT: and I forgot to explain the problem: indeed Date is not found, because it is a column of the data frame, you need to indicate that to R with my_data_inflow$Date. It is different if you use the tidyverse function mutate(), perhaps that's what you had in mind:
But that is because mutate() and other dplyr functions use a particular method to allow calling column names with the data frame implicitly declared. This only works inside those functions.
Wow, thank you so much for your help @AlexisW! I did that and it's almost perfect however it prints yes for each row in the new Month column even though the date isn't "7-Oct-19" each time. Do I maybe have the Date column assigned to the wrong variable type? For some reason, the if_else command isn't reading into the existing Date column. Do you have a suggestion for this? Thank you for your thoughtful and descriptive answer above, I really appreciate it!
Oh no, I totally missed that, sorry! No it totally makes sense: we test if "7-Oct-19" is in the column, yes it is always somewhere in the column! So the result is always yes.
The correct question to ask is whether that particular row is == "7-Oct-19":