[Rd] encountering difficulty asking R to manipulate the correct columns in Expression Set class (object 4). (PR#13464)
Full_Name: Guy W. Tillinghast Version: 2.8.0 OS: Windows XP professional Submission from: (NULL) (24.248.24.3) I am encountering difficulty asking R to manipulate the correct columns in Expression Set class (object 4). I download the ALL data with: library(golubEsets) data(Golub_Merge) Note, the data has the samples not in order. This is not R's fault (at least not that I can tell): > Golub_Merge$Samples [1] 39 40 42 47 48 49 41 43 44 45 46 70 71 72 68 69 67 55 56 59 52 53 51 50 54 [26] 57 58 60 61 65 66 63 64 62 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [51] 17 18 19 20 21 22 23 24 25 26 27 34 35 36 37 38 28 29 30 31 32 33 I want a subset: > learning.set<-c(1,2,3,6,8,10,11,12,13,15,16,17,18,19,20,21,23,24,26,30,31,32,34,35,36,37,39,43,44,45,46,47,48,49,50,51,52,53,55,56,57,58,59,60,62,63,64,65,66,67,68,69,70,72) > learningEset<-Golub_Merge[,learning.set] > learningEset$Samples [1] 39 40 42 49 43 45 46 70 71 68 69 67 55 56 59 52 51 50 57 65 66 63 62 1 2 [26] 3 5 9 10 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 34 35 36 37 38 28 [51] 29 30 31 33 Note what happened: 1) the order is difference than learning.set 2) samples have been switched: example: sample 72 out, sample 71 in. Okay, I troubleshoot: maybe it matters what order I request samples: > learning.set<-c(39,47,48,49,43,44,45,46,70,72,68,69,67,55,56,59,52,53,51,50,57,58,60,65,66,63,64,62,1,2,3,6,8,10,11,12,13,15,16,17,18,19,20,21,23,24,26,34,35,36,37,30,31,32) > learningEset<-Golub_Merge[,learning.set] > learningEset$Samples [1] 5 13 14 15 9 10 11 12 31 33 29 30 28 21 22 25 18 19 17 16 23 24 26 37 38 [26] 35 36 34 39 40 42 49 43 45 46 70 71 68 69 67 55 56 59 52 51 50 57 62 1 2 [51] 3 65 66 63 Frankly, this is troubling that R did not do what it was told. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] (PR#13464) encountering difficulty asking R to manipulate the correct columns in Expression Set class (object 4)
'Frankly, this is troubling' that you did not read the FAQ. This is a contributed package (from BioC, I presume) and you should report your troubles to the maintainer or the BioC support lists. Please do read the FAQ to find out why you have made work for people with better things to do. On Thu, 22 Jan 2009, guy.tillingh...@rivhs.com wrote: Full_Name: Guy W. Tillinghast Version: 2.8.0 OS: Windows XP professional Submission from: (NULL) (24.248.24.3) I am encountering difficulty asking R to manipulate the correct columns in Expression Set class (object 4). I download the ALL data with: library(golubEsets) data(Golub_Merge) Note, the data has the samples not in order. This is not R's fault (at least not that I can tell): Golub_Merge$Samples [1] 39 40 42 47 48 49 41 43 44 45 46 70 71 72 68 69 67 55 56 59 52 53 51 50 54 [26] 57 58 60 61 65 66 63 64 62 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [51] 17 18 19 20 21 22 23 24 25 26 27 34 35 36 37 38 28 29 30 31 32 33 I want a subset: learning.set<-c(1,2,3,6,8,10,11,12,13,15,16,17,18,19,20,21,23,24,26,30,31,32,34,35,36,37,39,43,44,45,46,47,48,49,50,51,52,53,55,56,57,58,59,60,62,63,64,65,66,67,68,69,70,72) learningEset<-Golub_Merge[,learning.set] learningEset$Samples [1] 39 40 42 49 43 45 46 70 71 68 69 67 55 56 59 52 51 50 57 65 66 63 62 1 2 [26] 3 5 9 10 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 34 35 36 37 38 28 [51] 29 30 31 33 Note what happened: 1) the order is difference than learning.set 2) samples have been switched: example: sample 72 out, sample 71 in. Okay, I troubleshoot: maybe it matters what order I request samples: learning.set<-c(39,47,48,49,43,44,45,46,70,72,68,69,67,55,56,59,52,53,51,50,57,58,60,65,66,63,64,62,1,2,3,6,8,10,11,12,13,15,16,17,18,19,20,21,23,24,26,34,35,36,37,30,31,32) learningEset<-Golub_Merge[,learning.set] learningEset$Samples [1] 5 13 14 15 9 10 11 12 31 33 29 30 28 21 22 25 18 19 17 16 23 24 26 37 38 [26] 35 36 34 39 40 42 49 43 45 46 70 71 68 69 67 55 56 59 52 51 50 57 62 1 2 [51] 3 65 66 63 Frankly, this is troubling that R did not do what it was told. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Italics in svg output display as bold (PR#13463)
Full_Name: Yan Wong Version: 2.8.1 OS: Mac OS X 10.4 Submission from: (NULL) (78.149.167.246) When printing a plot to and svg file, text intended to be in italics is rendered in bold (svg file viewed using both Safari 3.2.1 and Firefox 2.0.0.9. For example, try viewing the test.svg file generated by svg("test.svg", width=4,4,8) plot.new(); text(0.5,0.5,labels=expression(italic("This should be in italics"))) dev.off() Yan __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Italics in svg output display as bold (PR#13463)
It is a bug on your system: this is done by cairographics, and I suspect that the version you have is broken (or possibly your viewer). I'll attach the version I get, which does display in italics on my system. I used cairo-1.8.0-1.fc10.x86_64 (on Fedora 10). On Wed, 21 Jan 2009, y...@pixie.org.uk wrote: Full_Name: Yan Wong Version: 2.8.1 OS: Mac OS X 10.4 And how did you compile it? This might be a bug in the cairographics or fontconfig library used for the CRAN binary build, if you used that (and report such issues to R-sig-mac -- see the posting guide). Submission from: (NULL) (78.149.167.246) When printing a plot to and svg file, text intended to be in italics is rendered in bold (svg file viewed using both Safari 3.2.1 and Firefox 2.0.0.9. For example, try viewing the test.svg file generated by svg("test.svg", width=4,4,8) plot.new(); text(0.5,0.5,labels=expression(italic("This should be in italics"))) dev.off() Yan __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] encountering difficulty asking R to manipulate the correct columns in Expression Set class (object 4). (PR#13464)
Hi Guy -- As noted, this should be sent to the Bioconductor mailing list, see http://bioconductor.org/docs/mailList.html. Some more comments below... guy.tillingh...@rivhs.com writes: > Full_Name: Guy W. Tillinghast > Version: 2.8.0 > OS: Windows XP professional > Submission from: (NULL) (24.248.24.3) > > > I am encountering difficulty asking R to manipulate the correct columns in > Expression Set class (object 4). > > I download the ALL data with: > library(golubEsets) > data(Golub_Merge) > > Note, the data has the samples not in order. This is not R's fault (at least > not that I can tell): >> Golub_Merge$Samples > [1] 39 40 42 47 48 49 41 43 44 45 46 70 71 72 68 69 67 55 56 59 52 53 51 50 > 54 > [26] 57 58 60 61 65 66 63 64 62 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 > 16 > [51] 17 18 19 20 21 22 23 24 25 26 27 34 35 36 37 38 28 29 30 31 32 33 'Samples' is a covariate, not an index into the ExpressionSet. It is like any of the other 11 covariates in phenoData (try pData(Golub_Merge) to get a data frame of all covariates). > I want a subset: >> learning.set<-c(1,2,3,6,8,10,11,12,13,15,16,17,18,19,20,21,23,24,26,30,31,32,34,35,36,37,39,43,44,45,46,47,48,49,50,51,52,53,55,56,57,58,59,60,62,63,64,65,66,67,68,69,70,72) >> learningEset<-Golub_Merge[,learning.set] >> learningEset$Samples > [1] 39 40 42 49 43 45 46 70 71 68 69 67 55 56 59 52 51 50 57 65 66 63 62 1 > 2 > [26] 3 5 9 10 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 34 35 36 37 38 > 28 > [51] 29 30 31 33 This selects columns 1, 2, 3 etc of the ExpressionSet, and the corresponding phenoData. The column 1 corresponds to Sample 39, so you select that Sample, and so on. If you want individuals with particular values of the Samples column of phenoData, you might say something like Golub_Merge[, Golub_Merge$Samples %in% learning.set] just as you might select all the male samples with Golub_Merge[, Golub_Merge$Gender == "M"] Kind of a powerful idiom. > Note what happened: > 1)the order is difference than learning.set > 2)samples have been switched: example: sample 72 out, sample 71 in. > > Okay, I troubleshoot: maybe it matters what order I request samples: > >> learning.set<-c(39,47,48,49,43,44,45,46,70,72,68,69,67,55,56,59,52,53,51,50,57,58,60,65,66,63,64,62,1,2,3,6,8,10,11,12,13,15,16,17,18,19,20,21,23,24,26,34,35,36,37,30,31,32) >> learningEset<-Golub_Merge[,learning.set] >> learningEset$Samples > [1] 5 13 14 15 9 10 11 12 31 33 29 30 28 21 22 25 18 19 17 16 23 24 26 37 > 38 > [26] 35 36 34 39 40 42 49 43 45 46 70 71 68 69 67 55 56 59 52 51 50 57 62 1 > 2 > [51] 3 65 66 63 > Frankly, this is troubling that R did not do what it was told. All Bioconductor packages have vignettes, which is a good place to start to understand a package. An ExpressionSet is defined in Biobase, so visit (from the front page of the Bioconductor site, following the software link) http://bioconductor.org/packages/2.3/bioc/html/Biobase.html and read the ExpressionSetIntroduction.pdf as a starting point. There is also extensive training material (under the 'workshops' tab at the top of the page) and some excellent books. The bioconductor mailing list and mailing list archives are also very helpful places. Martin > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M2 B169 Phone: (206) 667-2793 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] pdf() and pch problems
On Thu, 2009-01-22 at 15:21 +0100, Martin Maechler wrote: > > "TZ" == T Zumbrunn > > on Thu, 22 Jan 2009 14:52:37 +0100 writes: > > TZ> Quoting Brian D Ripley : > >> On Thu, 22 Jan 2009, Robin Hankin wrote: > >> > >>> Hi > >>> > >>> R-2.8.1, Suse 11.1 > >>> > >>> I'm having problems with pdf(). In the following > >>> transcript, file 'f.pdf' does not use the expected symbols for the > plot. > >>> It uses a 'q' letter instead of the open circle I get when > >>> viewing the graphics window. > >>> > >>> I also get the same under r47678. > >>> > >>> Does anyone else get this? > >> > >> Yes, if you use a broken PDF viewer (you have not told us yours). From > ?pdf > >> > >> useDingbats: logical. Should small circles be rendered _via_ the > >> Dingbats font? Defaults to true, which produces smaller and > >> better output - this is provided for those who insist on > >> using broken PDF viewers. > >> > >> I get the problem in evince but not acroread in F10. > > TZ> The problem is caused by missing fontconfig rules in openSUSE 11.1 > TZ> (that the PDF library poppler depends on). I reported the problem a > TZ> while ago here http://bugs.freedesktop.org/show_bug.cgi?id=18002 > TZ> (instructions on how to fix the issue are included) and filed a bug > at > TZ> the openSUSE bug database > TZ> https://bugzilla.novell.com/show_bug.cgi?id=434676. The bug was > TZ> closed, but I reopened it. > > That's interesting, thank you very much, Thomas, for the extra > explanation! > > As you know (but your text above could be read differently) this > bug ... quite long standing! ... seems to be much wider spread > than just (Open)SuSE. I have seen and still see it on Redhat > (RHEL 5) and many Ubuntu versions too. > > And indeed, the workaround recommended (somewhere) in the above > URL is working for me too: > > Add the following (without the "-" lines) to your > ~/.fonts.conf file (or create such a file) : > --snip- > > ZapfDingbats > Dingbats > > --snip- > > Martin Maechler, ETH Zurich [Moved to R-Devel] Same problem on Fedora 8 through 10. The snippet Martin shows fixes the problem on those systems also. It would be very useful to have this documented somewhere either as a note in ?pdf or in perhaps in the R Installation and Administration Manual, until such a time as distro's fix these problems. To that end I'll also be filing a bug against fedora 10 when I get home (and confirm it is still there) as my system has an entry for 'Zapf Dingbats' but not 'ZapfDingbats' which causes the problems on my boxes. Great to finally have worked around this issue --- not that it was R's fault. I had completely missed the useDingbats argument of pdf(). The Rd file does however make it sound that the default (TRUE) is there to fix the problem of broken PDF viewers, where surely it is the FALSE state that fixes the problem, or perhaps what was intended was that it is the argument itself that was provided to fix buggy viewers. I'd be happy to patch any/all of those sources if someone in R Core would be willing to take a lot and possibly apply them? All the best, G > > > > >>> le112:~/scratch/R-2.8.1% R --vanilla --quiet > pdf(file='~/f.pdf') > plot(1:10 , pch=1) > dev.off() > >>> null device > >>> 1 > sessionInfo() > >>> R version 2.8.1 (2008-12-22) > >>> i686-pc-linux-gnu > >>> > >>> locale: > >>> > LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C > >>> > >>> attached base packages: > >>> [1] stats graphics grDevices utils datasets methods > >>> base> q() > >>> le112:~/scratch/R-2.8.1% > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> -- > >>> Robin K. S. Hankin > >>> Uncertainty Analyst > >>> University of Cambridge > >>> 19 Silver Street > >>> Cambridge CB3 9EP > >>> 01223-764877 > >>> > >>> __ > >>> r-h...@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. > >>> > >> > >> -- > >> Brian D. Ripley, rip...@stats.ox.ac.uk > >> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > >> University of Oxford, Tel: +44 1865 272861 (self) > >> 1 South Parks Road,
Re: [Rd] [R] pdf() and pch problems
On Thu, 22 Jan 2009, Gavin Simpson wrote: On Thu, 2009-01-22 at 15:21 +0100, Martin Maechler wrote: "TZ" == T Zumbrunn on Thu, 22 Jan 2009 14:52:37 +0100 writes: TZ> Quoting Brian D Ripley : >> On Thu, 22 Jan 2009, Robin Hankin wrote: >> >>> Hi >>> >>> R-2.8.1, Suse 11.1 >>> >>> I'm having problems with pdf(). In the following >>> transcript, file 'f.pdf' does not use the expected symbols for the plot. >>> It uses a 'q' letter instead of the open circle I get when >>> viewing the graphics window. >>> >>> I also get the same under r47678. >>> >>> Does anyone else get this? >> >> Yes, if you use a broken PDF viewer (you have not told us yours). From ?pdf >> >> useDingbats: logical. Should small circles be rendered _via_ the >> Dingbats font? Defaults to true, which produces smaller and >> better output - this is provided for those who insist on >> using broken PDF viewers. >> >> I get the problem in evince but not acroread in F10. TZ> The problem is caused by missing fontconfig rules in openSUSE 11.1 TZ> (that the PDF library poppler depends on). I reported the problem a TZ> while ago here http://bugs.freedesktop.org/show_bug.cgi?id=18002 TZ> (instructions on how to fix the issue are included) and filed a bug at TZ> the openSUSE bug database TZ> https://bugzilla.novell.com/show_bug.cgi?id=434676. The bug was TZ> closed, but I reopened it. That's interesting, thank you very much, Thomas, for the extra explanation! As you know (but your text above could be read differently) this bug ... quite long standing! ... seems to be much wider spread than just (Open)SuSE. I have seen and still see it on Redhat (RHEL 5) and many Ubuntu versions too. And indeed, the workaround recommended (somewhere) in the above URL is working for me too: Add the following (without the "-" lines) to your ~/.fonts.conf file (or create such a file) : --snip- ZapfDingbats Dingbats --snip- Martin Maechler, ETH Zurich [Moved to R-Devel] Same problem on Fedora 8 through 10. The snippet Martin shows fixes the problem on those systems also. It would be very useful to have this documented somewhere either as a note in ?pdf or in perhaps in the R Installation and Administration Manual, until such a time as distro's fix these problems. To that end I'll also be filing a bug against fedora 10 when I get home (and confirm it is still there) as my system has an entry for 'Zapf Dingbats' but not 'ZapfDingbats' which causes the problems on my boxes. It is there on my F10 system (brand-new, installed last night). Great to finally have worked around this issue --- not that it was R's fault. I had completely missed the useDingbats argument of pdf(). The Rd file does however make it sound that the default (TRUE) is there to fix the problem of broken PDF viewers, where surely it is the FALSE state that fixes the problem, or perhaps what was intended was that it is the argument itself that was provided to fix buggy viewers. The argument itself. (This is not the only issue in PDF viewers, BTW, but here xpdf and gs both also work correctly.) I'd be happy to patch any/all of those sources if someone in R Core would be willing to take a lot and possibly apply them? Send them to me and I'll take a look. All the best, G >>> le112:~/scratch/R-2.8.1% R --vanilla --quiet pdf(file='~/f.pdf') plot(1:10 , pch=1) dev.off() >>> null device >>> 1 sessionInfo() >>> R version 2.8.1 (2008-12-22) >>> i686-pc-linux-gnu >>> >>> locale: >>> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C >>> >>> attached base packages: >>> [1] stats graphics grDevices utils datasets methods >>> base> q() >>> le112:~/scratch/R-2.8.1% >>> >>> >>> >>> >>> >>> >>> >>> >>> -- >>> Robin K. S. Hankin >>> Uncertainty Analyst >>> University of Cambridge >>> 19 Silver Street >>> Cambridge CB3 9EP >>> 01223-764877 >>> >>> __ >>> r-h...@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. >>> >> >> -- >> Brian D. Ripley, rip...@stats.ox.ac.uk >> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ >> University of Oxford, Tel: +44 1865 272861 (self) >> 1 South Parks Road, +44 1865 272866 (PA) >> Oxford OX1 3TG, UK
[Rd] Accessing a c-level complicated structure from R
Hello, R-devel seems to be the appropriated list for what I'm to ask: soory if I'm wrong. I am a c newbie but nevertheless I am trying to 'couple' an extern c software with R. The compiled library is actually a stand-alone c program, which uses text file for input and output. It uses *lots* of differents and (to me) rather complicated and nested "struct"s to represent data for intern calculation. I want to make this program a -shared lib to use with R. I have (among many others) the following question: can I access from R a c-level defined struct, as input/output of my .C called function? If yes... how? Any clue, manual, tutorial on c programming with R (other than R-exts and R-ints), and hint is greatly appreciated... Thanks, Scion __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] pdf() and pch problems
On Thu, 2009-01-22 at 15:08 +, Brian D Ripley wrote: > On Thu, 22 Jan 2009, Gavin Simpson wrote: > > > On Thu, 2009-01-22 at 15:21 +0100, Martin Maechler wrote: > >>> "TZ" == T Zumbrunn > >>> on Thu, 22 Jan 2009 14:52:37 +0100 writes: > >> > >> TZ> Quoting Brian D Ripley : > >>>> On Thu, 22 Jan 2009, Robin Hankin wrote: > > > I'd be happy to patch any/all of those sources if someone in R Core > > would be willing to take a lot and possibly apply them? > > Send them to me and I'll take a look. Thanks Brian, Attached is a patch to pdf.Rd against the SVN trunk, revision 47685, which modifies the emphasis in the useDingbats argument and adds information about the workaround on unix systems only. Please edit/use as you see fit. If this is sufficient to document the issue and workaround I won't patch R-admin.texi as there doesn't appear to be anywhere suitable to insert this note in that file - most platform specific information appears to pertain to /building/ R not tweaking your system to work around a problem whilst using R. In case the attachment gets mangled somewhere on long the line, you can grab the patch from: http://www.homepages.ucl.ac.uk/~ucfagls/files/pdf.Rd.patch All the best, Gavin > > > > > All the best, > > > > G > > > >> > >> > >> > >>>>> le112:~/scratch/R-2.8.1% R --vanilla --quiet > >> pdf(file='~/f.pdf') > >> plot(1:10 , pch=1) > >> dev.off() > >>>>> null device > >>>>> 1 > >> sessionInfo() > >>>>> R version 2.8.1 (2008-12-22) > >>>>> i686-pc-linux-gnu > >>>>> > >>>>> locale: > >>>>> > >> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C > >>>>> > >>>>> attached base packages: > >>>>> [1] stats graphics grDevices utils datasets methods > >>>>> base> q() > >>>>> le112:~/scratch/R-2.8.1% > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> -- > >>>>> Robin K. S. Hankin > >>>>> Uncertainty Analyst > >>>>> University of Cambridge > >>>>> 19 Silver Street > >>>>> Cambridge CB3 9EP > >>>>> 01223-764877 > >>>>> > >>>>> __ > >>>>> r-h...@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. > >>>>> > >>>> > >>>> -- > >>>> Brian D. Ripley, rip...@stats.ox.ac.uk > >>>> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > >>>> University of Oxford, Tel: +44 1865 272861 (self) > >>>> 1 South Parks Road, +44 1865 272866 (PA) > >>>> Oxford OX1 3TG, UKFax: +44 1865 272595 > >>>> > >>>> __ > >>>> r-h...@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. > >> > >> TZ> __ > >> TZ> r-h...@r-project.org mailing list > >> TZ> https://stat.ethz.ch/mailman/listinfo/r-help > >> TZ> PLEASE do read the posting guide > >> http://www.R-project.org/posting-guide.html > >> TZ> and provide commented, minimal, self-contained, reproducible code. > >> > >> __ > >> r-h...@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. > > -- > > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% > > Dr. Gavin Simpson [t] +44 (0)20 7679 0522 > > ECRC, UCL Geography, [f] +44 (0)20 7679 0565 > > Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk > > Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ > > UK. WC1E 6BT. [w] http://www.freshwaters.org.uk > > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% > > > > __ > > R-devel@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl
Re: [Rd] Accessing a c-level complicated structure from R
Hi. 2009/1/22 Scionforbai : > Hello, > R-devel seems to be the appropriated list for what I'm to ask: soory > if I'm wrong. I am a c newbie but nevertheless I am trying to 'couple' > an extern c software with R. The compiled library is actually a > stand-alone c program, which uses text file for input and output. It > uses *lots* of differents and (to me) rather complicated and nested > "struct"s to represent data for intern calculation. I want to make > this program a -shared lib to use with R. > I have (among many others) the following question: can I access from R > a c-level defined struct, as input/output of my .C called function? If > yes... how? > If you have to pass these data structures up to R you have to use the .Call interface and wrap your C objects in an extern ptr R obj. That's described in "Writing R extensions". Let me note you're undertaking a major work. If the software isn't conceived as being used as a shared library, it can be much work to translate it that way. You can consider to use the external program as is, i.e. a stand-alone program, and use temp text files for input-output. You can wrap it in convenient R functions, and keep all that invisible to the end user. This would require much less work... That's for instance how RTisean and some BUGS related CRAN packages works, and I'm sure there are others there. > Any clue, manual, tutorial on c programming with R (other than R-exts > and R-ints), and hint is greatly appreciated... Actually, R-exts has the info you need. Look at it more carefully. You don't even need R-ints. HTH, a.f. > Thanks, > Scion > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Antonio, Fabio Di Narzo Ph.D. student at Department of Statistical Sciences University of Bologna, Italy __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] x <- 1:2; dim(x) <- 2? A vector or not?
Martin Maechler wrote: "TP" == Tony Plate on Fri, 16 Jan 2009 13:10:04 -0700 writes: TP> Martin Maechler wrote: >>> "PatB" == Patrick Burns >>> on Tue, 13 Jan 2009 17:00:40 + writes: >>> >> PatB> Henrik Bengtsson wrote: >> >> Hi. >> >> >> >> On Mon, Jan 12, 2009 at 11:58 PM, Prof Brian Ripley >> >> wrote: >> >> >> >>> What you have is a one-dimensional array: they crop up >> >>> in R most often from table() in my experience. >> >>> >> >>> >> f <- table(rpois(100, 4)) str(f) >> >> >>> 'table' int [, 1:10] 2 6 18 21 13 16 13 4 3 4 - attr(*, >> >>> "dimnames")=List of 1 ..$ : chr [1:10] "0" "1" "2" "3" >> >>> ... >> >>> >> >>> and yes, f is an atmoic vector and yes, str()'s notation >> >>> is confusing here but if it did [1:10] you would not >> >>> know it was an array. I recall discussing this with >> >>> Martin Maechler (str's author) last century, and I've >> >>> just checked that R 2.0.0 did the same. >> >>> >> >>> The place in which one-dimensional arrays differ from >> >>> normal vectors is how names are handled: notice that my >> >>> example has dimnames not names, and ?names says >> >>> >> >>> For a one-dimensional array the 'names' attribute really >> >>> is 'dimnames[[1]]'. >> >>> >> >> >> >> Thanks for this explanation. One could then argue that >> >> [1:10,] is somewhat better than [,1:10], but that is just polish. >> >> yes. And honestly I don't remember anymore why I chose the >> "[,1:n]" notation. It definitely was there already before R >> came into existence, as S also has had one-dimensional arrays, >> and I programmed the first version of str() in 1990. >> PatB> Perhaps it could be: >> PatB> [1:10(,)] >> PatB> That is weird enough that it should not lead people to PatB> believe that it is a matrix. But might prompt them a PatB> bit in that direction. >> >> Well, str() was always aimed a bit at experienced S (and R) >> users, and I had always aimed somewhat to keep it's output >> "compact". I'm quite astonished that the OP didn't know about >> 1D arrays in spite of the many years he's been using R. >> Would a wierd solution like the above have helped? >> >> At the moment, I'd tend to keep it "as is" if only just for >> historical reminescence, but I can be convinced to change the >> current "tendency" ... >> >> Martin Maechler, ETH Zurich >> TP> What about just including "(1d-array)", something like this >> str(f) TP> 'table' int [1:10](1d array) 5 5 9 23 26 16 9 4 2 1 TP> - attr(*, "dimnames")=List of 1 TP> ..$ : chr [1:10] "0" "1" "2" "3" ... >> TP> only 9 extra characters for a rare case, and much, much less cryptic? well,.. the next text request is to use "character" instead of "chr", only 6 extra characters -> no way: str() has its very concise "style" and should keep that. Brevity is good, but clarity is important too. The output of str is usually decipherable, but not so much in this case. It's easy to dismiss suggestions like replacing "chr" with "character" - the increase in clarity would be minimal. However, the potential increase in clarity for a 1-d array is significant - the decrease in brevity is at question here. Given the rarity of the case it seems like a decent tradeoff to add "(1d-array)" (one could even just write "(1d)"). 1-d arrays are sufficiently rare that no concise and clear method of indicating them using brackets or other symbols has arisen. You did say you "can be convinced to change" it, but I won't attempt beyond this! :-) best, Tony Plate Martin TP> -- Tony Plate >> >> PatB> Patrick Burns patr...@burns-stat.com +44 (0)20 8525 PatB> 0696 http://www.burns-stat.com (home of "The R PatB> Inferno" and "A Guide for the Unwilling S User") >> >> /Henrik >> >> >> >> >> >>> I think these days we have enough internal glue in place >> >>> that an end user would not notice the difference (but >> >>> those working at C level with R objects may need to >> >>> know). >> >>> >> >>> On Mon, 12 Jan 2009, Henrik Bengtsson wrote: >> >>> >> >>> >> Ran into the follow intermediate case in an external >> package (w/ recent R v2.8.1 patched and R v2.9.0 >> devel): >> >> >> > x <- 1:2 dim(x) <- 2 dim(x) >> > >> [1] 2 >> >> > x >> > >> [1] 1 2 >> >> > str(x) >> > >> int [, 1:2] 1 2 >> >> > nrow(x) >> > >> [1] 2 >> >> > ncol(x) >> > >> [1] NA >> >> > is.vector(x) >> >