Save a data frame with list-columns as csv file

前端 未结 5 763
清歌不尽
清歌不尽 2021-02-09 06:01

I have the following data frame that looks like this (3 columns as list).

A tibble: 14 x 4
                                                    clinic_name drop_         


        
5条回答
  •  一向
    一向 (楼主)
    2021-02-09 06:54

    Is there any specific reason why you would like to save the columns as a list ? Alternatively, you can use unnest and save it in csv. example below

    library(tidyverse)
    df_list<-data_frame(abc = letters[1:3], lst = list(1:3, 1:3, 1:3))
    df_list %>% unnest() %>% write.csv("list.csv")
    

    further, when you read the file you can nest it back

    df <- read.csv("list.csv")[ ,2:3]
    df %>% nest(lst)
    

提交回复
热议问题