Question: In R! Write a function named month_convert(x, from_lang, to_lang) that will convert month names from one language to another. The function will accept three arguments:

In R!

Write a function named month_convert(x, from_lang, to_lang) that will convert month names from one language to another. The function will accept three arguments: x, which is a factor with month information; the language from which we are tranlating from_lang; and the language to which we are translating to_lang.

For example:

x <- factor(c("March","March","February","June"))

month_convert(x,"English","Spanish")

will output:

[1] marzo marzo debrero junio

Levels: febrero junio marzo

If the input contains a value that is not a real month, then it will be replaced with NA

x <- factor(c("March","March","February","June","Jaly"))

month_convert(x, "English", "Spanish")

[1] marzo marzo febrero junio

Levels: febrero junio marzo

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!