I've used the function acf
to AutoCorrelate by group:
group_by(filterindex) %>%
summarise(ac = list(acf(meanValence, lag.max = 10)))
My result is a DF with 2 column (filterindex and ac) and has 10 rows.
The secound column, "ac" contains in each cell "list of length 6".
I want to unlist()
these cells so I can build a plot of the data by each group.
In other words, I want to extract the data from the list into columns.
When I try to use unlist()
, I get an error:
Error: Assigned data
unlist(lagCheck$ac)
must be compatible with existing data. x Existing data has 10 rows. x Assigned data has 250 rows. i Only vectors of size 1 are recycled
Is there any way to extract the data from each cell into saparate columns?
Thanks!
I'm adding the file:
structure(list(filterindex = c("IY1234_11", "IY1234_14", "IY1234_2",
"IY1234_5", "IY1234_9", "YF1234_11", "YF1234_15", "YF1234_3",
"YF1234_5", "YF1234_9"), ac = list(structure(list(acf = structure(c(1,
0.811798556550654, 0.627386051181487, 0.525498436917337, 0.464521367964671,
0.414990027612064, 0.365357901454317, 0.317002282870693, 0.277628764819084,
0.252110413675042, 0.230857048035993), .Dim = c(11L, 1L, 1L)),
type = "correlation", n.used = 3559L, lag = structure(c(0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10), .Dim = c(11L, 1L, 1L)), series = "meanValence",
snames = NULL), class = "acf"), structure(list(acf = structure(c(1,
0.812954955747791, 0.660972431349436, 0.606200383929671, 0.566973727353185,
0.528695448431704, 0.497032929064658, 0.475277413972852, 0.451634687077036,
0.428070611800892, 0.410971876587924), .Dim = c(11L, 1L, 1L)),
type = "correlation", n.used = 3600L, lag = structure(c(0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10), .Dim = c(11L, 1L, 1L)), series = "meanValence",
snames = NULL), class = "acf"), structure(list(acf = structure(c(1,
0.794127006651825, 0.622911924040662, 0.526002295899464, 0.457914856216244,
0.396796288075039, 0.350437514598721, 0.31343606030936, 0.287429425131587,
0.261501017028658, 0.229603463164826), .Dim = c(11L, 1L, 1L)),
type = "correlation", n.used = 3511L, lag = structure(c(0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10), .Dim = c(11L, 1L, 1L)), series = "meanValence",
snames = NULL), class = "acf"), structure(list(acf = structure(c(1,
0.86214616647042, 0.736742907476865, 0.659146619768523, 0.598510521420571,
0.551973561891987, 0.512240559662018, 0.471883614972944, 0.437736880271234,
0.409875465478741, 0.384891544522991), .Dim = c(11L, 1L, 1L)),
type = "correlation", n.used = 3368L, lag = structure(c(0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10), .Dim = c(11L, 1L, 1L)), series = "meanValence",
snames = NULL), class = "acf"), structure(list(acf = structure(c(1,
0.832579604548681, 0.696017549671124, 0.619484328593781, 0.564440279554403,
0.519058064117993, 0.482773415455994, 0.448869933383051, 0.407332365756958,
0.366405526731125, 0.32757780840695), .Dim = c(11L, 1L, 1L)),
type = "correlation", n.used = 3576L, lag = structure(c(0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10), .Dim = c(11L, 1L, 1L)), series = "meanValence",
snames = NULL), class = "acf"), structure(list(acf = structure(c(1,
0.68556492740373, 0.454848510565868, 0.350286285053742, 0.268884136347556,
0.239078585315277, 0.210196854542057, 0.20006410547457, 0.192884602043769,
0.18454996341636, 0.171205027821855), .Dim = c(11L, 1L, 1L)),
type = "correlation", n.used = 3597L, lag = structure(c(0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10), .Dim = c(11L, 1L, 1L)), series = "meanValence",
snames = NULL), class = "acf"), structure(list(acf = structure(c(1,
0.670095995265377, 0.43372520047406, 0.352664781684659, 0.303693247694507,
0.251203828506515, 0.214518820918493, 0.205266460850874, 0.20293193447206,
0.203610756614635, 0.186680789521751), .Dim = c(11L, 1L, 1L)),
type = "correlation", n.used = 3205L, lag = structure(c(0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10), .Dim = c(11L, 1L, 1L)), series = "meanValence",
snames = NULL), class = "acf"), structure(list(acf = structure(c(1,
0.591650063857695, 0.347372920357488, 0.255988756063866, 0.223563644580496,
0.189783476665092, 0.175430441726183, 0.153872532976106, 0.142564779399524,
0.143779895895664, 0.127934048803667), .Dim = c(11L, 1L, 1L)),
type = "correlation", n.used = 3298L, lag = structure(c(0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10), .Dim = c(11L, 1L, 1L)), series = "meanValence",
snames = NULL), class = "acf"), structure(list(acf = structure(c(1,
0.71188624496217, 0.468914143623161, 0.375966807510404, 0.326107000887847,
0.284212517761139, 0.254411081196079, 0.236600345854638, 0.215266086252369,
0.190401107127801, 0.158506374580939), .Dim = c(11L, 1L, 1L)),
type = "correlation", n.used = 2938L, lag = structure(c(0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10), .Dim = c(11L, 1L, 1L)), series = "meanValence",
snames = NULL), class = "acf"), structure(list(acf = structure(c(1,
0.667430910491119, 0.435851760081718, 0.334174146985532, 0.262817311918962,
0.20353074131307, 0.186028793933915, 0.192253655643755, 0.197001241058914,
0.181144578826439, 0.181779077174667), .Dim = c(11L, 1L, 1L)),
type = "correlation", n.used = 3598L, lag = structure(c(0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10), .Dim = c(11L, 1L, 1L)), series = "meanValence",
snames = NULL), class = "acf"))), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))
Thanks!