简体   繁体   English

从表中提取日期 - R

[英]Extract dates from a table - R

For example: If I do a table with the variables "X1" and "X2", and I need to take only the first column from the table and put it into a new data frame with their respective names in columns, and index.:例如:如果我使用变量“X1”和“X2”创建一个表,我只需要从表中取出第一列并将其放入一个新的数据框中,在列中使用它们各自的名称和索引。:

在此处输入图片说明

¿How can I create a function for do that? ¿如何创建一个函数来做到这一点?

Thanks you!谢谢!

Is what you are looking for something like this?你正在寻找的东西是这样的吗?

df1 = data.frame(Yes=c(0.38, 0.34), No=c(0.62, 0.66))
rownames(df1) = c("Man", "Woman")
df1
##        Yes   No
## Man   0.38 0.62
## Woman 0.34 0.66

df2 = t(df1)
df2
##      Man Woman
## Yes 0.38  0.34
## No  0.62  0.66

df2[1,]
##  Man Woman 
## 0.38  0.34 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM