jeudi 31 mars 2016

If Else in R, if product ID is X then change Product Name

I am trying to figure our what is it working and the other why is not working for me. At the moment I have a list of shops I use and I need to change the naming every time, I have decided to go by the product_id which never change but my code is not working product_id <- vector()

This one is not working:

product_name[product_id == '40600000003'] <- 'my cool store']

but this one, do work

product_name[product_name == 'my#cool@Store'] <- 'my cool store'

now, I am not sure what am I doing wrong, I tried to do if

  if (product_id == '40600000003') {product_name = 'my cool shop'

}

Your help will be much welcomed I have a list of 15 shops that I need to change the naming as they arrive in the wrong format from the api connection.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire