Keith Jewell <k.jewell <at> campden.co.uk> writes:

> 
> Hi All,
> 
> This example code
> ----------------
> dDF <- structure(list(y = c(4.75587, 4.8451, 5.04139, 4.85733, 5.20412,
>  5.92428, 5.69897, 4.78958, 4, 4), t = c(0, 48, 144, 192, 240,
>  312, 360, 0, 48, 144), Batch = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1
>  ), T = c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2), pH = c(4.6, 4.6, 4.6,
>  4.6, 4.6, 4.6, 4.6, 4.6, 4.6, 4.6), S = c(0, 0, 0, 0, 0, 0, 0,
>  0, 0, 0), N = c(0, 0, 0, 0, 0, 0, 0, 80, 80, 80)), .Names = c("y",
>  "t", "Batch", "T", "pH", "S", "N"), row.names = c(NA, 10L), class = 
> "data.frame")
> str(dDF)
> expand.grid(dDF)
> ------------------------------------
> 'hangs' for a while and then gives an error

or even simpler

expand.grid(data.frame(1:3, 1:3))
Error in `[[<-.data.frame`(`*tmp*`, i, value = c(1L, 2L, 3L, 1L, 2L, 3L,  : 
  replacement has 9 rows, data has 3

but why do this on a data frame as it works fine on a list

expand.grid(list(1:3, 1:3))
  Var1 Var2
1    1    1
2    2    1
3    3    1
4    1    2
5    2    2
6    3    2
7    1    3
8    2    3
9    3    3

or just vectors
expand.grid(1:3, 1:3)
  Var1 Var2
1    1    1
2    2    1
3    3    1
4    1    2
5    2    2
6    3    2
7    1    3
8    2    3
9    3    3

-- 
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to