Re: [R] Size of windows graphics device
par(fin) : The figure region dimensions, |(width,height)|, in inches. par(din) : the device dimensions, |(width,height)|, in inches. On 2011-11-2 18:50, Erich Neuwirth wrote: R for Windows 2.14.0 Is there a function reporting the size of the current windows device after it has been resized manually? __ 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] ERROR: Object not found
Error originates in the customized function ode. When IN!=0, You did not assign a value to dIN which is required in list(c(dP1,dP2,dIN)). On 2010-9-21 2:30, Tianchan Niu wrote: Dear All, I am trying to use ode solver rk4 to solve an ODE system, however, it keeps saying: Error in eval(expr, envir, enclos) : object dIN not found. The sample codes are enclosed as follows, please help me. Thank you very much! rm(list=ls()) library(odesolve) # The ODE system ode- function(t,x,p){ with(as.list(c(x,p)),{ if(IN==0){ dIN- 1 switch- c } else { switch- 0 } dP1- a+b*P1-switch*P1 dP2- a-b*P1+switch*P2 list(c(dP1,dP2,dIN)) }) } # Parameters a- 0.1 b- 0.2 c- 0.5 parms- c(a=a,b=b,c=c) # Initial conditions P10- 100.0 P20- 0.0 IN0- 0.0 xstart- c(P1=P10,P2=P20,IN=IN0) # Time points times- seq(0,10,by=1) out- as.data.frame(rk4(xstart,times,ode,parms)) [[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] invalid 'row.names' length error when running scatterplots or plot in R Commander
I did not reproduce the error either, because I failed to find the function scattperplot in your script. :D I suggest that you check whether they read the data into R correctly. On 2010-9-20 10:00, Samantha McKenzie wrote: Hello, I teach statistics and use R Commander for teaching. I have 2 students out of 169 that can't get scatterplots or plot to work. I have had them update packages, restart R/R Commander/their computers and even reinstall R/R Commander. One is using Windows 7 on a new pc and the other is a pc user (not sure the OS). They are both using R2.11.1 and R Commander 1.6-0. The data look like this: Mass Mass Fore Bicep Chest Neck Shoulder Waist Height Calf Thigh Head 1 77.0 28.5 33.5 100.0 38.5114.0 85.0 178.0 37.5 53.0 58.0 2 85.5 29.5 36.5 107.0 39.0119.0 90.5 187.0 40.0 52.0 59.0 3 63.0 25.0 31.0 94.0 36.5102.0 80.5 175.0 33.0 49.0 57.0 4 80.5 28.5 34.0 104.0 39.0114.0 91.5 183.0 38.0 50.0 60.0 5 79.5 28.5 36.5 107.0 39.0114.0 92.0 174.0 40.0 53.0 59.0 6 94.0 30.5 38.0 112.0 39.0121.0 101.0 180.0 39.5 57.5 59.0 7 66.0 26.5 29.0 93.0 35.0105.0 76.0 177.5 38.5 50.0 58.5 8 69.0 27.0 31.0 95.0 37.0108.0 84.0 182.5 36.0 49.0 60.0 9 65.0 26.5 29.0 93.0 35.0112.0 74.0 178.5 34.0 47.0 55.5 10 58.0 26.5 31.0 96.0 35.0103.0 76.0 168.5 35.0 46.0 58.0 This script: scatterplot(Calf~Bicep, reg.line=lm, smooth=FALSE, spread=FALSE, + boxplots=FALSE, span=0.5, data=Mass) Produces this error: invalid 'row.names' length The data look fine and correlation/regression can be done on them with correct output. Just not scatterplots. I tried a work around using the following script, but still with the same result: attach(Mass) Mass str(Mass) names(Mass) plot(Calf~Bicep) abline(lm(Calf~Bicep)) I cannot repeat the error, nor have I found much information on that error message, and I'm a bit stumped why these two students are getting the error even after one has reinstalled the program. Cheers, Sam McKenzie The University of Queensland __ 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] Linux Editor
Try SciViews-K, an extension for Komodo Edit to transform it into a R editor and GUI. http://www.sciviews.org/SciViews-K/index.html On 2010-8-2 23:35, alphaace wrote: Hi Everyone, I recently have started using R again on a Linux box after spending several years on a Mac. Last I checked, the best way to use R was through EMACS using something like ESS. I remember that being serviceable but not always the most convenient. Is there anything comparable to the mac version of R with its built in console, editor, etc?? thanks! __ 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] WriteXLS problem
The maximum number of rows in excel 2003 or below is 65535, less than your number of rows, so if you export your data into xls files, probably you cannot see all your data in excel. Exel 2007 can hold as many as 1048575 lines, thus xlsx file is a better choice. On 2010-9-7 0:03, Kenneth Roy Cabrera Torres wrote: Hi R users: I don't know if you have had the following problem trying to export to an xls format file in a non windows platform. I try to use the following packages: 1. dataframes2xls (version 0.4.4) (with phyton 2.7 and 3.1) 2. WriteXLS (version 1.9.0) (with perl and testPerl working) Even xlsx package that take too long and do not finish. The data frame I try to export has 269363 row and 116 columns. In the first one (dataframe2xls) I get this message: Traceback (most recent call last): File C:/PROGRA~2/R/R-211~1.1PA/library/dataframes2xls/python/csv2xls.py, line 18, inmodule import pyexcelerator File C:\PROGRA~2\R\R-211~1.1PA\library\dataframes2xls\python\pyexcelerator \__init__.py, line 12, inmodule from Workbook import Workbook File C:\PROGRA~2\R\R-211~1.1PA\library\dataframes2xls\python\pyexcelerator \Workbook.py, line 526 boundsheets_len += len(BIFFRecords.BoundSheetRecord(0x00L, sheet.hidden, sheet.name).get()) ^ SyntaxError: invalid syntax Using the second option I get this message: Error en get(as.character(i)),envr=envir) : objeto '089' no encontrado Object '089' not found. Im using this R platform: sessionInfo() R version 2.11.1 Patched (2010-08-30 r52848) Platform: x86_64-unknown-linux-gnu (64-bit) Locale: LC_CTYPE=es_CO.UTF-8 Is the only solution to export to .csv and then to .xls format with other program like openoffice? Thank you for your help and advice. Kenneth __ 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 with same xlim and ylim scale
Well done! I was totally misled and trapped by the error message. Acturally the absence of 1.00 in the upper panel is an implicit indication that error occurred there. On 2010-9-3 13:02, Shi, Tao wrote: Hi Dejian, Thanks for the reply! I finally found the problem. It is actually in the panel.cor function. Adding ... in the function and text call fixed everything. Best, ...Tao - Original Message From: Dejian Zhaodejian.z...@gmail.com To: r-help@r-project.org Sent: Thu, September 2, 2010 7:57:55 PM Subject: Re: [R] pairs with same xlim and ylim scale When pairs draws plots, lower.panel invokes f.xy. Maybe there is something in f.xy incompatible with pairs. You can read the code of pairs to see what happens. pairs has two methods, as you can see in the help message (?pairs). According to your code, pairs is supposed to invoke Default S3 method. methods(pairs) [1] pairs.default pairs.formula* Non-visible functions are asterisked Therefore, you should check the code of the function pairs.default to see how error occurs. Just type pairs.default at the R command prompt and enter, you can get the source code of pairs.default. On 2010-9-2 15:15, Shi, Tao wrote: Hi Dejian, You're right on this! Do you know how to pass those two argument into lower.panel? Thanks! ...Tao From: Dejian Zhaozha...@ioz.ac.cn To:r-help@r-project.org Sent: Tue, August 31, 2010 6:10:16 PM Subject: Re: [R] pairs with same xlim and ylim scale I think you have successfully passed the xlim and ylim into the function pairs1. Compare the two graphs produced by the codes you provided, you can find the xlim and ylim in the second graph have been reset to the assigned value. It seems that the program halted in producing the second plot after adding xlim and ylim. According to the error message, the two added parameters were not used in lower.panel, or the customized function f.xy. On 2010-9-1 2:26, Shi, Tao wrote: Hi list, I have a function which basically is a wrapper of pairs with some useful panel functions. However, I'm having trouble to pass the xlim and ylim into the function so the x and y axes are in the same scale and 45 degree lines are exactly diagonal. I've looked at some old posts, they didn't help much. I [[elided Yahoo spam]] Thanks! ...Tao pairs1- function(x, ...) { f.xy- function(x, y, ...) { points(x, y, ...) abline(0, 1, col = 2) } panel.cor- function(x, y, digits=2, prefix=, cex.cor) { usr- par(usr); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r- abs(cor(x, y, method=p, use=pairwise.complete.obs)) txt- format(c(r, 0.123456789), digits=digits)[1] txt- paste(prefix, txt, sep=) if(missing(cex.cor)) cex- 0.8/strwidth(txt) text(0.5, 0.5, txt, cex = cex * r) } panel.hist- function(x, ...) { usr- par(usr); on.exit(par(usr)) par(usr = c(usr[1:2], 0, 1.5) ) h- hist(x, plot = FALSE) breaks- h$breaks; nB- length(breaks) y- h$counts; y- y/max(y) rect(breaks[-nB], 0, breaks[-1], y, col=cyan, ...) } pairs(x, lower.panel=f.xy, upper.panel=panel.cor, diag.panel=panel.hist, ...) } x- rnorm(100, sd=0.2) x- cbind(x=x-0.1, y=x+0.1) pairs1(x) pairs1(x, xlim=c(-1,1), ylim=c(-1,1)) Error in lower.panel(...) : unused argument(s) (xlim = c(-1, 1), ylim = c(-1, 1)) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://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 guidehttp://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 guidehttp://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. __ R-help@r-project.org mailing list
Re: [R] pairs with same xlim and ylim scale
When pairs draws plots, lower.panel invokes f.xy. Maybe there is something in f.xy incompatible with pairs. You can read the code of pairs to see what happens. pairs has two methods, as you can see in the help message (?pairs). According to your code, pairs is supposed to invoke Default S3 method. methods(pairs) [1] pairs.default pairs.formula* Non-visible functions are asterisked Therefore, you should check the code of the function pairs.default to see how error occurs. Just type pairs.default at the R command prompt and enter, you can get the source code of pairs.default. On 2010-9-2 15:15, Shi, Tao wrote: Hi Dejian, You're right on this! Do you know how to pass those two argument into lower.panel? Thanks! ...Tao From: Dejian Zhaozha...@ioz.ac.cn To:r-help@r-project.org Sent: Tue, August 31, 2010 6:10:16 PM Subject: Re: [R] pairs with same xlim and ylim scale I think you have successfully passed the xlim and ylim into the function pairs1. Compare the two graphs produced by the codes you provided, you can find the xlim and ylim in the second graph have been reset to the assigned value. It seems that the program halted in producing the second plot after adding xlim and ylim. According to the error message, the two added parameters were not used in lower.panel, or the customized function f.xy. On 2010-9-1 2:26, Shi, Tao wrote: Hi list, I have a function which basically is a wrapper of pairs with some useful panel functions. However, I'm having trouble to pass the xlim and ylim into the function so the x and y axes are in the same scale and 45 degree lines are exactly diagonal. I've looked at some old posts, they didn't help much. I [[elided Yahoo spam]] Thanks! ...Tao pairs1- function(x, ...) { f.xy- function(x, y, ...) { points(x, y, ...) abline(0, 1, col = 2) } panel.cor- function(x, y, digits=2, prefix=, cex.cor) { usr- par(usr); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r- abs(cor(x, y, method=p, use=pairwise.complete.obs)) txt- format(c(r, 0.123456789), digits=digits)[1] txt- paste(prefix, txt, sep=) if(missing(cex.cor)) cex- 0.8/strwidth(txt) text(0.5, 0.5, txt, cex = cex * r) } panel.hist- function(x, ...) { usr- par(usr); on.exit(par(usr)) par(usr = c(usr[1:2], 0, 1.5) ) h- hist(x, plot = FALSE) breaks- h$breaks; nB- length(breaks) y- h$counts; y- y/max(y) rect(breaks[-nB], 0, breaks[-1], y, col=cyan, ...) } pairs(x, lower.panel=f.xy, upper.panel=panel.cor, diag.panel=panel.hist, ...) } x- rnorm(100, sd=0.2) x- cbind(x=x-0.1, y=x+0.1) pairs1(x) pairs1(x, xlim=c(-1,1), ylim=c(-1,1)) Error in lower.panel(...) : unused argument(s) (xlim = c(-1, 1), ylim = c(-1, 1)) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://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 guidehttp://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 guidehttp://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] vglm
My previous expression is ok. But I agree using argument 'data' will be a better choice especially when there are many variables from the object specified by 'data'. On 2010-9-1 16:23, Gavin Simpson wrote: On Wed, 2010-09-01 at 11:05 +0800, Dejian Zhao wrote: try fit=vglm(mydata[,Loss]~1,pareto1(location=alpha),trace=TRUE,crit=c) No, please don't. That is not a good example of formula use in R. Several responders have already pointed out that the 'R' way of doing this would be to use a data argument to tell vglm where to find the variables mentioned in the formula. So your example would become: fit- vglm(Loss ~ 1, data = mydata, family = pareto1(location = alpha), trace = TRUE, crit = coef) HTH G On 2010-9-1 3:20, choonhong ang wrote: Hi All, could anybody help me to understand what is this error means ? mydata=read.table(C:/Documents and Settings/angieb/Desktop/CommercialGL/cl_ilf_claimdata.csv,header=TRUE,sep=,) names(mydata) [1] ILFTableliabLimit AnnAggLimit DedAmt Loss TIL fit=vglm(Loss~1,pareto1(location=alpha),trace=TRUE,crit=c) Error in eval(expr, envir, enclos) : object Loss not found [[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. __ 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] vglm
I am glad it works. But you should reply to the list, thus more people can trace the process of the question. As to your second question, I have no idea how to solve it. I suggest you start another thread. There will be someone able to answer you in the R mailing list. Remember to reply to the list, thus you can get more answers from the list. On 2010-9-2 4:44, choonhong ang wrote: Hi, thank you it is working now. i have another question that from the R documentation, for pareto1if the estimate of k is less or equal to unity then the fitted values will be NA. I have the same problem that my fitted values is NA. from the R document (f...@extra mailto:f...@extra is to get the estimate of alpha, how about to get the estimate of k ?) any idea how to solve the NA problem ? thanks again On Tue, Aug 31, 2010 at 10:05 PM, Dejian Zhao zha...@ioz.ac.cn mailto:zha...@ioz.ac.cn wrote: try fit=vglm(mydata[,Loss]~1,pareto1(location=alpha),trace=TRUE,crit=c) On 2010-9-1 3:20, choonhong ang wrote: Hi All, could anybody help me to understand what is this error means ? mydata=read.table(C:/Documents and Settings/angieb/Desktop/CommercialGL/cl_ilf_claimdata.csv,header=TRUE,sep=,) names(mydata) [1] ILFTableliabLimit AnnAggLimit DedAmt Loss TIL fit=vglm(Loss~1,pareto1(location=alpha),trace=TRUE,crit=c) Error in eval(expr, envir, enclos) : object Loss not found [[alternative HTML version deleted]] __ R-help@r-project.org mailto: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 http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailto: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 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] Can WinBUGS run two processes through R at the same time?
Does winbugs write anything to the file 'inits1.txt'? If yes,possibly the file is exclusively occupied by the first winbugs process. On 2010-9-1 1:12, 潘家群 wrote: Dear all, I want to run two winBugs processes through R (by R2WinBUGS package). The first WinBUGS process can successfully perform under R. The error message appears while I put the code to run for the second WinBUGS process. The error message: Error in file(file, ifelse(append, a, w)) : cannot open the connection In addition: Warning message: In file(file, ifelse(append, a, w)) : cannot open file 'inits1.txt': Permission denied Can WinBUGS run two processes through R at the same time? If it can, how should I modify the setting to do this? 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 with same xlim and ylim scale
I think you have successfully passed the xlim and ylim into the function pairs1. Compare the two graphs produced by the codes you provided, you can find the xlim and ylim in the second graph have been reset to the assigned value. It seems that the program halted in producing the second plot after adding xlim and ylim. According to the error message, the two added parameters were not used in lower.panel, or the customized function f.xy. On 2010-9-1 2:26, Shi, Tao wrote: Hi list, I have a function which basically is a wrapper of pairs with some useful panel functions. However, I'm having trouble to pass the xlim and ylim into the function so the x and y axes are in the same scale and 45 degree lines are exactly diagonal. I've looked at some old posts, they didn't help much. I think this is b/c I have multiple panel functions. Help! Thanks! ...Tao pairs1- function(x, ...) { f.xy- function(x, y, ...) { points(x, y, ...) abline(0, 1, col = 2) } panel.cor- function(x, y, digits=2, prefix=, cex.cor) { usr- par(usr); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r- abs(cor(x, y, method=p, use=pairwise.complete.obs)) txt- format(c(r, 0.123456789), digits=digits)[1] txt- paste(prefix, txt, sep=) if(missing(cex.cor)) cex- 0.8/strwidth(txt) text(0.5, 0.5, txt, cex = cex * r) } panel.hist- function(x, ...) { usr- par(usr); on.exit(par(usr)) par(usr = c(usr[1:2], 0, 1.5) ) h- hist(x, plot = FALSE) breaks- h$breaks; nB- length(breaks) y- h$counts; y- y/max(y) rect(breaks[-nB], 0, breaks[-1], y, col=cyan, ...) } pairs(x, lower.panel=f.xy, upper.panel=panel.cor, diag.panel=panel.hist, ...) } x- rnorm(100, sd=0.2) x- cbind(x=x-0.1, y=x+0.1) pairs1(x) pairs1(x, xlim=c(-1,1), ylim=c(-1,1)) Error in lower.panel(...) : unused argument(s) (xlim = c(-1, 1), ylim = c(-1, 1)) [[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] mode function
R does have a mode function, but it seems NOT to do the same thing as in matlab. A - matrix(c(1:3,1,3,2,3,3,2),nrow=3,byrow=F) A [,1] [,2] [,3] [1,]113 [2,]233 [3,]322 A[,2] [1] 1 3 2 mode(A) [1] numeric mode(A[,2]) [1] numeric On 2010-9-1 5:19, Iain Martyn wrote: Hi, I have what I think is a simple question/issue but I have unable to find the answer for it either in the R-manual or by browsing the web. I would like to know if there is a mode function in R, such that from a vector or matrix the function returns the most common value. In other programs I use (such as Matlab) I can have for exampe a 3X3 matrix A, A=[1 2 3; 1 3 2; 3 3 2] and I can find the mode of the rows so that mode(A[1:3,:]) returns a 1X3 matrix [1 3 2]. Is this possible in R as well? If not, how would one go about this? Thank you very much, Bill [[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] vglm
try fit=vglm(mydata[,Loss]~1,pareto1(location=alpha),trace=TRUE,crit=c) On 2010-9-1 3:20, choonhong ang wrote: Hi All, could anybody help me to understand what is this error means ? mydata=read.table(C:/Documents and Settings/angieb/Desktop/CommercialGL/cl_ilf_claimdata.csv,header=TRUE,sep=,) names(mydata) [1] ILFTableliabLimit AnnAggLimit DedAmt Loss TIL fit=vglm(Loss~1,pareto1(location=alpha),trace=TRUE,crit=c) Error in eval(expr, envir, enclos) : object Loss not found [[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] checking if a package is installed
require() does what you want. Run ?require for details. require() returns 'FALSE' and gives a warning (rather than an error as 'library()' does by default) if the package does not exist. 'require' returns (invisibly) a logical indicating whether the required package is available. (You can capture the logical value by assigning it to a variable, eg. tmp - require(pkg_name)) On 2010-8-27 9:07, pdb wrote: Hi, I am writing a function that requires a specific package to be installed. Is there a way of checking if the package is installed and returning a TRUE / FALSE result so my function can return an appropriate error message and exit the function gracefully rather than just bombing out? I'm thinking along the following lines (but want code that works), f_checkpackage- function() { if (library(madeupname) == TRUE) { cat(package loaded OK\n) } else { cat(ERROR: package not loaded) } } f_checkpackage() __ 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 and MySQL
I am not sure whether you are working under windows. Hope the following message helps. Using the RMySQL package under Windows http://www.stat.berkeley.edu/users/spector/s133/RMySQL_windows.html On 2010-8-27 5:03, quant wrote: I installed MySQL 5.0.67 and R. I installed RMySQL and added env variable MYSQL_HOME. But R still does not want to load the library. It says Error : .onLoad failed in loadNamespace() for 'RMySQL', details: call: NULL error: MYSQL_HOME was set but does not point to a directory Error: package/namespace load failed for 'RMySQL' Please help. __ 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] How to remove all objects except a few specified objects?
If your specified objects have a certain pattern, you can use the parameter pattern in ls() to remove or keep it. rm(list=ls(..., pattern=your_pattern)) If not, possibly you have to manually specify them. On 2010-8-24 3:00, Cheng Peng wrote: How to remove all R objects in the RAM except for a few specified ones? rm(list=ls()) removes all R objects in the R work space. Another question is that whether removing all R objects actually releases the RAM? Thanks. __ 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] Fancy Page layout
I think you can use grid.layout() to create the appropriate layout, allocating proper space for the upper plotting area and the bottom text region, and then use viewport() with the layout parameter to control the output by pushing the viewport at the proper region on the graphical device. Viewport alone can solve your three quesions, but with grid.layout the layout is better controlled. The above-mentioned functions, or grid.layout(), viewport() and pushViewport(), are in the grid package. Possibly the work can be done by combining lattice with grid. On 2010-6-2 1:10, Noah Silverman wrote: Thanks Jim, That helps. Ben Bolker had a nice suggestion on how to get the lattice package to easily plot all 22 variables in one window. Ultimately, I'd like to generate a PDF that will print on a standard (8.5 x 11) page. A few things I'm still stuck are: 1) How to use the lattice command AND leave room at the bottom for a text block 2) How to tell lattice the size of the window 3) How to integrate all this together - draw a big window, plot trellis in the top half and then text box in the bottom. Any thoughts? -N On 6/1/10 4:53 AM, Jim Lemon wrote: On 06/01/2010 04:16 AM, Noah Silverman wrote: Hi, Working on a report that is going to have a large number of graphs and summaries. We have 80 groups with 20 variables each. Ideally, I'd like to produce ONE page for each group. It would have two columns of 10 graphs and then the 5 number summary of the variables at the bottom. So, perhaps the top 2/3 of the page has the graphs and the bottom third has 20 rows of data summary(maybe a table of sorts.) This COULD be done in Latex, but would have to be hand coded for each of the 80 groups which would be painfully slow. I can easily do the graphs with par(mfrow=c(5,2)) band then draw the graphs in a loop. But I am stuck from here: 1) How do I control the size of the plot window. (Ideally, it should print to fill an 8.5 x 11 piece of paper) 2) Is there a way to easily insert a 5 number summary (summary command) into the lower half of the page. Does anybody have any ideas?? Hi Noah, One easy way is to leave some space at the bottom, either by using: par(mfrow=c(6,2)) or the more flexible layout function, and then use text or a fancier function (textbox, boxed.labels, addtable2plot, etc.) to add your text after: par(xpd=NA) allows you to display the text anywhere you please. If you use a bitmap graphics device, make it big: png(numberoneofeighty.png,850,1100) so that it won't look lumpy on the printed page. 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. __ 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] sort a data.frame
If you want to sort the data frame according to column b, the followding code does this work. attach(dd) dd-dd[order(b),] detach(dd) If you want to sort the data frame according to the chr number in column b, you should extract the numbers first into a vector, say chrnum, and then use order(chrnum) as the index to sort the data frame dd. Suppose that the chr numbers have been extracted to vector chrnum. The code is as follows: chrnum -c(2,1,15,13) attach(dd) dd-dd[order(chrnum),] detach(dd) The result is dd b x y z 2 chr1 D 3 1 1 chr2 A 8 1 4 chr13 C 9 2 3 chr15 A 9 1 But I don't know how to extract the numbers conveniently. Please respond if anyone knows. Many thanks! On 05/20/2010 08:28 PM, Yuan Jian wrote: Hello, I have a dataframe: dd- data.frame(b = c(chr2, chr1, chr15, chr13), x = c(A, D, A, C), y = c(8, 3, 9, 9), z = c(1, 1, 1, 2)) dd b x y z 1 chr2 A 8 1 2 chr1 D 3 1 3 chr15 A 9 1 4 chr13 C 9 2 Now I want to sort them according column b, but only its number is considered: b x y z 1 chr1 D 3 1 2 chr13 C 9 2 3 chr15 A 9 1 4 chr2 A 8 1 thanks jian __ 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] about chisq.test()
Dear all, I want to check whether 5 decimal data is 1:1:1:1:1. For example, data = c(14.3,16.2,14.7,18.7,14.5) Since chisq.test() can do the goodness-of-fit test, it becomes my choice. However, I find in the ?chisq.test help file that it requires non-negative integers! It seems that it is inappropriate to do the test using this function. The function requires integer. But what if we input some decimals as mentioned above? Actually I did it and it seems goes well. data = c(14.3,16.2,14.7,18.7,14.5) chisq.test(data) Chi-squared test for given probabilities data: data X-squared = 0.8704, df = 4, p-value = 0.9288 Is this result reliable? Thanks! Dejian __ 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.