如何将表绑定到列中(How to bind table into columns)

系统教程 行业动态 更新时间:2024-06-14 16:59:47
如何将表绑定到列中(How to bind table into columns)

我有下表delete :

complete creditcheck disclosure getduedates package payment probing serviceability 1 2 3 3 2 2 1 1

如何将这些列添加到我的数据框data_frame ?

假设data_frame与data_frame具有相同的行数。

I have the following table delete:

complete creditcheck disclosure getduedates package payment probing serviceability 1 2 3 3 2 2 1 1

How do I add these columns, as they appear, to my data frame data_frame?

Assume that data_frame has the same number of rows as delete.

最满意答案

尝试

library(dplyr) bind_rows(df1, as.data.frame.list(delete)) # Source: local data frame [4 x 3] # A B C #1 1 4 7 #2 2 5 8 #3 3 6 9 #4 10 10 10

如果您需要使用现有列来“删除”

bind_cols(df2, as.data.frame.list(delete)) # V1 V2 V3 A B C #1 1 2 3 10 10 10

数据

df1 <- data_frame(A=1:3, B=4:6, C=7:9) b <- factor(rep(c("A","B","C"), 10)) delete <- table(b) df2 <- data_frame(V1= 1, V2=2, V3=3)

Try

library(dplyr) bind_rows(df1, as.data.frame.list(delete)) # Source: local data frame [4 x 3] # A B C #1 1 4 7 #2 2 5 8 #3 3 6 9 #4 10 10 10

If you need to cbind the 'delete' with the existing columns

bind_cols(df2, as.data.frame.list(delete)) # V1 V2 V3 A B C #1 1 2 3 10 10 10

data

df1 <- data_frame(A=1:3, B=4:6, C=7:9) b <- factor(rep(c("A","B","C"), 10)) delete <- table(b) df2 <- data_frame(V1= 1, V2=2, V3=3)

更多推荐

data_frame,delete,serviceability,probing,电脑培训,计算机培训,IT培训"/> <meta

本文发布于:2023-04-17 09:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/8f837c542dfb35e6ed8afda9f20d23b5.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   如何将   到列中   columns   table

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!