mardi 4 avril 2017

Working with dummy variable to extract information from another variable

I am posting here because I am unsure how to search for the solution.

I have a data set with 18 variables, and I am working with r. I have created many new dummy variables. For example, one of my dummy variables is named "let". If "let" is = to 1, I want it to extract information from another variable called "Decision_date" which is in this format:

2003-07-09 00:00:00.0

I am very new to this and think that I have to use the ifelse function? I have something like this:

infringements$let_date <- ifelse(infringements$let == 1
           yes = infringements$Decision_date, no = FALSE)

I know that this is wrong, but can anyone help me?

To say it in other words: I want a finished data set where it would look like this:

let            let_date
1              2003-07-09 00:00:00.0
1              2004-07-09 00:00:00.0
1              2005-07-09 00:00:00.0

Any help would be appreciated. Thanks very much.

Aucun commentaire:

Enregistrer un commentaire