sách gpt4 ai đã đi

read.csv thay thế các ký tự tên cột như `.` bằng `?` và thay thế `...` bằng `-`

In lại 作者:行者123 更新时间:2023-12-04 14:27:11 26 4
mua khóa gpt4 Nike

我正在使用 RStudio,但我在控制台上的输出被截断了。我找不到如何停止截断(我尝试搜索 ?options 以及在谷歌上搜索的时间比我想承认的要长)。

编辑:我向大家道歉!我最初的长名称为“ThisIsAReallyReallyReallyReallyReallyLongName”,但问题只出现了“翻译服务信息 - 哪个翻译服务?”的长名称。我想我发现了这个问题。 ...不是截断,而是替换未知字符,如 ?-.... .

Mã số

# 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"

我想找回 mycolnames[2]的非截断版本(例如“ThisIsAReallyReallyReallyReallyReallyReallyLongName”)

cài đặt

我使用的是 Windows 7 64 位,RStudio 版本 0.98.1091,R 版本 3.0.1 (2013-05-16)——“Good Sport”平台: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

Char Replacement instead of truncating issue

1 Câu trả lời

Đây là read.csv 的预期行为, 而不是 R 中的截断问题。当文件的列名中有空格和特殊字符时,read.csv. 替换它们中的每一个除非您指定 check.names = FALSE
Đây làmake.names的一瞥,这就是read.table产生列名。

nm <- "Translation Service Info - Which translation service?"
make.names(nm)
# [1] "Translation.Service.Info...Which.translation.service."

这是来自 read.table 的相关行
if (check.names) 
col.names <- make.names(col.names, unique = TRUE)

关于read.csv 用 `?` 替换 `.` 等列名字符,用 `-` 替换 `...`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27640242/

26 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com