SciencesPo (version 1.3.8)

destring: Factors to numeric

Description

Converts factors to numeric like in Stata.

Usage

destring(x)

Arguments

x
A factor whose levels will be converted.

encoding

UTF-8

Examples

Run this code
mylevels <- c('Strongly Disagree', 'Disagree', 'Neither', 'Agree', 'Strongly Agree')

myvar <- factor(sample(mylevels[1:5], 10, replace=TRUE))

unclass(myvar) # testing order

destring(myvar)

Run the code above in your browser using DataLab