Re: [R] R CMD SHLIB: file not recognized: File format not recognized
Hello Dirk, thank you for your chick answer. I tried another file and there it works. so i removed all files which were created during of the compilation of add.c in windows and so i could compile it under ubuntu too. During the windows compilation there is some *.o file which is created during the compilation, if i delete it and try the compilation under ubuntu everything works fine, don't know why? best regards Andreas Dirk Eddelbuettel wrote: On Sun, Oct 19, 2008 at 01:27:06AM +0200, Andreas Wittmann wrote: Dear R useRs, on ubuntu 8.04 i try to create a shared object out of a c-file this is // add.c #include Rinternals.h SEXP addiere(SEXP a, SEXP b) { int i, n; n = length(a); for (i = 0; i n; i++) REAL(a)[i] += REAL(b)[i]; return(a); } in terminal i type R CMD SHLIB add.c and get gcc -std=gnu99 -shared -o add.so add.o -L/usr/lib/R/lib -lR add.o: file not recognized: File format not recognized my gcc version is 4.2.3 and my R version is 2.7.2. I can't replicate that on Ubuntu 8.04: [EMAIL PROTECTED]:/tmp$ R CMD SHLIB add.c gcc -std=gnu99 -I/usr/share/R/include -fpic -g -O2 -c add.c -o add.o gcc -std=gnu99 -shared -o add.so add.o -L/usr/lib/R/lib -lR [EMAIL PROTECTED]:/tmp$ Works fine here. Have you compiled other files? Or are you maybe missing some -dev packages? Dirk Searching R-help, Writing R Extensions and R Installation and Administration guide i don't get any idea whats wrong here? Creating a dll-file on windows xp with the same c-file works fine. best regards Andreas __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] R CMD SHLIB: file not recognized: File format not recognized
From the help page: 'R CMD SHLIB' is the mechanism used by 'INSTALL' to compile source code in packages. Please consult section 'Creating shared objects' in the manual 'Writing R Extensions' for how to customize it (for example to add 'cpp' flags and to add libraries to the link step) and for details of some of its quirks. ^ and from that reference Note that as R CMD SHLIB uses Make, it will not remake a shared object just because the flags have changed, and if test.c and test.f both exist in the current directory R CMD SHLIB test.f will compile test.c! In your case the target systen has changed, but that's not enough to force recompilation of the .c file. On Sun, 19 Oct 2008, Andreas Wittmann wrote: Hello Dirk, thank you for your chick answer. I tried another file and there it works. so i removed all files which were created during of the compilation of add.c in windows and so i could compile it under ubuntu too. During the windows compilation there is some *.o file which is created during the compilation, if i delete it and try the compilation under ubuntu everything works fine, don't know why? best regards Andreas Dirk Eddelbuettel wrote: On Sun, Oct 19, 2008 at 01:27:06AM +0200, Andreas Wittmann wrote: Dear R useRs, on ubuntu 8.04 i try to create a shared object out of a c-file this is // add.c #include Rinternals.h SEXP addiere(SEXP a, SEXP b) { int i, n; n = length(a); for (i = 0; i n; i++) REAL(a)[i] += REAL(b)[i]; return(a); } in terminal i type R CMD SHLIB add.c and get gcc -std=gnu99 -shared -o add.so add.o -L/usr/lib/R/lib -lR add.o: file not recognized: File format not recognized my gcc version is 4.2.3 and my R version is 2.7.2. I can't replicate that on Ubuntu 8.04: [EMAIL PROTECTED]:/tmp$ R CMD SHLIB add.c gcc -std=gnu99 -I/usr/share/R/include -fpic -g -O2 -c add.c -o add.o gcc -std=gnu99 -shared -o add.so add.o -L/usr/lib/R/lib -lR [EMAIL PROTECTED]:/tmp$ Works fine here. Have you compiled other files? Or are you maybe missing some -dev packages? Dirk Searching R-help, Writing R Extensions and R Installation and Administration guide i don't get any idea whats wrong here? Creating a dll-file on windows xp with the same c-file works fine. best regards Andreas __ R-help@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. [[alternative HTML version deleted]] __ R-help@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, [EMAIL PROTECTED] 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-help@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.
[R] convert lines to inches
Hi, how can I convert the unit lines of par(mar) into inches? par(mai) could help, but does not (see code below). I want to plot a curve in a predefined size in pdf (I add some margin space to the plot widthheight, everything is in cm): pdf(test.pdf,width=(20+2+4)/2.54,height=(10+3+1)/2.54) plot(10:30, 9*cos(10:30),type=l,xlim=c(10,30),ylim=c(-10,15),xaxs=i,yaxs=i,asp=1) #par(mar=c(0,0,0,0)) par(mai=c(2,3,4,1)/2.54) box(figure, col=darkblue) dev.off() The size of the darkblue box is fine, but I cannot yet control the size of the plot area (although http://research.stowers-institute.org/efg/R/Graphics/Basics/mar-oma/index.htm helped me a lot). And seeting the mar to zero (#) works in a R figure, but not in a pdf. Why? I already asked (draw a 5cm x 3cm rectangle) a related question three days ago, but I was unable to get a more complicated example in the grid package (solution there) running. Thanks for giving hints, Thomas __ R-help@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.
Re: [R] R CMD SHLIB: file not recognized: File format not recognized
Andreas Wittmann wrote: Hello Dirk, thank you for your chick answer. I tried another file and there it works. so i removed all files which were created during of the compilation of add.c in windows and so i could compile it under ubuntu too. During the windows compilation there is some *.o file which is created during the compilation, if i delete it and try the compilation under ubuntu everything works fine, don't know why? The object files produced during a Windows build won't work on a different target system. There's a --preclean option to R CMD SHLIB and R CMD INSTALL that will remove products of earlier builds; it's a good idea to use it when you start compiling for a new system. Duncan Murdoch best regards Andreas Dirk Eddelbuettel wrote: On Sun, Oct 19, 2008 at 01:27:06AM +0200, Andreas Wittmann wrote: Dear R useRs, on ubuntu 8.04 i try to create a shared object out of a c-file this is // add.c #include Rinternals.h SEXP addiere(SEXP a, SEXP b) { int i, n; n = length(a); for (i = 0; i n; i++) REAL(a)[i] += REAL(b)[i]; return(a); } in terminal i type R CMD SHLIB add.c and get gcc -std=gnu99 -shared -o add.so add.o -L/usr/lib/R/lib -lR add.o: file not recognized: File format not recognized my gcc version is 4.2.3 and my R version is 2.7.2. I can't replicate that on Ubuntu 8.04: [EMAIL PROTECTED]:/tmp$ R CMD SHLIB add.c gcc -std=gnu99 -I/usr/share/R/include -fpic -g -O2 -c add.c -o add.o gcc -std=gnu99 -shared -o add.so add.o -L/usr/lib/R/lib -lR [EMAIL PROTECTED]:/tmp$ Works fine here. Have you compiled other files? Or are you maybe missing some -dev packages? Dirk Searching R-help, Writing R Extensions and R Installation and Administration guide i don't get any idea whats wrong here? Creating a dll-file on windows xp with the same c-file works fine. best regards Andreas __ R-help@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. [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] convert lines to inches
Thomas Steiner wrote: Hi, how can I convert the unit lines of par(mar) into inches? par(mai) could help, but does not (see code below). I want to plot a curve in a predefined size in pdf (I add some margin space to the plot widthheight, everything is in cm): pdf(test.pdf,width=(20+2+4)/2.54,height=(10+3+1)/2.54) plot(10:30, 9*cos(10:30),type=l,xlim=c(10,30),ylim=c(-10,15),xaxs=i,yaxs=i,asp=1) #par(mar=c(0,0,0,0)) par(mai=c(2,3,4,1)/2.54) box(figure, col=darkblue) dev.off() The size of the darkblue box is fine, but I cannot yet control the size of the plot area (although http://research.stowers-institute.org/efg/R/Graphics/Basics/mar-oma/index.htm helped me a lot). And seeting the mar to zero (#) works in a R figure, but not in a pdf. Why? I already asked (draw a 5cm x 3cm rectangle) a related question three days ago, but I was unable to get a more complicated example in the grid package (solution there) running. Sorry, but I can't make heads or tails of this. You are not stating what you intend to achieve, hence there is no way to see what you mean by is fine or doesn't work. You have par(mar)/par(mai) [1] 5 5 5 5 par(csi) [1] 0.2 par(lheight) [1] 1 which should give you a strong hint about the conversion. Also: par(pin)+ rev(rowSums(matrix(par(mai),2))) == par(fin) (up to rounding error). -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@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.
[R] time-series noise filter
Hello, I have a very large data set (collected automatically) of animal heart frequencies. The data of course forms a time series. My problem is I do not only have the real heart frequencies, but also quite a lot of non-sense noise which needs to be filtered out. Visually inspecting the data (plotting data index against noisy heart frequencies) one can see a band of denser data points, which make up the true heart frequency, and the rest both above and below (that is, higher and lower frequency) is the noise. My task is to filter out the noise, that is the dense band. As I have only limited knowledge of time-series analyses, and virtually none of filtering techniques my first question is if there is a specific statistical method you would suggest. My second question is if there is a ready implementation in R that I can use. Finally, if you know of a good book suitable for the problem so I can read more about the details that would also be great. Many thanks, Thomas __ R-help@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.
Re: [R] Plot table of counts
[EMAIL PROTECTED] wrote: I have a data set which is comprised of counts, that is, the number of times a mass spectrometer measured a particular mass at a particular time (the rows and columns of the table). Is there a way to make a plot so that it draws a square at the mass/time spot on the graphic if there is a count and leave it empty if it's empty? Hi pofigster, You can do this with color2D.matplot in the latest version of plotrix (2.4-8) that has just been uploaded (may take a day or two to appear): color2D.matplot(mydata,1,0,1) will produce a plot with purple rectangles at each number and white (default, you can change it) rectangles where there are NAs. Jim __ R-help@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.
Re: [R] Simple Gantt like chart for numbers rather dates
Jim, Gabor is right, gantt.chart comes close but you will have to change all the POSIXct axis calls to plain old axis calls and manually create the list of gantt.info with the x values as numbers. Mmm, I have had a quick look at the code and it seems a bit beyond me, but it could be a good exercise :-) Certainly, this exactly what I want. Thanks, Graham __ R-help@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.
Re: [R] convert lines to inches
Ok, thanks Peter, I try to be more accurate: pdf(test.pdf,width=(20+2+4)/2.54,height=(10+3+1)/2.54) x=seq(0,pi,length=100) par( mai=c(2,3,4,1)/2.54 ) plot(x,cos(x),type=l,xlim=c(0,3),ylim=c(-1.2,1.2),xaxs=i,yaxs=i,asp=1) conv=par(mar)/par(mai) box(figure, col=darkblue) dev.off() Then figure has as expected the size 26x14cm. But the size of the *Plot Area* is not as expected 20x10cm, but 22x8cm, although I chose the margins in inches as 2 and 4 cm below and above (=26-(2+4)). Probably I confuse something with lines and inches. I'd like to have a plot area of 20x10cm and around it a (2,3,4,1)cm margin. Thanks for hints and have a nice Sunday, Thomas __ R-help@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.
Re: [R] definition of dffits
Check out: http://en.wikipedia.org/wiki/DFFITS On Sun, Oct 19, 2008 at 1:26 AM, Kunio takezawa [EMAIL PROTECTED] wrote: R-users E-mail: r-help@r-project.org Hi! R-users. I am just wondering what the definition of dffits in R language is. Let me show you an simple example. function() { library(MASS) xx - c(1,2,3,4,5) yy - c(1,3,4,2,4) data1 - data.frame(x=xx, y=yy) lm.out - lm(y~., data=data1, x=T) lev1 - lm.influence(lm.out)$hat sig1 - lm.influence(lm.out)$sigma res1 - residuals(lm.out) ey - fitted(lm.out) py - ey + res1/(1-lev1) df1 - dffits(lm.out, infl = lm.influence(lm.out)) df1 - dffits(lm.out) print(df1: dffits) print(df1) my_df1 - (ey-py)/(sig1*sqrt(lev1)) print(my_df1) print(my_df1) my_df2 - -lev1*(ey-py)/(sig1*sqrt(lev1)) print(my_df2) print(my_df2) } [1] df1: dffits 1 2 3 4 5 -1.333 0.4082483 0.600 -1.0475699 0.2672612 [1] my_df1 1 2 3 4 5 2.222 -1.3608276 -3.000 3.4918995 -0.4454354 [1] my_df2 1 2 3 4 5 -1.333 0.4082483 0.600 -1.0475699 0.2672612 I think that my_df1 is dffits( http://en.wikipedia.org/wiki/DFFITS ), but in R language, my_df2 gives the difinition of dffits. Please let me know why. -- *[EMAIL PROTECTED]* http://cse.naro.affrc.go.jp/takezawa/intro.html [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] plot - central limit theorem
Thanks, Duncan, I agree with you in terms of doing the tests independently. I've modified the code and updated the package at R-forge. As for the choice of vertical bars or points, you are free to provide the option type = 'h' or type = 'p' in the function. Regards, Yihui -- Yihui Xie [EMAIL PROTECTED] Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China On Fri, Oct 17, 2008 at 2:26 AM, Duncan Murdoch [EMAIL PROTECTED] wrote: My suggestion (and this is a matter of taste) would be to do the tests independently, rather than using the same dataset plus new observations each time. It is hard to understand the behaviour of p-values even without complicating things by giving a correlated sequence of them. And this is even more a matter of taste: I'd plot the p-values as points, not as vertical bars. Showing that a p-value of 0.8 is twice as big as a p-value of 0.4 isn't useful for interpreting them. Duncan Murdoch __ R-help@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.
Re: [R] Simple Gantt like chart for numbers rather dates
Then try something like this. We plot it as a stacked horizontal bargraph where the first bar in the stack is white and with border = 0 so its not visible. # test data - rows are from and to points and # column names are the labels mat - matrix(1:10, 2, byrow = TRUE, dimnames = list(c(from, to), letters[1:5])) bp - barplot(mat, col = c(white, lightblue), border = 0, horiz = TRUE) text(mat[1, ], bp, mat[1,], pos = 4) text(colSums(mat), bp, mat[2,], pos = 2) On Sun, Oct 19, 2008 at 6:49 AM, Graham Smith [EMAIL PROTECTED] wrote: Jim, Gabor is right, gantt.chart comes close but you will have to change all the POSIXct axis calls to plain old axis calls and manually create the list of gantt.info with the x values as numbers. Mmm, I have had a quick look at the code and it seems a bit beyond me, but it could be a good exercise :-) Certainly, this exactly what I want. Thanks, Graham __ R-help@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. __ R-help@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.
Re: [R] convert lines to inches
Thomas Steiner wrote: Ok, thanks Peter, I try to be more accurate: pdf(test.pdf,width=(20+2+4)/2.54,height=(10+3+1)/2.54) x=seq(0,pi,length=100) par( mai=c(2,3,4,1)/2.54 ) plot(x,cos(x),type=l,xlim=c(0,3),ylim=c(-1.2,1.2),xaxs=i,yaxs=i,asp=1) conv=par(mar)/par(mai) box(figure, col=darkblue) dev.off() Then figure has as expected the size 26x14cm. But the size of the *Plot Area* is not as expected 20x10cm, but 22x8cm, although I chose the margins in inches as 2 and 4 cm below and above (=26-(2+4)). Probably I confuse something with lines and inches. I'd like to have a plot area of 20x10cm and around it a (2,3,4,1)cm margin. Thanks for hints and have a nice Sunday, Thomas Ah, now I see it. Notice that the _order_ in par(mai) follows the conventions for side=n; that is, bottom, left, top, right. So you want either mai=c(3,2,1,4) or width=20+3+1,height=10+2+4. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@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.
Re: [R] Simple Gantt like chart for numbers rather dates
Gabor, Then try something like this. We plot it as a stacked horizontal bargraph where the first bar in the stack is white and with border = 0 so its not visible. # test data - rows are from and to points and # column names are the labels mat - matrix(1:10, 2, byrow = TRUE, dimnames = list(c(from, to), letters[1:5])) bp - barplot(mat, col = c(white, lightblue), border = 0, horiz = TRUE) text(mat[1, ], bp, mat[1,], pos = 4) text(colSums(mat), bp, mat[2,], pos = 2) Thanks, that's a clever approach, I think I will still have a go at editing the Gantt code, but I can get my head around this approach a bit easier. Graham __ R-help@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.
Re: [R] definition of dffits
Dear Kunio, The approach in dffits() in R is equivalent to the definition of DFFITS_i in Belsley, Kuh, and Welch, Regression Diagnostics (which is, I believe the original source, or close to it), generalized to WLS. Possibly a more transparent definition would be dfs - function(mod){ rs - rstudent(mod) h - hatvalues(mod) sqrt(h/(1 - h))*rs } I hope this helps, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kunio takezawa Sent: October-19-08 1:27 AM To: r-help@r-project.org Subject: [R] definition of dffits R-users E-mail: r-help@r-project.org Hi! R-users. I am just wondering what the definition of dffits in R language is. Let me show you an simple example. function() { library(MASS) xx - c(1,2,3,4,5) yy - c(1,3,4,2,4) data1 - data.frame(x=xx, y=yy) lm.out - lm(y~., data=data1, x=T) lev1 - lm.influence(lm.out)$hat sig1 - lm.influence(lm.out)$sigma res1 - residuals(lm.out) ey - fitted(lm.out) py - ey + res1/(1-lev1) df1 - dffits(lm.out, infl = lm.influence(lm.out)) df1 - dffits(lm.out) print(df1: dffits) print(df1) my_df1 - (ey-py)/(sig1*sqrt(lev1)) print(my_df1) print(my_df1) my_df2 - -lev1*(ey-py)/(sig1*sqrt(lev1)) print(my_df2) print(my_df2) } [1] df1: dffits 1 2 3 4 5 -1.333 0.4082483 0.600 -1.0475699 0.2672612 [1] my_df1 1 2 3 4 5 2.222 -1.3608276 -3.000 3.4918995 -0.4454354 [1] my_df2 1 2 3 4 5 -1.333 0.4082483 0.600 -1.0475699 0.2672612 I think that my_df1 is dffits( http://en.wikipedia.org/wiki/DFFITS ), but in R language, my_df2 gives the difinition of dffits. Please let me know why. -- *[EMAIL PROTECTED]* http://cse.naro.affrc.go.jp/takezawa/intro.html [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] Dep setting for install of packages...
Its showing you the install.packages command that the menu invokes. You can keep pressing Enter to step through that and you can try entering the same command from your R console to verify its operation. On Sun, Oct 19, 2008 at 10:09 AM, Brian Lunergan [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: Your .libPaths() has a single component. The number of characters in it is not relevant so it should be bringing in the dependenies. Suggest you try this: debug(utils:::menuInstallPkgs) and try using the menu now and see what comes up. chooseCRANmirror() debug(utils:::menuInstallPkgs) utils:::menuInstallPkgs() debugging in: utils:::menuInstallPkgs() debug: { install.packages(NULL, .libPaths()[1], dependencies = NA, type = type) } Browse[1] Cursor waiting quietly at that prompt, but nothing else happened after entering the debug command and clicking the menu option. Keep in mind I am not a programmer and this sort of deep dive into the inner workings of a software tool I make use of is way outside my range of experience. Was there a next step I should have made, or is this what was supposed to happen? No list of packages appeared. The program simply paused waiting for something else to be done by the human looking at the screen. On Sat, Oct 18, 2008 at 9:37 PM, Brian Lunergan [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: dependencies = NA is only identical to dependencies = FALSE if .libPaths() has multiple components. If it has a single component then its the same as dependencies = c(Depends, Imports). Read the dependencies= entry on the ?install.packages page. Also read ?.libPaths Ok, ran .libPaths() and got: .libPaths() [1] C:/R-2.7.0/library That, as I understand the notes, is a valid path entry of 1 character. What am I missing about this? I already know, using the install.packages example below, that explicitly stating dep = TRUE sends R off on a hunt for the dependencies of a particular package during installation. What I would like to know and understand is whether that is the only way to do so since dep = TRUE has been turned off for the Install package(s) menu option or is there a 'tweak' of the menu possible to turn the ability back on without having to recompile the whole blessed program?? On Sat, Oct 18, 2008 at 8:30 PM, Brian Lunergan [EMAIL PROTECTED] wrote: Evening again folks: Bear with me while crow is consumed. I had asserted that 2.7.2 had dep = NA while prior installations had it turned on. Incorrect on my part. Dumped that version and stepped back two iterations to 2.7.0. Tried it with that one and the setting is indeed off for installing by menu. My apologies for the lack of information in my original post and for what has clearly turned out to be a misconception on my part. My question now... Is there a modification I can make to turn dep back on when using the menu without recompiling, or is install.packages() the only way to install and have the program chase the needed dependencies for a package? BTW, here is a more detailed look at the current run with 2.7.0. R version 2.7.0 (2008-04-22) i386-pc-mingw32 locale: LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_MONETARY=English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.7.0 OS is Windows XP SP2 Chose Ontario, Canada using PackagesSet CRAN mirror Chose ctv using PackagesInstall package(s). ctv was all that was pulled in. Retried using install.packages(ctv, dep = TRUE) at the prompt and pulled in XML and ctv. -- Brian Lunergan Nepean, Ontario Canada --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 081018-0, 2008-10-18 Tested on: 2008-10-19 10:09:34 avast! - copyright (c) 1988-2008 ALWIL Software. http://www.avast.com __ R-help@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.
Re: [R] Variable shortlisting for the logistic regression
Frank's remark was made in response to my posting. As funny as it was - it was the best thing that could have happened to me. It sparked an enlightening discussion between my committee and me (in particular, the pros cons of stepwise vs. information theoretic approach to model selection). Being new to the R help list, I had no idea who Frank was. I googled him (and asked around) and found very quickly that he should be taken seriously. And so should his remark. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rolf Turner Sent: Thursday, October 16, 2008 1:34 PM To: useR Cc: r-help@r-project.org Subject: Re: [R] Variable shortlisting for the logistic regression On 17/10/2008, at 8:22 AM, useR wrote: Let's try to bring this discussion back again after Frank made very funny remark! Frank's remark was *serious*. Take it seriously. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@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. No virus found in this incoming message. Checked by AVG - http://www.avg.com 8:02 PM __ R-help@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.
[R] zoo in ggplot2
library(zoo) d-(structure(c(1.39981554315924, 0.89196314359498, 0.407816250252697, 0.823496839063978, 1.14429021220358, 1.23971035967413, 0.960868900583432, 0.927685306209829, 1.22072345292821, 0.249842897450642, 1.00879641624694, 0.925372139878243, 0.317259909172362, 0.382677149697482), index = structure(c(11808, 11869, 11961, 11992, 12084, 12173, 12265, 12418, 12600, 12631, 12753, 12996, 13057, 13149), class = Date), class = zoo)) plot(d) is there a way to do this in ggplot? -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@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.
Re: [R] Plot table of counts
Thank you for your suggestions - image() produced a plot that worked, I'll be trying out all these other options as well. - Mark Ewing On Sun, Oct 19, 2008 at 4:03 AM, Jim Lemon [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I have a data set which is comprised of counts, that is, the number of times a mass spectrometer measured a particular mass at a particular time (the rows and columns of the table). Is there a way to make a plot so that it draws a square at the mass/time spot on the graphic if there is a count and leave it empty if it's empty? Hi pofigster, You can do this with color2D.matplot in the latest version of plotrix (2.4-8) that has just been uploaded (may take a day or two to appear): color2D.matplot(mydata,1,0,1) will produce a plot with purple rectangles at each number and white (default, you can change it) rectangles where there are NAs. Jim [[alternative HTML version deleted]] __ R-help@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.
[R] PCA HCA
Hi I am attempting PCA and HCA on a dataset The head of the table looks like this VariableSamp1Samp2Samp3 109232 276 352 222 244 I cant stop R from treating the 1st column as a sample Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@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.
[R] Date classes in ggplot2
updn.gg - (structure(list(date = structure(c(11808, 11869, 11961, 11992, 12084, 12173, 12265, 12418, 12600, 12631, 12753, 12996, 13057, 13149), class = Date), unrestored = c(1.13789418691602, 0.704948049842955, 0.276777348238899, 0.417586861554189, 0.504870337754768, 0.673201771716216, 0.560704221510771, 0.835737007551542, 1.10773858390693, 0.197070828834836, 0.942350681588179, 0.950447141061461, 0.246637790002705, 0.324035567509960 ), restored = c(1.39981554315924, 0.89196314359498, 0.407816250252697, 0.823496839063978, 1.14429021220358, 1.23971035967413, 0.960868900583432, 0.927685306209829, 1.22072345292821, 0.249842897450642, 1.00879641624694, 0.925372139878243, 0.317259909172362, 0.382677149697482)), .Names = c(date, unrestored, restored), row.names = c(NA, -14L), class = data.frame)) #I would like to do this in ggplot xyplot(unrestored+restored~date, data=updn.gg, type=c(l), auto.key=TRUE) #this is what I have tried and get an error message melt.updn - melt(updn.gg, id.var=date) -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@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.
Re: [R] Getting names of variables without quotes
Dear AJSS, Perhaps: # --- # Data set # --- mydata=read.table(textConnection( V1V2V3 1 15 10 4 26 4 7 3 10 5 2 48 6 6),header=TRUE) closeAllConnections() # --- # Regression models # --- # Combinations library(forward) comb=t(fwd.combn(colnames(mydata),2)) # Summaries res=apply(comb,1,function(x){ y1=mydata[,x[1]] x1=mydata[,x[2]] m=lm(y1~x1) summary(m) } ) names(res)= apply(comb,1,paste,collapse=/,sep=) # Output in an external file sink(C:/out.txt) res sink() HTH, Jorge On Sun, Oct 19, 2008 at 11:38 AM, Amarjit Singh Sethi [EMAIL PROTECTED]wrote: Dear Jorge/Dieter Thank you very much for your help. I indeed have been able to get names of the variables through 'noquote( )'statement. Yet my problem (regarding running regression analysis iteratively: of V1 upon V2; of V1 upon V3; and of V2 upon V3) could not be solved. My input data: V1V2V3 1 15 10 4 26 4 7 3 10 5 2 48 6 6 I tried the following code: x=read.table(sample.txt,header=T,sep=\t) sink(out.txt) for (i in 1:2){ dep=noquote(nm[i]) for(j in i+1:3){ ind=noquote(nm[j]) slr=lm(dep ~ ind, data=x) smr=summary(slr) smr } } sink() But I could not get any results. Kindly help or suggest suitable alternative. The data and the code are given as attachments also. Regards ajss --- On *Sun, 19/10/08, Jorge Ivan Velez [EMAIL PROTECTED]* wrote: From: Jorge Ivan Velez [EMAIL PROTECTED] Subject: Re: [R] Getting names of variables without quotes To: [EMAIL PROTECTED] Cc: r-help@r-project.org Date: Sunday, 19 October, 2008, 1:04 AM Dear AJSS, Perhaps ?noquote might be useful for you. Here is an example: x=c('V1','V2','V3','V4') x [1] V1 V2 V3 V4 noquote(x) [1] V1 V2 V3 V4 HTH, Jorge On Sat, Oct 18, 2008 at 3:04 PM, Amarjit Singh Sethi [EMAIL PROTECTED]wrote:  Dear R-helpers, hello I am seeking your help in somehow getting names of variables without quotes ( ). Let us say, we have a table with 3 variables V1, V2 and V3. After the table is read, I get names of the variables (thro' the following code) as under quotes (like V1 rather than the original representation V1)   x=read.table(sample.txt,header=T,sep=\t) x    V1   V2   V3 1 15    10     4 2   6      4      7 3 10     5      2 4   8     6      6 nm=names(x) nm [1] V1 V2 V3  In fact I need the variables in the original representation (i.e., as they appear in the input data file) so as to use them repeatedly (through loop statement) in regression analysis. Kindly help. Regards ajss d Now! http://messenger.yahoo.com/download.php [[alternative HTML version deleted]] __ R-help@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.htmlhttp://www.r-project.org/posting-guide..html and provide commented, minimal, self-contained, reproducible code. Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Date classes in ggplot2
On Sun, Oct 19, 2008 at 10:49 AM, stephen sefick [EMAIL PROTECTED] wrote: updn.gg - (structure(list(date = structure(c(11808, 11869, 11961, 11992, 12084, 12173, 12265, 12418, 12600, 12631, 12753, 12996, 13057, 13149), class = Date), unrestored = c(1.13789418691602, 0.704948049842955, 0.276777348238899, 0.417586861554189, 0.504870337754768, 0.673201771716216, 0.560704221510771, 0.835737007551542, 1.10773858390693, 0.197070828834836, 0.942350681588179, 0.950447141061461, 0.246637790002705, 0.324035567509960 ), restored = c(1.39981554315924, 0.89196314359498, 0.407816250252697, 0.823496839063978, 1.14429021220358, 1.23971035967413, 0.960868900583432, 0.927685306209829, 1.22072345292821, 0.249842897450642, 1.00879641624694, 0.925372139878243, 0.317259909172362, 0.382677149697482)), .Names = c(date, unrestored, restored), row.names = c(NA, -14L), class = data.frame)) #I would like to do this in ggplot xyplot(unrestored+restored~date, data=updn.gg, type=c(l), auto.key=TRUE) #this is what I have tried and get an error message melt.updn - melt(updn.gg, id.var=date) What error message? It works for me. Hadley -- http://had.co.nz/ __ R-help@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.
Re: [R] Date classes in ggplot2
well I must have either resolve it without knowing it, ot something funny is going on... sorry I didn't run it in a clean R session. Should have. works fine thanks Stephen Sefick On Sun, Oct 19, 2008 at 12:01 PM, hadley wickham [EMAIL PROTECTED] wrote: On Sun, Oct 19, 2008 at 10:49 AM, stephen sefick [EMAIL PROTECTED] wrote: updn.gg - (structure(list(date = structure(c(11808, 11869, 11961, 11992, 12084, 12173, 12265, 12418, 12600, 12631, 12753, 12996, 13057, 13149), class = Date), unrestored = c(1.13789418691602, 0.704948049842955, 0.276777348238899, 0.417586861554189, 0.504870337754768, 0.673201771716216, 0.560704221510771, 0.835737007551542, 1.10773858390693, 0.197070828834836, 0.942350681588179, 0.950447141061461, 0.246637790002705, 0.324035567509960 ), restored = c(1.39981554315924, 0.89196314359498, 0.407816250252697, 0.823496839063978, 1.14429021220358, 1.23971035967413, 0.960868900583432, 0.927685306209829, 1.22072345292821, 0.249842897450642, 1.00879641624694, 0.925372139878243, 0.317259909172362, 0.382677149697482)), .Names = c(date, unrestored, restored), row.names = c(NA, -14L), class = data.frame)) #I would like to do this in ggplot xyplot(unrestored+restored~date, data=updn.gg, type=c(l), auto.key=TRUE) #this is what I have tried and get an error message melt.updn - melt(updn.gg, id.var=date) What error message? It works for me. Hadley -- http://had.co.nz/ -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@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.
Re: [R] help
Sonam sonam at ms.ie.u-ryukyu.ac.jp writes: hello there, can anyone tell me how to correct this error, Error in nlm(if(analytic.gradient) objective.2 else objective.1, start,: probable coding error in analytic gradient) thanks in advance. sonam Look for an error in your analytic gradient function? :-) If that doesn't help, we need a lot more information -- start by reading the posting guide and then (1) tell us what you're trying to do, (2) what packages or functions you're using (I'm guessing nlm, but it might be deeply nested within some other functions) -- sessionInfo() output is always helpful -- and (3) PROVIDE A REPRODUCIBLE EXAMPLE! cheers Ben Bolker __ R-help@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.
Re: [R] multivariate integral with ADAPT when the parameter is close to boundary
Thanks so much for the comments. Of course, integrating dbeta(theta[1],0.005,0.005)*dbeta(theta[2],0.005,0.005) over the whole range is not something I am really interested in. I am just concerned about the results I got for other integrands with extreme priors using ADAPT function. It is true that some of the functions that I want to integrate are products. But then there should be a similar problem with 1-D function INTEGRATE for the extreme integrands in my setting, that is, lower and upper limits have to be set very very close to the boundaries. However, the closer I set those limits to the boundaries, the longer it takes to run. I was just wondering if anybody had encountered the similar problem before and tried some way to get around such as transforming the variables. Again, thank you for the comments. On Sun, Oct 19, 2008 at 1:51 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote: 1) That integrand is a product, so you can do this a product of integrals, and do those analytically. 2) Do you have any idea how extreme beta(0.005, 0.005) is? See the comment in the help for integrate: Like all numerical integration routines, these evaluate the function on a finite set of points. If the function is approximately constant (in particular, zero) over nearly all its range it is possible that the result and error estimate may be seriously wrong. delta - 1e-4 x - seq(delta, 1-delta, delta) plot(x, dbeta(x, 0.005, 0.005), type=l) pbeta(0., 0.005, 0.005) - pbeta(0.0001, 0.005, 0.005) so 95% of the mass is outside the limits you set. On Sun, 19 Oct 2008, Muhtar Osman wrote: Dear All, There is one problem I encountered when I used ADAPT to compute some 2-D integral w.r.t beta density. For example, when I try to run the following comments: fun2-function(theta){return(dbeta(theta[1],0.005,0.005)*dbeta(theta[2],0.005,0.005))} int.fun2-adapt(ndim=2,lo = c(0,0), up = c(1,1),functn = fun2,eps = 1e-4) It seems it will take very long time to run. Acturally, I stopped the program after it was running for like 20 minutes. I thought this might be due to the inclusion of the lower and upper in to the integral computation, so I tried to change the lower and upper limits: fun2-function(theta){return(dbeta(theta[1],0.005,0.005)*dbeta(theta[2],0.005,0.005))} int.fun2-adapt(ndim=2,lo = c(0.0001,0.0001), up = c(0.,0.),functn = fun2,eps = 1e-4) It only took few seconds to run, but it gave me the wrong result: int.fun2= 0.00202210665273673, whereas the correct result should be int.fun2=1. No, that's the correct answer for the problem you set. I guess the reason for this is beta(0.005,0.005) has very high density close to the boundary (theta=0). So even letting lo = c(0.0001,0.0001) will cause some loss of probability mass in the integral computation. I was wondering if anybody has encountered the similar problem before. Any comments are appreciated. Thanks. Muhtar Osman Dept.of Stats NCSU __ R-help@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, [EMAIL PROTECTED] 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-help@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.
Re: [R] zoo in ggplot2
zoo does have plot.zoo and xyplot.zoo library(zoo) xyplot(d) plot(d) but there is no zoo method for ggplot2 currently; however, you can qplot d from its constituent pieces: library(ggplot2); library(zoo) qplot(time(d), coredata(d)) On Sun, Oct 19, 2008 at 11:22 AM, stephen sefick [EMAIL PROTECTED] wrote: library(zoo) d-(structure(c(1.39981554315924, 0.89196314359498, 0.407816250252697, 0.823496839063978, 1.14429021220358, 1.23971035967413, 0.960868900583432, 0.927685306209829, 1.22072345292821, 0.249842897450642, 1.00879641624694, 0.925372139878243, 0.317259909172362, 0.382677149697482), index = structure(c(11808, 11869, 11961, 11992, 12084, 12173, 12265, 12418, 12600, 12631, 12753, 12996, 13057, 13149), class = Date), class = zoo)) plot(d) is there a way to do this in ggplot? -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@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. __ R-help@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.
Re: [R] Getting names of variables without quotes
Dear Jorge Many thanks for your prompt reply. I tried to make use of the code provided by you (as per file attached), but it did not work for me; got the following output: # --- # Data set # --- mydata=read.table(textConnection( + V1V2V3 + 115104 + 2647 + 31052 + 4866),header=TRUE) closeAllConnections() # --- # Regression models # --- # Combinations library(forward) comb=t(fwd.combn(colnames(mydata),2)) Error in fwd.combn(colnames(mydata), 2) : n m # Summariesres=apply(comb,1,function(x){ y1=mydata[,x[1]] Error in .subset(x, j) : invalid subscript type 'list' x1=mydata[,x[2]] Error in .subset(x, j) : invalid subscript type 'list' m=lm(y1~x1) Error in eval(expr, envir, enclos) : object y1 not found summary(m) Error in summary(m) : object m not found } Error: unexpected '}' in } ) Error: unexpected ')' in ) names(res)= apply(comb,1,paste,collapse=/,sep= ) Error in apply(comb, 1, paste, collapse = /, sep = ) : object comb not found # Output in an external file sink(E:/out.txt) res Error: object res not found sink() I do not know as to where the problem lies (Frankly, I have not been able to grasp intricacies of this code). Will you kindly help me in getting rid of the problem. Regards ajss --- On Sun, 19/10/08, Jorge Ivan Velez [EMAIL PROTECTED] wrote: From: Jorge Ivan Velez [EMAIL PROTECTED] Subject: Re: [R] Getting names of variables without quotes To: [EMAIL PROTECTED] Cc: Dieter Menne [EMAIL PROTECTED], R mailing list r-help@r-project.org Date: Sunday, 19 October, 2008, 9:19 PM Dear AJSS, Perhaps: # --- # Data set # --- mydata=read.table(textConnection( V1 V2 V3 1 15 10 4 2 6 4 7 3 10 5 2 4 8 6 6),header=TRUE) closeAllConnections() # --- # Regression models # --- # Combinations library(forward) comb=t(fwd.combn(colnames(mydata),2)) # Summaries res=apply(comb,1,function(x){ y1=mydata[,x[1]] x1=mydata[,x[2]] m=lm(y1~x1) summary(m) } ) names(res)= apply(comb,1,paste,collapse=/,sep=) # Output in an external file sink(C:/out.txt) res sink() HTH, Jorge On Sun, Oct 19, 2008 at 11:38 AM, Amarjit Singh Sethi [EMAIL PROTECTED] wrote: Dear Jorge/Dieter Thank you very much for your help. I indeed have been able to get names of the variables through 'noquote( )'statement. Yet my problem (regarding running regression analysis iteratively: of V1 upon V2; of V1 upon V3; and of V2 upon V3) could not be solved. My input data: V1 V2 V3 1 15 10 4 2 6 4 7 3 10 5 2 4 8 6 6 I tried the following code: x=read.table(sample.txt,header=T,sep=\t) sink(out.txt) for (i in 1:2){ dep=noquote(nm[i]) for(j in i+1:3){ ind=noquote(nm[j]) slr=lm(dep ~ ind, data=x) smr=summary(slr) smr } } sink() But I could not get any results. Kindly help or suggest suitable alternative. The data and the code are given as attachments also. Regards ajss --- On Sun, 19/10/08, Jorge Ivan Velez [EMAIL PROTECTED] wrote: From: Jorge Ivan Velez [EMAIL PROTECTED] Subject: Re: [R] Getting names of variables without quotes To: [EMAIL PROTECTED] Cc: r-help@r-project.org Date: Sunday, 19 October, 2008, 1:04 AM Dear AJSS, Perhaps ?noquote might be useful for you. Here is an example: x=c('V1','V2','V3','V4') x [1] V1 V2 V3 V4 noquote(x) [1] V1 V2 V3 V4 HTH, Jorge On Sat, Oct 18, 2008 at 3:04 PM, Amarjit Singh Sethi [EMAIL PROTECTED] wrote:  Dear R-helpers, hello I am seeking your help in somehow getting names of variables without quotes ( ). Let us say, we have a table with 3 variables V1, V2 and V3. After the table is read, I get names of the variables (thro' the following code) as under quotes (like V1 rather than the original representation V1)   x=read.table(sample.txt,header=T,sep=\t) x    V1   V2   V3 1 15    10     4 2   6      4      7 3 10     5      2 4   8     6      6 nm=names(x) nm [1] V1 V2 V3  In fact I need the variables in the original representation (i.e.., as they appear in the input data file) so as to use them repeatedly (through loop statement) in regression analysis. Kindly help. Regards ajss d Now! http://messenger.yahoo.com/download.php [[alternative HTML version deleted]] __ R-help@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. # --- # Data set # --- mydata=read.table(textConnection( V1 V2 V3 1 15 10 4 2 6 4 7 3 10 5 2 4 8 6 6),header=TRUE)
Re: [R] Getting names of variables without quotes
Dear AJSS, The problem is in how we read the data set. Here is a slight modification: # --- # Data set # --- mydata=data.frame( V1=c(15,6,10,8), V2=c(10,4,5,6), V3=c(4,7,2,6)) # --- # Regression models # --- # Combinations library(forward) comb=t(fwd.combn(colnames(mydata),2)) # Summaries res=apply(comb,1,function(x){ y1=mydata[,x[1]] x1=mydata[,x[2]] m=lm(y1~x1) summary(m) } ) names(res)= apply(comb,1,paste,collapse=/,sep= ) res # Output in an external file sink(E:/out.txt) res sink() Be aware you need the forward package. HTH, Jorge sessionInfo() R version 2.7.2 Patched (2008-09-20 r46656) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] forward_1.0.1 MASS_7.2-44 On Sun, Oct 19, 2008 at 2:31 PM, Amarjit Singh Sethi [EMAIL PROTECTED]wrote: Dear Jorge Many thanks for your prompt reply. I tried to make use of the code provided by you (as per file attached), but it did not work for me; got the following output: # --- # Data set # --- mydata=read.table(textConnection( + V1V2V3 + 115104 + 2647 + 31052 + 4866),header=TRUE) closeAllConnections() # --- # Regression models # --- # Combinations library(forward) comb=t(fwd.combn(colnames(mydata),2)) Error in fwd.combn(colnames(mydata), 2) : n m # Summariesres=apply(comb,1,function(x){ y1=mydata[,x[1]] Error in .subset(x, j) : invalid subscript type 'list' x1=mydata[,x[2]] Error in .subset(x, j) : invalid subscript type 'list' m=lm(y1~x1) Error in eval(expr, envir, enclos) : object y1 not found summary(m) Error in summary(m) : object m not found } Error: unexpected '}' in } ) Error: unexpected ')' in ) names(res)= apply(comb,1,paste,collapse=/,sep= ) Error in apply(comb, 1, paste, collapse = /, sep = ) : object comb not found # Output in an external file sink(E:/out.txt) res Error: object res not found sink() I do not know as to where the problem lies (Frankly, I have not been able to grasp intricacies of this code). Will you kindly help me in getting rid of the problem. Regards ajss --- On Sun, 19/10/08, Jorge Ivan Velez [EMAIL PROTECTED] wrote: From: Jorge Ivan Velez [EMAIL PROTECTED] Subject: Re: [R] Getting names of variables without quotes To: [EMAIL PROTECTED] Cc: Dieter Menne [EMAIL PROTECTED], R mailing list r-help@r-project.org Date: Sunday, 19 October, 2008, 9:19 PM Dear AJSS, Perhaps: # --- # Data set # --- mydata=read.table(textConnection( V1V2V3 1 15 10 4 26 4 7 3 10 5 2 48 6 6),header=TRUE) closeAllConnections() # --- # Regression models # --- # Combinations library(forward) comb=t(fwd.combn(colnames(mydata),2)) # Summaries res=apply(comb,1,function(x){ y1=mydata[,x[1]] x1=mydata[,x[2]] m=lm(y1~x1) summary(m) } ) names(res)= apply(comb,1,paste,collapse=/,sep=) # Output in an external file sink(C:/out.txt) res sink() HTH, Jorge On Sun, Oct 19, 2008 at 11:38 AM, Amarjit Singh Sethi [EMAIL PROTECTED] wrote: Dear Jorge/Dieter Thank you very much for your help. I indeed have been able to get names of the variables through 'noquote( )'statement. Yet my problem (regarding running regression analysis iteratively: of V1 upon V2; of V1 upon V3; and of V2 upon V3) could not be solved. My input data: V1V2V3 1 15 10 4 26 4 7 3 10 5 2 48 6 6 I tried the following code: x=read.table(sample.txt,header=T,sep=\t) sink(out.txt) for (i in 1:2){ dep=noquote(nm[i]) for(j in i+1:3){ ind=noquote(nm[j]) slr=lm(dep ~ ind, data=x) smr=summary(slr) smr } } sink() But I could not get any results. Kindly help or suggest suitable alternative. The data and the code are given as attachments also. Regards ajss --- On Sun, 19/10/08, Jorge Ivan Velez [EMAIL PROTECTED] wrote: From: Jorge Ivan Velez [EMAIL PROTECTED] Subject: Re: [R] Getting names of variables without quotes To: [EMAIL PROTECTED] Cc: r-help@r-project.org Date: Sunday, 19 October, 2008, 1:04 AM Dear AJSS, Perhaps ?noquote might be useful for you. Here is an example: x=c('V1','V2','V3','V4') x [1] V1 V2 V3 V4 noquote(x) [1] V1 V2 V3 V4 HTH, Jorge On Sat, Oct 18, 2008 at 3:04 PM, Amarjit Singh Sethi [EMAIL PROTECTED] wrote:  Dear R-helpers, hello I am seeking your help in somehow getting names of variables without quotes ( ). Let us say, we have a table with 3 variables V1, V2 and V3. After the table
Re: [R] How to save/load RWeka models into/from a file?
Paulo Cortez writes: Achim Zeileis wrote: On Thu, 16 Oct 2008, Paulo Cortez wrote: Hi, I want to save a RWeka model into a file, in order to retrive it latter with a load function. See this example: library(RWeka) NB - make_Weka_classifier(weka/classifiers/bayes/NaiveBayes) model-NB(formula,data=data,...) # does not run but you get the idea save(model,file=model.dat) # simple save R command # ... load(model.dat) # load the model from the previously saved file... model # should work but I get instead this error: Error in .jcall(x$classifier, S, toString) : RcallMethod: attempt to call a method of a NULL object. What is wrong and how can I solve this problem? The R object is just a reference to the corresponding object on the Java side (in Weka). When you close R, the Java/Weka session is also closed and the model is gone. Thus, when you load the object again in a new session, you only have a reference to a Java object that does not live anymore. Z Thanks, I understand now what is happening. Yet, I still need to save/load a RWeka model to/from a file. Thus, how can I do this? Is it impossible in R? Any help? Using a current version of rJava, you can register the Java side objects for serialization using .jcache(). E.g., m1 - J48(Species ~ ., data = iris) .jcache(m1$classifier) then save/load will work as expected. Eventually, the above may happen automagically. -k __ R-help@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.
Re: [R] Please help
On 19/10/2008, at 6:55 AM, Sonam wrote: Dear R-experts, I am trying to fit my model but I couldn't because of this error. here is the error Error in solve.default(dial(m) -A) : Lapack routine dgesv: system is exactly singular thank you all. sonam Hey! Maybe the problem is that the system is exactly singular!!! cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@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.
Re: [R] wrireframe
On 10/17/08, Chibisi Chima-Okereke [EMAIL PROTECTED] wrote: Dear all, Does anyone know how to overlay a 3d line on a wireframe plot? See http://lmdvr.r-forge.r-project.org/figures/figures.html?chapter=13;figure=13_07; I would also like to be able to keep the legend that you get when using the option: drape = TRUE when using the option: shade = TRUE. The colors used when shade = TRUE are not completely defined by height, so such a legend does not make sense. You can get an arbitrary color key by providing a suitable colorkey argument (i.e., colorkey = list(col=..., at=...), etc.). In addition, I would like to know how to keep the axes while getting rid of the box, I use this: par.box = list(col = NA) to get rid of the box but that also causes the axes to disappear. ?wireframe has an example (using cloud, but the same idea applies). -Deepayan __ R-help@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.
Re: [R] lattice histogram question
On 10/17/08, Sharma, Dhruv [EMAIL PROTECTED] wrote: Hi, When I do a conditional histogram of X by Y and my Y ranges 0-100,000 I get the x axis bin labels in scientific notation. 0 to 2e+06 etc. is there a way to view the histogram bins without scientific notation? Look at the scipen option in ?options. -Deepayan __ R-help@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.
[R] Handling complex sampling designs in R
Hi all, I typically need to analyze data from large scale surveys obtained under complex sampling designs and where sampling weights are provided. I suspect that weights can be handled for some, but not all, packages. Can someone point me to information about which packages can incorporate sampling weights? Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ R-help@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.
[R] derivatives and integrals in R
Hi all, Can anyone recommend a good reference for taking scalar and matrix derivatives in R, and also doing integration in R. I've searched the list and have not come across anything thus far. Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ R-help@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.
[R] R-square in robust regression
Hi there, I have just started using the MASS package in R to run M-estimator robust regressions. The final output appears to only give coefficients, degrees of freedom and t-stats. Does anyone know why R doesn't compute R or R-squared and why doesn't give you any other indices of goodness of fit? Does anyone know how to compute these in R? Sophie -- View this message in context: http://www.nabble.com/R-square-in-robust-regression-tp20060475p20060475.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Handling complex sampling designs in R
This looks fantastic. Thanks! David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 === Tobias Verbeke wrote: Dear professor Kaplan, I typically need to analyze data from large scale surveys obtained under complex sampling designs and where sampling weights are provided. I suspect that weights can be handled for some, but not all, packages. Can someone point me to information about which packages can incorporate sampling weights? The most feature-rich package to analyze data originating from complex sampling designs is the survey package by Thomas Lumley. A feature list (as well as a wide assortment of package documentation) can be found at http://faculty.washington.edu/tlumley/survey/ The package itself can be installed from CRAN install.packages(survey) Kind regards, Tobias Verbeke __ R-help@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.
Re: [R] number of required trials
On 20/10/2008, at 9:51 AM, Boks, M.P.M. wrote: Dear Experts, Probably trivial, but I am struggling to get what I want: I need to know how the number of required trials to get a certain number of successes. By example: How many trials do I need to have 98% probability of 50 successes, when the a priory probability is 0.1 per trial. The Negative binomial function may do the job (not sure): NegBinomial {stats} The Negative Binomial Distribution Description Density, distribution function, quantile function and random generation for the negative binomial distribution with parameters size and prob. Usage dnbinom(x, size, prob, mu, log = FALSE) pnbinom(q, size, prob, mu, lower.tail = TRUE, log.p = FALSE) qnbinom(p, size, prob, mu, lower.tail = TRUE, log.p = FALSE) rnbinom(n, size, prob, mu) I tried finding out how to do this by using examples, but I am at a loss. Any help would be much appreciated! As far as I can see (which is often not very far) the negative binomial distribution has nothing to do with it. You want Pr(X = 50) = 0.98 where X is binomially distributed with n = ?, p = 0.1. Equivalently Pr(X = 49) = 0.02. After some trial-and-error I found: pbinom(49,645:655,0.1,lower=FALSE) [1] 0.9786144 0.9792460 0.9798610 0.9804599 0.9810430 0.9816106 0.9821632 [8] 0.9827009 0.9832242 0.9837334 0.9842288 I.e. the *smallest* n that makes Pr(X=50) = 0.98 is n = 648. Note that you have to be careful with the ``at leasts'' here; it's easy to make parity errors in respect of looking at upper and lower tails when dealing the cumulative distribution of a discrete random variable. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@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.
Re: [R] definition of dffits
R-users E-mail: r-help@r-project.org Hi! R-users. Check out: http://en.wikipedia.org/wiki/DFFITS The approach in dffits() in R is equivalent to the definition of DFFITS_i in Belsley, Kuh, and Welch, Regression Diagnostics (which is, I believe the original source, or close to it), generalized to WLS. Possibly a more transparent definition would be dfs - function(mod){ rs - rstudent(mod) h - hatvalues(mod) sqrt(h/(1 - h))*rs } Now, I understand it clearly. Thank you very much. 2008/10/19, John Fox [EMAIL PROTECTED]: Dear Kunio, The approach in dffits() in R is equivalent to the definition of DFFITS_i in Belsley, Kuh, and Welch, Regression Diagnostics (which is, I believe the original source, or close to it), generalized to WLS. Possibly a more transparent definition would be dfs - function(mod){ rs - rstudent(mod) h - hatvalues(mod) sqrt(h/(1 - h))*rs } I hope this helps, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kunio takezawa Sent: October-19-08 1:27 AM To: r-help@r-project.org Subject: [R] definition of dffits R-users E-mail: r-help@r-project.org Hi! R-users. I am just wondering what the definition of dffits in R language is. Let me show you an simple example. function() { library(MASS) xx - c(1,2,3,4,5) yy - c(1,3,4,2,4) data1 - data.frame(x=xx, y=yy) lm.out - lm(y~., data=data1, x=T) lev1 - lm.influence(lm.out)$hat sig1 - lm.influence(lm.out)$sigma res1 - residuals(lm.out) ey - fitted(lm.out) py - ey + res1/(1-lev1) df1 - dffits(lm.out, infl = lm.influence(lm.out)) df1 - dffits(lm.out) print(df1: dffits) print(df1) my_df1 - (ey-py)/(sig1*sqrt(lev1)) print(my_df1) print(my_df1) my_df2 - -lev1*(ey-py)/(sig1*sqrt(lev1)) print(my_df2) print(my_df2) } [1] df1: dffits 1 2 3 4 5 -1.333 0.4082483 0.600 -1.0475699 0.2672612 [1] my_df1 1 2 3 4 5 2.222 -1.3608276 -3.000 3.4918995 -0.4454354 [1] my_df2 1 2 3 4 5 -1.333 0.4082483 0.600 -1.0475699 0.2672612 I think that my_df1 is dffits( http://en.wikipedia.org/wiki/DFFITS), but in R language, my_df2 gives the difinition of dffits. Please let me know why. -- *[EMAIL PROTECTED]* http://cse.naro.affrc.go.jp/takezawa/intro.html [[alternative HTML version deleted]] __ R-help@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. -- *[EMAIL PROTECTED]* http://cse.naro.affrc.go.jp/takezawa/intro.html [[alternative HTML version deleted]] __ R-help@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.
[R] The evaluation of optional function arguments
Dear R-helpers, I've got two functions; callTimes() calls times(), passing it an optional argument (bar) by name (bar=harry). times() then believes it has been passed a name, rather than a value — but I want the value, not the name. Worse, if I evaluate the name, it is evaluated in the environment times() was defined, not where it is called. How can I call times(), defining its optional argument as a variable, and have times() know the variable's value (at the moment of calling)? Below some code: (1) The basic case (2) A working kludge-around (but I'm still looking for the Right Way.) (3) A bunch of variants, so that you may get an idea of the behaviour involved. (3 starts from the simplest case and builds up from there. Think of it as background reading.) Actually, I'll put (1) up here: ## (1) The basic case ## ## The calling function ## passes an optional argument (bar), as a variable (bar=harry). callTimes - function(tom, harry) { print(match.call(expand.dots=TRUE)) # callTimes(tom = 2, harry = 7) timesDefineInside(foo=tom, bar=harry) } ## The called function ## does not explicitly ask for bar. timesDefineInside - function(foo, ...) { # Checks to ensure this code is only executed if bar is given. print(match.call(expand.dots=TRUE))# times(foo = tom, bar = harry) bar - match.call(expand.dots=TRUE)$bar print(foo) # [1] 2 print(bar) # harry print(mode(bar)) # name print(eval(bar)) # [1] 13 foo*bar# Error in foo * bar : non-numeric argument to binary operator } harry - 13 # Now, let's see whether it thinks harry==13, or harry==7 callTimes(2, 7) ## For the output, see the above inline comments. ## And THERE we have my problem. I have yet to find a way to call a function, ## give one of the optional arguments as argument=variable, and have it pick up ## on that variable's *value*, rather than its name. (It's not even the ## reference it picks up on: as you can see, if I evaluate the name, it uses ## the definition environment, rather than the calling environment. (For the work-around, scroll down.) A second question, not essential: I spent a while searching on this topic, and found myself unsure of the terminology. Tried a number of things, found nothing, now I'm not sure whether that's because I didn't know the right words. How would you phrase/define this problem? Kind regards, and thanks in advance, Sietse Sietse Brouwer # ## Code below. ## ## Two comment-signs for comments, one for output, none for input. ## ## (2) A working kludge ## ## I can kludge around it by using callTimes - function(tom, harry) { timesArgs - list(foo = tom, bar = harry) do.call(times, timesArgs) } ## ; but is there a Right Way, too? ## (3) Some variants, starting from the simplest case... ## ## ...and increasing in complexity. ## (3.1) This is the function I have trouble with: I can't get it to get bar ## from the arguments. times - function(foo, ...) { print(match.call(expand.dots=TRUE)) # Some checks and a guard statement. You can safely assume that if there # ain't no bar argument (bar fight?), this part will not be reached. foo*bar } ## here we run it, and see that it gets bar not from ## the argument list, but from the defining environment. ls(bar) # Error in as.environment(pos) : no item called bar on the search list times(foo=2, bar=3) # times(foo = 2, bar = 3) # [1] Error in times(foo = 2, bar = 3): object bar not found ## Somehow, it doesn't cotton on to the fact that there's a bar ## in the argument list. bar - 5 times(foo=2, bar=3) # [1] 10 ## Ah. it looks for bar in the environment where the function was defined, not ## in the one where it is evaluated. Lexical scoping, plus a rule of ## inheritance/who's-your-parent-now that I don't quite understand. ## (3.2) Now we try explicitly getting it from the argument list. rm(bar) timesDefineInside - function(foo, ...) { print(match.call(expand.dots=TRUE)) # again, imagine checks here. bar - match.call(expand.dots=TRUE)$bar foo*bar } timesDefineInside(foo=7, bar=11) # [1] 77 ## So this works, and all is well, nay? Nay. Turn thou to (1) to see what ## doth happen when we call timesDefineInside from inside another function. -- Sietse Brouwer -- [EMAIL PROTECTED] -- +31 6 13456848 Wildekamp 32 -- 6721 JD Bennekom -- the Netherlands MSN: [EMAIL PROTECTED] -- ICQ: 341232104 __ R-help@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.
Re: [R] Dep setting for install of packages...
Gabor Grothendieck wrote: Its showing you the install.packages command that the menu invokes. You can keep pressing Enter to step through that and you can try entering the same command from your R console to verify its operation. Tried an install of car three different times. Once from the menu (with the debug function active as you described earlier) and two variations of manual entry of the install.packages() command. Only one that pulled in the dependencies was the third where dep = TRUE was explicitly included. The session print follows. Back to my original question. Since it is obviously turned off and non-functional in the menu code, is there a modification I can make to turn it back on without recompiling the whole package?? utils:::menuInstallPkgs() debugging in: utils:::menuInstallPkgs() debug: { install.packages(NULL, .libPaths()[1], dependencies = NA, type = type) } Browse[1] debug: install.packages(NULL, .libPaths()[1], dependencies = NA, type = type) Browse[1] trying URL 'http://probability.ca/cran/bin/windows/contrib/2.7/car_1.2-8.zip' Content type 'application/zip' length 714888 bytes (698 Kb) opened URL downloaded 698 Kb package 'car' successfully unpacked and MD5 sums checked The downloaded packages are in c:\temp\RtmpCbKGWy\downloaded_packages updating HTML package descriptions exiting from: utils:::menuInstallPkgs() NULL install.packages(NULL, .libPaths()[1], dependencies = NA) trying URL 'http://probability.ca/cran/bin/windows/contrib/2.7/car_1.2-8.zip' Content type 'application/zip' length 714888 bytes (698 Kb) opened URL downloaded 698 Kb package 'car' successfully unpacked and MD5 sums checked The downloaded packages are in c:\temp\RtmpCbKGWy\downloaded_packages updating HTML package descriptions install.packages(NULL, .libPaths()[1], dependencies = TRUE) also installing the dependency ‘leaps’ trying URL 'http://probability.ca/cran/bin/windows/contrib/2.7/leaps_2.7.zip' Content type 'application/zip' length 116782 bytes (114 Kb) opened URL downloaded 114 Kb trying URL 'http://probability.ca/cran/bin/windows/contrib/2.7/car_1.2-8.zip' Content type 'application/zip' length 714888 bytes (698 Kb) opened URL downloaded 698 Kb package 'leaps' successfully unpacked and MD5 sums checked package 'car' successfully unpacked and MD5 sums checked The downloaded packages are in c:\temp\RtmpCbKGWy\downloaded_packages updating HTML package descriptions On Sun, Oct 19, 2008 at 10:09 AM, Brian Lunergan [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: Your .libPaths() has a single component. The number of characters in it is not relevant so it should be bringing in the dependenies. Suggest you try this: debug(utils:::menuInstallPkgs) and try using the menu now and see what comes up. chooseCRANmirror() debug(utils:::menuInstallPkgs) utils:::menuInstallPkgs() debugging in: utils:::menuInstallPkgs() debug: { install.packages(NULL, .libPaths()[1], dependencies = NA, type = type) } Browse[1] Cursor waiting quietly at that prompt, but nothing else happened after entering the debug command and clicking the menu option. Keep in mind I am not a programmer and this sort of deep dive into the inner workings of a software tool I make use of is way outside my range of experience. Was there a next step I should have made, or is this what was supposed to happen? No list of packages appeared. The program simply paused waiting for something else to be done by the human looking at the screen. On Sat, Oct 18, 2008 at 9:37 PM, Brian Lunergan [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: dependencies = NA is only identical to dependencies = FALSE if .libPaths() has multiple components. If it has a single component then its the same as dependencies = c(Depends, Imports). Read the dependencies= entry on the ?install.packages page. Also read ?.libPaths Ok, ran .libPaths() and got: .libPaths() [1] C:/R-2.7.0/library That, as I understand the notes, is a valid path entry of 1 character. What am I missing about this? I already know, using the install.packages example below, that explicitly stating dep = TRUE sends R off on a hunt for the dependencies of a particular package during installation. What I would like to know and understand is whether that is the only way to do so since dep = TRUE has been turned off for the Install package(s) menu option or is there a 'tweak' of the menu possible to turn the ability back on without having to recompile the whole blessed program?? On Sat, Oct 18, 2008 at 8:30 PM, Brian Lunergan [EMAIL PROTECTED] wrote: Evening again folks: Bear with me while crow is consumed. I had asserted that 2.7.2 had dep = NA while prior installations had it turned on. Incorrect on my part. Dumped that version and stepped back two iterations to 2.7.0. Tried it with that one and the setting is indeed off for installing by menu. My apologies for the lack of information in my original post and for what has
Re: [R] Calculate SPE in PLS package
Dear list, I want to calculate SPE (squared prediction error) in x-space, can someone help? Here are my codes: fit.pls- plsr(Y~X,data=DAT,ncomp=3,scale=T,method='oscorespls',validation=CV,x= T) actual-fit.pls$model$X pred-fit.pls$scores %*% t(fit.pls$loadings) SPE.x-rowSums((actual-pred)^2) Am I missing something here? Thanks in advance. Stella Sim DISCLAIMER:\ This email contains confidential informatio...{{dropped:11}} __ R-help@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.
Re: [R] Dep setting for install of packages...
leaps is not in Depends or Imports for car. It is in Suggests and those don't get automatically pulled in when dependencies = NA. What you could do is to replace the builtin menuInstallPkgs with your own by running this: assignInNamespace(menuInstallPkgs, function (type = getOption(pkgType)) { install.packages(NULL, .libPaths()[1], dependencies = TRUE, type = type) }, ns = utils) You will need to do that in every session that you want to use the install menu or you could just add it to your Rprofile.site file which you can find by running this: file.path(R.home(), etc, Rprofile.site) On Sun, Oct 19, 2008 at 10:09 PM, Brian Lunergan [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: Its showing you the install.packages command that the menu invokes. You can keep pressing Enter to step through that and you can try entering the same command from your R console to verify its operation. Tried an install of car three different times. Once from the menu (with the debug function active as you described earlier) and two variations of manual entry of the install.packages() command. Only one that pulled in the dependencies was the third where dep = TRUE was explicitly included. The session print follows. Back to my original question. Since it is obviously turned off and non-functional in the menu code, is there a modification I can make to turn it back on without recompiling the whole package?? utils:::menuInstallPkgs() debugging in: utils:::menuInstallPkgs() debug: { install.packages(NULL, .libPaths()[1], dependencies = NA, type = type) } Browse[1] debug: install.packages(NULL, .libPaths()[1], dependencies = NA, type = type) Browse[1] trying URL 'http://probability.ca/cran/bin/windows/contrib/2.7/car_1.2-8.zip' Content type 'application/zip' length 714888 bytes (698 Kb) opened URL downloaded 698 Kb package 'car' successfully unpacked and MD5 sums checked The downloaded packages are in c:\temp\RtmpCbKGWy\downloaded_packages updating HTML package descriptions exiting from: utils:::menuInstallPkgs() NULL install.packages(NULL, .libPaths()[1], dependencies = NA) trying URL 'http://probability.ca/cran/bin/windows/contrib/2.7/car_1.2-8.zip' Content type 'application/zip' length 714888 bytes (698 Kb) opened URL downloaded 698 Kb package 'car' successfully unpacked and MD5 sums checked The downloaded packages are in c:\temp\RtmpCbKGWy\downloaded_packages updating HTML package descriptions install.packages(NULL, .libPaths()[1], dependencies = TRUE) also installing the dependency 'leaps' trying URL 'http://probability.ca/cran/bin/windows/contrib/2.7/leaps_2.7.zip' Content type 'application/zip' length 116782 bytes (114 Kb) opened URL downloaded 114 Kb trying URL 'http://probability.ca/cran/bin/windows/contrib/2.7/car_1.2-8.zip' Content type 'application/zip' length 714888 bytes (698 Kb) opened URL downloaded 698 Kb package 'leaps' successfully unpacked and MD5 sums checked package 'car' successfully unpacked and MD5 sums checked The downloaded packages are in c:\temp\RtmpCbKGWy\downloaded_packages updating HTML package descriptions On Sun, Oct 19, 2008 at 10:09 AM, Brian Lunergan [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: Your .libPaths() has a single component. The number of characters in it is not relevant so it should be bringing in the dependenies. Suggest you try this: debug(utils:::menuInstallPkgs) and try using the menu now and see what comes up. chooseCRANmirror() debug(utils:::menuInstallPkgs) utils:::menuInstallPkgs() debugging in: utils:::menuInstallPkgs() debug: { install.packages(NULL, .libPaths()[1], dependencies = NA, type = type) } Browse[1] Cursor waiting quietly at that prompt, but nothing else happened after entering the debug command and clicking the menu option. Keep in mind I am not a programmer and this sort of deep dive into the inner workings of a software tool I make use of is way outside my range of experience. Was there a next step I should have made, or is this what was supposed to happen? No list of packages appeared. The program simply paused waiting for something else to be done by the human looking at the screen. On Sat, Oct 18, 2008 at 9:37 PM, Brian Lunergan [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: dependencies = NA is only identical to dependencies = FALSE if .libPaths() has multiple components. If it has a single component then its the same as dependencies = c(Depends, Imports). Read the dependencies= entry on the ?install.packages page. Also read ?.libPaths Ok, ran .libPaths() and got: .libPaths() [1] C:/R-2.7.0/library That, as I understand the notes, is a valid path entry of 1 character. What am I missing about this? I already know, using the install.packages example below, that explicitly stating dep = TRUE sends R off on a hunt for the dependencies of a particular package
Re: [R] The evaluation of optional function arguments
Try this for timesDefineInside: timesDefineInside - function(foo, ...) { extra.args - list(...) bar - extra.args$bar foo * bar } -Kaom On Oct 19, 2008, at 6:34 PM, Sietse Brouwer wrote: Dear R-helpers, I've got two functions; callTimes() calls times(), passing it an optional argument (bar) by name (bar=harry). times() then believes it has been passed a name, rather than a value but I want the value, not the name. Worse, if I evaluate the name, it is evaluated in the environment times() was defined, not where it is called. How can I call times(), defining its optional argument as a variable, and have times() know the variable's value (at the moment of calling)? Below some code: (1) The basic case (2) A working kludge-around (but I'm still looking for the Right Way.) (3) A bunch of variants, so that you may get an idea of the behaviour involved. (3 starts from the simplest case and builds up from there. Think of it as background reading.) Actually, I'll put (1) up here: ## (1) The basic case ## ## The calling function ## passes an optional argument (bar), as a variable (bar=harry). callTimes - function(tom, harry) { print(match.call(expand.dots=TRUE)) # callTimes(tom = 2, harry = 7) timesDefineInside(foo=tom, bar=harry) } ## The called function ## does not explicitly ask for bar. timesDefineInside - function(foo, ...) { # Checks to ensure this code is only executed if bar is given. print(match.call(expand.dots=TRUE))# times(foo = tom, bar = harry) bar - match.call(expand.dots=TRUE)$bar print(foo) # [1] 2 print(bar) # harry print(mode(bar)) # name print(eval(bar)) # [1] 13 foo*bar# Error in foo * bar : non-numeric argument to binary operator } harry - 13 # Now, let's see whether it thinks harry==13, or harry==7 callTimes(2, 7) ## For the output, see the above inline comments. ## And THERE we have my problem. I have yet to find a way to call a function, ## give one of the optional arguments as argument=variable, and have it pick up ## on that variable's *value*, rather than its name. (It's not even the ## reference it picks up on: as you can see, if I evaluate the name, it uses ## the definition environment, rather than the calling environment. (For the work-around, scroll down.) A second question, not essential: I spent a while searching on this topic, and found myself unsure of the terminology. Tried a number of things, found nothing, now I'm not sure whether that's because I didn't know the right words. How would you phrase/define this problem? Kind regards, and thanks in advance, Sietse Sietse Brouwer # ## Code below. ## ## Two comment-signs for comments, one for output, none for input. ## ## (2) A working kludge ## ## I can kludge around it by using callTimes - function(tom, harry) { timesArgs - list(foo = tom, bar = harry) do.call(times, timesArgs) } ## ; but is there a Right Way, too? ## (3) Some variants, starting from the simplest case... ## ## ...and increasing in complexity. ## (3.1) This is the function I have trouble with: I can't get it to get bar ## from the arguments. times - function(foo, ...) { print(match.call(expand.dots=TRUE)) # Some checks and a guard statement. You can safely assume that if there # ain't no bar argument (bar fight?), this part will not be reached. foo*bar } ## here we run it, and see that it gets bar not from ## the argument list, but from the defining environment. ls(bar) # Error in as.environment(pos) : no item called bar on the search list times(foo=2, bar=3) # times(foo = 2, bar = 3) # [1] Error in times(foo = 2, bar = 3): object bar not found ## Somehow, it doesn't cotton on to the fact that there's a bar ## in the argument list. bar - 5 times(foo=2, bar=3) # [1] 10 ## Ah. it looks for bar in the environment where the function was defined, not ## in the one where it is evaluated. Lexical scoping, plus a rule of ## inheritance/who's-your-parent-now that I don't quite understand. ## (3.2) Now we try explicitly getting it from the argument list. rm(bar) timesDefineInside - function(foo, ...) { print(match.call(expand.dots=TRUE)) # again, imagine checks here. bar - match.call(expand.dots=TRUE)$bar foo*bar } timesDefineInside(foo=7, bar=11) # [1] 77 ## So this works, and all is well, nay? Nay. Turn thou to (1) to see what ## doth happen when we call timesDefineInside from inside another function. -- Sietse Brouwer -- [EMAIL PROTECTED] -- +31 6 13456848 Wildekamp 32 -- 6721 JD Bennekom -- the Netherlands MSN: [EMAIL PROTECTED] -- ICQ: 341232104 __
Re: [R] The evaluation of optional function arguments
Why don't you want to do this? timesDefineInside - function(foo, bar...) { foo * bar } It seems like the obvious solution to your problem. Hadley On Sun, Oct 19, 2008 at 8:34 PM, Sietse Brouwer [EMAIL PROTECTED] wrote: Dear R-helpers, I've got two functions; callTimes() calls times(), passing it an optional argument (bar) by name (bar=harry). times() then believes it has been passed a name, rather than a value — but I want the value, not the name. Worse, if I evaluate the name, it is evaluated in the environment times() was defined, not where it is called. How can I call times(), defining its optional argument as a variable, and have times() know the variable's value (at the moment of calling)? Below some code: (1) The basic case (2) A working kludge-around (but I'm still looking for the Right Way.) (3) A bunch of variants, so that you may get an idea of the behaviour involved. (3 starts from the simplest case and builds up from there. Think of it as background reading.) Actually, I'll put (1) up here: ## (1) The basic case ## ## The calling function ## passes an optional argument (bar), as a variable (bar=harry). callTimes - function(tom, harry) { print(match.call(expand.dots=TRUE)) # callTimes(tom = 2, harry = 7) timesDefineInside(foo=tom, bar=harry) } ## The called function ## does not explicitly ask for bar. timesDefineInside - function(foo, ...) { # Checks to ensure this code is only executed if bar is given. print(match.call(expand.dots=TRUE))# times(foo = tom, bar = harry) bar - match.call(expand.dots=TRUE)$bar print(foo) # [1] 2 print(bar) # harry print(mode(bar)) # name print(eval(bar)) # [1] 13 foo*bar# Error in foo * bar : non-numeric argument to binary operator } harry - 13 # Now, let's see whether it thinks harry==13, or harry==7 callTimes(2, 7) ## For the output, see the above inline comments. ## And THERE we have my problem. I have yet to find a way to call a function, ## give one of the optional arguments as argument=variable, and have it pick up ## on that variable's *value*, rather than its name. (It's not even the ## reference it picks up on: as you can see, if I evaluate the name, it uses ## the definition environment, rather than the calling environment. (For the work-around, scroll down.) A second question, not essential: I spent a while searching on this topic, and found myself unsure of the terminology. Tried a number of things, found nothing, now I'm not sure whether that's because I didn't know the right words. How would you phrase/define this problem? Kind regards, and thanks in advance, Sietse Sietse Brouwer # ## Code below. ## ## Two comment-signs for comments, one for output, none for input. ## ## (2) A working kludge ## ## I can kludge around it by using callTimes - function(tom, harry) { timesArgs - list(foo = tom, bar = harry) do.call(times, timesArgs) } ## ; but is there a Right Way, too? ## (3) Some variants, starting from the simplest case... ## ## ...and increasing in complexity. ## (3.1) This is the function I have trouble with: I can't get it to get bar ## from the arguments. times - function(foo, ...) { print(match.call(expand.dots=TRUE)) # Some checks and a guard statement. You can safely assume that if there # ain't no bar argument (bar fight?), this part will not be reached. foo*bar } ## here we run it, and see that it gets bar not from ## the argument list, but from the defining environment. ls(bar) # Error in as.environment(pos) : no item called bar on the search list times(foo=2, bar=3) # times(foo = 2, bar = 3) # [1] Error in times(foo = 2, bar = 3): object bar not found ## Somehow, it doesn't cotton on to the fact that there's a bar ## in the argument list. bar - 5 times(foo=2, bar=3) # [1] 10 ## Ah. it looks for bar in the environment where the function was defined, not ## in the one where it is evaluated. Lexical scoping, plus a rule of ## inheritance/who's-your-parent-now that I don't quite understand. ## (3.2) Now we try explicitly getting it from the argument list. rm(bar) timesDefineInside - function(foo, ...) { print(match.call(expand.dots=TRUE)) # again, imagine checks here. bar - match.call(expand.dots=TRUE)$bar foo*bar } timesDefineInside(foo=7, bar=11) # [1] 77 ## So this works, and all is well, nay? Nay. Turn thou to (1) to see what ## doth happen when we call timesDefineInside from inside another function. -- Sietse Brouwer -- [EMAIL PROTECTED] -- +31 6 13456848 Wildekamp 32 -- 6721 JD Bennekom -- the Netherlands MSN: [EMAIL PROTECTED] -- ICQ: 341232104 __
[R] passing a list where names arguments are expected
hi, say i have a function f and i'd like to to call it like this: 1) f(list(a=...,b=...)) but i can't do it, because f is defined as: 2) f-function(a=NULL,b=NULL){...} is there a way that i can approximate 1), such as mapping list(a=,...b=...) to list(a=,...b=...) and then replacing list by f, and then evaluating the expression? thanks. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] passing a list where names arguments are expected
I believe you want do.call(f, list(a =..., b=...)) ?do.call -Kaom On Oct 19, 2008, at 7:55 PM, erwann rogard wrote: hi, say i have a function f and i'd like to to call it like this: 1) f(list(a=...,b=...)) but i can't do it, because f is defined as: 2) f-function(a=NULL,b=NULL){...} is there a way that i can approximate 1), such as mapping list(a=,...b=...) to list(a=,...b=...) and then replacing list by f, and then evaluating the expression? thanks. [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] pairs plots in R
One idea: if the primary variable of interest is a categorical (binary), I would rather look at univariate plots for each of your 100 variables, grouped by the primary one. e.g. library(latticeExtra) marginal.plot(~ myBigDat, data = myBigData, groups = myBinaryVar, auto.key = TRUE, layout = c(4, 4)) (This is a convenient interface to lattice::densityplot and lattice::dotplot) If you view 16 such densityplots per page, that still gives you 7 pages. You could use playwith() (from playwith package) to scroll through the pages. -Felix 2008/10/20 Sharma, Dhruv [EMAIL PROTECTED]: Hi, is there a way to take a data frame with 100+ columns and large data set to do efficient exploratory analysis in R with pairs? I find using pairs on the whole matrix is slow and the resulting matrix is tiny. Also the variable of interest for me is a binary var Y or N . Is there an efficient way to graphically view many variable relationships that does not look teeny ? I could do pairs 10 at a time but this seems too brute force. thanks Dhruv [[alternative HTML version deleted]] __ R-help@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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ R-help@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.
Re: [R] passing a list where names arguments are expected
Indeed, that's all I need. Thanks! On Sun, Oct 19, 2008 at 11:09 PM, Kaom Te [EMAIL PROTECTED] wrote: I believe you want do.call(f, list(a =..., b=...)) ?do.call -Kaom On Oct 19, 2008, at 7:55 PM, erwann rogard wrote: hi, say i have a function f and i'd like to to call it like this: 1) f(list(a=...,b=...)) but i can't do it, because f is defined as: 2) f-function(a=NULL,b=NULL){...} is there a way that i can approximate 1), such as mapping list(a=,...b=...) to list(a=,...b=...) and then replacing list by f, and then evaluating the expression? thanks. [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] R-square in robust regression
On Sun, 19 Oct 2008, PARKERSO wrote: Hi there, I have just started using the MASS package in R to run M-estimator robust regressions. The final output appears to only give coefficients, degrees of freedom and t-stats. Does anyone know why R doesn't compute R or R-squared These as only valid for least-squares fits -- they will include the possible outliers in the measure of fit. And BTW, it is not 'R', but the uncredited author of the package who made such design decisions. and why doesn't give you any other indices of goodness of fit? Which ones did you have in mind? It does give a scale estimate of the residuals, and this determines the predition accuracy. Does anyone know how to compute these in R? Yes. Sophie -- Brian D. Ripley, [EMAIL PROTECTED] 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-help@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.