Translatation in R

Hi.

I have a column in a dataframe where the weekdays are written in different languages and I want to translate them to english.
My data is similiar to the following:

weekdays<-c("Monday", "Tuesday","zondag","viernes", "Friday","lunes","dinsdag", "domingo" )
  Animal<-c("Lion","Cat", "Dog", "Horse", "Bird", "Snake", "Giraf", "Mouse")
Visit_number<-c(5,6,2,0,3,8,6,1)
  
  mydata<-data.frame(Animal, weekdays,Visit_number)
 mydata
  Animal weekdays Visit_number
1   Lion   Monday            5
2    Cat  Tuesday            6
3    Dog   zondag            2
4  Horse  viernes            0
5   Bird   Friday            3
6  Snake    lunes            8
7  Giraf  dinsdag            6
8  Mouse  domingo            1

Any suggestion on how to do this?

You could make a translation vector as in the following code. I am not sure all of my translations are correct!

weekdays<-c("Monday", "Tuesday","zondag","viernes", "Friday","lunes","dinsdag", "domingo" )
Animal<-c("Lion","Cat", "Dog", "Horse", "Bird", "Snake", "Giraf", "Mouse")
Visit_number<-c(5,6,2,0,3,8,6,1)
mydata<-data.frame(Animal, weekdays,Visit_number, stringsAsFactors = FALSE)

TranslVec <- c(Monday = "Monday", Tuesday = "Tuesday", zondag = "Sunday", viernes = "Friday",
                Friday = "Friday", lunes = "Monday", dinsdag = "Tuesday", domingo = "Sunday")

mydata$EnglishWeekday <- TranslVec[mydata$weekdays]
mydata
  Animal weekdays Visit_number EnglishWeekday
1   Lion   Monday            5         Monday
2    Cat  Tuesday            6        Tuesday
3    Dog   zondag            2         Sunday
4  Horse  viernes            0         Friday
5   Bird   Friday            3         Friday
6  Snake    lunes            8         Monday
7  Giraf  dinsdag            6        Tuesday
8  Mouse  domingo            1         Sunday

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.