{
tol <- 1e-6
T
}
{
#t
#t.default
xmat <- matrix(1:4,2,2)
txmat <- t.default(xmat)
all(diag(xmat-txmat)<tol)
}
{
#t.data.frame
xdf <- data.frame(x=1:4,y=factor(c("dog","cat","dog","cat")))
txdf <- t.data.frame(xdf)
is.matrix(txdf)
}
{
#t.test
x <- 1:4
y <- c(2.3,4.5,1.2,6.5)
t.test(x,y)$p.value - 0.4345432  < tol
}
{
#table
age.x <- c(34,23,34,56)
sex.x <- c("F","F","F","M")
contin <- table(age.x, sex.x)
all(dim(contin) == c(3,2))
}
{
#tabulate
tabulate(cut(lottery.payoff,10),10)[1] - 37 < tol
}
{
#tan
tan(0) < tol
}
{
#tanh
tanh(0) < tol
}
{
#tapply
income <- c(1,2,3,1,2,3)
gender <- c("m","f","m","f","m","f")
age <- c( 21,22,30,23,12,32)
example <- tapply(income, list(cut(age, 5), gender), mean)
all(dim(example)==c(5,2))
}
{
#tempfile
fname <- tempfile()
is.character(fname)
}
{
#terms
tobj <- terms(a~b)
class(tobj) == "terms"
}
{
#terms.inner
tobj <- terms.inner(a~b)
class(tobj) == "terms"
}
{
#time
time(corn.rain)[1] - 1890 < tol
}
{
#topic
if(platform() == "WIN386") TRUE
else 
platform() == "DOS386" || exists("topic", mode="function")
}
{
#tprint
exists("tprint")
}
{
#trace
exists("trace")
}
{
#trace.ms                   # Support for Function ms()
exists("trace.ms", mode="function")
}
{
#trace.nls                   # Support for Function nls()
exists("trace.nls")
}
{
#trace.on
exists("trace.on")
}
{
#traceback
exists("traceback")
}
{
#tree
zfuel <- tree(formula = Mileage ~ Weight, data=fuel.frame)
class(zfuel) == "tree"
}
{
#tree.control
tree.control(23)$minsize - 10 < tol
}
{
#deviance.tree
abs(deviance.tree(zfuel) - 218.71944444 ) < tol
}
{
#residuals.tree
length(residuals.tree(zfuel))==60
}
{
#summary.tree
summary.tree(zfuel)$size == 9
}
{
#select.tree
class(select.tree(zfuel,3))=="tree"
}
{
#snip.tree
class(snip.tree(zfuel,3))=="tree"
}
{
#shrink.tree
abs(shrink.tree(zfuel)$dev[1] - 784.09268159 ) < tol
}
{
#tree.depth
tree.depth(23) < tol
}
{
#trunc
trunc(3.3)-3 < tol
}
{
#ts
xts <- ts(1:12,start=1990)
is.ts(xts)
}
{
#tsmatrix
xts <- tsmatrix(cbind(1:12,13:24))
is.ts(xts)
}
{
#tsp
all(tsp(xts) ==c(1,12,1))
}
{
#tsp<-
tsp(xts)<-c(1981,1992,1)
start(xts)[1] == 1981
}
{
#twoway
abs(twoway(cereal.attitude, trim=.25)$grand - 14.44637394) < tol
}
{
#unclass
zff <- unclass(zfuel)
is.list(zff)
}
{
#unique
all(unique(rep(1:3,1:3)) == 1:3 )
}
{
#unix/dos
if (platform() == "DOS386" || platform() == "WIN386") {
	dos("dir") -> junk
	T
} else
	is.character(unix("date"))	# DOS command 'date' hangs waiting for input
}
{
#unix.time; length is 1 on DOS, 5 on unix
mode(unix.time(x <- 12))=="numeric"
}
{
#unlink
x<-1:5
assign("x",value=x,w=1)
dump("x")
unlink("dumpdata")
rm(x)
T
}
{
#unlist
lista <- list(1:3, a=5:7, b=list(b1=12:14, b2=c(23, 25, 28)))
length(unlist(lista))==12
}
{
#untrace
exists("untrace")
}
{
#update.default
all.equal(zfuel$call,update.default(zfuel,evaluate=F))
}
{
#update.formula
#upd.formula
all.equal(update.formula(zfuel),Mileage ~ Weight)
}
{
#using.X
if(platform() == "WIN386") TRUE
else
platform() == "DOS386" || is.logical(using.X())
}
#{
##using.suntools
#if(platform() == "WIN386") TRUE
#else
#platform() == "DOS386" || is.logical(using.suntools())
#}
{
#var
abs(var(corn.rain)-5.1321763869) < tol
}
{
#var.test
vtst <- var.test(corn.yield[1:19],corn.yield[20:38])
abs(vtst$statistic - 1.9534621871 ) < tol
}
{
#vector
alist <- vector("list", 10)
is.list(alist)
}
{
#vi
exists("vi")
}
#{
##warning
#warning("Ignore this phony warning\n")
#T
#}
{
#warnings
exists("warnings")
}
{
#weighted.mean
weighted.mean(1:4,w=rep(1,4)) == mean(1:4)
}
{
#which.inf
as.logical(which.inf(1/0))
}
{
#which.na
as.logical(which.na(NA))
}
{
#which.nan
as.logical(which.nan(0/0))
}
{
#wilcox.test
#wil.rank.sum
corny <- unique(corn.yield)
wtst <- wilcox.test(corny[1:16],corny[17:32])
abs(wtst$statistic - 234) < tol
}
{
#wil.sign.rank
wtst <- wilcox.test(corny[1:16])
abs(wtst$statistic - 136 ) < tol
}
{
#window
wlx <- window(lynx,start=1900)
length(wlx) == 35
}
{
#world.xy
exists("world.xy")
}
{
#write
write(file=temp <- tempfile(), "write works")
unlink(temp)
T
}
{
#wt.andrews
abs(wt.andrews(2) - 0.6675088067) < tol
}
{
#wt.bisquare
abs(wt.bisquare(2) - 0.66873341189) < tol
}
{
#wt.cauchy
abs(wt.cauchy(2) - 0.587127673 ) < tol
}
{
#wt.default
exists("wt.default")     # Called by rreg.  Cannot work independently.
}
{
#wt.fair
abs(wt.fair(2) - 0.169550173 ) < tol
}
{
#wt.hampel
abs(wt.hampel(2) -1 ) < tol
}
{
#wt.huber
abs(wt.huber(2) -  0.6725 ) < tol
}
{
#wt.logistic
abs(wt.logistic(2) - 0.56043564 ) < tol
}
{
#wt.median
abs(wt.median(2) - .5 ) < tol
}
{
#wt.talworth
abs(wt.talworth(2) - 1) < tol
}
{
#wt.welsch
abs(wt.welsch(2) -  0.798946557 ) < tol
}
{
#xor
a <- c(12,13,11)
b <- 1:3
x <- c(99,88,77)
x[xor(a==13,b==4)]==88
}
{
#xpdrows.data.frame         # Support for Functions [<-.data.frame()
exists("xpdrows.data.frame")
}
{
#xysort
x <- c(3,4,2,1,5)
y <- c(23,12,23,45,26)
xyst <- xysort(x,y)
is.list(xyst)
}
{
#ylim.scale                 # Support for gplot.factor()
exists("ylim.scale")
}
{
#zapsmall
zapsmall(0, 1) == 0
}
