[R] sets package: converting a set to data frame?
Henrique Dallazuanna
wwwhsd at gmail.com
Mon Mar 22 22:39:52 CET 2010
Try this:
data.frame(row.names = unlist(a), gset_memberships(a))
On Mon, Mar 22, 2010 at 6:26 PM, Czerminski, Ryszard
<Ryszard.Czerminski at astrazeneca.com> wrote:
> I just started using nice package "sets"
> and I wonder if there are utilities to convert (some) sets to data frame
> (as in the example below)
>
>> library(sets)
>> a <- gset(elements = list(e('A', 0.1), e('B', 0.8)))
>> lst <- as.list(a)
>> nr <- length(lst)
>> rnames <- character()
>> for (i in 1:nr) rnames[i] <- lst[[i]]
>> df <- data.frame(row.names=rnames)
>> df$memberships <- attr(lst, 'memberships')
>> a
> {"A" [0.1], "B" [0.8]}
>> df
> memberships
> A 0.1
> B 0.8
>>
>
> Best regards,
> Ryszard
> ---
> Ryszard Czerminski
>
>
> --------------------------------------------------------------------------
> Confidentiality Notice: This message is private and may ...{{dropped:11}}
>
> ______________________________________________
> R-help at 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.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list