Question

In R! Write a function named month_convert(x, from_lang, to_lang) that will convert month names from one...

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 Levels: febrero junio marzo 2 I have uploaded a file called “month_names.txt” on CCLE which has the month names in several European languages. Use month_names <- read.delim("month_names.txt", encoding="UTF-8", row.names=1) to import the file.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Add the following to your existing functions.php file:

function ra_change_translate_text( $translated_text ) {
    if ( $translated_text == 'January' ) {
        $translated_text = 'Jan11';
    }
    return $translated_text;
}
add_filter( 'gettext', 'ra_change_translate_text', 20 );

If you want to change multiple strings, use this function instead:

function ra_change_translate_text_multiple( $translated ) {
    $text = array(
        'January' => 'Jan11',
        'February' => 'Feb22',
        'March' => 'Mar33',
    );
    $translated = str_ireplace(  array_keys($text),  $text,  $translated );
    return $translated;
}
add_filter( 'gettext', 'ra_change_translate_text_multiple', 20 );
Add a comment
Know the answer?
Add Answer to:
In R! Write a function named month_convert(x, from_lang, to_lang) that will convert month names from one...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT