I used RNCEP backstage to get a reanalyses data for temp. My data looks something like this:
(DD1 <- array(1:12, dim = c(2, 3, 2),
dimnames = list(c("A", "B"),
c("a", "b", "c"),
c("First", "Second"))))
# , , First
#
# a b c
# A 1 3 5
# B 2 4 6
#
# , , Second
#
# a b c
# A 7 9 11
# B 8 10 12
str(DD1)
# int [1:2, 1:3, 1:2] 1 2 3 4 5 6 7 8 9 10 ...
# - attr(*, "dimnames")=List of 3
# ..$ : chr [1:2] "A" "B"
# ..$ : chr [1:3] "a" "b" "c"
# ..$ : chr [1:2] "First" "Second"
I think this is a tabular data?
I need to write the data as csv file where I have something like this:
y a a b b c c
x A B A B A B
1 2 3 4 5 6
7 8 9 10 11 12
But when I used write.csv
I got this:
write.csv(DD1)
# "","a.First","b.First","c.First","a.Second","b.Second","c.Second"
# "A",1,3,5,7,9,11
# "B",2,4,6,8,10,12
I thought I had to transpose the data first. So I used this:
DD2 <- as.data.frame.table(DD1)
I also used t()
but that also did not work.