0

So i have this matrix which looks like thislist matrix

and i would like to expand all the elements in the list and im trying "unlist", "lappy" and "do.call(rbind)" - but nothing seems to be working for me -it can't be this hard?

Thanks, Chris

dput(y)
structure(list(Data = "Data     : example", Response = "Response variable    : Domestic.Pax", 
    Independent = "Explanatory variables: Domestic.GDP, Domestic.Airfare, Puerto.Rico.Population", 
    Intercept = "(Intercept)            11028544.153 1710074.846   6.449  < .001 ***", 
    X1 = "Domestic.GDP             408667.401   91321.734   4.475  < .001 ***", 
    X2 = "Domestic.Airfare          -4538.832    5527.947  -0.821   0.420", 
    X3 = "Puerto.Rico.Population -2347450.969  642070.743  -3.656   0.001 **", 
    `R-Square` = "R-squared: 0.868,  Adjusted R-squared: 0.851", 
    `F-Statistic` = "F-statistic: 50.514 df(3,23), p.value < .001", 
    n = "Nr obs: 27", market = "dom", version = "1"), .Names = c("Data", 
"Response", "Independent", "Intercept", "X1", "X2", "X3", "R-Square", 
"F-Statistic", "n", "market", "version"), row.names = c(NA, -1L
), class = c("tbl_df", "tbl", "data.frame"))
Chris
  • 33
  • 4
  • 2
    Please use `dput()` to provide some example data as described [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – tobiasegli_te Nov 21 '17 at 14:43
  • If it really is a matrix try: `as.vector(mat)` – Mike H. Nov 21 '17 at 14:53
  • What does "expand all the elements in the list" mean? What exactly is the desired output? How to you create such an object in the first place? Seems odd to have so much structured data in a plain character strings. – MrFlick Nov 21 '17 at 15:12
  • Hey MrFlick, so the desired output is for for example rather than X1 = Domestic GDP 408667.401 91321.734 4.475 <.001 *** Could i get this as 5 different rows of Domestic GDP to <.001 *** ?? – Chris Nov 21 '17 at 15:18
  • Do you want something like ```library(stringr); x %>% str_split(pattern = " ") %>% unlist()``` ? – rsmith54 Nov 21 '17 at 15:57
  • Yes rsmith54 - that is exactly what I wanted - Thanks!! – Chris Nov 23 '17 at 10:45

0 Answers0