seqXtend(sfsmisc)
seqXtend()所属R语言包:sfsmisc
Sequence Covering the Range of X, including X
序列覆盖范围的X,其中X
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Produce a sequence of unique values (sorted increasingly), containing the initial set of values x. This can be useful for setting prediction e.g. ranges in nonparametric regression.
产生一系列的唯一值(排序越来越多的),其中包含的初始设置值x。设置预测例如,这可能是有用的在非参数回归的范围。
用法----------Usage----------
seqXtend(x, length., method = c("simple", "aim", "interpolate"),
from = NULL, to = NULL)
参数----------Arguments----------
参数:x
numeric vector.
数字矢量。
参数:length.
integer specifying approximately the desired length() of the result.
整数,指定大约所需的length()的结果。
参数:method
string specifying the method to be used. The default, "simple" uses seq(*, length.out = length.) where "aim" aims a bit better towards the desired final length, and "interpolate" interpolates evenly inside each interval (x[i], x[i+1]) in a way to make all the new intervalls of approximately the same length.
字符串,指定要使用的方法。默认情况下,"simple"使用seq(*, length.out = length.)其中"aim"的目的是更好一点对所需的最终长度,和"interpolate"插值均匀地在每个时间间隔(x[i], x[i+1])的方式,以使所有的新的卷时间大致相同的长度。
参数:from, to
numbers to be passed to (the default method for) seq(), defaulting to the minimal and maximal x value, respectively.
数字被传递到(默认方法)seq(),默认的最小和最大的x这个值。
值----------Value----------
numeric vector of increasing values, of approximate length length. (unless length. < length(unique(x)) in which case, the result is simply sort(unique(x))), containing the original values of x.
数字矢量的增加值,长度大约length.(除非length. < length(unique(x))在这种情况下,结果是sort(unique(x))),包含原始值x。
From, r <- seqXtend(x, *), the original values are at indices ix <- match(x,r), i.e., identical(x, r[ix]).
从r <- seqXtend(x, *),原来的值是在指数ix <- match(x,r),即identical(x, r[ix])。
注意----------Note----------
method = "interpolate" typically gives the best results. Calling roundfixS, it also need more computational resources than the other methods.
method = "interpolate"通常给出了最好的结果。调用roundfixS,它比其他方法还需要更多的计算资源。
(作者)----------Author(s)----------
Martin Maechler
参见----------See Also----------
seq; plotDS can make particularly good use of seqXtend()
seqplotDS可以使用seqXtend()特别好
实例----------Examples----------
a <- c(1,2,10,12)
seqXtend(a, 12)# --> simply 1:12[ - >简单1:12]
seqXtend(a, 12, "interp")# ditto[同上]
seqXtend(a, 12, "aim")# really worse[真是雪上加霜]
stopifnot(all.equal(seqXtend(a, 12, "interp"), 1:12))
## for a "general" x, however, "aim" aims better than default[然而,编号为“一般”X“目的”的宗旨,比默认]
x <- c(1.2, 2.4, 4.6, 9.9)
length(print(seqXtend(x, 12))) # 14[14]
length(print(seqXtend(x, 12, "aim"))) # 12[12]
length(print(seqXtend(x, 12, "int"))) # 12[12]
## "interpolate" is really nice:[“插”是非常好的:]
xt <- seqXtend(x, 100, "interp")
plot(xt, main="seqXtend(*, 100, \"interpol\")")
points(match(x,xt), x, col = 2, pch = 20)
# .... you don't even see that it's not equidistant[....你甚至看不到它的不等距]
# whereas the cheap method shows ...[而廉价的方法,显示...]
xt2 <- seqXtend(x, 100)
plot(xt2, col="blue")
points(match(x,xt2), x, col = 2, pch = 20)
## with "Date" objects[#“日期”对象]
Drng <- as.Date(c("2007-11-10", "2012-07-12"))
(px <- pretty(Drng, n = 16)) # say, for the main labels[说,主标签]
## say, a finer grid, for ticks -- should be almost equidistant[#说,更精细的网格,刻度线 - 应该是几乎等距离]
n3 <- 3*length(px)
summary(as.numeric(diff(seqXtend(px, n3)))) # wildly varying[疯狂不同]
summary(as.numeric(diff(seqXtend(px, n3, "aim")))) # (ditto)[(同上)]
summary(as.numeric(diff(seqXtend(px, n3, "int")))) # around 30[约30]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|