read.spss(foreign)
read.spss()所属R语言包:foreign
Read an SPSS Data File
阅读SPSS数据文件
译者:生物统计家园网 机器人LoveR
描述----------Description----------
read.spss reads a file stored by the SPSS save or export commands.
read.spss读取存储的文件的SPSS save或export命令。
用法----------Usage----------
read.spss(file, use.value.labels = TRUE, to.data.frame = FALSE,
max.value.labels = Inf, trim.factor.names = FALSE,
trim_values = TRUE, reencode = NA, use.missings = to.data.frame)
参数----------Arguments----------
参数:file
Character string: the name of the file or URL to read.
字符串:文件或URL的名称改为。
参数:use.value.labels
Convert variables with value labels into R factors with those levels?
值标签的变量转换成R因子的水平?
参数:to.data.frame
return a data frame?
返回一个数据框?
参数:max.value.labels
Only variables with value labels and at most this many unique values will be converted to factors if use.value.labels = TRUE.
只有变量值标签,并在大多数许多独特的价值将被转换为的因素,如果use.value.labels = TRUE。
参数:trim.factor.names
Logical: trim trailing spaces from factor levels?
逻辑:修剪尾随因子水平的空间?
参数:trim_values
logical: should values and value labels have trailing spaces ignored when matching for use.value.labels = TRUE?
逻辑:价值观和价值标签use.value.labels = TRUE匹配时忽略尾随空间?
参数:reencode
logical: should character strings be re-encoded to the current locale. The default, NA, means to do so in a UTF-8 locale, only. Alternatively a character string specifying an encoding to assume for the file.
逻辑:字符串应该被重新编码,以目前的语言环境。默认情况下,NA,这意味着这样做,只有在UTF-8语言环境。或者指定一个编码字符串,假设该文件。
参数:use.missings
logical: should information on user-defined missing values be used to set the corresponding values to NA?
逻辑:用户定义的缺失值的信息可用来设置相应的值NA?
Details
详情----------Details----------
This uses modified code from the PSPP project (http://www.gnu.org/software/pspp/ for reading the SPSS formats.
使用PSPP项目(http://www.gnu.org/software/pspp/读取SPSS格式修改后的代码。
If the filename appears to be a URL (of schemes http:, ftp: or https the URL is first downloaded to a temporary file and then read. (https: is only supported on some platforms.)
如果文件名似乎是一个URL(计划http:,ftp:或https:)的网址是先下载到一个临时文件,然后读取。 (https:只在某些平台上的支持。)
Occasionally in SPSS, value labels will be added to some values of a continuous variable (e.g. to distinguish different types of missing data), and you will not want these variables converted to factors. By setting max.val.labels 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 non-missing values that have no value label. The value labels are then returned in the "value.labels" attribute of the variable.
偶尔在SPSS中,值标签将被添加到一个连续变量的某些值(例如,区分不同类型的数据丢失),你不会想这些变量转换的因素。通过设置max.val.labels你可以指定一个不同值的大量的变量不能转换的因素,即使他们有值标签。此外,变量将不被转换的因素,如果有非缺失值,没有任何价值标签。 "value.labels"属性的变量值标签,然后返回。
If SPSS variable labels are present, they are returned as the "variable.labels" attribute of the answer.
如果SPSS变量标签是目前他们正在返回"variable.labels"属性的答案。
Fixed length strings (including value labels) are padded on the right with spaces by SPSS, and so are read that way by R. The default argument trim_values=TRUE causes trailing spaces to be ignored when matching to value labels, as examples have been seen where the strings and the value labels had different amounts of padding. See the examples for sub for ways to remove trailing spaces in character data.
固定长度的字符串(包括值标签)上的权利与空间填充用SPSS,读取R.这样的默认参数trim_values=TRUE导致尾随空格被忽略匹配时,值标签,作为例子有被视为字符串和值标签的地方有不同填充量。见sub的办法来消除尾随空格字符数据的例子。
URL http://msdn.microsoft.com/en-us/library/ms776446(VS.85).aspx provides a list of translations from Windows codepage numbers to encoding names that iconv is likely to know about and so suitable values for reencode. Automatic re-encoding is attempted for apparent codepages of 200 or more in a UTF-8 locale: some other high-numbered codepages can be re-encoded on most systems, but the encoding names are platform-dependent (see iconvlist).
网址http://msdn.microsoft.com/en-us/library/ms776446(VS.90)。ASPX提供iconv可能是了解和Windows代码页号码的编码名称的翻译列表reencode合适的值。自动重新编码200个或更多的明显的codepages一个UTF-8语言环境中尝试其他一些高的codepages可以在大多数系统上重新编码,但编码名称是依赖于平台的(见iconvlist )。
值----------Value----------
A list (or data frame) with one component for each variable in the saved data set.
一个列表(或数据框),每个变量中保存的数据集的一个组成部分。
If what looks like a Windows codepage was recorded in the SPSS file, it is attached (as a number) as attribute "codepage" to the result.
如果看起来像Windows代码页在SPSS文件记录,它是附加属性"codepage"(数字)的结果。
There may be attributes "label.table" and "variable.labels". Attribute "label.table" is a named list of value labels with one element per variable, either NULL or a named character vector. Attribute "variable.labels" is a named character vector with names the short variable names and elements the long names.
可能有属性"label.table"和"variable.labels"。属性"label.table"的每个变量的一个元素的值标签的命名列表,要么NULL或命名的特征向量。属性"variable.labels"是一个名字短的变量名称和元素的长文件名的命名的特征向量。
If there are user-defined missing values, there will be a attribute "Missings". This is a named list with one list element per variable. Each element has an element type, a length-one character vector giving the type of missingness, and may also have an element value with the values corresponding to missingness. This is a complex subject (where the R and C source code for read.spss is the main documentation), but the simplest cases are types "one", "two" and "three" with a corresponding number of (real or string) values whose labels can be found from the "label.table" attribute. Other possibilities are a finite or semi-infinite range, possibly plus a single value. See also http://www.gnu.org/software/pspp/manual/html_node/Missing-Observations.html#Missing-Observations.
如果有用户定义缺失值,会有一个属性"Missings"。这是每一个变量的列表元素命名名单。每个元素都有一个元素type,长度为一个字符向量给的missingness类型,也可能与值到missingness相应有一个元素value。这是一个复杂的课题(read.spss是主文件),但最简单的情况是类型"one","two"和"three"用R和C源代码相应的数字值(真实的或字符串)的标签可以从"label.table"属性。其他的可能性是有限的或半无限大的范围,可能还要加上一个单一的值。也看到http://www.gnu.org/software/pspp/manual/html_node/Missing-Observations.html~~V#失踪的观测。
注意----------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,….
如果SPSS值标签转换因素的基础数值代码不会是一般为SPSS数值相同,因为在R的数值代码总是1,2,3,…。
You may see warnings about the file encoding for SPSS save files: it is possible such files contain non-ASCII character data which need re-encoding. The most common occurrence is Windows codepage 1252, a superset of Latin-1. The encoding is recorded (as an integer) in attribute "codepage" of the result if it looks like a Windows codepage. Automatic re-encoding is done only in UTF-8 locales: see argument reencode.
您可能会看到有关SPSS软件save文件的文件编码的警告:它是这样的文件可能包含非ASCII字符的数据,需要重新编码。最常见的发生是Windows代码页1252,Latin-1的超集。编码被记录在属性(整数)"codepage"如果它看起来像一个Windows代码页的结果。自动重新编码只在UTF-8语言:参见参数reencode。
作者(S)----------Author(s)----------
Saikat DebRoy and the R-core team
参见----------See Also----------
A different interface also based on the PSPP codebase is available in package memisc: see its help for spss.system.file.
PSPP的codebase根据不同的接口,也可以在包memisc:帮助spss.system.file。
举例----------Examples----------
## Not run: [#无法运行:]
read.spss("datafile")
## don't convert value labels to factor levels[不转换因子水平的价值标签]
read.spss("datafile", use.value.labels = FALSE)
## convert value labels to factors for variables with at most[#转换价值标签变量因素,在最]
## ten distinct values.[10个不同的值。]
read.spss("datafile", max.val.labels = 10)
## End(Not run)[#结束(不运行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|