seqdef(TraMineR)
seqdef()所属R语言包:TraMineR
Create a state sequence object
创建一个状态序列对象
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Create a state sequence object with attributes such as alphabet, color palette and state labels. Most TraMineR functions for state sequences require such a state sequence object as input argument. There are specific methods for plotting, summarizing and printing state sequence objects.
创建一个状态序列对象的属性,如字母,调色板和状态标签。大多数TraMineR状态序列的功能需要这样的一个状态序列对象作为输入参数。有绘图,汇总和打印状态序列对象的具体方法。
用法----------Usage----------
seqdef(data, var=NULL, informat="STS", stsep=NULL,
alphabet=NULL, states=NULL, id=NULL, weights=NULL, start=1,
left=NA, right="DEL", gaps=NA, missing=NA, void="%", nr="*",
cnames=NULL, xtstep=1, cpal=NULL, missing.color="darkgrey",
labels=NULL, ...)
参数----------Arguments----------
参数:data
a data frame or matrix containing sequence data.
一个数据框或含有序列数据的矩阵。
参数:var
the list of columns containing the sequences. Default is NULL, i.e. all the columns. The function detects automatically whether the sequences are in the compressed (successive states in a character string) or extended format.
列表中包含序列的列。默认是NULL,即所有列。该功能自动检测是否序列压缩(连续状态中的字符串)或扩展格式。
参数:informat
format of the original data. Default is "STS". Available formats are: "STS", "SPS", "SPELL". See TraMineR user's manual (<CITE>Gabadinho et al., 2010</CITE>) for a description of the formats.
的原始数据格式。默认是"STS"。可用的格式有:"STS","SPS","SPELL"。特拉米纳用户手册(<CITE> Gabadinho等。,2010年</ CITE>)的说明的格式。
参数:stsep
the character used as separator in the original data if input format is successive states in a character string. If NULL (default value), the seqfcheck function is called for detecting automatically a separator among "-" and ":". Other separators must be specified explicitly.
使用的字符作为分隔符在原始数据的输入格式,如果是在字符串中的连续状态。如果NULL(默认值),seqfcheck功能被称为自动检测分隔符“ - ”和“:”。必须明确指定其他分隔符。
参数:alphabet
optional vector containing the alphabet (the list of all possible states). Use this option if some states in the alphabet don't appear in the data or if you want to reorder the states. The specified vector MUST contain AT LEAST all the states appearing in the data. It may possibly contain additional states not appearing in the data. If NULL, the alphabet is set to the distinct states appearing in the data as returned by the seqstatl function. See details.
可选向量的字母(列表中的所有可能的状态)。使用此选项,如果某些国家不会出现在字母表中的数据,或者如果您要重新排序的状态。指定的向量必须至少包含所有出现在数据的状态。它可能出现在数据可能包含额外的状态。如果NULL,字母表设置seqstatl函数返回的数据出现在不同的状态。查看详细信息。
参数:states
an optional vector containing the short state labels. Must have a length equal to the size of the alphabet and the labels must be ordered conformably with alpha-numeric ordered values returned by the seqstatl function, or, when alphabet= is set, with the thus newly defined alphabet.
一个可选的向量,,包含短路状态的标签。长度必须相等大小的字母和字母数字有序的返回值seqstatl功能,或者,当alphabet=设置的标签必须有序整合,因此,新定义的字母。
参数:id
optional argument for setting the rownames of the sequence object. If NULL (default), the rownames are taken from the input data. If set to "auto", sequences are numbered from 1 to the number of sequences. A vector of rownames of length equal to the number of sequences may be specified as well.
可选参数设置的序列对象的行名。如果NULL(默认),行名是从输入数据。如果设置为"auto",顺序从1开始编号的序列数。长度相等的序列数的向量行名可以被指定为良好。
参数:weights
optional numerical vector containing weights, which are accounted for by plotting and statistical functions when applicable.
可选的数值向量中的权重,这是占了绘图和统计功能,当适用。
参数:start
starting time. For instance, if sequences begin at age 15, you can specify 15. At this stage, used only for labelling column names.
的开始时间。例如,如果序列在15岁开始,您可以指定15。在此阶段,仅用于标签列名。
参数:left
the behavior for missing values appearing before the first (leftmost) valid state in each sequence. See <CITE>Gabadinho et al. (2010)</CITE> for more details on the options for handling missing values when defining sequence objects. By default, left missing values are treated as 'real' missing values and converted to the internal missing value code defined by the nr option. Other options are "DEL" to delete the positions containing missing values or a state code (belonging to the alphabet or not) to replace the missing values.
遗漏值出现之前,每个序列中的第一个(最左边)的有效状态的行为。请参阅<CITE> Gabadinho等。 (2010)</ CITE>的选项的更多详细信息,处理缺失值定义序列对象时。默认情况下,左遗漏值将被视为“真正的”缺失值和转换为内部缺失值定义的代码nr选项。其他选项"DEL"删除的位置遗漏值或状态码(属于字母或)以替换丢失的值。
参数:right
the behavior for missing values appearing after the last (rightmost) valid state in each sequence. Same options as for the left argument.
遗漏值后出现在每个序列的最后一个(最右边)的有效状态的行为。 left参数相同的选项。
参数:gaps
the behavior for missing values appearing inside the sequences, i.e. after the first (leftmost) valid state and before the last (rightmost) valid state of each sequence. Same options as for the left argument.
的行为序列内出现的遗漏值的,即在第一个(最左边)的有效状态,每个序列前的最后一个(最右边)的有效状态。 left参数相同的选项。
参数:missing
the code used for missing values in the input data. When specified, all cells containing this value will be replaced by NA's, the internal R code for missing values. If 'missing' is not specified, cells containing NA's are considered as missing values.
使用的代码输入数据中的缺失值。当指定的所有单元格中包含这个值将被替换为NA的遗漏值,内部研发代码。如果missing未指定,单元内含有NA的被视为缺失值的。
参数:void
the internal code used by TraMineR for representing void elements in the sequences. Default is"%".
内部所使用的代码特拉米纳代表无效序列中的元素。默认是"%"。
参数:nr
the internal code used by TraMineR for representing real missing elements in the sequences. Default is"*".
内部所使用的代码特拉米纳代表真正缺少的元素序列。默认是"*"。
参数:cnames
optional names for the columns composing the sequence data. Those names will be used by default in the graphics as axis labels. If NULL (default), names are taken from the original column names in the data.
可选名称的列构成的序列数据。默认情况下,这些名称将被用于在图形轴标签。如果NULL(默认),名称是从原始列名的数据。
参数:xtstep
step between displayed tick-marks and labels on the x-axis of state sequence plots. If not overridden by the user, plotting functions retrieve this parameter from the xtstep attribute of the sequence object. For example, with xtstep=3 a tick-mark is displayed at positions 1, 4, 7, etc... Default value is 1; i.e., a tick mark is displayed at each position. The display of the corresponding labels depends on the available space and is dealt with automatically.
步骤显示的刻度线标志和标签上的状态序列图的x轴之间。如果不重写用户,绘图函数检索此参数,从xtstep的序列对象的属性。例如,xtstep=3一个刻度线会显示在位置1,4,7,等..默认值是1,即一个刻度标记显示在每个位置上。的相应的标签的显示取决于可用的空间和自动处理。
参数:cpal
an optional color palette for representing the states in the graphics. If NULL (default), a color palette is created by calling the brewer.pal function of the RColorBrewer package. If number of states is less or equal than 8, the "Accent" palette is used. If number of states is between 8 and 12, the "Set3" palette is used. If the number of states in the data is greater than 12 you have to specify your own palette. The list of available colors is displayed by the colors function. You can also use alternatively some other palettes from the RColorBrewer package.
一个可选的调色板为代表的国家在图形。如果NULL(默认),调色板创建通过调用brewer.pal功能RColorBrewer包。如果状态数为小于或等于8,"Accent"调色板使用。如果状态数为8和12之间,"Set3"调色板。如果在数据的国家的数目大于12,你必须指定自己的调色板。可用的颜色列表显示colors功能的。您还可以使用从RColorBrewer包或者一些其他的调色板。
参数:missing.color
alternative color for representing missing values inside the sequences. Defaults to "darkgrey".
另一种颜色代表缺失值序列内。默认为"darkgrey"的。
参数:labels
optional state labels used for the color legend of TraMineR's graphics. If NULL (default), the state names in the alphabet are used as state labels as well.
使用可选的状态标签的颜色传说中的特拉米纳的图形。 NULL如果(默认),国家名称中的字母所使用的状态标签为好。
参数:...
options passed to the seqformat function for handling input data that is not in STS format.
选项传递给seqformat功能的STS格式是不是在处理输入数据。
Details
详细信息----------Details----------
Applying subscripts to sequence objects (eg. seq[,1:5] or seq[1:10,]) returns a state sequence object with some attributes preserved (alphabet, missing) and some others (start, column names) adapted to the selected column or row subset. If only one column is specified, a factor is returned. <br>
将标序列对象(如seq[,1:5] or seq[1:10,])将返回一个状态序列对象保存一些属性(字母,缺少)和其他一些人(启动,列名),适用于选定的列或行子集。如果只有一列被指定,则返回一个因素。参考
For reordering the states use the alphabet argument. This may for instance be of interest when you want to compare data from different sources with different codings of similar states. Using alphabet permits to order the states conformably in all sequence objects. Otherwise, the default state order is the alpha-numeric order returned by the seqstatl function
重新排序的状态用alphabet参数。例如,这可能会感兴趣的,当你想从不同来源的数据进行比较相似的国家的不同编码。使用alphabet允许命令的状态一致地在所有的序列对象。否则,默认状态下的顺序是按字母数字顺序,返回seqstatl功能的
值----------Value----------
An object of class stslist. There are print, plot and summary methods for such objects. State sequence objects are required as argument to other functions such as plotting functions (seqdplot, seqiplot or seqfplot), functions to compute distances (seqdist),
对象的类stslist。有print,plot和summary这些对象的方法。状态序列需要对象作为参数传递给其他的功能,如绘图功能(seqdplot,seqiplot或seqfplot),函数计算距离(seqdist),
参考文献----------References----------
package: A user's guide. Department of Econometrics and
参见----------See Also----------
plot.stslist to plot state sequence objects,<br> seqplot for high level plots of state sequence objects,<br> seqecreate to create an event sequence object,<br>
plot.stslist绘制状态序列对象,参考seqplot高层次的状态序列图对象,参考seqecreate创建一个事件序列对象参考
实例----------Examples----------
## Creating a sequence object with the columns 13 to 24[#创建一个序列对象列13至24]
## in the 'actcal' example data set[#在“actcal”示例数据集]
data(actcal)
actcal.seq <- seqdef(actcal,13:24,
labels=c("> 37 hours", "19-36 hours", "1-18 hours", "no work"))
## Displaying the first 10 rows of the sequence object[#显示第10行的序列对象]
actcal.seq[1:10,]
## Displaying the first 10 rows of the sequence object[#显示第10行的序列对象]
## in SPS format[#SPS格式]
print(actcal.seq[1:10,], format="SPS")
## Plotting the first 10 sequences[#绘制的第10个序列]
plot(actcal.seq)
## Re-ordering the alphabet[#重新排序的字母]
actcal.seq <- seqdef(actcal,13:24,alphabet=c("B","A","D","C"))
alphabet(actcal.seq)
## Adding a state not appearing in the data to the[#添加没有出现在数据的状态]
## alphabet[#字母]
actcal.seq <- seqdef(actcal,13:24,alphabet=c("A","B","C","D","E"))
alphabet(actcal.seq)
## Adding a state not appearing in the data to the[#添加没有出现在数据的状态]
## alphabet and changing the states labels[#字母和不断变化的状态标签]
actcal.seq <- seqdef(actcal,13:24,
alphabet=c("A","B","C","D","E"),
states=c("FT","PT","LT","NO","TR"))
alphabet(actcal.seq)
actcal.seq[1:10,]
## ============================[#============================]
## Example with missing values[#示例缺失值]
## ============================[#============================]
data(ex1)
## With right="DEL" default value[#右=“DEL”默认值]
seqdef(ex1,1:13)
## Eliminating 'left' missing values[#消除“左”的缺失值]
seqdef(ex1,1:13, left="DEL")
## Eliminating 'left' missing values and gaps[#消除“左”的缺失值和差距]
seqdef(ex1,1:13, left="DEL", gaps="DEL")
## ====================[#====================]
## Example with weights[#示例重量]
## ====================[#====================]
ex1.seq <- seqdef(ex1, 1:13, weights=ex1$weights)
## weighted sequence frequencies[#加权序列频率]
seqtab(ex1.seq)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|