More environments facilities ?
1
0
Entering edit mode
Adrian Alexa ▴ 400
@adrian-alexa-936
Last seen 10.2 years ago
Dear Bioconductor developers, I'm using Bioconductor packages and I use more often environments. I was happy to see that there are new functions in the Biobase package that work with environments: copyEnv, l2e, etc. Unfortunately I didn't find a function that returns the 'lenght' (no. of elements) of an environment. I know that I can do: > length(ls(env)) but I think this is slow and somehow redundant. Also I know that I can write a simple C function, but I will like to have this facility into R and not loading my function every time. I would like to know if such a function can (or will) be included into a next version of biobase package. Many thanks, Adrian -- Adrian Alexa Max-Planck-Institut fuer Informatik Stuhlsatzenhausweg 85 Room 514 66123 Saarbruecken, Germany
Biobase Biobase • 650 views
ADD COMMENT
0
Entering edit mode
rgentleman ★ 5.5k
@rgentleman-7725
Last seen 9.6 years ago
United States
On Fri, Oct 01, 2004 at 04:58:40PM +0200, Adrian Alexa wrote: > Dear Bioconductor developers, > > > I'm using Bioconductor packages and I use more often environments. I > was happy to see that there are new functions in the Biobase package > that work with environments: copyEnv, l2e, etc. And there are even more in R itself, things like $ and [[ work (but NOT for numeric indices, only for character values and they do NOT do partial matching). Also of note is as.list, which will coerce an environment to a list. If you want something that let's you peak at the values let me suggest DPExplorer. And also, please do note that eapply is a reasonable choice of apply for environments. > > Unfortunately I didn't find a function that returns the 'lenght' (no. > of elements) of an environment. I know that I can do: > > > length(ls(env)) why not length(env), which seems to both work and be faster... > > but I think this is slow and somehow redundant. Also I know that I can > write a simple C function, but I will like to have this facility into > R and not loading my function every time. > > I would like to know if such a function can (or will) be included into > a next version of biobase package. > > > Many thanks, > > Adrian > > > > -- > Adrian Alexa > Max-Planck-Institut fuer Informatik > Stuhlsatzenhausweg 85 Room 514 > 66123 Saarbruecken, Germany > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor -- +--------------------------------------------------------------------- ------+ | Robert Gentleman phone : (617) 632-5250 | | Associate Professor fax: (617) 632-2444 | | Department of Biostatistics office: M1B20 | | Harvard School of Public Health email: rgentlem@jimmy.harvard.edu | +--------------------------------------------------------------------- ------+
ADD COMMENT
0
Entering edit mode
On Fri, 1 Oct 2004 11:57:27 -0400, Robert Gentleman <rgentlem@jimmy.harvard.edu> wrote: > On Fri, Oct 01, 2004 at 04:58:40PM +0200, Adrian Alexa wrote: > > Dear Bioconductor developers, > > > > > > I'm using Bioconductor packages and I use more often environments. I > > was happy to see that there are new functions in the Biobase package > > that work with environments: copyEnv, l2e, etc. > > And there are even more in R itself, things like $ and [[ work (but > NOT for numeric indices, only for character values and they do NOT do > partial matching). Also of note is as.list, which will coerce an > environment to a list. If you want something that let's you peak at > the values let me suggest DPExplorer. > > And also, please do note that eapply is a reasonable choice of apply > for environments. > > > > > > Unfortunately I didn't find a function that returns the 'lenght' (no. > > of elements) of an environment. I know that I can do: > > > > > length(ls(env)) > > why not length(env), which seems to both work and be faster... > > > > > > but I think this is slow and somehow redundant. Also I know that I can > > write a simple C function, but I will like to have this facility into > > R and not loading my function every time. > > > > I would like to know if such a function can (or will) be included into > > a next version of biobase package. > > > > > > Many thanks, > > > > Adrian > > > > Thank you very much for your answer Robert. I know about the facilities that R offer for environments, but I was saying that I found the new Biobase functions very useful . Probably I wasn't to clear, so I will try to explain again what I wanted. First, I'm using R 1.9.1 on a Debian Sarge machine and as far as I observed eapply is not in this version (I sow is a R 2.0 feature, which I think is great). As for length(env) it does not work on this version. If this is a facility of the new R 2.0 version that please excuse my impatience. This is a small example of what I would expected: > e <- new.env(hash = T, parent = NULL) > assign('a', 1, e) > assign('b', letters[1:5], e) > length(e) [1] 0 > length(ls(e)) [1] 2 > ls(e) [1] "a" "b" I'm working with GO and GOstats packages and I will like a function that will do: > envLen(GOTERM) [1] 16843 Of course I can do > length(ls(GOTERM)) [1] 16843 or > length(as.list(GOTERM)) [1] 16843 but I think this is slow for big environments. I sow, by looking at the envToList() C code that the length of the environment can be easily obtain (using internal C function length(env)), so I was taking about having a R version of this function. Thank you again for your answer, Adrian Alexa
ADD REPLY

Login before adding your answer.

Traffic: 824 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6