1

I have this kind of data frame at the moment :

 gauche droite
1        0      1
2        0      0
3        1      0
4        0      0
5        0      0
6        0      0
7        0      0
8        0      0
9        0      0
10       0      0
11       0      0

and would like to display the rows in a list, having:

[row1,column1], [row1,column2],[row2,column1],[row2,column2],[row3,column1][row3,column2] etc....

Thanks for your answers!

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
EEFB
  • 25
  • 4
  • 1
    Please explain what you mean by "as a list". List is a special structure in R and it's not clear if that's what you're after. Also, consider sharing your data in an easy to paste form. – Roman Luštrik Jun 30 '17 at 13:46
  • 4
    Does `c(t(your_data))` give you what you want? – Dason Jun 30 '17 at 13:53
  • 2
    It would just be a lot more clear if you showed a concrete example of your desired output – Dason Jun 30 '17 at 13:55
  • 5
    @akrun I have no idea if it is. I mean... it probably is but the desired output isn't clear to me so I'm not sure what question would be the appropriate dupe candidate. – Dason Jun 30 '17 at 13:58
  • I do not get the pattern...(1,1) (1,2) (2,1) (2,2) (3,1) (3,2) then what? Any recursive formula? – amonk Jun 30 '17 at 14:44

2 Answers2

1

Use purrr::transpose to transpose a list (a data frame is a list).

F. Privé
  • 11,423
  • 2
  • 27
  • 78
0
N=10
gauche<-rep(1:N)
droite<-ifelse(runif(N)>0.5,1,0)
resultat<-expand.grid(gauche,droite)

resulting in:

lapply(c(1,4,6),function(x) paste0(resultat[x,]))

[[1]]
[1] "1" "0"

[[2]]
[1] "4" "0"

[[3]]
[1] "6" "0"

PS:

Of course the c(1,4,6) is arbitrary. OP needs to update the initial request in order to better formulate the answer.

amonk
  • 1,769
  • 2
  • 18
  • 27