breakline.index(RPMG)
breakline.index()所属R语言包:RPMG
Break a vector into segments
打破了矢量段
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Break a vector into segments
打破了矢量段
用法----------Usage----------
breakline.index(Z, ww)
参数----------Arguments----------
参数:Z
vector
向量
参数:ww
indices where the breaks should occur. if a matrix is provided the start and end indices are given, else the breaks are provded.
指数的时间应发生。如果一个矩阵设置的开始和结束指数给出,否则符每档均有。
Details
详细信息----------Details----------
Codes used for maps to break map segments along boundaries. But this is more general, nd can be used to break any vector according to given indices. See examples.
使用的代码映射到打破沿着边界的图段。但是,这是比较一般,第二根据给定的指标,可以用来打破的任何向量。见的例子。
值----------Value----------
List of indices that are segments.
名单指数分部。
(作者)----------Author(s)----------
Jonathan M. Lees<jonathan.lees@unc.edu>
实例----------Examples----------
### example with a vector of breaks[##例如用一个向量的中断]
h = 1:20
k = breakline.index(h, c(8, 14))
######## select with a matrix of start-ends[#######选择的起始端部的矩阵]
r1 = rbind(c(3,10), c(14, 18))
k = breakline.index(h, r1)
j1 = seq(from=3, to=17, by=3)
j2 = j1+5
########## overlapping sequences[#########重叠序列]
r1 = cbind(j1, j2)
k = breakline.index(h, r1)
###### example with coordinates[#####例如坐标]
#### some data:[###的一些数据:]
uu=list()
uu$x=c(136.66,136.34,136.07,136.07,135.62,135.03,134.98,
134.98,135.07,135.25,135.75,137.07,137.35,137.44,138.07,
138.07,137.80,137.75,137.25)
uu$y=c(39.878,39.749,39.490,39.296,39.200,39.135,38.909,
38.618,38.327,38.004,37.875,37.875,38.327,38.489,
38.812,39.006,39.232,39.587,39.943)
### plot raw data[##图原始数据]
plot(uu$x, uu$y, type="l")
#### cutoff:[###截止:]
z1 = 39
h = 1:length(uu$x)
w1 = which( uu$y>z1)
g1 = list(x=uu$x[w1] , y=uu$y[w1] )
lines(g1, col='red')
############ notice the connecting line.[###########注意到连接线。]
######### how can we avoid this?[########如何,才能避免这种情况呢?]
w2 = which(diff(w1)!=1)
k = breakline.index(w1, w2)
for(i in 1:length(k)) lines(uu$x[ k[[i]] ], uu$y[ k[[i]] ], col='blue')
###### see, line is broken correctly[#####看到的,线断了正确]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|