gpt4 book ai didi

r - R程序中的'Con not a connection'错误

转载 作者:行者123 更新时间:2023-12-01 23:23:25 24 4
gpt4 key购买 nike

我正在尝试在 R 中使用 readLines,但出现以下错误

orders1<-readLines(orders,2)
# Error in readLines(orders, 2) : 'con' is not a connection

代码 :
orders<-read.csv("~/orders.csv")

orders

orders1<-readLines(orders,2)

orders1

数据:
id,item,quantity_ordered,item_cost
1,playboy roll,1,12
1,rockstar roll,1,10
1,spider roll,1,8
1,keystone roll,1,25
1,salmon sashimi,6,3
1,tuna sashimi,6,2.5
1,edamame,1,6
2,salmon skin roll,1,8
2,playboy roll,1,12
2,unobtanium roll,1,35
2,tuna sashimi,4,2.5
2,yellowtail hand roll,1,7
4,california roll,1,4
4,cucumber roll,1,3.5
5,unagi roll,1,6.5
5,firecracker roll,1,9
5,unobtanium roll,1,35
,chicken teriaki hibachi,1,7.95
,diet coke,1,1.95

最佳答案

我猜你想要这个:

orders1 <- readLines( file("~/orders.csv") )

不清楚为什么要进行自己的解析或替换,但这应该给 readLines 一个有效的连接对象。

关于r - R程序中的'Con not a connection'错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25298840/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com