Wil*_*ill 6 r names rstudio read.csv
我正在使用RStudio,我在控制台上的输出被截断.我找不到如何阻止截断(我试着搜索?options以及谷歌搜索的时间超过我想承认的时间).
编辑:我为大家道歉!我最初的名字是'ThisIsAReallyReallyReallyReallyReallyLongName',但问题只出现在'翻译服务信息 - 哪个翻译服务?'的长名称.我想我发现了这个问题.在...没有截断,它被替换,如未知人物?和-有.和....
码
# Load File
myfile <- read.csv(file="C:\\Users\\wliu\\Desktop\\myfile.csv",
sep=",", header=TRUE, stringsAsFactors=FALSE, skip=2)
# Get my column names
mycolnames <- colnames(myfile)
# When I request a shorter name, this returns the full name
mycolnames[1] # Assuming first col is a short name
[1] "ThisIsAShortName"
# However, when I request a longer name, this returns a truncated version
mycolnames[2] # Assuming second col is a really long name
[1] "ThisIsA...Long...Name"
Run Code Online (Sandbox Code Playgroud)
我想找回非截断版本mycolnames[2](例如"ThisIsAReallyReallyReallyReallyReallyLongName")
建立
我在Windows 7 64bit,RStudio版本0.98.1091,R版本3.0.1(2013-05-16) - 平台的"好运动":x86_64-w64-mingw32/x64(64位).我尝试使用'使用Git Bash作为Git项目的shell'开启和关闭.
myfile.csv
ThisIsAShortName, Translation Service Info - Which translation service?
23143505, Yes
23143614, No
23143324, Yes
Run Code Online (Sandbox Code Playgroud)

这是 的预期行为read.csv,而不是 R 中的截断问题。当文件的列名中包含空格和特殊字符时,read.csv请将它们替换为 ,.除非您指定check.names = FALSE
下面是 的一瞥make.names,它是如何read.table生成列名称的。
nm <- "Translation Service Info - Which translation service?"
make.names(nm)
# [1] "Translation.Service.Info...Which.translation.service."
Run Code Online (Sandbox Code Playgroud)
这是来自的相关行read.table
if (check.names)
col.names <- make.names(col.names, unique = TRUE)
Run Code Online (Sandbox Code Playgroud)