I have the following data:
data <- list(list(eventId = 8, subEventName = "Simple pass", tags = list(
list(id = 1801)), playerId = 122671, positions = list(list(
y = 50, x = 50), list(y = 53, x = 35)), matchId = 2057954,
eventName = "Pass", teamId = 16521, matchPeriod = "1H", eventSec = 1.656214,
subEventId = 85, id = 258612104), list(eventId = 8, subEventName = "High pass",
tags = list(list(id = 1801)), playerId = 139393, positions = list(
list(y = 53, x = 35), list(y = 19, x = 75)), matchId = 2057954,
eventName = "Pass", teamId = 16521, matchPeriod = "1H", eventSec = 4.487814,
subEventId = 83, id = 258612106))
I want to create a data frame out of this list. I use unlist(data)
, which creates a row with repeated variables.
> unlist(data)
eventId subEventName tags.id playerId positions.y positions.x positions.y
"8" "Simple pass" "1801" "122671" "50" "50" "53"
positions.x matchId eventName teamId matchPeriod eventSec subEventId
"35" "2057954" "Pass" "16521" "1H" "1.656214" "85"
id eventId subEventName tags.id playerId positions.y positions.x
"258612104" "8" "High pass" "1801" "139393" "53" "35"
positions.y positions.x matchId eventName teamId matchPeriod eventSec
"19" "75" "2057954" "Pass" "16521" "1H" "4.487814"
subEventId id
"83" "258612106"
Each observation starts with the eventId
variable. So, basically I have to split the data into dataframes starting with eventId
, and then moving those dataframes one under the other. I.e. having two observations in this case. Do you have any idea? thanks in advance
question from:
https://stackoverflow.com/questions/65946359/all-data-in-a-row-move-observations-under-each-other 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…