typeof()获取;整数;对于R中的繁体汉字 我的R代码如下: 请将dput(head(landtrading$fort))和sessionInfo()的输出添加到您的问题中。@Roland非常感谢您!因为输出有点长,所以我在原始问题中添加了它们。由于内
typeof()获取;整数;对于R中的繁体汉字 我的R代码如下:typeof()获取;整数;对于R中的繁体汉字 我的R代码如下: 请将dput(head(landtrading$fort))和sessionInfo()的输出添加到您的问题中。@Roland非常感谢您!因为输出有点长,所以我在原始问题中添加了它们。由于内,r,class,special-characters,non-ascii-characters,typeof,R,Class,Special Characters,Non Ascii Characters,Typeof,typeof()获取;整数;对于R中的繁体汉字 我的R代码如下: 请将dput(head(landtrading$fort))和sessionInfo()的输出添加到您的问题中。@Roland非常感谢您!因为输出有点长,所以我在原始问题中添加了它们。由于内部因子是integers,这就是typeof报告的内容。但是,class不可能使用此输入返回character。它必须返回因子。因此,我不相信您显示的输出。在使用(Landctrading,levels(fort)[fort])阅读后,将它们转
请将
dput(head(landtrading$fort))
和sessionInfo()
的输出添加到您的问题中。@Roland非常感谢您!因为输出有点长,所以我在原始问题中添加了它们。由于内部因子是integer
s,这就是typeof
报告的内容。但是,class
不可能使用此输入返回character
。它必须返回因子
。因此,我不相信您显示的输出。在使用(Landctrading,levels(fort)[fort])阅读后,将它们转换为字符。
或在read.xls()中使用stringsAsFactors=FALSE
,这基本上在注释中得到了回答,但OP可能早已消失。最初的评论者之一,或者@Werner,是否愿意为了结束而提供答案?
landtrading <- read.xls("landtrading/landtradingdata.xlsx")
names(landtrading)
#[1] "GISID" "fort" "fortid" "jo" "joid" "cho" "mktpj"
class(landtrading$fort)
# factor
typeof(landtrading$fort)
# integer
> dput(head(landtrading$fort))
# structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("三貂堡",
# "下茄苳北堡", "下茄苳南堡", "二林上堡", "二林下堡",
# "二結堡", "五城堡", "仁和里", "仁壽上里", "仁壽下里",
# (too many names, so partly omitted)
# "鯉魚頭堡", "鳳山上里", "鳳山下里", "鹽水港堡",
# "鹿仔草堡", "龍蛟潭堡"), class = "factor")
> sessionInfo()
# R version 3.1.2 (2014-10-31)
# Platform: x86_64-apple-darwin13.4.0 (64-bit)
# locale:
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
# attached base packages:
# [1] splines stats graphics grDevices utils datasets methods
# [8] base
# other attached packages:
# [1] gdata_2.13.3 doBy_4.5-13 survival_2.37-7 RColorBrewer_1.0-5
# [5] plyr_1.8.1 rgdal_0.8-16 sp_1.0-17 ggplot2_1.0.0
# [9] foreign_0.8-61
# loaded via a namespace (and not attached):
# [1] colorspace_1.2-4 digest_0.6.4 grid_3.1.2 gtable_0.1.2
# [5] gtools_3.4.1 lattice_0.20-29 MASS_7.3-35 Matrix_1.1-4
# [9] munsell_0.4.2 proto_0.3-10 Rcpp_0.11.2 reshape2_1.4
# [13] scales_0.2.4 stringr_0.6.2 tools_3.1.2