导出到CSV时stream-delim出错

k10s72fa  于 2023-05-11  发布在  其他
关注(0)|答案(2)|浏览(418)

我试图将此StatsBomb数据写入CSV,但我不断收到以下错误消息:
Error in stream_delim_(df, path, ..., bom = bom, quote_escape = quote_escape) : Don't know how to handle vector of type list.
我迷路了(尝试了很多东西),不确定我在这里做错了什么。有人知道怎么解决这个问题吗?我把代码写在下面。

library(StatsBombR)
library(tidyverse)

### Read in all free events and matches from the FAWSL
data <- StatsBombFreeEvents()
matches <- FreeMatches(Competitions = 72)

### Clean and separate all data loaded above
dataclean <- allclean(data)

### Filter event data to include only FAWSL data.
data1 <- dataclean %>% 
  filter(dataclean$competition_id == 72) 

### Join event and match data by "match_id"
data1 <- left_join(data1, matches, by = "match_id")

FullData <- data1 %>% 
  select(-c(related_events, tactics.lineup, shot.freeze_frame, location, pass.end_location, shot.end_location, goalkeeper.end_location))

setwd()
write_csv(FullData, "StatsBomb_FullData.csv")
0lvr5msh

0lvr5msh1#

我也有同样的问题。取消列表修复了我的。

df$listcolumn <- sapply(df$listcolumn, function(x) paste0(unlist(x), collapse = "\n"))
qvsjd97n

qvsjd97n2#

创建一个不带vector的 Dataframe 和另一个vector的 Dataframe :

library(StatsBombR)

Comp <- FreeCompetitions()

Matches <- FreeMatches(Comp)

events <-get.matchFree(Matches[1,])

df2 = events[c("id","minute","second","possession","duration","location","under_pressure","counterpress","out","type.id","type.name","possession_team.id","possession_team.name","play_pattern.id","play_pattern.name","team.id","team.name")]

相关问题