0

我有一个这样的数据集:

Date Tank Time Female.in.Middle Female.in.R.assoc Female.in.L.assoc R.side.of.divider
96  16-May   I3 1045           0.6080            0.0646            0.2561            0.0000
97  16-May   I3  215           0.5583            0.4210            0.0058            0.0000
100 17-May   I3  115           0.5190            0.3346            0.1381            0.0000
102 21-May   I3 1030           0.2184            0.3120            0.1335            0.3256
104 30-May   I3 1045           0.0092            0.0520            0.2067            0.0000
106 31-May   I3 1045           0.0000            0.0000            0.0000            0.0000
    L.side.of.Divider Tank.1 Date.Entered M.L.name Male.L.Length Male.L.Weight M.R.name
96             0.0655     I3       15-May  green 2           7.8         16.67   pink 1
97             0.0000     I3       15-May  green 2           7.8         16.67   pink 1
100            0.0000     I3       15-May  green 2           7.8         16.67   pink 1
102            0.0000     I3       15-May  green 2           7.8         16.67   pink 1
104            0.6652     I3       15-May  green 2           7.8         16.67   pink 1
106            0.9767     I3       15-May  green 2           7.8         16.67   pink 1
    Male.R.Length Male.R.Weight Side.of.Spawn F.Length F.Weight F.name last.female.spawn.date
96            7.8         20.99             L      4.3     2.84     1c                  5-May
97            7.8         20.99             L      4.3     2.84     1c                  5-May
100           7.8         20.99             L      4.3     2.84     1c                  5-May
102           7.8         20.99             L      4.3     2.84     1c                  5-May
104           7.8         20.99             L      4.3     2.84     1c                  5-May
106           7.8         20.99             L      4.3     2.84     1c                  5-May
    spawn.date.in.paradigm X d.in.p dbs X.1 X.2 X.3
96                  29-May        1  13  NA  NA  NA
97                  29-May        1  13  NA  NA  NA
100                 29-May        2  12  NA  NA  NA
102                 29-May        6   8  NA  NA  NA
104                 29-May       15  -1  NA  NA  NA
106                 29-May       16  -2  NA  NA  NA

使用 cbind() 函数创建边合计后:

rside1c<-cbind(jd1c$Female.in.R.assoc + jd1c$R.side.of.divider)
lside1c<-cbind(jd1c$Female.in.L.assoc + jd1c$L.side.of.Divider)

我想使用 rbind() 创建一个表,但它只是将它们像一个列表一样放在一起。如果我使用 rside1c 和 lside1c 的值创建向量,那么它工作得很好。我想跳过这一步虽然..如何更改此数据以正常工作?

而不是这个:

    [,1]
 [1,] 0.0646
 [2,] 0.4210
 [3,] 0.3346
 [4,] 0.6376
 [5,] 0.0520
 [6,] 0.0000
 [7,] 0.3216
 [8,] 0.0058
 [9,] 0.1381
[10,] 0.1335
[11,] 0.8719
[12,] 0.9767

我想要这个:

 [,1]   [,2]   [,3]   [,4]   [,5]   [,6]
vr 0.0646 0.4210 0.3346 0.6376 0.0520 0.0000
vl 0.3216 0.0058 0.1381 0.1335 0.8719 0.9767

不这样做:

vr<-c(.0646, .4210, .3346, .6376, .0520, .0)

vl<-c(.3216, .0058, .1381, .1335, .8719, .9767)

tab1<-rbind(vr, vl)

谢谢

4

1 回答 1

0

你可以简单地用t函数转置它

dat <- data.frame(vr, vl)
dat
#      vr     vl
#1 0.0646 0.3216
#2 0.4210 0.0058
#3 0.3346 0.1381
#4 0.6376 0.1335
#5 0.0520 0.8719
#6 0.0000 0.9767
t(dat)
#     [,1]   [,2]   [,3]   [,4]   [,5]   [,6]
#vr 0.0646 0.4210 0.3346 0.6376 0.0520 0.0000
#vl 0.3216 0.0058 0.1381 0.1335 0.8719 0.9767
于 2012-07-17T16:37:08.083 回答