我试图在R中使用readLines,但我得到低于错误
orders1<-readLines(orders,2)
# Error in readLines(orders, 2) : 'con' is not a connection
Run Code Online (Sandbox Code Playgroud)
orders<-read.csv("~/orders.csv")
orders
orders1<-readLines(orders,2)
orders1
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
我猜你想要这个:
orders1 <- readLines( file("~/orders.csv") )
Run Code Online (Sandbox Code Playgroud)
目前尚不清楚为什么要进行自己的解析或替换,但这应该为readLines提供有效的连接对象.