For a function that takes an argument as a list of lists of parameters,
I'd like to be able to convert that
to a data.frame and vice versa, but can't quite figure out how.
pats <- list(structure(list(shape = 0, shape.col = "black", shape.lty = 1,
cell.fill = "white", back.fill = "white", labe
Not very elegant but seems to work:
pats.df <- as.data.frame(t(sapply (1:length(pats), function (i)
do.call(cbind,pats[[i]]
colnames(pats.df) <- names(pats[[1]])
# then
pats2 <- lapply (1:nrow(pats.df), function (i) as.list(t(pats.df)[,i]))
Nael
On Wed, Jul 23, 2008 at 3:23 PM, Michael Frie
Try this:
pats.df <- do.call(rbind, pats)
On Wed, Jul 23, 2008 at 10:23 AM, Michael Friendly <[EMAIL PROTECTED]> wrote:
> For a function that takes an argument as a list of lists of parameters, I'd
> like to be able to convert that
> to a data.frame and vice versa, but can't quite figure out how.
on 07/23/2008 08:23 AM Michael Friendly wrote:
For a function that takes an argument as a list of lists of parameters,
I'd like to be able to convert that
to a data.frame and vice versa, but can't quite figure out how.
pats <- list(structure(list(shape = 0, shape.col = "black", shape.lty = 1,
try
?unlist
it may help
regards
+-
| Patrizio Frederic
| Research associate in Statistics,
| Department of Economics,
| University of Modena and Reggio Emilia,
| Via Berengario 51,
| 41100 Modena, Italy
|
| tel: +39 059 205 6727
| fax: +39 059 2
Michael Friendly yorku.ca> writes:
>
> For a function that takes an argument as a list of lists of parameters,
> I'd like to be able to convert that
> to a data.frame and vice versa, but can't quite figure out how.
>
[snip data]
pats.df <- do.call("rbind",pats)
pats2 <- apply(pats.df,1,
Dear Michael,
Perhaps,
data.frame(do.call(rbind,lapply(pats,function(x) t(as.matrix(x,ncol=10)
HTH,
Jorge
On Wed, Jul 23, 2008 at 9:23 AM, Michael Friendly <[EMAIL PROTECTED]> wrote:
> For a function that takes an argument as a list of lists of parameters, I'd
> like to be able to conv
on 07/23/2008 09:42 AM Henrique Dallazuanna wrote:
Try this:
pats.df <- do.call(rbind, pats)
Henrique,
Take note of the object that results from this:
> do.call(rbind, pats)
shape shape.col shape.lty cell.fill back.fill label label.size
[1,] 0 "black" 1 "white" "white"
Oh, you are rigth Marc, thanks.
Another option is:
pats.df <- do.call(rbind.data.frame, pats)
On Wed, Jul 23, 2008 at 1:10 PM, Marc Schwartz
<[EMAIL PROTECTED]> wrote:
> on 07/23/2008 09:42 AM Henrique Dallazuanna wrote:
>>
>> Try this:
>>
>> pats.df <- do.call(rbind, pats)
>
> Henrique,
>
> Tak
9 matches
Mail list logo