[R] estimating mode
Dear all, I am considering a problem related to density regression. After we got the estimation of probability density function f(x), how can we estimate the mode of that population? Does the sm package support mode estimation? If not, is there any other function in R can estimate the mode according to the estimation of pdf f(x)? Univariate case is ok. If the function further support higher dimensions, it is perfect. Thanks. _ Take a break! Find destinations on MSN Travel. http://www.msn.com.sg/travel/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Memory clear problem
Suzanne E. Blatt wrote: Hello. I think this is a simple problem. I have R running a program which generates variables that it 'remembers'. The trouble is that I've modified the file that it's generating these variables from but doesn't seem to realize that. When I type 'trees' - I get the same data set produced. I tried shutting R down and not saving the workspace, but when I open 'er up again and type 'trees', there is that same data set. I saw a memory clear command somewhere in one of the help files but I'll be danged if I can locate it now. Please tell me this is a simple problem with a nice(one-line) solution. Thanks, Suzanne __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html From ?rm: ## remove (almost) everything in the working environment. ## You will get no warning, so don't do this unless you are really sure. rm(list = ls()) Uwe Ligges __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] memory problem for R
On Thu, 29 Jan 2004, Yun-Fang Juan wrote: Here is the exact error I got -- Read 73 items Error: cannot allocate vector of size 1953 Kb Execution halted --- I am running R on Freebsd 4.3 with double CPU and 2 GB memory Is that sufficient? Clearly not. What is the structure of your `attributes'? As Andy Liaw said, the design matrix may be bigger than that if there are factors involved. (And you need several copies of the design matrix.) I would try a 10% sample of the rows to get a measure of what will fit into your memory. I have never seen a regression problem for which 600k cases were needed, and would be interested to know the context. (It is hard to imagine that the cases are from a single homogeneous population and that a linear model fits so well that the random error is not dominated by systematic error.) Yun-Fang - Original Message - From: Yun-Fang Juan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 29, 2004 7:03 PM Subject: [R] memory problem for R Hi, I try to use lm to fit a linear model with 600k rows and 70 attributes. But I can't even load the data into the R environment. The error message says the vector memory is used up. Is there anyone having experience with large datasets in R? (I bet) Please advise. thanks, Yun-Fang [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Su requerimiento. [uid]078e98bc9346259a0c7552344053ba04[/uid]
Muchas gacias por su mensaje e interés en Vivendi Universal Games. Estamos trabajando lo más rápido posible en una solución a su pregunta. Gracias por su atención, Su equipo de soporte técnico Vivendi Universal Games. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] GLMM (lme4) vs. glmmPQL output (summary with lme4 revised)
This is a summary and extension of the thread GLMM (lme4) vs. glmmPQL output http://maths.newcastle.edu.au/~rking/R/help/04/01/0180.html In the new revision (#Version: 0.4-7) of lme4 the standard errors are close to those of the 4 other methods. Thanks to Douglas Bates, Saikat DebRoy for the revision, and to Göran Broström who run a simulation. In response to my first posting, Prof. B. Ripley wrote: ___ Although it has not been stated nor credited, this is very close to an example in MASS4 (there seems a difference in coding). Both the dataset and much of the alternative analyses are from the work of my student James McBroom (and other students have contributed). Well, I thought having repeated MASS four times in the header of my submitted test programm was enough credit for the r-help audience, but he certainly is right: the base example glmmPQL is from MASS, http://www.stats.ox.ac.uk/pub/MASS4/ #Package: lme4 #Version: 0.4-7 #Date: 2004/01/26 !! Revised --- GLMM/lme4/Pinheiro/Bates Estimate Std. Error DF z value Pr(|z|) (Intercept) 3.412020.65874 169 5.1796 2.223e-07 trtdrug -1.247360.81824 47 -1.5244 0.1273995 trtdrug+ -0.754330.81993 47 -0.9200 0.3575758 I(week 2)TRUE -1.607260.45525 169 -3.5305 0.0004148 --- glmmPQL/MASS/VenablesRipley Value Std.Error DF t-value p-value (Intercept) 3.41 0.519 1696.58 0. trtdrug -1.25 0.644 47 -1.94 0.0588 trtdrug+-0.75 0.645 47 -1.17 0.2484 I(week 2)TRUE -1.61 0.358 169 -4.49 0. --- glmmML/glmmML/Broström coef se(coef) z Pr(|z|) (Intercept) 3.5790.701 5.10 3.3e-07 trtdrug -1.3690.694 -1.97 4.8e-02 trtdrug+-0.7890.700 -1.13 2.6e-01 I(week 2)TRUE -1.6270.482 -3.38 7.3e-04 --- geese/geepack/Jun Yan estimate san.se waldp (Intercept)2.844 0.529 28.92 7.56e-08 trtdrug -1.113 0.586 3.61 5.76e-02 trtdrug+ -0.634 0.544 1.36 2.44e-01 I(week 2)TRUE -1.325 0.368 12.96 3.18e-04 --- glmm/repeated/J.K.Lindsey Estimate Std. Error z value Pr(|z|) (Intercept) -3.569 0.549 -6.51 7.8e-11 *** trtdrug1.367 0.4862.81 0.00490 ** trtdrug+ 0.786 0.4981.58 0.11408 week2TRUE 1.623 0.4593.53 0.00041 *** sd 1.294 0.2505.17 2.3e-07 *** --- --- data(bacteria,package=MASS) UseMASS-T # must restart R after changing because of nlme/lme4 clash if (UseMASS){ library(MASS) # required for bacteria options(digits=3) cat(--- glmmPQL/MASS/VenablesRipley\n) print(summary(glmmPQL(y ~ trt + I(week 2), random = ~ 1 | ID, family = binomial, data = bacteria))) cat(--- glmmML/glmmML/Broström\n) library(glmmML) print(glmmML(y==y~trt+I(week2), data=bacteria,cluster=bacteria$ID)) cat(--- geese/geepack/Jun Yan\n) library(geepack) print(summary(geese(y == y ~ trt + I(week 2), family = binomial, id = ID, corstr = exchangeable,data=bacteria))) library(repeated) cat(--- glmm/repeated/J.K.Lindsey\n) # reformat data as required by glmm. reshape should be safer... bac-as.data.frame(xtabs(~ID+trt+I(week2)+y,data=bacteria)) names(bac,)[3]-week2 nr-nrow(bac) bac-cbind(bac[1:(nr/2),-4],bac$Freq[(nr/2+1):nr]) names(bac,)[4]-Freq.n names(bac,)[5]-Freq.y attach(bac) # couldn't find the right sytax without this print(summary(glmm(cbind(Freq.n,Freq.y)~trt+week2, data=bac, nest=ID, family=binomial))) } else { cat(--- GLMM/lme4/Pinheiro/Bates\n) library(lme4) bac.GLMM-GLMM(y ~ trt + I(week 2), random = ~ 1 | ID, family = binomial, data = bacteria,method=PQL) print(bac.GLMM) } __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Doubt about pattern
Marcelo Luiz de Laia wrote: I have a very simple problem. I have several files in a same directory. I would like to send for an object only the files that finish in .sens.. I execute the command below, files - dir(pattern=*.sens) That's not even a valid regular expression in most applications, but dir does allow it, for some reason. Anyway, I think you are mixing globs and regular expressions. If *.sens is a glob, then it will find all files ending with .sens, which is not the same as .sens. which you said above. Stefano Calza [EMAIL PROTECTED] wrote: dir(pattern=\\.sens+$) That will find files ending with .sens, .senss, .sensss, etc. To find files ending with .sens., the regex is dir(pattern = \\.sens\\.$) If there is a file called just .sens., you have to use all.files = TRUE, since files beginning with a . are invisible. Peter -- Peter J. Acklam - [EMAIL PROTECTED] - http://home.online.no/~pjacklam __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Doubt about pattern
On Fri, Jan 30, 2004 at 12:46:44PM +0100, Peter J. Acklam wrote: ...cut... Stefano Calza [EMAIL PROTECTED] wrote: dir(pattern=\\.sens+$) That will find files ending with .sens, .senss, .sensss, etc. To find files ending with .sens., the regex is dir(pattern = \\.sens\\.$) If there is a file called just .sens., you have to use all.files = TRUE, since files beginning with a . are invisible. Ops you're perfectly right. Should not put +!! Thanks, Ste Peter -- Peter J. Acklam - [EMAIL PROTECTED] - http://home.online.no/~pjacklam -- Stefano Calza, Sezione di Statistica Medica Dip. di Scienze Biomediche e Biotecnologie Università degli Studi di Brescia - Italy Viale Europa, 11 25123 Brescia email: [EMAIL PROTECTED] Telefono/Phone: +390303717532 Fax: +390303701157 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] lines in 3d-cloud plot (lattice)
Hi all, I'd like to plot a set of data (x,y,z) as 3D-cloud, and add several line plots to the same 3D graph: Two questions: 1) How do I connect points to get a line? cloud(z~x*y,data=d,zlim=c(0,1))# works cloud(z~x*predict(l),data=d,zlim=c(0,1),type=l) # type=l doesn't Warning message: type = l not implemented, consider using 'panel.3d.cloud = panel.3dscatter.old' in: panel.3d.cloud(x = x, y = y, z = z, rot.mat = rot.mat, za = za, help.search(panel.3d.cloud) also didn't report any hits. 2) How do I superimpose a second data set onto the same graph? (something equivalent to the sequence plot(), followed by points() or lines() in the base plotting functions) Thanks for any help Pascal __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Object validation and formal classes
On 29 Jan 2004 at 20:04, Robert Gentleman wrote: There are some efficiency issues that prevent constant checking (at least at the present time). There are also some other issues that need to be adequately addressed too. For example, suppose I had an object with two slots a - a character string b - the number of characters Yes, efficiency was also a concern I had with my original understanding of what the validation function is supposed to do. Reading the docs I got the impression that 1) during an assignment the validation function will be called with a copy of the object that already has the new value assigned 2) if it returns TRUE that copy is returned as the result of the assigment 3) otherwise, an error is raised. That would be pretty inefficient for large objects. What does actually happen when I call slot- ? I suppose that this always operates on the object in sys.parent() of slot- and never creates a copy of the specified object. and I set my validity checker to make sure that the length of the string is the number in b. Now that basically means that I can never change the string (except to other strings of the same length) if validity checking happened after every change. I somehow need changing both a and b to be instantaneous (which they currently are not). We have not really gone far enough down that path yet to know what the right thing is, but we are working on it. So for now validity checking occurs at a few specific points and if/when you ask for it. What about access control ? The docs state it isn't implemented yet. If there was something similar to C++ one could set critical slots to private and only allow access and assignment via (replacement) methods. At first sight, this seems feasible and shouldn't cost much performance. Another approach might be an (optional) validation function for each individual slot or for groups of slots that doesn't need to validate the whole object but only changes that may occur in conjunction with a single slot or group of slots. Of course, efficiency issues are more likely to occur in this scenario. The @- operator seems to call slot- by default, maybe I can overload slot- for my class and implement this kind of validation on my own ? I guess some tricks will be necessary here to prevent that slot- is called recursively if the validation function for one slot attempts to make an assignemt to another slot. So if I don't find a feasible solution in the meantime, the best way would be writing wrappers for those slots that need validation and tell the users to use those instead of changing the object directly ? Thanks again, Torsten [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Doubt about pattern
On Fri, 30 Jan 2004, Peter J. Acklam wrote: Marcelo Luiz de Laia wrote: I have a very simple problem. I have several files in a same directory. I would like to send for an object only the files that finish in .sens.. I execute the command below, files - dir(pattern=*.sens) That's not even a valid regular expression in most applications, but dir does allow it, for some reason. Anyway, I think you It is a valid regex in GNU's regex code as used by R, and all the GNU and non-GNU applications I tried accepted it. `*' matches itself when not used as a repetition qualifier. (I tried several greps, including those claiming strict POSIX compliance.) So, can you please list the `most applications' you tried or give a reference for your assertion? are mixing globs and regular expressions. If *.sens is a glob, then it will find all files ending with .sens, which is not the same as .sens. which you said above. -- 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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Doubt about pattern
Prof Brian Ripley [EMAIL PROTECTED] wrote: Peter J. Acklam wrote: Marcelo Luiz de Laia wrote: files - dir(pattern=*.sens) That's not even a valid regular expression in most applications, but dir does allow it, for some reason. Anyway, I think you It is a valid regex in GNU's regex code as used by R, and all the GNU and non-GNU applications I tried accepted it. `*' matches itself when not used as a repetition qualifier. (I tried several greps, including those claiming strict POSIX compliance.) So, can you please list the `most applications' you tried or give a reference for your assertion? I should have said many applications, not most applications. I use Solaris, and I don't know one Solaris application which allows it, including egrep, oawk, and nawk. And no version of Perl allows it. GNU-tools allow it, but in an inconsistent way. GNU Emacs treats `*x' as `\*x' (match a literal star and a literal x), but GNU grep (version 2.5) treats `*x' as `.*x' (match anything up to and including the first x), which is something quite different. It's a mess, it's inconsistent, and it's not portable. I suggest people stop using *... and use \*... or .*... depending on what is wanted. Peter -- Peter J. Acklam - [EMAIL PROTECTED] - http://home.online.no/~pjacklam __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] memory problem for R
Hello, Yun-Fan: Prof. Ripley's comments will get you started. Part of the key is finding informative ways to subset and summarize the data so you don't try to read it all into R at once. You can read segments using arguments skip and nrows in read.table. You can then analyze a portion, save a summary, discard the bulk of the data and read another portion. Beyond this, you may know that Kalman filtering is essentially linear regression performed one observation or one group of observations at a time, downweighting older observations gracefully. It essentially assumes that the regression parameters follow a random walk between observations or groups of observations. I've done ordinary least squares with Kalman filtering software one observation at a time, just by setting the migration variance to zero. R software for Kalman filtering was discussed recently in this list; to find it, I would use the search facilities described in the posting guide at the end of every r-help email. hope this helps. spencer graves Prof Brian Ripley wrote: On Thu, 29 Jan 2004, Yun-Fang Juan wrote: Here is the exact error I got -- Read 73 items Error: cannot allocate vector of size 1953 Kb Execution halted --- I am running R on Freebsd 4.3 with double CPU and 2 GB memory Is that sufficient? Clearly not. What is the structure of your `attributes'? As Andy Liaw said, the design matrix may be bigger than that if there are factors involved. (And you need several copies of the design matrix.) I would try a 10% sample of the rows to get a measure of what will fit into your memory. I have never seen a regression problem for which 600k cases were needed, and would be interested to know the context. (It is hard to imagine that the cases are from a single homogeneous population and that a linear model fits so well that the random error is not dominated by systematic error.) Yun-Fang - Original Message - From: Yun-Fang Juan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 29, 2004 7:03 PM Subject: [R] memory problem for R Hi, I try to use lm to fit a linear model with 600k rows and 70 attributes. But I can't even load the data into the R environment. The error message says the vector memory is used up. Is there anyone having experience with large datasets in R? (I bet) Please advise. thanks, Yun-Fang [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Memory clear problem
Hi, Suzanne: R makes a copy of the file and does not operate on the original file. If you want R to see and process the changes, you must reread the file and rerun the script to recompute whatever you want. hope this helps. spencer graves Uwe Ligges wrote: Suzanne E. Blatt wrote: Hello. I think this is a simple problem. I have R running a program which generates variables that it 'remembers'. The trouble is that I've modified the file that it's generating these variables from but doesn't seem to realize that. When I type 'trees' - I get the same data set produced. I tried shutting R down and not saving the workspace, but when I open 'er up again and type 'trees', there is that same data set. I saw a memory clear command somewhere in one of the help files but I'll be danged if I can locate it now. Please tell me this is a simple problem with a nice(one-line) solution. Thanks, Suzanne __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html From ?rm: ## remove (almost) everything in the working environment. ## You will get no warning, so don't do this unless you are really sure. rm(list = ls()) Uwe Ligges __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Sua mensagem não pôde ser entregue
ESTE EMAIL É AUTOMÁTICO. POR FAVOR, NÃO RESPONDA, POIS ELA NÃO SERÁ LIDA. Não foi possível entregar a sua mensagem. O destinatário não recebeu a sua mensagem. Veja a seguir a descrição do motivo. [EMAIL PROTECTED]: A caixa postal do destinatário excedeu o limite de capacidade de armazenamento e por isso não pode receber mensagens. The users mailfolder is over the allowed quota (size). --- Below this line is a copy of the message. Return-Path: [EMAIL PROTECTED] Received: (qmail 8132 invoked from network); 30 Jan 2004 12:41:52 - Received: from unknown ([200.226.132.94]) (envelope-sender ) by mailserver-27.ig.com.br (qmail-ldap-1.03) with QMQP for ; 30 Jan 2004 12:41:52 - Delivered-To: CLUSTERHOST email-93.ig.com.br [EMAIL PROTECTED] Received: (qmail 25354 invoked from network); 30 Jan 2004 12:41:49 - Received: from bhe044017.res-com.wayinternet.com.br (HELO lists.r-project.org) ([200.150.44.17]) (envelope-sender [EMAIL PROTECTED]) by email-93.ig.com.br (qmail-ldap-1.03) with SMTP for [EMAIL PROTECTED]; 30 Jan 2004 12:41:49 - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Mail Delivery System Date: Fri, 30 Jan 2004 10:53:20 -0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary==_NextPart_000__2FE38087.E67A5B91 X-Priority: 3 X-MSMail-Priority: Normal This is a multi-part message in MIME format. --=_NextPart_000__2FE38087.E67A5B91 Conten --- End of message stripped. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] estimating mode
You can find some Splus code on Prof. Minnotte's web page: http://math.usu.edu/~minnotte/research/pubs.html. You can try and see if those can be use directly in R. If not, porting may not be too hard. Prof. Marron's `SiZer' might also be of interest, but I only know of the Matlab code that are provided by Steve. HTH, Andy From: Z P Dear all, I am considering a problem related to density regression. After we got the estimation of probability density function f(x), how can we estimate the mode of that population? Does the sm package support mode estimation? If not, is there any other function in R can estimate the mode according to the estimation of pdf f(x)? Univariate case is ok. If the function further support higher dimensions, it is perfect. Thanks. _ Take a break! Find destinations on MSN Travel. http://www.msn.com.sg/travel/ -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to plot a small figure in a bigger one???
Hi, I want to insert a small figure into a bigger plot. I saw people are doing this all the time, but I just could not figure out how to do it in R. Thanks for your help! Jinfeng Zhang __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to create own distance measure in cluster ?
Hi everyone, I want to create my own distance measure, other than 'euclidean' or 'manhatan', to use in cluster pckgs. To do this I think that I need to change dist(), in mva pckg, or daisy(), in cluster pckg. (or is there a cleaver way ?) But this functions are in fact things like: .Fortran( daisy, ... ) or .C(dist,...). I tried unsuccessfully to find source code of .Fortran or .C function to lear how R calculate dissimilarity matrix and then modify source to add my own distance metrix. Could someone help me ? Help me to find .Fortran(...) source or helpe me with better idea to implement my own distance metrix ? __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Doubt about pattern
Your question has by now been answered but I thought I would add that if you want to do it via file globbing on Windows rather than regular expressions then this function would help: list.files.glob - function( spec ) { # returns list of files or NULL if none: spec uses globbing and can # use either forward or backward slashes. # e.g list.files.glob( c:/a*.* ) # e.g. list.files.glob( c:/myfolder/my*.dat) # only works on Windows if ( substring(spec,2,2) != : ) spec - paste( C, spec, sep= : ) z - system( paste(cmd /c attrib, spec), intern = T, invisible = T) if ( !pmatch(File not found - , z[1], nomatch = 0) ) substring(z,12) } For example: list.files.glob( *.sens ) On Thu, Jan 29, 2004 at 11:33:25AM -0300, Marcelo Luiz de Laia (mlaia at fcav.unesp.br) wrote: Hi All, I have a very simple problem. I have several files in a same directory. I would like to send for an object only the files that finish in .sens.. I execute the command below, files - dir(pattern=*.sens) but it includes all of the files that have sens, independent of they be in the end or in the middle of the name of the file. How could I solve this? I sought in the html_help but I didn't find similar to this. My files script_sens.txt, Sen_155_01_R1.sens, Sen_155_01_R2.sens, Sen_155_01_R3.sens, Sen_155_02_R1.sens, Sen_155_02_R2.sens, Sen_155_02_R3.sens, Sen_155_03_R1.sens, Sen_155_03_R2.sens, Sen_155_03_R3.sens, tome2sens_time1sens.txt Tahnks very much -- Marcelo Luiz de Laia, M.Sc. Dep. de Tecnologia, Lab. Bioquímica e de Biologia Molecular Universidade Estadual Paulista - UNESP Via de Acesso Prof. Paulo Donato Castelane, Km 05 14.884-900 - Jaboticabal, SP, Brazil PhoneFax: 16 3209-2675/2676/2677 R. 202/208/203 (trab.) HomePhone: 16 3203 2328 - www.lbm.fcav.unesp.br - [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to generate a report with graphics and tables?
Just to expand on an earlier suggestion: I have some data sets which change on a daily bases. So far I have imported these sets into R, done all my evaluations resulting in a couple of plots, charts and tables of numbers which I copypasted via clipboard into Powerpoint. The procedure is always the same and I wonder, whether there is no easier way for doing so. Is there some type of report generator available or some HowTo on this. Can anybody give me a hint on where to look for? Regards, Olaf Bürger ... One other possibility is to use the R2HTML package (and maybe the xtable package, too) to write the `report' in HTML. HTH, Andy R2HTML is not (yet) as far along as Sweave, but depending on how much sympathy you have for your clients, html can be a very nice solution. An important requirement for many reports is that computer-naive clients be able to edit and copy from the reports to an MS application, preferably without severe font and formatting problems and without needing to install/understand foo2bar type applications. See comments to this effect in the recent R2HTML article by the package author, Eric Lecoutre in the most recent R News (vol 3/3). As Andy noted, xtable is nice to use in conjunction with R2HTML (just write a little xtable method like the one following this message): In particular, a naive user viewing the html file with Internet Explorer (I know v. 5.5 or greater will work) will have an option, under the File menu to Edit with Microsoft Word for Windows. This assumes they have set MS Word as their HTML editor within IE. It also assumes some minimal formatting requirements for the HTML file (but you can worry about this, the client won't have to). I find this solution keeps everyone happy: 1. I can auto-generate text source for my documents; 2. clients without proprietary software can view the report; 3. clients with standard MS software but without a clue can easily edit and copy. Cheers, Jim HTML.xtable - function(x, file = .HTML.file, append = TRUE) { sink(file = file, append = append) print(x, type = html) sink() } James A. Rogers Manager, Nonclinical Statistics PGRD Groton Labs Eastern Point Road (MS 8260-1331) Groton, CT 06340 office: (860) 686-0786 fax: (860) 715-5445 LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] How to create own distance measure in cluster ?
The simplest way, if you have a function that returns the distance matrix, is to use as.dist(). E.g., myDist - function(...) { ## compute distance matrix dmat. ... return(as.dist(dmat)) } I believe most clustering algorithms in R will accept dist objects. If that doesn't do it, you can download the source for the `cluster' package from CRAN. Andy From: Ricardo Zorzetto Nicoliello Vencio Hi everyone, I want to create my own distance measure, other than 'euclidean' or 'manhatan', to use in cluster pckgs. To do this I think that I need to change dist(), in mva pckg, or daisy(), in cluster pckg. (or is there a cleaver way ?) But this functions are in fact things like: .Fortran( daisy, ... ) or .C(dist,...). I tried unsuccessfully to find source code of .Fortran or .C function to lear how R calculate dissimilarity matrix and then modify source to add my own distance metrix. Could someone help me ? Help me to find .Fortran(...) source or helpe me with better idea to implement my own distance metrix ? __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R]Running R remotely in Windows Environment? Thanks!
Thanks to Prof Ripley, Arne, Andy Bill for unambiguous suggestions! Linux box is on order. I'll take notes on our experience post a follow-up in a few weeks. May be useful to other folks stuck in the Windows world. -Jim At 06:24 AM 1/29/2004, Pikounis, Bill wrote: Jim, I would really like to reiterate Professor Ripley's and Arne Henningsen comments. The problem goes for any analytic software or system you might want to use, not just R. My impression is that at least for part of it, you want the individual users to use R as they would on their own desktops. (If that is not the case, much of the rest of this note is pure FYI.) Even in its most advanced 2003 Server edition, Windows is simply not designed to be a multi-user system. Sure, it can reliably host a web server that may need to run quick bursts of R batch-type jobs (analytics) and return results to a client (e.g. web browser), but that does not sound like what you are looking for (at least in part). And beyond the technical limitations, use of Windows Terminal Server (Remote Desktop) / Citrix, etc. will cost much money and implementation hassle and probably even legal headaches. We have had colleagues here at Merck (over my and Andy Liaw's disbelief) that have tried to shoehorn Windows this way, and even the speed of single, small jobs by 1 logged-on took longer on the server than on their much less powerful laptops. A Linux solution is very flexible, in our experiences (we have Windows XP as corporate desktop standard). As stated, with Samba, you can map directories that look like just another drive in Windows Explorer. Printing is just as transparent in either direction. VNC (Virtual Network Computing) is very, very nice to provide the individual user's Linux environment as just another window on their Windows desktop. With the free utility of autocutsel, clipboards can be synchronized for ease of cutting and pasting. And KDE, one of several window manager analogues to Windows, is very sophisticated and shares a lot in common with the Windows GUI from a user operations standpoint. While it may sound like a hassle to get up and running now if your shop is currently 99% Windows, the benefit will absolutely be clear later. Hope that helps, Bill Bill Pikounis, Ph.D. Biometrics Research Department Merck Research Laboratories PO Box 2000, MailDrop RY33-300 126 E. Lincoln Avenue Rahway, New Jersey 07065-0900 USA Phone: 732 594 3913 Fax: 732 594 1565 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Arne Henningsen Sent: Thursday, January 29, 2004 3:45 AM To: Jim Porzak Cc: [EMAIL PROTECTED] Subject: Re: [R]Running R remotely in Windows Environment? Hi, I also suggest to use a Linux Server. You can work on this machine via ssh (e.g. with PuTTY) and transfer the input and output files with scp or a samba server (which is easy to install and very convenient to use for windows users). Arne On Thursday 29 January 2004 08:53, Prof Brian Ripley wrote: On Wed, 28 Jan 2004, Jim Porzak wrote: We are considering setting up a fast, RAM loaded machine as an R-server to handle the big problems not suitable for individual desktops and, also, to process ad hoc analysis requests via our portal. We are 99% a Windows shop, so first choice is a windows server. We'll use (D)COM for the portal interface and understand that. What has me stumped is how to easily interface individual analyst's Windows desktops to the R-server. I haven't seen anything in the archives, but I can't imagine this hasn't been done. What am I missing? R is not designed to be client-server on Windows. People I know who do this use Windows Terminal Server or Citrix. I would question the value of this approach. Unless you propose to run 64-bit Windows, a `RAM loaded' machine isn't `loaded', and R under Windows handles large amounts of memory much less effectively than under Linux. 64-bit Windows is uncharted territory for R, whereas 64-bit Unix/Linux is well trodden. -- Arne Henningsen Department of Agricultural Economics University of Kiel Olshausenstr. 40 D-24098 Kiel (Germany) Tel: +49-431-880 4445 Fax: +49-431-880 1397 [EMAIL PROTECTED] http://www.uni-kiel.de/agrarpol/ahenningsen/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED]
Re: [R] Doubt about pattern
Gabor == Gabor Grothendieck [EMAIL PROTECTED] on Fri, 30 Jan 2004 08:56:59 -0500 (EST) writes: Gabor Your question has by now been answered but I thought Gabor I would add that if you want to do it via file globbing on Windows Gabor rather than regular expressions then this function would help: Gabor list.files.glob - function( spec ) { Gabor # returns list of files or NULL if none: spec uses globbing and can Gabor # use either forward or backward slashes. Gabor # e.g list.files.glob( c:/a*.* ) Gabor # e.g. list.files.glob( c:/myfolder/my*.dat) = Gabor # only works on Windows = Gabor if ( substring(spec,2,2) != : ) spec - paste( C, spec, sep= : ) Gabor z - system( paste(cmd /c attrib, spec), intern = T, invisible = T) Gabor if ( !pmatch(File not found - , z[1], nomatch = 0) ) substring(z,12) Gabor } Gabor For example: Gabor list.files.glob( *.sens ) Since we are diverting, here is my 12 year old (back then, using unix(..) and 'sed' inside Unix all for S-plus) solution to this problem -- yes, the function _name_ is a misnomer -- which is platform independent pat2grep - function(pattern) { ## Purpose: Change ls aka wildcard aka globbing _pattern_ to ## Regular Expression (as in grep, perl, emacs, ...) ## - ## Author: Martin Maechler ETH Zurich, ~ 1991 ## New version using [g]sub() : 2004 p - gsub('\\.','.', paste('^', pattern, '$', sep='')) sub('\\.\\*\\$$','', gsub('\\?', '.', gsub('\\*', '.*', p))) } and now you can use, e.g. list.files(pat2grep(*.R)) and get what you expect. Beginners in regular expressions now can also use pat2grep( my favorite wildcard expression ) and see the correct (I hope; the tests were not realy extended) regular expression for this. Martin Maechler [EMAIL PROTECTED] http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Robust nonlinear regression
Dear R experts This is a general question: Does R have functions for nonlinear robust regression, analogous to e.g. LTS? Searching google I have found 1, an abstract to generalize LTS for nonlinear regression models, see: http://smealsearch.psu.edu/1509.html 2, an AD-model builder, see: http://otter-rsch.com/admodel/cc1.html but no mention of R/S Thank you in advance Best regards Christian _._._._._._._._._._._._._._._._ C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a V.i.e.n.n.a A.u.s.t.r.i.a _._._._._._._._._._._._._._._._ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lines in 3d-cloud plot (lattice)
Pascal - Getting away from Trellis graphics, you might consider using persp() with regular graphics. Look at example # 2 under help(persp). - tom blackwell - u michigan medical school - ann arbor - On Fri, 30 Jan 2004, Deepayan Sarkar wrote: On Friday 30 January 2004 06:13, Pascal A. Niklaus wrote: Hi all, I'd like to plot a set of data (x,y,z) as 3D-cloud, and add several line plots to the same 3D graph: Two questions: 1) How do I connect points to get a line? cloud(z~x*y,data=d,zlim=c(0,1))# works cloud(z~x*predict(l),data=d,zlim=c(0,1),type=l) # type=l doesn't Warning message: type = l not implemented, consider using 'panel.3d.cloud = panel.3dscatter.old' in: panel.3d.cloud(x = x, y = y, z = z, rot.mat = rot.mat, za = za, Well, have you considered taking the hint and try cloud(z~x*predict(l),data=d,zlim=c(0,1),type=l, panel.3d.cloud = panel.3dscatter.old) ? help.search(panel.3d.cloud) also didn't report any hits. panel.3d.cloud is the name of an argument to the panel.cloud function. See ?panel.cloud for details. (Unfortunately, the docs are a bit outdated). Briefly, panel.3dscatter.old is a very simple function, that calculates the 2D projections of the given 3D points and then calls panel.xyplot with those. Any 'type' argument which works with panel.xyplot would also work here, including 'p' and 'l'. But no consideration is made of the fact that these are 3D data. For instance, type = 'h' would not give you what you would expect. panel.3dscatter (the newer version) is a bit more sophisticated. For type = 'p', it draws the points in order of increasing depth, so that closer points overwrite distant ones. Unfortunately, a collection of line segments is not well ordered, and I haven't decided yet what to do in that case (which is why the older version is still retained). 2) How do I superimpose a second data set onto the same graph? (something equivalent to the sequence plot(), followed by points() or lines() in the base plotting functions) I'm not sure what you mean. Trellis plots are not supposed to be used for two unrelated data sets, they are typically very much dependent on the structure of the data set. Maybe we could help if you give more details of what exactly you want to do, but before that you should read the ?panel.cloud help page carefully, since anything 'special' would almost invariably involve playing with things documented there. Hth, Deepayan __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] memory problem for R
Pleaase see the comments below. Here is the exact error I got -- Read 73 items Error: cannot allocate vector of size 1953 Kb Execution halted --- I am running R on Freebsd 4.3 with double CPU and 2 GB memory Is that sufficient? Clearly not. What is the structure of your `attributes'? As Andy Liaw said, the design matrix may be bigger than that if there are factors involved. (And you need several copies of the design matrix.) I would try a 10% sample of the rows to get a measure of what will fit into your memory. I have never seen a regression problem for which 600k cases were needed, and would be interested to know the context. (It is hard to imagine that the cases are from a single homogeneous population and that a linear model fits so well that the random error is not dominated by systematic error.) I tried 10% sample and it turned out the matrix became singular after I did that. Ther reason is some of the attributes only have zero values most of the time. The data i am using is web log data and after some transformation, they are all numeric. Can we specify some parameters in read.table so that the program will treat all the vars as numeric (with this context, hopefully that will reduce the memory consumption) ? thanks a lot, Yun-Fang Yun-Fang - Original Message - From: Yun-Fang Juan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 29, 2004 7:03 PM Subject: [R] memory problem for R Hi, I try to use lm to fit a linear model with 600k rows and 70 attributes. But I can't even load the data into the R environment. The error message says the vector memory is used up. Is there anyone having experience with large datasets in R? (I bet) Please advise. thanks, Yun-Fang [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Object validation and formal classes
It was never the intention that validity checking happen automatically on _every_ assignment of an object from the class--since those assignments take place frequently during evaluation of functions, the overhead would be unacceptable. And as Robert points out, one needs to postpone validity checking until a set of mutually dependent changes is finished. The Programming with Data description says that validity checking takes place on permanent assignment. But this was not written with R in mind, and the idea of permanent assignment is ambiguous in R. It could mean all assignments into the Global environment, or it could mean on serializing (saving the workspace, e.g.). If we agree on a useful interpretation, automatic validity checking might be reasonable in that sense in the future. Torsten Steuernagel wrote: On 29 Jan 2004 at 20:04, Robert Gentleman wrote: There are some efficiency issues that prevent constant checking (at least at the present time). There are also some other issues that need to be adequately addressed too. For example, suppose I had an object with two slots a - a character string b - the number of characters Yes, efficiency was also a concern I had with my original understanding of what the validation function is supposed to do. Reading the docs I got the impression that 1) during an assignment the validation function will be called with a copy of the object that already has the new value assigned 2) if it returns TRUE that copy is returned as the result of the assigment 3) otherwise, an error is raised. That would be pretty inefficient for large objects. What does actually happen when I call slot- ? I suppose that this always operates on the object in sys.parent() of slot- and never creates a copy of the specified object. and I set my validity checker to make sure that the length of the string is the number in b. Now that basically means that I can never change the string (except to other strings of the same length) if validity checking happened after every change. I somehow need changing both a and b to be instantaneous (which they currently are not). We have not really gone far enough down that path yet to know what the right thing is, but we are working on it. So for now validity checking occurs at a few specific points and if/when you ask for it. What about access control ? The docs state it isn't implemented yet. If there was something similar to C++ one could set critical slots to private and only allow access and assignment via (replacement) methods. At first sight, this seems feasible and shouldn't cost much performance. Another approach might be an (optional) validation function for each individual slot or for groups of slots that doesn't need to validate the whole object but only changes that may occur in conjunction with a single slot or group of slots. Of course, efficiency issues are more likely to occur in this scenario. The @- operator seems to call slot- by default, maybe I can overload slot- for my class and implement this kind of validation on my own ? I guess some tricks will be necessary here to prevent that slot- is called recursively if the validation function for one slot attempts to make an assignemt to another slot. So if I don't find a feasible solution in the meantime, the best way would be writing wrappers for those slots that need validation and tell the users to use those instead of changing the object directly ? Thanks again, Torsten [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] coupled statistical models
Can someone point me to the appropriate functions for fitting multiple statistical models that are coupled to each other. The data are measurements of salinity s and temperature t at stations id and pressures at p as well as surface elevations h at stations id. The problem is, for any new station, to estimate s at all p, given t at all p and given h. If h is ignored, the for each p, there would be an independent model like rlm(s~t+I(t^2)). No problem. (I have been using a loop, but I think they can be computed simultaneously using lm(s~as.factor(p)/(t+I(t^2))-1). However, rlm(s~as.factor(p)/(t+I(t^2))-1) does not converge!) The h data couple the models. Surface elevation reflects the water's specific volume at each depth (pressure). The volume vp (p to indicate pressure) depends on s,t, and p, and h is essentially a sum over the volume at each p. When the individual models are computed, coefficients should be chosen so that this is satisfied. How to do this in R? Without the coupling the least-squares formulation would seek coefficients a_p and b_p to minimize: sum_p(sum_p((s_id,p - a_p t_id,p + b_k)^2)). Minimization at each p is independent. With coupling, there would be an additional term: sum_id((sum_p(vp)-h_id)^2) where vp is a function of a_p t_id,p + b_k and of t_id. The functions for vp are nonlinear, but if necessary with some work it should be possible to get a linear function that is good enough. Also, not all stations have values at all pressures. Thanks, Carlisle -- William Carlisle Thacker Atlantic Oceanographic and Meteorological Laboratory 4301 Rickenbacker Causeway, Miami, Florida 33149 USA Office: (305) 361-4323 Fax: (305) 361-4392 Too many have dispensed with generosity in order to practice charity. Albert Camus __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Measures of central tendency - mode
Greetings, This seems too rudimentary to ask but for the life of me I cannot locate a readily easy method to compute the univariate mode. I know mode is not correct and table provides a reasonable count but I figured there would be an easy way to extract the value from the table after I do something like: max(table(mydadat$myvar)) unfortunately it only returns the max count and not the value that is observed most. Would some kind soul help me out with this seemingly trivial problem? Thanks in advance. Cheers, Patrick __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [Re: Error]
Due to the very heavy volume of e-mail requests for information, we can no longer respond to individual requests for information. Instructions for applying to the Graduate Group in Computer Science can be received by visiting the Department of Computer Science website at: http://www.cs.ucdavis.edu Please pay particular attention to the Frequently Asked Question regarding admission. The deadline for applying for Fall 2004 has passed. We will begin accepting applications for Fall 2005 in November 2004. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Detect the presence of an object
Is there a function like is.there such that is.there ( a ) returns TRUE is object 'a' is in the current environment and FALSE otherwise? exists() __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Detect the presence of an object
try the function exists() On Fri, 30 Jan 2004, Francisco J Molina wrote: Is there a function like is.there such that is.there ( a ) returns TRUE is object 'a' is in the current environment and FALSE otherwise? Thank you. Francisco J. Molina __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Paulo Justiniano Ribeiro Jr Departamento de Estatística Universidade Federal do Paraná Caixa Postal 19.081 CEP 81.531-990 Curitiba, PR - Brasil Tel: (+55) 41 361 3471 Fax: (+55) 41 361 3141 e-mail: [EMAIL PROTECTED] http://www.est.ufpr.br/~paulojus __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Detect the presence of an object
Have you considered exists or missing? hope this helps. spencer graves Francisco J Molina wrote: Is there a function like is.there such that is.there ( a ) returns TRUE is object 'a' is in the current environment and FALSE otherwise? Thank you. Francisco J. Molina __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] exporting directly to a file
Have you considered sink? hope this helps. spencer graves Christian Landry wrote: Hi, I would like to know what is the function in R that allows exporting results of an operation directly to a file as the analysis is running. I am performing an analysis on a large matrix and the resulting object takes too much memory to be exported as a file. Thanks, Christian __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Trouble plotting with factor
On Fri, 2004-01-30 at 15:04, Paul Johnson wrote: With R 1.8.1 running in Fedora Core 1 Linux, I am having some trouble recoding and ploting some factor variables. First, can I give you some example data? Here is a column of names for age groups: agegroups - c( 15-19, 20-24, 25-29,30-34, 35-39, 40-44,45-49,50-54,55-59,60-64, 65-69, 70-74, 75-79, 80-84, OVER) Here is an index for driver's license ownership in each age group: fracld 0.4914204 0.9752746 1.0864465 1.0555984 1.0631969 1.0738725 1.0971969 1.0657212 1.0217373 0.9761226 0.9043233 0.9045744 0.8573243 0.7889182 0.5217992 I want to take several similar columns of numbers and put them into a single line plot, one line for each column. I can get a graph with the inside part that looks roughly like I want if I just do: plot(fracld,type=l) The horizontal axis, of course, is just the sequence from 1:15, not the age labels. That's no good. But, If I try plot(as.factor(agegroup), fracld, type=l) the plot does not have the line I want, but rather only flat steps showing the values. It does have a nice looking horizontal axis, though, showing the age groups. So I think to myself I'll outsmart them by adding the lines after creating the plot, but if I do this plot(agegroup,fracld,type=n) The step markers still appear. So if I want the tick marks and value lables on the horzontal axis, there is apparently no way to plot lines? What to do? Paul, I did not see any responses come through yet on this, so I don't know if you got anything offlist. I do not know how your data is structured, but one approach, if your data is in a matrix, with the numbers being the columns and the agegroups being the rownames, is the following: # Create the agegroups agegroups - c(15-19, 20-24, 25-29,30-34, 35-39, 40-44,45-49,50-54,55-59,60-64, 65-69, 70-74, 75-79, 80-84, OVER) # Create the first column fracld - c(0.4914204, 0.9752746, 1.0864465, 1.0555984, 1.0631969, 1.0738725, 1.0971969, 1.0657212, 1.0217373, 0.9761226, 0.9043233, 0.9045744, 0.8573243, 0.7889182, 0.5217992) # Now create two additional columns for the example # 'fracld2' won't make sense real world since many vals # will be 1.0 fracld1 - fracld - 0.25 fracld2 - fracld + 0.25 # Create the matrix df - cbind(fracld, fracld1, fracld2) # Set the rownames rownames(df) - agegroups df fracld fracld1 fracld2 15-19 0.4914204 0.2414204 0.7414204 20-24 0.9752746 0.7252746 1.2252746 25-29 1.0864465 0.8364465 1.3364465 30-34 1.0555984 0.8055984 1.3055984 35-39 1.0631969 0.8131969 1.3131969 40-44 1.0738725 0.8238725 1.3238725 45-49 1.0971969 0.8471969 1.3471969 50-54 1.0657212 0.8157212 1.3157212 55-59 1.0217373 0.7717373 1.2717373 60-64 0.9761226 0.7261226 1.2261226 65-69 0.9043233 0.6543233 1.1543233 70-74 0.9045744 0.6545744 1.1545744 75-79 0.8573243 0.6073243 1.1073243 80-84 0.7889182 0.5389182 1.0389182 OVER 0.5217992 0.2717992 0.7717992 # Now use matplot() to plot each column # Do not plot the axes matplot(df, type = l, axes = FALSE, xlab = Age Group, ylab = Proportion DL Ownership) # Create the X axis, specifying 15 tick marks # and using rownames(df) as the labels axis(1, at = 1:nrow(df), labels = rownames(df)) # Now draw the Y axis with defaults axis(2) # Put a box around the whole thing box() BTW, this is also using FC1 and R 1.8.1 Patched. HTH, Marc Schwartz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html