# Creating dummy variables [closed]

I have a Eurobarometer dataset and want to eventually create a logistic regression model and a linear probability model using a set of dates as the dependent variable.

However, the dates in the dataset are displayed as long descriptors such as "Sunday 21st May 2005" in a column labelled v584 .

1. How can I create a dummy variable to say 0 = before Sunday 29th May 2005, 1 = after Sunday 29th May 2005 from the dates listed?

2. And how can I include only specific date (E.g., only including the dates a week before "Sunday 29th May 2005" in 0 and only the dates a week after in 1)?

New contributor
user14031981 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Since you're using R check the lubridate package: lubridate.tidyverse.org – Erwan 2 days ago
• I think this question will be better answered in StackOverflow. – Let's try 2 days ago
• Hi, and welcome to Data Science Stack Exchange. You question, as it stands, is purely a technical one: How to perform this operation on the dataset in R. This question is in the scope of Stack Overflow, and would be better suited there. To learn more on how to use this site, please visit: datascience.stackexchange.com/tour. And of course, to ask in Stack Overflow, please visit stackoverflow.com/tour. Good luck! – Itamar Mushkin 12 hours ago

The lubridate package provides functions to easily convert character strings into dates in a sensible way. For example, the dmy function can parse strings in a variety of formats so long as the string is in the order of day-month-year. The lubridate functions handle all sorts of separators and extraneous characters.
As for your dummy variable, after you convert your v584 column into dates, just create a new column:
new_column <- as.integer(v584 > dmy("Sunday 29th May 2005"))