r软件及统计分析因子列表数据框程序设计结构(编辑修改稿)内容摘要:
出函数利用 cat()和 formatC来控制: apply(da, 1, function(r) cat(formatC(r[1], format=39。 d39。 , width=2, flag=39。 039。 ), 39。 39。 , formatC(r[2], format=39。 d39。 , width=2, flag=39。 039。 ), 39。 39。 , formatC(r[3], format=39。 d39。 , width=2, flag=39。 039。 ), 39。 \n39。 , sep=39。 39。 )) 990103 961109 650518 NULL • 这里我们知道 apply函数第一个参数指定了一个矩阵,第二个参数说明对行操作还是对列操作,第三个参数是一个函数,这里我们使用了直接定义一个函数作为参数的办法。 输出结果中多了一个 NULL函数,这是因为我们在交互运行, apply的结果作为一个表达式的值( NULL )会被显示出来。 • 为避免显示,可以把结果赋给一个临时变量名,或者把整个表达式作为 invisible() 函数的参数,这时不显示表达式值。 • S的输出缺省显示在交互窗口。 可以用 sink()函数指定一个文件以把后续的输出转向到这个文件,并可用 append参数指定是否要在文件末尾附加: sink(“E:/work/, append=TRUE) ls() d sink() 调用无参数的 sink()把输出恢复到交互窗口。 • write(t(x),file=„文件名’, nol=nol(x))把一个矩阵 X输出到文件中,把 X转置后输出因为 R中矩阵是列优先的,如果不转置则输出是按列输出的。 如果不指定列数则缺省使用 5列。 文件名缺省用’ data‟. • (x,file=„文件名’ )把数据框 X输出到文件中,输出包括变量名表头和行名。 ’ . • cl = (“E:/R/, =c(1), + =c(Name, Sex, Age, Height, Weight)) cl 输入 • 为了从外部文件读入一个数值型向量, S提供了 scan()函数。 如果指定了 file参数(也是第一参数),则从指定文件读入,缺省情况下读入一个数值向量,文件中各数据以空白分隔,读到文件尾为止。 例如: • cat(1:12, 39。 \n39。 , file=„E:/work/39。 ) • x scan(39。 c:/work/39。 ) • 如果文件中是一个用 空白分隔 的矩阵(或数组),我们可以先用 scan()把它读入到一个向量然后用 matrix()函数(或 array()函数)转换。 如: • y matrix(scan(„E:/work/39。 ), ncol=3, byrow=T) • 实际上, scan()也能够读入一个多列的表格,只要用what参数指定一个列表,则列表每项的类型为需要读取的类型。 用 skip参数可以跳过文件的开始若干行不读。 用 sep参数可以指定数据间的分隔符。 详见帮助。 • scan()不指定读取文件名时是交互读入,读入时用一个空行结束。 • 如果要读取一个数据框, S提供了一个 ()函数。 它只要给出一个文件名,就可以把文件中用空白分隔的表格数据每行读入为数据框的一行。 比如,文件E:\ 中内容如下: Zhou 15 3 “Li Ming” 9 李明 Zhang Wang • 用 : x („E:/39。 , =T) x V1 V2 V3 1 Zhou 15 3 2 Li Ming 9 李明 3 Zhang Wang 读入结果为数据框。 • 函数可以自动识别表列是数值型还是字符型,并在缺省情况下把字符型数据转换为因子(加上 =T可以保留字符型不转换)。 • 函数自动为数据框变量指定“ V1 ”、“ V2”这样的变量名,指定“ 1”、“ 2”这样的行名。 可以用 指定一个字符型向量作为数据框的变量名。 • ()可以读入带有表头的文件,只要加上header=TRUE参数即可。 可以用 sep 参数指定表行各项的分隔符。 例如,为了读入如下带有表头的逗号分隔文件 E:\: Name,score, Zhou,15,3 Li Ming, 9, 李明 Zhang, , Wang • 使用如下语句: x=(„E:/39。 , header=T, sep=39。 ,39。 ) x Name score 1 Zhou 3 2 Li Ming 李明 3 Zhang Wang • 其它一些用法见帮助。 • cl =(E:/R/, =c(1), =c(Name, Sex, Age, Height, Weight))。 cat(39。 names(cl)39。 ,names(cl))。 • =(E:/R/,header=T,sep=39。 ,39。 )。 cat(39。 names()39。 ,names())。 • Edata = (39。 E:/R/Employee 39。 ,header=T,sep=39。 ,39。 ) cat(39。 names(Edata)39。 ,names(Edata))。 • package:foreign R Documentation Read an SPSS data file • Description: 39。 39。 reads a file stored by the SPSS 39。 save39。 and 39。 export39。 mands and returns a list. • Usage: (file, =TRUE, =FALSE, =Inf, =FALSE) • Arguments: file: character variable with the name of the file to read. : Convert variables with value labels into R factors with those levels? : return a data frame? : Only variables with at most this many unique values will be converted to factors : Trim trailing spaces from factor levels? • Details: This uses modified code from the PSPP project for reading the SPSS formats. Occasionally in SPSS value labels will be added to some values of a continuous variable (eg to distinguish different types of missing data), and you will not want these variables converted to factors. By setting 39。 39。 you can specify that variables with a large number of distinct values are not converted to factors even if they have value labels. In addition, variables will not be converted to factors if there are nonmissing values that have no value label. The value labels are then returned in the 39。 39。 attribute of the variable. • If SPSS variable labels are present, they are returned as the 39。 39。 attribute of the answer. Fixed length strings (including value labels) are padded on the right with spaces by SPSS, and so are read that way by R. See the examples for 39。 sub39。 for ways to remove trailing spaces in string data. • Value: A list (or data frame) with one ponent for each variable in the saved data set. • Note: If SPSS value labels are converted to factors the underlying numerical codes will not in general be the same as the SPSS numerical values, since the numerical codes in R are always 1,2,3,... • Author(s): Saikat DebRoy • Examples: Not run: (datafile) don39。 t convert value labels to factor levels (datafile,=FALSE) convert value labels。r软件及统计分析因子列表数据框程序设计结构(编辑修改稿)
相关推荐
2 + (权值3) * 4 + (权值4) * 8 1 *1 + 1 * 2 + 0 * 4 + 0 + 8 = 3列的地址 = (权值5) * 1 + (权值6) * 2 + (权值7) * 4 + (权值8) * 8 0 *1 + 1 * 2 + 0 * 4 + 0 + 8 = 2系统连接安装方式:拼接单元框图嵌入式处理系统,每一单元都有独立的处理模块和电源模块,并通过串口实现单元间的通讯。
~ Jn8 1~ 8 层内选输入及应答输出 J9 为输入端口,端口定义如下: 端口号 位置 定义 CMM J91 公共端 KMV1 J92 开门限位输入 GMV1 J93 关门限位输入 KAB1 J94 安全触板 1 输入 CZ J95 超载输入 MZ J96 满载输入 KAB2 J97 安全触板 2 输入 QZ J98 轻载输入 KZ J99 空载输入 SZH J910 司机输入 J2J6
d2。 infile 39。 d:\test\39。 missover。 input age 2. sex $1. height birthday yymmdd8.。 run。 • data d3。 infile 39。 d:\test\39。 input age sex $ height birthday yymmdd8.。 run。 46 三种不同原始数据排列方式的特性
协助乙方编制标书。 乙方业务如需向河北 省 之外 地区拓展,应 向甲方申请项目注册,经甲方批准后,享受本协议待遇。 甲 、 乙双方应及时互通市场信息,相互合作共同为用户提供最优质的服务。 在市场推广中,如供电系统人员要求考查生产厂家或北方地区用户使用情况时,甲方应积极予以 配合,并负责接待及相关接待费用。 五、 代理价格及发货方式 甲方承诺给予乙方代理甲方生产的产品为全国最低价, RTV
没有虫害出没的痕迹,灰尘或外来物; 没有掉落油漆。 食品暴露的地方不允许使用木质的托盘。 • Section : 处置储藏和运输 • 散装的原材料在装卸中要防止污染。 拥有散装车辆装卸货物的程序。 遵守卫生规范-恰当使用网罩 /袋子等。 收货时要求有相关的食品安全文件(如清洗条,检验证书)。 散装料的传送带,接管和货口不用时要保持适当的状况: 上锁; 盖子不放在不干净的表面; 接管头保持离地;
12. As a general rule, the sale or exchange of an option to buy or sell property results in capital gain or loss if the property subject to the option is (or would be) a capital asset in the hands of