将列表转换为所需的结构化数据帧

时间:2018-07-10 17:56:42

标签: r dataframe dplyr data-manipulation

我尝试了一下方法,并将其成功转换为结构化数据框架。但是我正在寻找一种有效的方法。

我所拥有的:

df <- structure(list(cosine = structure(c(5, 10, 20, 0.821125674737054, 
0.820584021682407, 0.818784175213887, 1.02581587604008, 1.02509431944765, 
1.02307664820754), .Dim = c(3L, 3L), .Dimnames = list(NULL, c("nn", 
"MAE", "RMSE"))), pearson = structure(c(5, 10, 20, 0.812128346301661, 
0.809514288963746, 0.805891663287308, 1.01707402319237, 1.01404764325875, 
1.00991824600438), .Dim = c(3L, 3L), .Dimnames = list(NULL, c("nn", 
"MAE", "RMSE"))), adjcos = structure(c(5, 10, 20, 0.767064143922509, 
0.755128645946231, 0.752496198186588, 0.978331072924123, 0.963633899712655, 
0.959829138319945), .Dim = c(3L, 3L), .Dimnames = list(NULL, 
    c("nn", "MAE", "RMSE")))), .Names = c("cosine", "pearson", 
"adjcos"))

> df


#> $cosine
#>      nn       MAE     RMSE
#> [1,]  5 0.8211257 1.025816
#> [2,] 10 0.8205840 1.025094
#> [3,] 20 0.8187842 1.023077
#> 
#> $pearson
#>      nn       MAE     RMSE
#> [1,]  5 0.8121283 1.017074
#> [2,] 10 0.8095143 1.014048
#> [3,] 20 0.8058917 1.009918
#> 
#> $adjcos
#>      nn       MAE      RMSE
#> [1,]  5 0.7670641 0.9783311
#> [2,] 10 0.7551286 0.9636339
#> [3,] 20 0.7524962 0.9598291

我想要什么:

#>    Method nn               MAE              RMSE
#>   cosine  5 0.821125674737054  1.02581587604008
#>   cosine 10 0.820584021682407  1.02509431944765
#>   cosine 20 0.818784175213887  1.02307664820754
#>  pearson  5 0.812128346301661  1.01707402319237
#>  pearson 10 0.809514288963746  1.01404764325875
#>  pearson 20 0.805891663287308  1.00991824600438
#>   adjcos  5 0.767064143922509 0.978331072924123
#>   adjcos 10 0.755128645946231 0.963633899712655
#>   adjcos 20 0.752496198186588 0.959829138319945

谢谢!

1 个答案:

答案 0 :(得分:1)

您可以使用<com.wonderkiln.blurkit.BlurLayout android:id="@+id/blurred_area" android:layout_width="match_parent" android:layout_height="210dp" android:layout_alignParentBottom="true"> </com.wonderkiln.blurkit.BlurLayout> .id 参数根据列表元素的名称创建一个新列。输出将是折叠的数据框,其中的标识符额外一栏。

bind_rows