I've a data set with two columns shown below:
x1 | x2 ontime |ontime Alate |ontime ontime |Blate Alate |Blate
my desired output is
x12 ontime Alate Blate Alate
I was trying to write multiple if loops:
`df$x12<- if(df$x1=='Alate' & df$x2=='ontime')
{
print('Alate')
}else if(df$x1=='ontime' & df$x2=='Blate')
{
print('Blate')
}else if(df$x1=='Alate' & df$x2=='Blate')
{
print('Alate')
}else
print('ontime')`
but it is not working it just prints "ontime" for all the rows with a warning: the condition has length > 1 and only the first element will be used
Aucun commentaire:
Enregistrer un commentaire