Learn R Programming

SciencesPo (version 0.11.21)

vreplace: Replace elements

Description

Replace many elements in a vector at the same time

Usage

vreplace(vector, from, to)

Arguments

vector
A vector
from
From what
to
To what

encoding

UTF-8

Examples

Run this code
countries <- c('United States', 'Ecuador', 'Russia', 'Russia', 'Ecuador')
vreplace(vec=countries, from=c('Ecuador','Russia','United States'), 
to=c('ECU', 'RUS', 'USA'))

Run the code above in your browser using DataLab