##
## 1. simple example
##
fakeF1 <- data.frame(yr=c('1948', '1947 (1)'),
q1=c('1,234', ''), duh=rep(NA, 2),
dol=c('$1,234', ''),
pct=c('1%', '2%'))
nF1 <- asNumericDF(fakeF1)
nF1. <- data.frame(yr=asNumericChar(fakeF1$yr),
q1=asNumericChar(fakeF1$q1),
dol=asNumericChar(fakeF1$dol),
pct=c(.01, .02))
nF1c <- data.frame(yr=1948:1947, q1=c(1234, NA),
dol=c(1234, NA), pct=c(.01, .02))
stopifnot(
all.equal(nF1, nF1.)
)
stopifnot(
all.equal(nF1., nF1c)
)
##
## 2. orderBy=1:2
##
nF. <- asNumericDF(fakeF1, orderBy=1:2)
stopifnot(
all.equal(nF., nF1c[2:1,])
)
Run the code above in your browser using DataLab