'rfm_table_order'函数,返回小标题。但是,tibble输出仅在控制台中可见,无法在R中查看或导出它

问题描述 投票:0回答:1

我正在研究客户细分问题。并在R中处理rfm包。使用'rfm_table_order'函数时,我将其输出存储在'rfm_result'变量中(默认情况下,该变量为tibble创建)。运行“ rfm_result”后,控制台将显示正确数量的变量和观察值。但是,在全局环境中,rfm_result仅显示5个变量和0个观察值。所以我无法查看整个'rfm_result'数据集。另外,我无法导出它,因为“ rfm_result”仅作为空数据集存储在csv文件中。请帮助。

我试图将小节转换为无法工作的dataFrame。不过,rfm_result有0个观察结果

代码:

rfm_result <- rfm_table_order(data, CustomerID, InvoiceDate, Amount, analysis_date)

控制台中的输出(显示正确的行数和列数):

A tibble: 3,891 x 9
   customer_id date_most_recent recency_days transaction_count  amount recency_score frequency_score monetary_score rfm_score
         <int> <date>                  <dbl>             <dbl>   <dbl>         <int>           <int>          <int>     <dbl>
 1       12346 2011-01-18                326                 2     0               1               1              1       111
 2       12747 2011-12-07                  3                96  3837.              5               4              5       545
 3       12748 2011-12-09                  1              4279 27215.              5               5              5       555
 4       12749 2011-12-06                  4               231  3868.              5               5              5       555
 5       12820 2011-12-06                  4                59   942.              5               4              4       544
 6       12821 2011-05-09                215                 6    92.7             1               1              1       111
 7       12822 2011-09-30                 71                47   919.              2               3              4       234
 8       12823 2011-09-26                 75                 5  1760.              2               1              4       214
 9       12824 2011-10-11                 60                25   397.              3               2              2       322
10       12826 2011-12-07                  3                94  1468.              5               4              4       544

...还有3,881行

但是全球环境显示的小标题“ rfm_result”有0个观察值和5个变量

此外,如果我用dim(rfm_result)检查'rfm_result'的尺寸,我得到的输出将是0个观测值和5个变量。

我什至无法通过write.csv()函数导出此小节。其导出空白CSV文件。

[请帮助,如何在CSV中导出此小标题或查看此小标题R。

r rstudio cluster-analysis tibble
1个回答
0
投票
class(rfm_result)
  [1] "rfm_table_order" "tibble"          "data.frame"
rfm_result$rfm

上面的代码将向您显示整个结果。

#converting to csv
write.table(result$rfm,file="rfm_results.csv",sep=",",append=FALSE,row.names = FALSE)
© www.soinside.com 2019 - 2024. All rights reserved.