jeudi 6 août 2015

How to merge names using R?

I have a dataframe (day) with columns that looks like this:

AM Monday
PM Monday
AM Tuesday
PM Tuesday
...

I am trying to create another column that looks like this:

Mon_AM
Mon_PM
Tue_AM
Tue_PM
...

Essentially, I am trying to merge the two columns together into one. I tried using an if statement like this:

if (day$time == 'AM' & day$day == 'Monday') {
day$session == 'Mon_AM'
} 

but this seems kind of bulky, and it didn't seem to be working.
Does anyone know another way to do this? Looked into the merge command but was confused. Any ideas?

Aucun commentaire:

Enregistrer un commentaire