marcozanotti/dispositionEffect

Exporting a list of dataframes from R to Excel

Closed this issue · 4 comments

I would like to conduct further analysis in excel, having computed Gains and Losses counts from a package "dispositionEffect" in R. The output having run the code below is also presented below.

code

p_res_full <- purrr::map(trx_list, portfolio_compute, market_prices = mkt)
p_res_full

This generates a list of data frames (more than 3000), as below for example.The columns for each of the data frame have same variables (same number), but there are different rows.

[992]]
  investor   asset  quantity  price   datetime      RG_count    RL_count   PG_count   PL_count
1    1932   NSK    223          6       2017-03-17        0                0            0                 0

[[993]]
  investor asset   quantity  price   datetime           RG_count    RL_count     PG_count     PL_count
1    1933   MC     7639        8        2016-03-02        0                    0                0                  0
2    1933  NL       4700       50       2016-02-22       NA                   NA           NA               NA
3    1933  RL       3880        2        2016-02-16        0                       0              0                  0

[[994]]
  investor  asset   quantity    price            datetime                          RG_count RL_count  PG_count  PL_count
1    1936     IV          439        10.6          2010-09-15 01:00:00               0                  0          1            0

[[995]]
  investor asset    quantity   price            datetime                         RG_count RL_count     PG_count PL_count
1    1940   PL    272              55                 2017-03-27 01:00:00        0                   0             1              0


[[997]]
  investor           asset    quantity  price            datetime                         RG_count   RL_count  PG_count PL_count
1    1944            FB         9040      6.0                2011-07-14 01:00:00        0                    0          1               0
2    1944            MC        21490    3.00              2010-10-20 01:00:00        0                   0           1               0
3    1944           RL          9340     1.20               2012-03-13 00:00:00        0                   0            0              0
4    1944            NM        6300     2.75              2012-03-22 00:00:00       NA                NA        NA              NA

I would like to export all these dataframes into a single excel sheet for further analysis. Please help out. I tried to use write_xlsx() but got error messages that i do not have enogh memory.

Grateful for your kind feedback

Not related to dispositionEffect

Hi @DLAtatem,
once again, this has nothing to do with dispositionEffect. This is an R topic.

By the way, try collapsing the list into a single dataframe first (for example with bind_rows()), then write it to excel or csv (better).

Yes, it is not a bug. I sent it as a question, seeking help. Am sorry for asking.

Thanks for the feedback. Again, sorry for asking.