sagarnikam123
2012-Feb-22 09:49 UTC
[R] how to make hash?& append element, if i want following condition
i want hash like A : 1.2, 3.4, 4.5 B : 9.7, 5.6, 4.8 C : 3.4 ,5.7, 4.6 where A key contain all three value at right sight how to append single keys & values if i have predefined hash with known length -- View this message in context: http://r.789695.n4.nabble.com/how-to-make-hash-append-element-if-i-want-following-condition-tp4409761p4409761.html Sent from the R help mailing list archive at Nabble.com.
R. Michael Weylandt
2012-Feb-22 14:17 UTC
[R] how to make hash?& append element, if i want following condition
The easiest way to get a hash structure is to use environments. hash1 <- new.env() hash1$A <- c(1.2, 3.4, 4.5) # etc. If I remember right there is a package on CRAN that abstracts some of this interface away (it's not the most intuitive) but this would likely be the core of it. Michael On Wed, Feb 22, 2012 at 4:49 AM, sagarnikam123 <sagarnikam123 at gmail.com> wrote:> i want hash like > A ?: ?1.2, 3.4, 4.5 > B ?: ?9.7, 5.6, 4.8 > C ?: ?3.4 ,5.7, 4.6 > > where A key contain all three value at right sight > > how to append single keys & values if i have predefined hash with known > length > > -- > View this message in context: http://r.789695.n4.nabble.com/how-to-make-hash-append-element-if-i-want-following-condition-tp4409761p4409761.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
sagarnikam123
2012-Feb-22 14:53 UTC
[R] how to make hash?& append element, if i want following condition
i did it, but using hash package ,i got error like>hash1 <- new.env() > hash1$A <- c(1.2, 3.4, 4.5) > hash1$A[1] 1.2 3.4 4.5> h<-hash(keys=c("A","B"),values=c(hash1$A,hash1$A) )Error in .set(h, ...) : Keys of length 2 do not match values of length 6 how should i proceed -- View this message in context: http://r.789695.n4.nabble.com/how-to-make-hash-append-element-if-i-want-following-condition-tp4409761p4410576.html Sent from the R help mailing list archive at Nabble.com.