gsr: Global Search and Replace

Description Usage Arguments Value Author(s) References Examples

Description

The function performs search and replace.

Usage

1

Arguments

file

is a vector or a data.frame.

search

is the item to be replaced.

replace

is the new item or value to be attributed.

Value

An object of the same type as file.

Author(s)

Daniel Marcelino

References

http://danielmarcelino.com/SciencePo

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# First example: generate some raw data

data <- data.frame( 
	i=i <- rep(1, len = 100),
	t=t<-sample(c('2008', '2012'), 100, replace=TRUE),
	p=p <- sample(LETTERS[1:3], 100, replace=TRUE),
	j=j <- sample(letters[1:13], 100, replace=TRUE) )

data$ide <-gsr(data$p, 
	c('A', 'B'), 
	c('Left', 'Centre'))

print(data)

  

SciencePo documentation built on May 2, 2019, 5:53 p.m.