我在列表中放置了一个数据框。然后,当尝试将其提取回来时-我得到了所有以该数据框的列表键为前缀的列名,有没有办法完全按照最初传递的方式提取数据框?
cols<-c("column1", "Column2", "Column3")
df1<-data.frame(matrix(ncol = 3, nrow = 1))
colnames(df1)<-cols
df1
result<-list()
result['df1']<-list(df1)
newdf1<-as.data.frame(result['df1'])
newdf1
得到结果(列名以 df1 为前缀):
> cols<-c("column1", "Column2", "Column3")
> df1<-data.frame(matrix(ncol = 3, nrow = 1))
> colnames(df1)<-cols
> df1
column1 Column2 Column3
1 NA NA NA
>
> result<-list()
> result['df1']<-list(df1)
>
> newdf1<-as.data.frame(result['df1'])
> newdf1
df1.column1 df1.Column2 df1.Column3
1 NA NA NA
当然,我可以手动删除前缀,但可能有一种正确的方法可以做到这一点。谢谢!