vendredi 4 octobre 2019

How to convert a string to a number in R

I am using R to do some analysis, however, as it is will known first I have to clean my data.

I have columns consisting of 1-5 number and "Not Applicable". I already removed the NA using na.omit() and now I want to replace "Not Applicable" with number 6.

I have done this as per below:

sNPS <- na.omit(sNPS)
dim(sNPS)

sNPS$OpeningTimes <- if(sNPS$Open == "Not applicable",6)

When I am doing the above code the below is being prompted:

Error: unexpected ',' in "sNPS$Open<- if(sNPS$Open== "Not applicable"

Can someone help how cna I tackle this please?

Aucun commentaire:

Enregistrer un commentaire