如何将列表转换为R中的数据框

时间:2013-05-30 13:40:40

标签: r

我有如下列表,并喜欢将其转换为数据框,任何想法?

X

str(x)看起来像这样:

List of 2
 $ :List of 8
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : chr "2013-MAY-30 09:17 AM"
  .. ..$ SITE         : chr "Home Page - User Time]"
  .. ..$ RESPONSE_TIME: chr "-"
  .. ..$ AVAIL_PERCENT: chr "-"
  .. ..$ AGENT        : num 45693
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : chr "2013-MAY-30 09:17 AM"
  .. ..$ SITE         : chr "Logon To My Accounts - User Time]"
  .. ..$ RESPONSE_TIME: chr "-"
  .. ..$ AVAIL_PERCENT: chr "-"
  .. ..$ AGENT        : num 45693
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : chr "2013-MAY-30 09:17 AM"
  .. ..$ SITE         : chr " Check - User Time]"
  .. ..$ RESPONSE_TIME: chr "-"
  .. ..$ AVAIL_PERCENT: chr "-"
  .. ..$ AGENT        : num 45693
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : chr "2013-MAY-30 09:17 AM"
  .. ..$ SITE         : chr " Activity - User Time]"
  .. ..$ RESPONSE_TIME: chr "-"
  .. ..$ AVAIL_PERCENT: chr "-"
  .. ..$ AGENT        : num 45693
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : chr "2013-MAY-30 09:17 AM"
  .. ..$ SITE         : chr "List - User Time]"
  .. ..$ RESPONSE_TIME: chr "-"
  .. ..$ AVAIL_PERCENT: chr "-"
  .. ..$ AGENT        : num 45693
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : chr "2013-MAY-30 09:17 AM"
  .. ..$ SITE         : chr "Recipient - User Time"
  .. ..$ RESPONSE_TIME: chr "-"
  .. ..$ AVAIL_PERCENT: chr "-"
  .. ..$ AGENT        : num 45693
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : chr "2013-MAY-30 09:17 AM"
  .. ..$ SITE         : chr "Cancel - User Time]"
  .. ..$ RESPONSE_TIME: chr "-"
  .. ..$ AVAIL_PERCENT: chr "-"
  .. ..$ AGENT        : num 45693
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : chr "2013-MAY-30 09:17 AM"
  .. ..$ SITE         : chr "Log Off - User Time]"
  .. ..$ RESPONSE_TIME: chr "-"
  .. ..$ AVAIL_PERCENT: chr "-"
  .. ..$ AGENT        : num 45693
 $ :List of 6
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : POSIXct[1:1], format: "2013-05-30 09:17:00"
  .. ..$ SITE         : chr "-Online Home Page - User Time]"
  .. ..$ RESPONSE_TIME: chr "4.145"
  .. ..$ AVAIL_PERCENT: chr "100.00"
  .. ..$ AGENT        : num 42627
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : POSIXct[1:1], format: "2013-05-30 09:17:00"
  .. ..$ SITE         : chr "-Logon To My Accounts - User Time]"
  .. ..$ RESPONSE_TIME: chr "6.185"
  .. ..$ AVAIL_PERCENT: chr "100.00"
  .. ..$ AGENT        : num 42627
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : POSIXct[1:1], format: "2013-05-30 09:17:00"
  .. ..$ SITE         : chr "-Pay Bills - User Time]"
  .. ..$ RESPONSE_TIME: chr "8.206"
  .. ..$ AVAIL_PERCENT: chr "100.00"
  .. ..$ AGENT        : num 42627
  ..$ :'data.frame':    1 obs. of  5 variables:
  .. ..$ DATE_TIME    : POSIXct[1:1], format: "2013-05-30 09:17:00"
  .. ..$ SITE         : chr "-Enter Payment Amounts - User Time]"
  .. ..$ RESPONSE_TIME: chr "4.976"
  .. ..$ AVAIL_PERCENT: chr "100.00"
  .. ..$ AGENT        : num 42627

1 个答案:

答案 0 :(得分:1)

这看起来像是一个双重嵌套的data.frames列表,所以请尝试:

do.call(rbind,unlist(x,FALSE))