[R] Entering data into a multi-way array?

Victoria_Stuart 1 at VictoriasJourney.com
Thu Oct 6 04:41:58 CEST 2011


Solution:  I figured this out on my own (below).

> gnames<-read.csv("/home/victoria/R/gnames.csv",header=FALSE,sep=",")

> gnames
         V1        V2        V3        V4        V5           V6        V7
1 NM_005588 NM_004407 NM_006136 NM_004817 NM_006012 NM_001008693 NM_181435
[snip]
       V497      V498      V499      V500
1 NM_152546 XM_375762 NM_020696 NM_138459

# Saved 500 genes (values only): 3 replicates of (8 time points for
treatment 1) + 3 replicates of (8 time points for treatment 2)  = 500 x 48
.csv file

> X<-matrix(scan("/home/victoria/R/X.csv",n=500*48),500,48,byrow=TRUE)

Read 24000 items

> dim(X)

[1] 500  48

> dim(X)<-c(500,3,8,2)

# Looks good: Checked all, below, against 'source'  file "X.ods" : OK!

, , 1, 1   # = Time Point 1 replicates (columns) for Treatment 1
                [,1]          [,2]         [,3]
  [1,] -3.2093000000 -2.1463000000  0.347800000
  [2,]  0.1689000000 -0.0945000000 -0.383400000
  [3,] -0.0487000000 -0.8695000000 -1.990200000
[snip]

, , 2, 1   # = Time Point 2 replicates (columns) for Treatment 1
          [,1]          [,2]    [,3]
  [1,] -2.8531 -3.2044000000 -1.3212
  [2,]  0.5820  0.1358000000  0.4183
  [3,]  1.0075  0.3211000000 -1.7940
[snip]

, , 8, 1   # = Time Point 8 replicates (columns) for Treatment 1
                [,1]          [,2]    [,3]
  [1,] -2.3661000000 -1.8353000000  0.0682
  [2,]  0.6607000000  0.0726000000 -0.1255
  [3,] -0.4960000000 -1.8894000000 -0.9466
[snip]

, , 1, 2   # = Time Point 1 replicates (columns) for Treatment 2
                [,1]    [,2]    [,3]
  [1,] -2.0151000000 -1.4385 -0.9281
  [2,] -0.0482000000  0.2382 -0.1319
  [3,] -1.3375000000 -1.4805 -1.4416
[snip]

, , 2, 2   # = Time Point 2 replicates (columns) for Treatment 2
          [,1]    [,2]          [,3]
  [1,] -2.3212 -1.3964 -1.1155000000
  [2,]  0.0264  0.2057  0.1566000000
  [3,] -0.3569 -0.9750 -0.8666000000
[snip]

, , 7, 2   # = Time Point 7 replicates (columns) for Treatment 2
                [,1]          [,2]    [,3]
  [1,] -1.2615000000 -2.1288000000 -1.8844
  [2,]  0.1048000000 -0.2306000000 -0.0634
  [3,] -1.4571000000  0.7725000000 -1.0384
[snip]

, , 8, 2   # = Time Point 8 replicates (columns) for Treatment 2
          [,1]          [,2]    [,3]
  [1,] -0.0819 -1.8137000000 -1.4085
  [2,] -0.1336  0.2744000000  1.2913
  [3,] -1.1404 -0.7546000000 -1.2400
[snip]

Thanks anyway - Victoria  :-)


--
View this message in context: http://r.789695.n4.nabble.com/Entering-data-into-a-multi-way-array-tp3862054p3876874.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list