[R] Recall() and sapply()
Hi. I'm having difficulty following the advice given in help(Recall). Consider the two following toy functions: f1 - function(n){ if(length(n)1){return(sapply(n,f1))} matrix(n,n,n) } f2 - function(n){ if(length(n)1){return(sapply(n,Recall))} matrix(n,n,n) } f1() works as desired (that is, f(1:3), say, gives me a three element list whose i-th element is an i-by-i matrix whose elements are all i). But f2() doesn't. How do I modify either function to use Recall()? What exactly is Recall() calling here? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] From FAQ 7.21 to a command like apply(sapply(list(f1,f2,f3),is.na),2,sum)
At 16:13 29.03.2005 -0800, Thomas Lumley wrote: On Wed, 30 Mar 2005, Heinz Tuechler wrote: Dear all, Last December there was a thread regarding the famous FAQ 7.21 How can I turn a string into a variable? and asking what people want to do with these strings. My, certainly trivial application would be as follows: Assume I have a data.frame containing besides others also the columns f1, f2, ..., fn and I want to create a command like: apply(sapply(list(f1,f2,f3),is.na),2,sum) or summary(cbind(f1,f2,f3)) Can I start from paste('f',1:3,sep='') to arrive at the abovementioned command? No parse,as.name or other complications needed. It's all just indexing. Suppose your data frame is called dd fs-paste('f',1:3,sep='') apply(sapply(dd[,fs],is.na),2,sum) summary(dd[,fs]) -thomas Thank you, Thomas, for your answer. I was curious if there was a simple way to do this without referring to the data.frame, so that the resulting command would correspond in its effect exactly to the abovementioned examples. It's not urgent, but I will try further. Many thanks Heinz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] From FAQ 7.21 to a command likeapply(sapply(list(f1,f2,f3),is.na),2,sum)
At 09:32 30.03.2005 +0200, Heinz Tuechler wrote: At 16:13 29.03.2005 -0800, Thomas Lumley wrote: On Wed, 30 Mar 2005, Heinz Tuechler wrote: Dear all, Last December there was a thread regarding the famous FAQ 7.21 How can I turn a string into a variable? and asking what people want to do with these strings. My, certainly trivial application would be as follows: Assume I have a data.frame containing besides others also the columns f1, f2, ..., fn and I want to create a command like: apply(sapply(list(f1,f2,f3),is.na),2,sum) or summary(cbind(f1,f2,f3)) Can I start from paste('f',1:3,sep='') to arrive at the abovementioned command? No parse,as.name or other complications needed. It's all just indexing. Suppose your data frame is called dd fs-paste('f',1:3,sep='') apply(sapply(dd[,fs],is.na),2,sum) summary(dd[,fs]) -thomas Thank you, Thomas, for your answer. I was curious if there was a simple way to do this without referring to the data.frame, so that the resulting command would correspond in its effect exactly to the abovementioned examples. It's not urgent, but I will try further. Many thanks Heinz Continuation: Maybe not an elegant solution, but it seems to work: apply(sapply(eval(parse(text=paste('list(',paste('f',1:3,sep='', collapse=','),')'))) ,is.na),2,sum) What I missed in my earlier attempts was collapse=','. Heinz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] locfit
Hallo all, can somebody tell me if is possible use the locfit function like a semiparametric model. I need to use two explicative variables and one of them is a dummy variable. Thanks Michele - Giochi, Rubrica Scaricalo ora! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Habituation model
Dear all, I am looking at habituation of dogs trotting on a treadmill. I record the ground reaction force and I analyze it with several discrete variables (maximum, minimum,...) For each variable, I get between 40 and 50 data per sample. I record data at time 1 min, 2 min, and 4 min a day, and I have 4 days of measurement (one day a week). That means I have 12 samples : Day1_Min1, Day1_Min2, Day1_Min4, Day2_Min1,... Furthermore, I have 28 dogs to analyze. My questions is : when can I consider the data stabilized? The problem is I am studying habituation with several sessions. It seems logical that values from each first minute could be very dissimilar to others. It is not a fully linear training system. I have already done some ANOVAs with Day and Min factors. I found a significant effect. It is quite logical because the dog is learning. The question is then when does it stop learning? or more precisely when is it trained enough to be analyzed? I could do comparisons among all samples with Student test, but it is surely a simple approach. I can presuppose the maximal allowed variability for each variable : in the region of 5%. I am really new to both R and stats so if these questions are very simple and I am just missing something, suggestions about good texts or examples on R would be great. I am generating data with Scilab, I have a single matrix corresponding to each dog. But I can change it if needed. Any help would be greatly appreciated Thanks Laurent Fanchon DVM, MS Ecole Nationale Veterinaire d'Alfort France __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] about memory
How much memory is free when R fails (e.g., what does top show while trying to run your clustering)? If there's still a sizeable amount of free memory you may have to look into the system limits, maximum data segment size in particular. Many Linux distros have it set to unlimited but default Debian may not. If this turns out to be the problem, please do not, _do not_ raise it to unlimited, but only to enough for R to work. hth, jon b On Wed, 30 Mar 2005 18:36:37 +0800 ronggui [EMAIL PROTECTED] wrote: here is my system memory: [EMAIL PROTECTED] free total used free sharedbuffers cached Mem:256728 79440 177288 0 2296 36136 -/+ buffers/cache: 41008 215720 Swap: 481908 60524 421384 and i want to cluster my data using hclust.my data has 3 variables and 1 cases.but it fails and saying have not enough memory for the vector size. I read the help doc and use $R --max-vsize=800M to start the R 2.1.0beta under debian linux.but it still can not get the solution.so is my pc'memory not enough to carry this analysis or my mistake on setting the memory? thank you. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] error messages on R CMD check
Dear all, I am trying to wrap up a package. On entering R CMD check, I get the following error messages: [...] * checking S3 generic/method consistency ... WARNING Error in .try_quietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : package/namespace load failed for 'resper' Execution halted See section 'Generic functions and methods' of the 'Writing R Extensions' manual. * checking replacement functions ... WARNING Error in .try_quietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : package/namespace load failed for 'resper' Execution halted In R, the argument of a replacement function which corresponds to the right hand side must be named 'value'. * checking foreign function calls ... WARNING Error in .try_quietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : package/namespace load failed for 'resper' Execution halted See section 'System and foreign language interfaces' of the 'Writing R Extensions' manual. * checking Rd files ... OK * checking for missing documentation entries ... ERROR Error in .try_quietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : I am not getting these messages, nor their relation to section 'Generic functions and methods' of the 'Writing R Extensions' manual, as I did not write any generic methods in my package. There has been some discussion of the error message around Christmas 2003: http://maths.newcastle.edu.au/~rking/R/devel/03b/1438.html, but I can't see how the circumstances described there apply to my situation (export a class name). Could somebody give me a clue on how to give my search a direction? Greetings Johannes __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Habituation model
since you measure the same dog several times its measurements are correlated and you should take this into account in your analysis (i.e., aov() is not appropriate in this case). Probably you could find functions lme() and gls() in the nlme package very useful for your problem and for which a very good reference is: @Book{pinheiro.bates:00, author= {J. Pinheiro and D. Bates}, title = {Mixed-Effects Models in S and S-PLUS}, year = {2000}, address = {New York}, publisher = {Springer-Verlag} } I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Laurent Fanchon [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Wednesday, March 30, 2005 2:06 PM Subject: [R] Habituation model Dear all, I am looking at habituation of dogs trotting on a treadmill. I record the ground reaction force and I analyze it with several discrete variables (maximum, minimum,...) For each variable, I get between 40 and 50 data per sample. I record data at time 1 min, 2 min, and 4 min a day, and I have 4 days of measurement (one day a week). That means I have 12 samples : Day1_Min1, Day1_Min2, Day1_Min4, Day2_Min1,... Furthermore, I have 28 dogs to analyze. My questions is : when can I consider the data stabilized? The problem is I am studying habituation with several sessions. It seems logical that values from each first minute could be very dissimilar to others. It is not a fully linear training system. I have already done some ANOVAs with Day and Min factors. I found a significant effect. It is quite logical because the dog is learning. The question is then when does it stop learning? or more precisely when is it trained enough to be analyzed? I could do comparisons among all samples with Student test, but it is surely a simple approach. I can presuppose the maximal allowed variability for each variable : in the region of 5%. I am really new to both R and stats so if these questions are very simple and I am just missing something, suggestions about good texts or examples on R would be great. I am generating data with Scilab, I have a single matrix corresponding to each dog. But I can change it if needed. Any help would be greatly appreciated Thanks Laurent Fanchon DVM, MS Ecole Nationale Veterinaire d'Alfort France __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] fastbw question
Hello I am running R 2.0.1 on Windows, I am attempting to use Frank Harrell's 'fastbw' function (from the Design library), but I get an error that the fit was not created with a Design library fitting function; yet when I go to the help for fastbw (and also look in Frank's book Regression Modeling Strategies) it appears that fastbw should work with a model created with lm. Relevant code model.borrow.logols- lm(logborrow~age + sex + racgp + yrseduc + needlchg + gallery + totni + inject + poly(year.of.int,3) + druginj + inj.years + HTLV3) fastbw(model.borrow.logols) Thanks in advance Peter Peter L. Flom, PhD Assistant Director, Statistics and Data Analysis Core Center for Drug Use and HIV Research National Development and Research Institutes 71 W. 23rd St www.peterflom.com New York, NY 10010 (212) 845-4485 (voice) (917) 438-0894 (fax) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] discriminant function analysis in R
In message [EMAIL PROTECTED], r-help- [EMAIL PROTECTED] writes Dear R Users, I'm very very interested in learning how to use R to carry out a classification of data using discriminant function analysis. I've found the MASS package and the lda function, but the examples in the help system are a bit over my head. I'm not exactly sure how to interpret the output, for example, of if the inputs I've chosen are best suited to my needs. [...] I would recommend writing your own simple version of lda in R. For example, stick to two class problems, and don't worry too much about efficiency or dealing with bad input. Then think about how you might make your routines of more general use (but don't bother to implement this). This is a good way of learning R, and having got this far on your own, you will find the documentation and examples for lda make sense. Well, it worked for me. Here's some useful functions: ?%*% ?t ?determinant ?solve ?mean ?cov ?cat ?scan -- Graham Jones, author of SharpEye Music Reader http://www.visiv.co.uk 21e Balnakeil, Durness, Lairg, Sutherland, IV27 4PT, Scotland, UK __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Finding the height of a line of text for axis
On Wed, 2005-03-30 at 11:06 +0100, Steven J. Murdoch wrote: I would like to draw only the ticks of an axis, but not the axis itself. I don't think this can be done using axis(), so I am trying to write a cut-down version in R, which only draws ticks. The point at which I am stuck is that the length of a tick is set by par(tcl) as a fraction of the height of a line of text. So I would like to draw a line whose length is also this length. However I cannot find out how to convert the into units I can pass into lines(). I thought par(cxy), but it is too large, as is shown in the code below. Here the red tick marks are longer than the black ones created by axis. I have found the relevant function in plot.c: GConvertYUnits(Rf_gpptr(dd)-tcl, LINES, NFC, dd); but can't find the corresponding R function. Can anyone suggest how to find this out, or solve the problem in a different way? # Inward pointing ticks par(tcl=1) drawticks - function(at) { # Start of the ticks base-par(usr)[1] # Length of the ticks l-par(cxy)[2]*par(tcl) for (i in at) { lines(c(base,base+l),rep(i,2),col=red) } } # Test plot plot(c(1,2,3), axes=FALSE) # Draw ticks in red drawticks(axTicks(2)) # Overprint with normal axis axis(2, axTicks(2)) Steven, Are you trying to do something like this: plot(1:5, axes = FALSE) axis(1, col.axis = white, tcl = 1) axis(2, col.axis = white, tcl = 1) or perhaps something like this: plot(1:5, axes = FALSE) axis(1, col.axis = white, col = red, tcl = 1) axis(1, col.axis = white, col = black, tcl = 0) axis(2, col.axis = white, col = red, tcl = 1) axis(2, col.axis = white, col = black, tcl = 0) or even something like this: plot(1:5, axes = FALSE) axis(1, col.axis = white, col = red, tcl = 1) axis(1, col.axis = white, col = white, tcl = 0) axis(2, col.axis = white, col = red, tcl = 1) axis(2, col.axis = white, col = white, tcl = 0) If you do not want the axis labels, use: plot(1:5, axes = FALSE, ann = FALSE) HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Recall() and sapply()
I doubt it's possible to use Recall inside a sapply like this. sapply (and lapply) make a copy of the function (FUN - match.fun(FUN)) before passing it inside an internal function (rval - .Internal(lapply(X, FUN)). So, while I'm not precisely sure how Recall is coded up, I bet that once it is copied inside of sapply (and lapply), it loses the context from which it was called. I can think of a couple ways around this. First, you could construct a for loop instead of a sapply and use Recall. Second, you could replace Recall by just asking R what the name of the calling function is and pass that in to sapply. Something like this should work: sapply(n, match.fun(sys.call()[[1]])) HTH, Robert -Original Message- From: Robin Hankin [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 30, 2005 3:28 AM To: R-help@stat.math.ethz.ch Subject: [R] Recall() and sapply() Hi. I'm having difficulty following the advice given in help(Recall). Consider the two following toy functions: f1 - function(n){ if(length(n)1){return(sapply(n,f1))} matrix(n,n,n) } f2 - function(n){ if(length(n)1){return(sapply(n,Recall))} matrix(n,n,n) } f1() works as desired (that is, f(1:3), say, gives me a three element list whose i-th element is an i-by-i matrix whose elements are all i). But f2() doesn't. How do I modify either function to use Recall()? What exactly is Recall() calling here? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Recall() and sapply()
I believe that the function that Recall executes is the function in which Recall, itself, is evaluated -- not the function in which Recall appears. In normal cases these are the same but if you pass Recall to another function then they are not the same. Here Recall is being passed to sapply (which in turn is likely passing it to other functions). Because of lazy evaluation Recall does not get evaluated until it is found within sapply (or a function called by it or called by one called by it, etc.) and at that point its recalling the wrong function. AFAICS one cannot pass Recall to another function. You could rewrite the expression that uses sapply to use iteration instead or you could do it as shown below. In this example, the use of f2 within supply refers to the inner f2 which does not change even if the name of the outer f2 does. f2 - function(n) { f2 - function(n) if(length(n)1) sapply(n,f2) else matrix(n,n,n) f2(n) } f3 - f2 f2(1:3) f3(1:3) # gives same result On Wed, 30 Mar 2005 09:28:08 +0100, Robin Hankin [EMAIL PROTECTED] wrote: Hi. I'm having difficulty following the advice given in help(Recall). Consider the two following toy functions: f1 - function(n){ if(length(n)1){return(sapply(n,f1))} matrix(n,n,n) } f2 - function(n){ if(length(n)1){return(sapply(n,Recall))} matrix(n,n,n) } f1() works as desired (that is, f(1:3), say, gives me a three element list whose i-th element is an i-by-i matrix whose elements are all i). But f2() doesn't. How do I modify either function to use Recall()? What exactly is Recall() calling here? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] about memory
[EMAIL PROTECTED] ulimit -a core file size(blocks, -c) 0 data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files(-n) 1024 pipe size (512 bytes, -p) 8 stack size(kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes(-u) unlimited virtual memory(kbytes, -v) unlimited so it seems the data segment size is not limited. and it is still free mem(1000k or so),and swap(10k or so),and the error is(i translate it from chinese into english,maybe not exactly ,but i think the meanings are right): error:can not allocate the vector size of 390585kb. (: 390585 Kb) On Wed, 30 Mar 2005 07:34:13 -0500 jon butchar [EMAIL PROTECTED] wrote: How much memory is free when R fails (e.g., what does top show while trying to run your clustering)? If there's still a sizeable amount of free memory you may have to look into the system limits, maximum data segment size in particular. Many Linux distros have it set to unlimited but default Debian may not. If this turns out to be the problem, please do not, _do not_ raise it to unlimited, but only to enough for R to work. hth, jon b On Wed, 30 Mar 2005 18:36:37 +0800 ronggui [EMAIL PROTECTED] wrote: here is my system memory: [EMAIL PROTECTED] free total used free sharedbuffers cached Mem:256728 79440 177288 0 2296 36136 -/+ buffers/cache: 41008 215720 Swap: 481908 60524 421384 and i want to cluster my data using hclust.my data has 3 variables and 1 cases.but it fails and saying have not enough memory for the vector size. I read the help doc and use $R --max-vsize=800M to start the R 2.1.0beta under debian linux.but it still can not get the solution.so is my pc'memory not enough to carry this analysis or my mistake on setting the memory? thank you. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] A question about multiple comparison of analysis of covariance using SPSS
Hi, all, I have a question about multiple comparison of analysis of covariance using SPSS 10. The way I used was in the menu 'Analyze-General Linear Model-Mutivariate'. When I only chosed 'Dependent Variables' and 'Fixed Factor(s)', the button of 'Post Hoc' can be pressed and I can chose some ways to do multiple comparison. However, after I chosed 'Covariate(s)', the button of 'Post Hoc' became grey and could not be pressed. How can I do multiple comparison? By the way, I am not in the mail-list. Pls mail back to me. Thanks! ¨q ¨q¨q¨q ¨r¨r ¨q ¨q¨q¨q ¨r¨r ¨s ¨s¨s¨s ¨t ¨s ¨s¨s¨s ¨t ¨r¦á ¦á. ¦á ¦á¨q . ¨t ¦á ¨s .¨t ¦á ¨s ¡ï. ¡ï . ¡ï. ¡ï . ..¡î . . ¡î . - ×¢²áÊÀ½çÒ»Á÷Æ·ÖʵÄÑÅ»¢Ãâ·ÑµçÓÊ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] error messages on R CMD check
Dear Johannes I have noticed the same complaint, and you are right that it can be unconnected with faulty S3 methods, etc., in your package. For example, in my relimp package (current version 0.9-1, new on CRAN today) the DESCRIPTION file has Suggests: tcltk and that works fine (ie it passes R CMD check). But if I change that to Depends: tcltk I get the same kind of errors that you got: david% R CMD check relimp [...] * checking S3 generic/method consistency ... WARNING Error in .try_quietly({ : Error: package 'tcltk' could not be loaded Execution halted See section 'Generic functions and methods' of the 'Writing R Extensions' manual. * checking replacement functions ... WARNING Error in .try_quietly({ : Error: package 'tcltk' could not be loaded Execution halted In R, the argument of a replacement function which corresponds to the right hand side must be named 'value'. * checking foreign function calls ... WARNING Error in .try_quietly({ : Error: package 'tcltk' could not be loaded Execution halted See section 'System and foreign language interfaces' of the 'Writing R Extensions' manual. * checking Rd files ... OK * checking for missing documentation entries ... ERROR Error in .try_quietly({ : Error: package 'tcltk' could not be loaded In this case it is because the calling environment for R CMD check did not have the DISPLAY variable set, so tcltk could not be loaded. If instead I do david% setenv DISPLAY :0 david% R CMD check relimp then all checks are passed. This is with david% R --version R 2.0.1 (2004-11-15). This is not really an explanation of what you got, just a confirmation that something here probably needs fixing (even if it's only the error message). Perhaps one of us should file a bug report (having checked first that a fix is not already made in the latest development version)? David On 30 Mar, 2005, at 13:34, Johannes Hüsing wrote: Dear all, I am trying to wrap up a package. On entering R CMD check, I get the following error messages: [...] * checking S3 generic/method consistency ... WARNING Error in .try_quietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : package/namespace load failed for 'resper' Execution halted See section 'Generic functions and methods' of the 'Writing R Extensions' manual. * checking replacement functions ... WARNING Error in .try_quietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : package/namespace load failed for 'resper' Execution halted In R, the argument of a replacement function which corresponds to the right hand side must be named 'value'. * checking foreign function calls ... WARNING Error in .try_quietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : package/namespace load failed for 'resper' Execution halted See section 'System and foreign language interfaces' of the 'Writing R Extensions' manual. * checking Rd files ... OK * checking for missing documentation entries ... ERROR Error in .try_quietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : I am not getting these messages, nor their relation to section 'Generic functions and methods' of the 'Writing R Extensions' manual, as I did not write any generic methods in my package. There has been some discussion of the error message around Christmas 2003: http://maths.newcastle.edu.au/~rking/R/devel/03b/1438.html, but I can't see how the circumstances described there apply to my situation (export a class name). Could somebody give me a clue on how to give my search a direction? Greetings Johannes __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re:Plotting to A4 and replacing x-axis with actual years.
Hie, I have written before and probably missed the reply. 1.) I have my figures in a 3X3 array and want to fit them onto a A4 size page. I have written commands to try a represent them in eps format but still their cutting out information. 2.) I have an odd number of years and wanted to represent them say 1980 1985 1990 1995 2000 instead of 1 5 10 etc. However, the years are not overwritting in the year I want since the first year in my x-axis is 1979 which is year 1 and year 5 being 1984. Could you please help especially on the first problem. Thanking you in advance, Marshall Mdoka __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re:Plotting to A4 and replacing x-axis with actual years.
Hie, I have written before and probably missed the reply. 1.) I have my figures in a 3X3 array and want to fit them onto a A4 size page. I have written commands to try a represent them in eps format but still their cutting out information. 2.) I have an odd number of years and wanted to represent them say 1980 1985 1990 1995 2000 instead of 1 5 10 etc. However, the years are not overwritting in the year I want since the first year in my x-axis is 1979 which is year 1 and year 5 being 1984. Could you please help especially on the first problem. Thanking you in advance, Marshall Mdoka __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] about memory
hclust creates a distance matrix. In your case it is 10,000 x 10,000. For various reasons several copies are created, so you probably need at least 100M x 8 bytes per entry x 3 copies = 2.4 GB just for the distance matrix. If you don't have that much RAM the computation will probably take longer than you're willing to wait. Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ronggui Sent: Wednesday, March 30, 2005 5:37 AM To: r-help@stat.math.ethz.ch Subject: [R] about memory here is my system memory: [EMAIL PROTECTED] free total used free sharedbuffers cached Mem:256728 79440 177288 0 2296 36136 -/+ buffers/cache: 41008 215720 Swap: 481908 60524 421384 and i want to cluster my data using hclust.my data has 3 variables and 1 cases.but it fails and saying have not enough memory for the vector size. I read the help doc and use $R --max-vsize=800M to start the R 2.1.0beta under debian linux.but it still can not get the solution.so is my pc'memory not enough to carry this analysis or my mistake on setting the memory? thank you. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] fastbw question
Peter Flom wrote: Hello I am running R 2.0.1 on Windows, I am attempting to use Frank Harrell's 'fastbw' function (from the Design library), but I get an error that the fit was not created with a Design library fitting function; yet when I go to the help for fastbw (and also look in Frank's book Regression Modeling Strategies) it appears that fastbw should work with a model created with lm. Relevant code model.borrow.logols- lm(logborrow~age + sex + racgp + yrseduc + needlchg + gallery + totni + inject + poly(year.of.int,3) + druginj + inj.years + HTLV3) fastbw(model.borrow.logols) The error message was exactly correct. lm is not a Design fitting function. Try ols. -Frank Thanks in advance Peter Peter L. Flom, PhD Assistant Director, Statistics and Data Analysis Core Center for Drug Use and HIV Research National Development and Research Institutes 71 W. 23rd St www.peterflom.com New York, NY 10010 (212) 845-4485 (voice) (917) 438-0894 (fax) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R --max-vsize=4000M --max-nsize=4000M
hello! what's wrong??? i use 32 bit machine. every time i 'm connecting the server to do my work with R on it , after having done R --max-vsize=4000M --max-nsize=4000M i become wrong limits specification for Ncells: . gc() used(Mb) gc trigger (Mb) limit (Mb) Ncells 698799 18.7 1644099 44 112000 Vcells 65744346501.6 189257063 1444 4000 is there anything wrong? thanks a lot __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Recall() and sapply()
On Wed, 30 Mar 2005, Robin Hankin wrote: Hi. I'm having difficulty following the advice given in help(Recall). Consider the two following toy functions: f1 - function(n){ if(length(n)1){return(sapply(n,f1))} matrix(n,n,n) } f2 - function(n){ if(length(n)1){return(sapply(n,Recall))} matrix(n,n,n) } f1() works as desired (that is, f(1:3), say, gives me a three element list whose i-th element is an i-by-i matrix whose elements are all i). But f2() doesn't. How do I modify either function to use Recall()? What exactly is Recall() calling here? You can't use Recall here. I thought this was explicitly documented, but it turns out that it isn't, an omission I will fix. You don't need Recall, because R can easily have recursive functions without it (unlike S) - as you show in f1, the function can call itself - the problem with f1 is that it stops working if you change the name, but ?local shows how to get around this. This is probably the best way to implement recursion. - You can even implement Y, the appplicative-order fixed point operator to create anonymous recursive functions a la lambda calculus. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Solved - gnuclient problems witrh R/ESS in linux
Finally, I found a way to make fix() and edit() work with gnuclient in ESS-5.2.6/R-2.0.1/Xemacs-21.4.15-r3 on gentoo-linux. When invoking R/ESS the following is induced by ESS options(STERM='iESS', editor='gnuclient -q') It appears as if the problem is with 'gnuclient -q' (whatever does -q signify?? From the man page it appears to disconnect the association between the opened buffer and gnuclient - which was teh very problem) and when i changed a row in ess-5.2.6/lisp/gnu-cust.el things worked in the expected way. Change row if (featurep 'xemacs) gnuclient -q emacsclient))) ;; unix to if (featurep 'xemacs) gnuclient emacsclient))) ;; unix and all things work OK. The only thing needed in init.el for gnuclient to work in this setup is (gnuserv-start) and possibly (setq gnuserv-frame (selected-frame)) if you whant the gnuclient frame to open within Xemacs and no fuss with PATH Many thanks to Richard M. Heiberger for all help! Fredrik PS A peculiar thing though - In the latest manual for ESS it's said: 4.9 Using emacsclient When starting R or S under Unix, ESS sets options(editor=emacsclient). (Under Microsoft Windows, it will use gnuclient.exe rather than emacsclient, but the same principle applies.) but I got options(editor=gnuclient -q) now changed to options(editor=gnuclient ) DS - Original Message - From: Fredrik Lundgren [EMAIL PROTECTED] To: R-help r-help@stat.math.ethz.ch Sent: Monday, March 28, 2005 7:37 PM Subject: [R] gnuclient problems witrh R/ESS in linux Dear list, Not strictly R ... In R on Xemacs with ESS (R-2.0.1, Xemacs-21.4.15-r3, ESS-5.2.6) on gentoo-linux when I use k-edit(k) or fix(k) to change a small vector k - c(1,2,3,4,5,6) the opened window (called '6b8b4567') appears not to be connected to the gnuclient and I'm able to edit the file but has no instructions in the minibuffer and C-x # gives '6b8b4567 does not belong to gnuserv client' in init.el I have (require 'gnuserv) (gnuserv-start) (setq gnuserv-frame (selected-frame)) Any help please? Fredrik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Stratified Bootstrap question
Dear Qian, You might try the S+Resample library, which has built-in support for both sampling by subject and stratified sampling. If you are a student, there is a free student version of S+. See www.insightful.com/downloads/libraries (S+Resample) www.insightful.com/Hesterberg/bootstrap (has link to the student version) For the missing values, consider the S+Missing library, which offers multiple imputation. With S+, do library(missing) Tim Hesterberg P.S. The combination of sampling by subject and stratified sampling was terribly messy to program. If I'd known in advance how messy, I never would have done it :-( But it is done now. Dear R users, I have a question regarding stratified bootstrap question and how to implement it using boot() in R's boot package. My dataset is a longitudinal dataset (3 measurements per person at year 1, 4 and 7) composed of multiple clinic centers and multiple participants within each clinic. It has missing values. I want to do a bootstrap to find the standard errors and confidence intervals for my variance components. My model is a mixed model with random clinic and random participant within clinic. I thought two methods to do bootstrap: (1) bootstrap data; however, I have problem specifying the second parameter for my statistic function, shall I use indices, weight or frequency and how shall I relate to my dataset. (2) bootstrap residuals; however, the dataset has multiple measurements and missing values. I am wondering how to construct a new data frame containing the residuals and fitted values. Any ideas will be highly appreciated! Sincerely yours, Qian | Tim Hesterberg Research Scientist | | [EMAIL PROTECTED] Insightful Corp.| | (206)802-23191700 Westlake Ave. N, Suite 500 | | (206)283-8691 (fax) Seattle, WA 98109-3044, U.S.A. | | www.insightful.com/Hesterberg | Download the S+Resample library from www.insightful.com/downloads/libraries __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Installing GO 1.7.0
I'm in the process of packaging R (and R modules) for future inclusion in Fedora Extras, and I've managed to get several hundred modules installed without issue, however, the GO metadata package is refusing to comply. Since I'm packaging this in rpm format, I can't use any of the automated functions for build, I've got to do it locally through R. The following steps work for other metadata packages (directory names changing, obviously), but not for GO: With the GO tarball unpacked into R-GO-1.7.0/GO... cd R-GO-1.7.0/ rm -rf /var/tmp/R-GO-1.7.0-1-root-root mkdir -p /var/tmp/R-GO-1.7.0-1-root-root/usr/lib/R/library export R_LIBS=/var/tmp/R-GO-1.7.0-1-root-root/usr/lib/R/library /usr/bin/R CMD INSTALL \ -l /var/tmp/R-GO-1.7.0-1-root-root/usr/lib/R/library GO I get the following output: * Installing *source* package 'GO' ... ** R ** data ** preparing package for lazy loading ** help Building/Updating help pages for package 'GO' Formats: text html latex example GOtexthtmllatex GOALLLOCUSID texthtmllatex example GOBPANCESTOR texthtmllatex example GOBPCHILDREN texthtmllatex example GOBPOFFSPRING texthtmllatex example GOBPPARENTS texthtmllatex example GOCCANCESTOR texthtmllatex example GOCCCHILDREN texthtmllatex example GOCCOFFSPRING texthtmllatex example GOCCPARENTS texthtmllatex example GOLOCUSID texthtmllatex example GOLOCUSID2ALLGO texthtmllatex example GOLOCUSID2GO texthtmllatex example GOMFANCESTOR texthtmllatex example GOMFCHILDREN texthtmllatex example GOMFOFFSPRING texthtmllatex example GOMFPARENTS texthtmllatex example GOQC texthtmllatex GOTERMtexthtmllatex example But I never get the * DONE (GO) that I'm expecting. Instead, all of the memory on the machine allocates (512MB), it starts to swap out, and never completes. When I look at the output from ps, I see: 8290 pts/5S+ 0:00 /bin/sh /usr/lib/R/bin/INSTALL -l /var/tmp/R-GO-1.7.0-1-root-root/us 8364 ?S 0:00 8421 pts/5D+ 1:11 /usr/lib/R/bin/exec/R --vanilla When I kill the 8421 process, I get: /usr/lib/R/bin/INSTALL: line 381: 8088 Doneecho invisible(.libPaths(c(\${lib}\, .libPaths(; tools:::.install_package_indices(\.\, \${R_PACKAGE_DIR}\) 8089 Killed | R_DEFAULT_PACKAGES=NULL LANG=C ${R_EXE} --vanilla /dev/null ERROR: installing package indices failed I let this run for over 6 hours, and it didn't seem to complete (or make any changes). Unfortunately, lots of Bioconductor seems to depend on GO... so any help on getting this to install is appreciated. Thanks, ~spot -- Tom spot Callaway: Red Hat Sales Engineer || GPG Fingerprint: 93054260 Fedora Extras Steering Committee Member (RPM Standards and Practices) Aurora Linux Project Leader: http://auroralinux.org Lemurs, llamas, and sparcs, oh my! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how i can get input from user input
Also look at ?readline Greg Snow, Ph.D. Statistical Data Center [EMAIL PROTECTED] (801) 408-8111 Uwe Ligges [EMAIL PROTECTED] 03/29/05 11:43PM Cuichang Zhao wrote: Hello, Could you please tell me how i can get an input from the user in R? Depends on the kind of input. See, e.g., ?scan or ?menu Uwe Ligges C-Ming Mar 29, 2005 - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] about memory
Yes, you may need more memory unless you can somehow free a good amount of RAM or find a more memory-efficient method for clustering. If I'm reading it correctly, R wanted to allocate about 382 MB memory on top of what it had already taken but your computer had only about 98 MB swap plus about 1 MB RAM left to give. On Wed, 30 Mar 2005 22:02:04 +0800 ronggui [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] ulimit -a core file size(blocks, -c) 0 data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files(-n) 1024 pipe size (512 bytes, -p) 8 stack size(kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes(-u) unlimited virtual memory(kbytes, -v) unlimited so it seems the data segment size is not limited. and it is still free mem(1000k or so),and swap(10k or so),and the error is(i translate it from chinese into english,maybe not exactly ,but i think the meanings are right): error:can not allocate the vector size of 390585kb. (´íÎó: ÎÞ·¨·ÖÅä´óСΪ390585 KbµÄÏòÁ¿) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Installing GO 1.7.0
Hi Tom, I'm cc'ing to Bioconductor as that is probably a better place for the discussion. Tom 'spot' Callaway [EMAIL PROTECTED] writes: I'm in the process of packaging R (and R modules) for future inclusion in Fedora Extras, and I've managed to get several hundred modules installed without issue, however, the GO metadata package is refusing to comply. ERROR: installing package indices failed I let this run for over 6 hours, and it didn't seem to complete (or make any changes). We have a solution for this and will send or make available an updated GO package shortly. With the updated GO package you should be able to R CMD INSTALL without it taking much time. Best, + seth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [BioC] Follow-up to: [R] Annotation metadata kills help.search
Gerard Tromp [EMAIL PROTECTED] writes: Greetings, this is a follow-up to the mailing below. Seth Falcon replied and indicated that he and several others were unable to replicate the problem. Specifically he requested: We are not able to reproduce this issue. If you reinstall the annotation packages does the error reappear? If so, an exact transcript of the commands entered, their output, and the output of traceback() right after the error would be helpful --- and it would be best to move the discussion to the bioconductor list. === The answers are: Yes, the problem is reproducible. I did a complete reinstall of R and bioconductor end everything worked fine until I installed an annotation package. With the added information from Gerard, we were able to reproduce the problem and are currently working on a fix. Thanks, + seth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] how i can get input from user input
If you are on Windows and want to go GUI, see ?choose.files, ?winMenuAdd, ?winDialog, ?select.list -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Snow Sent: Wednesday, March 30, 2005 9:45 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] how i can get input from user input Also look at ?readline Greg Snow, Ph.D. Statistical Data Center [EMAIL PROTECTED] (801) 408-8111 Uwe Ligges [EMAIL PROTECTED] 03/29/05 11:43PM Cuichang Zhao wrote: Hello, Could you please tell me how i can get an input from the user in R? Depends on the kind of input. See, e.g., ?scan or ?menu Uwe Ligges C-Ming Mar 29, 2005 - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Step error
Could anyone tell me what am I doing wrong? pro-function(indep,dep){ + d-data.frame(indep) + form-formula(lm(dep~.,data=d)) + forward-step(lm(dep~X1,data=d),scope=form,trace=0,direction='f') + return(forward) + } pro(m,q) Error in inherits(x, data.frame) : Object d not found Where q is a vector with the dependent variable's values and m is a matrix containing the values of the independent variables. While writing the above without a function form has no problem, that is : d-data.frame(m) form-formula(lm(q~.,data=d)) forward-step(lm(q~X1,data=d),scope=form,trace=0,direction='f') forward Call: lm(formula = q ~ X1 + X2 + X5, data = d) Coefficients: (Intercept) X1 X2 X5 -15.7988.7656.774 -4.245 Thank you in advance! Vasilis __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] compute adjusted mean
Dear Sir/Madam: I have a question about computing adjusted mean using R. I am really new to this area. Suppose I have a response Y, and covariate: treat (binary), sex (binary) race (catogorical ) and age (continuous). the model: Y~treat+sex+race+age; I am asked to compute the adjusted mean of Y for treat=1. would you please tell me (in detail) how I can do this? I searched the R homepage and got some information, but not quite helpful. thanks a lot, Steven L. Lu - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] PDF and PS output
I'm using R 2.0 on Redhat Linux 9. When I try to produce PDF or PS output, the files are corrupted -- they won't open in Acroread, xpdf, ggv, and on attempting to convert to PNG, I get message This file has corrupted %%EOF marker. Perhaps I am just doing something wrong. I did: pdf() hist(unlist(foo.bar)) I have no trouble viewing the output in Xwindows. Thanks, Hans __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Stratified Bootstrap question
Dear Tim, Thank you very much for your information. I will try to play with S+ as you suggested. At the same time, I would like to share our idea with you about the stratified bootstrapping for my scenario. I am not sure if it is correct. I am playing with it now. We created a new dataset containing clinic and patient id within clinic, then stratified boot() function was used to bootstrap the newly-created dataset. Based on the indices of the bootstrap result, since patient id is unique, we found the patient ids from the new dataset, then found the corresponding dataset to fit a mixed model from the original dataset using patient ids. I am trying to run the program now, but it takes longer than what I expected. 500 times takes more than 3 hours and it is still running. I will see if this is working properly. Thank you very much for your input, Qian On 30 Mar 2005, Tim Hesterberg wrote: Dear Qian, You might try the S+Resample library, which has built-in support for both sampling by subject and stratified sampling. If you are a student, there is a free student version of S+. See www.insightful.com/downloads/libraries(S+Resample) www.insightful.com/Hesterberg/bootstrap (has link to the student version) For the missing values, consider the S+Missing library, which offers multiple imputation. With S+, do library(missing) Tim Hesterberg P.S. The combination of sampling by subject and stratified sampling was terribly messy to program. If I'd known in advance how messy, I never would have done it :-( But it is done now. Dear R users, I have a question regarding stratified bootstrap question and how to implement it using boot() in R's boot package. My dataset is a longitudinal dataset (3 measurements per person at year 1, 4 and 7) composed of multiple clinic centers and multiple participants within each clinic. It has missing values. I want to do a bootstrap to find the standard errors and confidence intervals for my variance components. My model is a mixed model with random clinic and random participant within clinic. I thought two methods to do bootstrap: (1) bootstrap data; however, I have problem specifying the second parameter for my statistic function, shall I use indices, weight or frequency and how shall I relate to my dataset. (2) bootstrap residuals; however, the dataset has multiple measurements and missing values. I am wondering how to construct a new data frame containing the residuals and fitted values. Any ideas will be highly appreciated! Sincerely yours, Qian | Tim Hesterberg Research Scientist | | [EMAIL PROTECTED] Insightful Corp.| | (206)802-23191700 Westlake Ave. N, Suite 500 | | (206)283-8691 (fax) Seattle, WA 98109-3044, U.S.A. | | www.insightful.com/Hesterberg | Download the S+Resample library from www.insightful.com/downloads/libraries *** Qian An Division of Biostatistics University of Minnesota (phone) 612-626-2263 (fax) 612-626-8892 Email: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PDF and PS output
Ach -- such a simple mistake. Thank you for pointing out my error, and I apologize for wasting your time. Best wishes, Hans Peter Dalgaard [EMAIL PROTECTED] writes: Hans Halvorson [EMAIL PROTECTED] writes: I'm using R 2.0 on Redhat Linux 9. When I try to produce PDF or PS output, the files are corrupted -- they won't open in Acroread, xpdf, ggv, and on attempting to convert to PNG, I get message This file has corrupted %%EOF marker. Perhaps I am just doing something wrong. I did: pdf() hist(unlist(foo.bar)) I have no trouble viewing the output in Xwindows. Did you terminate the device properly (dev.off() or exit from R)? -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PDF and PS output
Hi: dev.off() Check your file now... That's it! Hans Halvorson wrote: I'm using R 2.0 on Redhat Linux 9. When I try to produce PDF or PS output, the files are corrupted -- they won't open in Acroread, xpdf, ggv, and on attempting to convert to PNG, I get message This file has corrupted %%EOF marker. Perhaps I am just doing something wrong. I did: pdf() hist(unlist(foo.bar)) I have no trouble viewing the output in Xwindows. Thanks, Hans __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- U.M.A. http://sophie.fata.unam.mx/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Stratified Bootstrap question
Dear Tim, Thank you so much for your help. My random mixed model is as follows: b.lme - lme(sbp ~ age + gender, data=bdat, random=~1/clinic/id, na.action=na.omit) When doing bootstrap with stratum clinic, a patient's data may appear multiple times in the boostrap dataset and all of them share the same id. I am wondering if the data from the same patient will cause problems in lme fitting or not. Do you happen to know this or not? I am really sorry for coming up more questions. Thank you so much for your help. Sincerely yours, Qian On 30 Mar 2005, Tim Hesterberg wrote: Dear Tim, Thank you very much for your information. I will try to play with S+ as you suggested. At the same time, I would like to share our idea with you about the stratified bootstrapping for my scenario. I am not sure if it is correct. I am playing with it now. We created a new dataset containing clinic and patient id within clinic, then stratified boot() function was used to bootstrap the newly-created dataset. Based on the indices of the bootstrap result, since patient id is unique, we found the patient ids from the new dataset, then found the corresponding dataset to fit a mixed model from the original dataset using patient ids. That sounds reasonable. That is what the S+Resample library does internally. I am trying to run the program now, but it takes longer than what I expected. 500 times takes more than 3 hours and it is still running. I will see if this is working properly. This may be normal. Fitting mixed models is iterative, unlike simple linear regression for which there is a closed-form solution. So running many replications can take a while. It might help if you specify starting values for the fixed-effects coefficients. Run the model for the original data, and extract the fixed-effects coefficients. Then specify those as starting values; this could make the bootstrap replicates run faster. Thank you very much for your input, Qian On 30 Mar 2005, Tim Hesterberg wrote: Dear Qian, You might try the S+Resample library, which has built-in support for both sampling by subject and stratified sampling. If you are a student, there is a free student version of S+. See www.insightful.com/downloads/libraries (S+Resample) www.insightful.com/Hesterberg/bootstrap(has link to the student version) For the missing values, consider the S+Missing library, which offers multiple imputation. With S+, do library(missing) Tim Hesterberg P.S. The combination of sampling by subject and stratified sampling was terribly messy to program. If I'd known in advance how messy, I never would have done it :-( But it is done now. Dear R users, I have a question regarding stratified bootstrap question and how to implement it using boot() in R's boot package. My dataset is a longitudinal dataset (3 measurements per person at year 1, 4 and 7) composed of multiple clinic centers and multiple participants within each clinic. It has missing values. I want to do a bootstrap to find the standard errors and confidence intervals for my variance components. My model is a mixed model with random clinic and random participant within clinic. I thought two methods to do bootstrap: (1) bootstrap data; however, I have problem specifying the second parameter for my statistic function, shall I use indices, weight or frequency and how shall I relate to my dataset. (2) bootstrap residuals; however, the dataset has multiple measurements and missing values. I am wondering how to construct a new data frame containing the residuals and fitted values. Any ideas will be highly appreciated! Sincerely yours, Qian | Tim Hesterberg Research Scientist | | [EMAIL PROTECTED] Insightful Corp.| | (206)802-23191700 Westlake Ave. N, Suite 500 | | (206)283-8691 (fax) Seattle, WA 98109-3044, U.S.A. | | www.insightful.com/Hesterberg | Download the S+Resample library from www.insightful.com/downloads/libraries *** Qian An Division of Biostatistics University of Minnesota (phone) 612-626-2263 (fax) 612-626-8892 Email: [EMAIL PROTECTED] *** *** Qian An Division of Biostatistics University of Minnesota (phone) 612-626-2263 (fax) 612-626-8892 Email: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] French Curve
Dear R experts, Did someone implemented French Curve yet? Or can anyone point me some papers that I can follow to implement it? thanks in advance for your help. Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Base and lattice graphics on the same graphics page
Hi Deepayan Sarkar wrote: On Tuesday 29 March 2005 22:32, John Maindonald wrote: Although base graphics does not mix with lattice in the one graph, I've found that print.trellis(position=..., ) and the use of par(fig=...) to put regular and trellis graphics on the one graphics page works like a treat, at least in version 2.0.1 of R. [Base graphics functions that are themselves inconsistent with par(fig=...) are obviously disallowed.] I am wondering whether there are caveats of which I and others should be aware, or whether there is a risk that the ongoing development of R's graphics abilities will render such a cohabitation unworkably fractious. Paul would know better, but I think that's unlikely. In fact, the gridBase package allows you to do use grid (and hence lattice) functions to add to a base plot, as well as (I didn't realize this before) the other way round. The only caveat is that resizing the device may mess things up. Yep, sounds like you're doing exactly the sort of thing that gridBase does. See R News 3(2) for a discussion. Paul You may have to be careful with new devices. Your example pasted on a fresh session (tested only on r-devel) starts a new page for the boxplot since it thinks that new=TRUE doesn't make sense (because there's no 'old' plot yet). Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [BioC] Follow-up to: [R] Annotation metadata kills help.search
Hello Gerard, all, The annotation packages breaking help.search was due to improperly built annotation packages. We have posted updated annotation packages to the Bioconductor meta data repository. Reinstalling the annotation data packages should resolve the issue and allow help.search to function normally. Please let us know (on [EMAIL PROTECTED]) if you find otherwise. Thanks, + seth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] NA's?
Your message doesn't help us very much. You haven't said what kind of calculation it is you want to do, and that certainly matters. For example, for some kinds of computations the solution you started below would work fine: M - matrix(1:16, 4, 4) is.na(diag(M)) - TRUE M [,1] [,2] [,3] [,4] [1,] NA59 13 [2,]2 NA 10 14 [3,]37 NA 15 [4,]48 12 NA rowSums(M, na.rm = TRUE) [1] 27 26 25 24 colSums(M, na.rm = TRUE) [1] 9 20 31 42 You can also use apply( ) with functions that will accept missing values (and ignore them) for computations on either the rows or the columns. Hoping for a general mechanism that would somehow signal the diagonal values as values to be ignored in a general way is not a possibility. Just as a curiosity, what were you hoping that na.omit(M) would do? V. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Asha Jayanthi Sent: Thursday, 31 March 2005 11:22 AM To: r-help@stat.math.ethz.ch Subject: [R] NA's? I have a large matrix of data . The size of the matrix ranges from 100 x 100 to 1000 x 1000 Now i have to do computations on that. And should not consider the diagonal elements. I tried setting diag(M) = NA and M = na.omit(M). But this omits all the rows. I only want to omit that diagonal elements only but consider the whole row. diag(M) = 0 seems like a good option but this will affect my result. How to proceed with this. How to just ignore some specific values. what if i want to consider only the upper / lower triangular matrix Asha http://adfarm.mediaplex.com/ad/ck/4686-26272-10936-31?ck=RegSell Start your business. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] 2d plotting and colours
Since I was only concentrating on colour issues and not on your specific problem I was just showing the possibilities. Does this code help n - 5 par(mfrow = c(2,2)) palette(default) barplot(1:25,col = 1:25) palette(rainbow(n)) barplot(1:25,col = 1:25) palette(rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.))) barplot(1:25,col = 1:25) require(cluster) x - runif(100) * 8 + 2 cl - kmeans(x, n) palette(rainbow(n)) plot(x, col = cl$cluster) abline(h = cl$centers, lty = 2,col = grey ) palette(palette()[order(cl$centers)]) points(x,col = cl$cluster,pch = 20,cex = 0.4) However you may wish to choose your colours in a way that is different from cl$cluster which is why I changed the palette before plotting the points. You should see that they now are ordered from bottom to top of the last plot. You could also choose to create a vector with your colours and then use the value in cl$cluster to select the colours mycols - rainbow(n) plot(x,col = mycols[cl$cluster]) Tom -Original Message- From: Asha Jayanthi [mailto:[EMAIL PROTECTED] Sent: Thursday, 31 March 2005 9:17 AM To: r-help@stat.math.ethz.ch Subject: RE: [R] 2d plotting and colours Thank you very much. the code plot(x, col = s) points(cl$centers, col = s, pch = 8, cex=2) does not plot the points according to the group colors. The plots are used to identify the groups by colors That could be done by plot(x, col = cl$cluster) This means that we need to set the default colours , say col = cl$cluster = a set of group numbers say 1...10 should produce 10 distinct colours points grouped by colour. how to do this when you have more than 8 group colours to plot From: Mulholland, Tom [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch,Asha Jayanthi [EMAIL PROTECTED] Subject: RE: [R] 2d plotting and colours Date: Wed, 30 Mar 2005 15:59:46 +0800 And getting back to your question about the palette there are a lot of ways to do this assuming you have just started a session palette() # will give #[1] black red green3 bluecyan #[6] magenta yellow gray palette(rainbow(24)) # There's also 'heat.colors' 'topo.colors' palette() # [1] red #FF4000 #FF8000 # [4] #FFBF00 yellow #BFFF00 # [7] #80FF00 #40FF00 green #[10] #00FF40 #00FF80 #00FFBF #[13] cyandeepskyblue #0080FF #[16] #0040FF blue#4000FF #[19] #8000FF #BF00FF magenta #[22] #FF00BF #FF0080 #FF0040 palette(rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.))) palette() # [1] black #11 #22 #33 #44 # [6] #55 #66 #77 #88 #99 #[11] #AA #BB #CC #DD red2 #[16] red If you are looking to use colours that take account of colour blindness you could try the package dichromat. (I think 2.1 will have some of this inbuilt) Once you look through the help files associated with some of these options you will find the way that best suits your method of working. Tom -Original Message- From: Uwe Ligges [mailto:[EMAIL PROTECTED] Sent: Wednesday, 30 March 2005 3:18 PM To: TEMPL Matthias Cc: r-help@stat.math.ethz.ch; Asha Jayanthi Subject: Re: [R] 2d plotting and colours TEMPL Matthias wrote: Hi! There are more than 8 colors. Yes, e.g. for rgb space there are 16777216, see ?rgb. Uwe Ligges x - rbind(matrix(rnorm(100, sd = 0.3), ncol = 2), matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2)) (cl - kmeans(x, i, 20)) s - c(tomato4, turquoise, slateblue, wheat, snow, skyblue, peru, pink) # see at: colors() plot(x, col = s) points(cl$centers, col = s, pch = 8, cex=2) Best, Matthias Hi! I am new to R just 3 days in it and i apologize if my questions seem very trivial and consumed your valuable time. I am coding in perl and i stumbled upon R regarding plotting good statistical graphs. I tried the kmean clustering for a large matrix ,say 150 * 150 . I tried the example code given in the tutorial to perform 2d plot # i ranges from 2 to 10 cl - kmeans(x, i, 20) plot(x, col = cl$cluster) points(cl$centers, col = 1:i ) I see that there are only 8 colours defined , namely black,red,green,blue,cyan,magenta,yello,gray. How should i set my colour preferences to obtain my palette of colours? I checked in the totorial which talks about R.colors and palatte , but i failed to understand how to set it. Thank You Asha MSN Messenger! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Using kmeans given cluster centroids and data with NAs
Hello, I have used the functions agnes and cutree to cluster my data (4977 objects x 22 variables) into 8 clusters. I would like to refine the solution using a k-means or similar algorithm, setting the initial cluster centres as the group means from agnes. However my data matrix has NA's in it and the function kmeans does not appear to accept this? dim(centres) [1] 8 22 dim(data) [1] 4977 22 x - kmeans(data,centres) Error in kmeans(data, centres) : NA/NaN/Inf in foreign function call (arg 1) I have looked extensively through the mail archives but cannot find if/where someone has provided the answer. Thanks in advance, SB Sophie Bestley Pelagic Fisheries and Ecosystems CSIRO Marine Research GPO Box 1538 Hobart, Tasmania 7001 AUSTRALIA Phone: +61 3 6232 5048 Fax: +61 3 6232 5053 Email: [EMAIL PROTECTED] Website: http://www.marine.csiro.au [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] NA's?
See upper.tri and lower.tri. I think that you might also look for specific packages that function using matrices, from what I have seen these often have the capacity to ignore the diagonal or use just the upper or lower triangle. This is not an area that I use very much, but I have seen various posts about different types of matrices and there appears to be quite a lot of code that deals with the range of types and uses. Obvious candidates include the Matrix package, but a search for matrix in all of the CRAN packages brings up a bewildering variety of matrix related functions. You may find it useful to search for the specific type of manipulation that you are attempting. Tom -Original Message- From: Asha Jayanthi [mailto:[EMAIL PROTECTED] Sent: Thursday, 31 March 2005 9:22 AM To: r-help@stat.math.ethz.ch Subject: [R] NA's? I have a large matrix of data . The size of the matrix ranges from 100 x 100 to 1000 x 1000 Now i have to do computations on that. And should not consider the diagonal elements. I tried setting diag(M) = NA and M = na.omit(M). But this omits all the rows. I only want to omit that diagonal elements only but consider the whole row. diag(M) = 0 seems like a good option but this will affect my result. How to proceed with this. How to just ignore some specific values. what if i want to consider only the upper / lower triangular matrix Asha http://adfarm.mediaplex.com/ad/ck/4686-26272-10936-31?ck=RegSe ll Start your business. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Using kmeans given cluster centroids and data with NAs
Does ?na.omit help x - kmeans(na.omit(data),centres) of course if you have too many NAs you need to be sure that their removal does not unduly influence the results. Although I am a bit confused as I thought that agnes did not allow NAs. I assume that you are running an alternative clustering method using the results of the first process as the starting point for the partitioning process and are thus using the same initial data. Tom -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, 31 March 2005 11:33 AM To: r-help@stat.math.ethz.ch Subject: [R] Using kmeans given cluster centroids and data with NAs Hello, I have used the functions agnes and cutree to cluster my data (4977 objects x 22 variables) into 8 clusters. I would like to refine the solution using a k-means or similar algorithm, setting the initial cluster centres as the group means from agnes. However my data matrix has NA's in it and the function kmeans does not appear to accept this? dim(centres) [1] 8 22 dim(data) [1] 4977 22 x - kmeans(data,centres) Error in kmeans(data, centres) : NA/NaN/Inf in foreign function call (arg 1) I have looked extensively through the mail archives but cannot find if/where someone has provided the answer. Thanks in advance, SB Sophie Bestley Pelagic Fisheries and Ecosystems CSIRO Marine Research GPO Box 1538 Hobart, Tasmania 7001 AUSTRALIA Phone: +61 3 6232 5048 Fax: +61 3 6232 5053 Email: [EMAIL PROTECTED] Website: http://www.marine.csiro.au [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] NA's?
I am sorry about that. I like to do column mean, sd, var as well as kmeans on the matrix does this na.rm = TRUE work for such fuctions and only the diagonal is ignored? From: [EMAIL PROTECTED] To: [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] NA's? Date: Thu, 31 Mar 2005 11:42:05 +1000 Your message doesn't help us very much. You haven't said what kind of calculation it is you want to do, and that certainly matters. For example, for some kinds of computations the solution you started below would work fine: M - matrix(1:16, 4, 4) is.na(diag(M)) - TRUE M [,1] [,2] [,3] [,4] [1,] NA59 13 [2,]2 NA 10 14 [3,]37 NA 15 [4,]48 12 NA rowSums(M, na.rm = TRUE) [1] 27 26 25 24 colSums(M, na.rm = TRUE) [1] 9 20 31 42 You can also use apply( ) with functions that will accept missing values (and ignore them) for computations on either the rows or the columns. Hoping for a general mechanism that would somehow signal the diagonal values as values to be ignored in a general way is not a possibility. Just as a curiosity, what were you hoping that na.omit(M) would do? V. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Asha Jayanthi Sent: Thursday, 31 March 2005 11:22 AM To: r-help@stat.math.ethz.ch Subject: [R] NA's? I have a large matrix of data . The size of the matrix ranges from 100 x 100 to 1000 x 1000 Now i have to do computations on that. And should not consider the diagonal elements. I tried setting diag(M) = NA and M = na.omit(M). But this omits all the rows. I only want to omit that diagonal elements only but consider the whole row. diag(M) = 0 seems like a good option but this will affect my result. How to proceed with this. How to just ignore some specific values. what if i want to consider only the upper / lower triangular matrix Asha http://adfarm.mediaplex.com/ad/ck/4686-26272-10936-31?ck=RegSell Start your business. __ R-help@stat.math.ethz.ch 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://ads.mediaturf.net/event.ng/Type=clickFlightID=17307AdID=44925TargetID=9763Targets=9763Values=414,868,1093,2385Redirect=http:%2F%2Fwww.icicibanknripromotions.com%2Fm2i_feb%2Fnri_M2I_feb.jsp%3Fadid%3D44925%26siteid%3D1093%26flightid%3D17307 Get a FREE 30 minute India Calling Card. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] NA's?
i have not answered your query in the last mail. I hoped na.omit(M) will just ingnore the diagonal elements. i learnt by practice that it removes the whole row which has atleast one NA!! (that is not the case in Perl) Since I am bit new to R, i did not knew how to just ignore those elements in R From: [EMAIL PROTECTED] To: [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] NA's? Date: Thu, 31 Mar 2005 11:42:05 +1000 Your message doesn't help us very much. You haven't said what kind of calculation it is you want to do, and that certainly matters. For example, for some kinds of computations the solution you started below would work fine: M - matrix(1:16, 4, 4) is.na(diag(M)) - TRUE M [,1] [,2] [,3] [,4] [1,] NA59 13 [2,]2 NA 10 14 [3,]37 NA 15 [4,]48 12 NA rowSums(M, na.rm = TRUE) [1] 27 26 25 24 colSums(M, na.rm = TRUE) [1] 9 20 31 42 You can also use apply( ) with functions that will accept missing values (and ignore them) for computations on either the rows or the columns. Hoping for a general mechanism that would somehow signal the diagonal values as values to be ignored in a general way is not a possibility. Just as a curiosity, what were you hoping that na.omit(M) would do? V. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Asha Jayanthi Sent: Thursday, 31 March 2005 11:22 AM To: r-help@stat.math.ethz.ch Subject: [R] NA's? I have a large matrix of data . The size of the matrix ranges from 100 x 100 to 1000 x 1000 Now i have to do computations on that. And should not consider the diagonal elements. I tried setting diag(M) = NA and M = na.omit(M). But this omits all the rows. I only want to omit that diagonal elements only but consider the whole row. diag(M) = 0 seems like a good option but this will affect my result. How to proceed with this. How to just ignore some specific values. what if i want to consider only the upper / lower triangular matrix Asha http://adfarm.mediaplex.com/ad/ck/4686-26272-10936-31?ck=RegSell Start your business. __ R-help@stat.math.ethz.ch 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://creative.mediaturf.net/creatives/citibankrca/rca_msntagofline.htm Without minimum balance for 20 yrs! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Can I extract result row of table()?
x - c(5, 5, 8, 8, 8, 27) table(x) x 5 8 27 2 3 1 I want a way to use only 2, 3, 1, nomatter table or what other function used. Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Can I extract result row of table()?
Terry Mu wrote: x - c(5, 5, 8, 8, 8, 27) table(x) x 5 8 27 2 3 1 I want a way to use only 2, 3, 1, nomatter table or what other function used. as.vector() removes the attributes, if that is your question. Uwe Ligges Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] 2d plotting and colours
Thank you. mycols - c(brown,orange,tomato) plot(x,col = mycols[cl$cluster]) this works. I can define distinct colours and check the graph. the rest of the examples does not give a wide palette to choose from Asha From: Mulholland, Tom [EMAIL PROTECTED] To: Asha Jayanthi [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] 2d plotting and colours Date: Thu, 31 Mar 2005 10:14:13 +0800 Since I was only concentrating on colour issues and not on your specific problem I was just showing the possibilities. Does this code help n - 5 par(mfrow = c(2,2)) palette(default) barplot(1:25,col = 1:25) palette(rainbow(n)) barplot(1:25,col = 1:25) palette(rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.))) barplot(1:25,col = 1:25) require(cluster) x - runif(100) * 8 + 2 cl - kmeans(x, n) palette(rainbow(n)) plot(x, col = cl$cluster) abline(h = cl$centers, lty = 2,col = grey ) palette(palette()[order(cl$centers)]) points(x,col = cl$cluster,pch = 20,cex = 0.4) However you may wish to choose your colours in a way that is different from cl$cluster which is why I changed the palette before plotting the points. You should see that they now are ordered from bottom to top of the last plot. You could also choose to create a vector with your colours and then use the value in cl$cluster to select the colours mycols - rainbow(n) plot(x,col = mycols[cl$cluster]) Tom -Original Message- From: Asha Jayanthi [mailto:[EMAIL PROTECTED] Sent: Thursday, 31 March 2005 9:17 AM To: r-help@stat.math.ethz.ch Subject: RE: [R] 2d plotting and colours Thank you very much. the code plot(x, col = s) points(cl$centers, col = s, pch = 8, cex=2) does not plot the points according to the group colors. The plots are used to identify the groups by colors That could be done by plot(x, col = cl$cluster) This means that we need to set the default colours , say col = cl$cluster = a set of group numbers say 1...10 should produce 10 distinct colours points grouped by colour. how to do this when you have more than 8 group colours to plot From: Mulholland, Tom [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch,Asha Jayanthi [EMAIL PROTECTED] Subject: RE: [R] 2d plotting and colours Date: Wed, 30 Mar 2005 15:59:46 +0800 And getting back to your question about the palette there are a lot of ways to do this assuming you have just started a session palette() # will give #[1] black red green3 bluecyan #[6] magenta yellow gray palette(rainbow(24)) # There's also 'heat.colors' 'topo.colors' palette() # [1] red #FF4000 #FF8000 # [4] #FFBF00 yellow #BFFF00 # [7] #80FF00 #40FF00 green #[10] #00FF40 #00FF80 #00FFBF #[13] cyandeepskyblue #0080FF #[16] #0040FF blue#4000FF #[19] #8000FF #BF00FF magenta #[22] #FF00BF #FF0080 #FF0040 palette(rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.))) palette() # [1] black #11 #22 #33 #44 # [6] #55 #66 #77 #88 #99 #[11] #AA #BB #CC #DD red2 #[16] red If you are looking to use colours that take account of colour blindness you could try the package dichromat. (I think 2.1 will have some of this inbuilt) Once you look through the help files associated with some of these options you will find the way that best suits your method of working. Tom -Original Message- From: Uwe Ligges [mailto:[EMAIL PROTECTED] Sent: Wednesday, 30 March 2005 3:18 PM To: TEMPL Matthias Cc: r-help@stat.math.ethz.ch; Asha Jayanthi Subject: Re: [R] 2d plotting and colours TEMPL Matthias wrote: Hi! There are more than 8 colors. Yes, e.g. for rgb space there are 16777216, see ?rgb. Uwe Ligges x - rbind(matrix(rnorm(100, sd = 0.3), ncol = 2), matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2)) (cl - kmeans(x, i, 20)) s - c(tomato4, turquoise, slateblue, wheat, snow, skyblue, peru, pink) # see at: colors() plot(x, col = s) points(cl$centers, col = s, pch = 8, cex=2) Best, Matthias Hi! I am new to R just 3 days in it and i apologize if my questions seem very trivial and consumed your valuable time. I am coding in perl and i stumbled upon R regarding plotting good statistical graphs. I tried the kmean clustering for a large matrix ,say 150 * 150 . I tried the example code given in the tutorial to perform 2d plot # i ranges from 2 to 10 cl - kmeans(x, i, 20) plot(x, col = cl$cluster) points(cl$centers, col = 1:i ) I see that there are only 8 colours defined , namely black,red,green,blue,cyan,magenta,yello,gray. How should i set my colour preferences to obtain my palette of colours? I checked in the totorial which talks about R.colors and palatte , but i failed to
RE: [R] 2d plotting and colours
I'm not sure that I understand you comment about the other examples not giving a wide palette. Are you using wide to refer to the difference in colours rather than the number of choices in the palette? If this is your issue you should look at the dichromat package that I referred to, in particular the colorRamp function. You might also want to have a look at the RColorBrewer package and run the ColorBrewer example. This package specifically deals with the ability to distinguish one colour from another.As the ColorBrewer website notes the tool is designed to help people select good color schemes for maps and other graphics. By the way if the mycols code works then palette(c(brown,orange,tomato)) plot(x,col = cl$cluster) should produce exactly the same result. Tom -Original Message- From: Asha Jayanthi [mailto:[EMAIL PROTECTED] Sent: Thursday, 31 March 2005 2:36 PM To: Mulholland, Tom; r-help@stat.math.ethz.ch Subject: RE: [R] 2d plotting and colours Thank you. mycols - c(brown,orange,tomato) plot(x,col = mycols[cl$cluster]) this works. I can define distinct colours and check the graph. the rest of the examples does not give a wide palette to choose from Asha From: Mulholland, Tom [EMAIL PROTECTED] To: Asha Jayanthi [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] 2d plotting and colours Date: Thu, 31 Mar 2005 10:14:13 +0800 Since I was only concentrating on colour issues and not on your specific problem I was just showing the possibilities. Does this code help n - 5 par(mfrow = c(2,2)) palette(default) barplot(1:25,col = 1:25) palette(rainbow(n)) barplot(1:25,col = 1:25) palette(rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.))) barplot(1:25,col = 1:25) require(cluster) x - runif(100) * 8 + 2 cl - kmeans(x, n) palette(rainbow(n)) plot(x, col = cl$cluster) abline(h = cl$centers, lty = 2,col = grey ) palette(palette()[order(cl$centers)]) points(x,col = cl$cluster,pch = 20,cex = 0.4) However you may wish to choose your colours in a way that is different from cl$cluster which is why I changed the palette before plotting the points. You should see that they now are ordered from bottom to top of the last plot. You could also choose to create a vector with your colours and then use the value in cl$cluster to select the colours mycols - rainbow(n) plot(x,col = mycols[cl$cluster]) Tom -Original Message- From: Asha Jayanthi [mailto:[EMAIL PROTECTED] Sent: Thursday, 31 March 2005 9:17 AM To: r-help@stat.math.ethz.ch Subject: RE: [R] 2d plotting and colours Thank you very much. the code plot(x, col = s) points(cl$centers, col = s, pch = 8, cex=2) does not plot the points according to the group colors. The plots are used to identify the groups by colors That could be done by plot(x, col = cl$cluster) This means that we need to set the default colours , say col = cl$cluster = a set of group numbers say 1...10 should produce 10 distinct colours points grouped by colour. how to do this when you have more than 8 group colours to plot From: Mulholland, Tom [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch,Asha Jayanthi [EMAIL PROTECTED] Subject: RE: [R] 2d plotting and colours Date: Wed, 30 Mar 2005 15:59:46 +0800 And getting back to your question about the palette there are a lot of ways to do this assuming you have just started a session palette() # will give #[1] black red green3 bluecyan #[6] magenta yellow gray palette(rainbow(24)) # There's also 'heat.colors' 'topo.colors' palette() # [1] red #FF4000 #FF8000 # [4] #FFBF00 yellow #BFFF00 # [7] #80FF00 #40FF00 green #[10] #00FF40 #00FF80 #00FFBF #[13] cyandeepskyblue #0080FF #[16] #0040FF blue#4000FF #[19] #8000FF #BF00FF magenta #[22] #FF00BF #FF0080 #FF0040 palette(rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.))) palette() # [1] black #11 #22 #33 #44 # [6] #55 #66 #77 #88 #99 #[11] #AA #BB #CC #DD red2 #[16] red If you are looking to use colours that take account of colour blindness you could try the package dichromat. (I think 2.1 will have some of this inbuilt) Once you look through the help files associated with some of these options you will find the way that best suits your method of working. Tom -Original Message- From: Uwe Ligges [mailto:[EMAIL PROTECTED] Sent: Wednesday, 30 March 2005 3:18 PM To: TEMPL Matthias Cc: r-help@stat.math.ethz.ch; Asha Jayanthi Subject: Re: [R] 2d plotting and colours TEMPL Matthias wrote: Hi! There are more than 8 colors.
RE: [R] NA's?
is.na(diag(M)) - TRUE cmeans - colMeans(M, na.rm = TRUE) csd - apply(M, 2, sd, na.rm = TRUE) cvar - csd ^2 (or cvar - apply(M, 2, var, na.rm = TRUE) ) Using 'kmeans' on a matrix but 'ignoring the diagonal entries' just doesn't make sense as it stands, so I can't help you there. V. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Asha Jayanthi Sent: Thursday, 31 March 2005 3:48 PM To: r-help@stat.math.ethz.ch Subject: RE: [R] NA's? I am sorry about that. I like to do column mean, sd, var as well as kmeans on the matrix does this na.rm = TRUE work for such fuctions and only the diagonal is ignored? From: [EMAIL PROTECTED] To: [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] NA's? Date: Thu, 31 Mar 2005 11:42:05 +1000 Your message doesn't help us very much. You haven't said what kind of calculation it is you want to do, and that certainly matters. For example, for some kinds of computations the solution you started below would work fine: M - matrix(1:16, 4, 4) is.na(diag(M)) - TRUE M [,1] [,2] [,3] [,4] [1,] NA59 13 [2,]2 NA 10 14 [3,]37 NA 15 [4,]48 12 NA rowSums(M, na.rm = TRUE) [1] 27 26 25 24 colSums(M, na.rm = TRUE) [1] 9 20 31 42 You can also use apply( ) with functions that will accept missing values (and ignore them) for computations on either the rows or the columns. Hoping for a general mechanism that would somehow signal the diagonal values as values to be ignored in a general way is not a possibility. Just as a curiosity, what were you hoping that na.omit(M) would do? V. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Asha Jayanthi Sent: Thursday, 31 March 2005 11:22 AM To: r-help@stat.math.ethz.ch Subject: [R] NA's? I have a large matrix of data . The size of the matrix ranges from 100 x 100 to 1000 x 1000 Now i have to do computations on that. And should not consider the diagonal elements. I tried setting diag(M) = NA and M = na.omit(M). But this omits all the rows. I only want to omit that diagonal elements only but consider the whole row. diag(M) = 0 seems like a good option but this will affect my result. How to proceed with this. How to just ignore some specific values. what if i want to consider only the upper / lower triangular matrix Asha http://adfarm.mediaplex.com/ad/ck/4686-26272-10936-31?ck=RegSell Start your business. __ R-help@stat.math.ethz.ch 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://ads.mediaturf.net/event.ng/Type=clickFlightID=17307AdID=44925T argetID=9763Targets=9763Values=414,868,1093,2385Redirect=http:%2F%2Fw ww.icicibanknripromotions.com%2Fm2i_feb%2Fnri_M2I_feb.jsp%3Fadid%3D44925 %26siteid%3D1093%26flightid%3D17307 Get a FREE 30 minute India Calling Card. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] how i can get input from user input
BertG == Berton Gunter [EMAIL PROTECTED] on Wed, 30 Mar 2005 10:09:38 -0800 writes: BertG If you are on Windows and want to go GUI, see BertG ?choose.files, ?winMenuAdd, ?winDialog, ?select.list with the big drawback that it will only work on Windows. As Uwe says below, it depends on your context; for relative simple things, however please consider a portable solution, using menu(), readline(), .. BTW, menu() has been improved in R 2.1.0 (alpha -- please test!), and is now connected with select.list() which should work on all platforms (and uses tcltk on Linux when available). Martin Maechler, ETH Zurich BertG -- Bert Gunter BertG Genentech Non-Clinical Statistics BertG South San Francisco, CA BertG The business of the statistician is to catalyze the scientific learning BertG process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Snow Sent: Wednesday, March 30, 2005 9:45 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] how i can get input from user input Also look at ?readline Greg Snow, Ph.D. Statistical Data Center [EMAIL PROTECTED] (801) 408-8111 Uwe Ligges [EMAIL PROTECTED] 03/29/05 11:43PM Cuichang Zhao wrote: Hello, Could you please tell me how i can get an input from the user in R? Depends on the kind of input. See, e.g., ?scan or ?menu Uwe Ligges C-Ming Mar 29, 2005 - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html BertG __ BertG R-help@stat.math.ethz.ch mailing list BertG https://stat.ethz.ch/mailman/listinfo/r-help BertG PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problems with lpSolve/Memory ? R crashes
Unfortunately, I can't tell you how to solve this problem. However, I can confirm that this crash happens also on my machines (R 2.0.1 on Debian Sarge, AMD Athlon, 750 MHz, 256 MB RAM and R 2.0.0 on SuSE 9.0, Intel P4, 2.6 GHz, 512 MB RAM): R aaa(1000) alloc of 8 bytes failed alloc of 4 bytes failed Speicherzugriffsfehler We had a model, which consists of 1000+ linear programs with each about 550 rows and 1100 columns (http://www.unipr.it/arpa/dipseq/EAAE/PR/Parallel/ 42b4_henningsen.pdf). On MS-Windows 2000/XP this model always crashed after some hundreds linear programs, but using Linux on the same machines it _never_ crashed. I really can't see the reason why our much larger programs worked, but these small programs let R crash. I hope that this information may help to solve this problem. Arne On Wednesday 30 March 2005 12:16, TEMPL Matthias wrote: Hello! I have a curious problem, which I cannot solve. With my code I solve thousands of small linear programs with the package lpSolve automatically. But R crashes sometimes (~always, but always on different linear programs) in a strange way. For illustration, I tried to prepare a simple example, which shows the nature of the problem. The function aaa (see below) declares some constants (only in this special example) and in the end it solves the linear program. aaa(1) [,1] [,2] [1,]00 [2,]00 [3,]00 [4,]00 [5,] 520 [6,]22 [7,]00 [8,]20 [9,]00 [10,]00 [11,]00 [12,]00 [13,] 540 Works fine. Now I make the *same* calculation, say 1000 times: aaa(1000) R (I have tried it with R2.0.1, 2.0.0, 1.9.1, 2.1.0dev) crashes completly - without warning and error message under Windows XP, Intel Pentium 3 with 256 MB RAM Under Linux SuSe 8.2 R (2.0.1) it crashes again, but in this case I get the following message: Calloc of 40004 bytes failed on line 114 of file lpkit.c ... Calloc of 80008 bytes failed on line 113 of file lpkit.c Error: cannot allocate vector of size 3 Kb Now I´m completly lost. Solving the linear program one time makes no problem. Solving it twice in the same way makes no problem either. Running the same calculation, say 1000 times, causes a crash. Why should there be a problem with memory? For any hint, I would be really happy. Thank you, Matthias ### -- function aaa aaa - function(amount=1){ f.obj - rep(0,33) w - c(3,4,5,6,11,13,17,22,25,26,27,28,33) m - matrix(c(0,0,1,1,1,1,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 , 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,0,0,0,0,1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0, 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0, 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,1 ),ncol=33,byrow=TRUE) f.dir - c(=,=,=,=,=,=,=,=,=,=,=, =,=,=,=,=,=,=,=,=,=,=,=, =,=,=,=,=,=,=,=,=,=) f.rhs - c(-52,0,54,0,2,0,0,0,0,0,0,0,0,0) lp.out - matrix( ncol = 2, nrow = 13 ) for(ii in 1:amount){ # - simple iterate the same for( i in 1:13 ){ f.obj[ w[i] ] - 1 lp.out[ i, 1 ] - lp(min, f.obj, m, f.dir, f.rhs)$objval lp.out[ i, 2 ] - lp(max, f.obj, m, f.dir, f.rhs)$objval f.obj - rep( 0, 33 ) } } lp.out } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 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/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Finding the height of a line of text for axis
Thanks for your reply. On Wed, Mar 30, 2005 at 08:03:10AM -0600, Marc Schwartz wrote: or even something like this: plot(1:5, axes = FALSE) axis(1, col.axis = white, col = red, tcl = 1) axis(1, col.axis = white, col = white, tcl = 0) axis(2, col.axis = white, col = red, tcl = 1) axis(2, col.axis = white, col = white, tcl = 0) This is the effect I am trying to achieve. I did try the route of overdrawing in white, but decided against it. The reason I haven't used that, is that firstly I wasn't sure if there would be some rounding error in a printer which would cause the background to appear. Secondly, the end of the ticks look weird due to the different line end types: http://www.cl.cam.ac.uk/users/sjm217/volatile/r-lineend.png Changing to square caps might help, but I was hoping there would be a nice solution that would let me keep round caps. Any suggestions? Thank you, Steven Murdoch. -- w: http://www.cl.cam.ac.uk/users/sjm217/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Cox model qustion in R
Dear all, I have a beginner's R question for coxph() and survfit(). I have a data set with survival time (no censoring) and treatment indicator(0/1). I did something like fit-coxph( Surv(t)~treat, method=breslow,data=data) fit Call: coxph(formula = Surv(t) ~ treat, data = data, method = breslow) coef exp(coef) se(coef) z p treat -1.96 0.1400.243 -8.07 6.7e-16 Likelihood ratio test=80.3 on 1 df, p=0 n= 144 plot(survfit(fit)) But it only gives me the curve with combined treatment. How do I get a plot with two curves for different treatments. I don't want to do new-data.frame(treat=c(0,1)) and plot(survfit(fit,newdata=new)) cause it gives you predicted curves for two treatments. Thanks you so much for your help. Jimmy Chu [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Finding the height of a line of text for axis
Hi Steven J. Murdoch wrote: Thanks for your reply. On Wed, Mar 30, 2005 at 08:03:10AM -0600, Marc Schwartz wrote: or even something like this: plot(1:5, axes = FALSE) axis(1, col.axis = white, col = red, tcl = 1) axis(1, col.axis = white, col = white, tcl = 0) axis(2, col.axis = white, col = red, tcl = 1) axis(2, col.axis = white, col = white, tcl = 0) This is the effect I am trying to achieve. I did try the route of overdrawing in white, but decided against it. The reason I haven't used that, is that firstly I wasn't sure if there would be some rounding error in a printer which would cause the background to appear. Secondly, the end of the ticks look weird due to the different line end types: http://www.cl.cam.ac.uk/users/sjm217/volatile/r-lineend.png Changing to square caps might help, but I was hoping there would be a nice solution that would let me keep round caps. Any suggestions? The function GConvertYUnits() (and the functions it calls) are in the file graphics.c (same directory as plot.c), but I'd book a week off before trying to trace the calculations performed therein. A more accurate calculation than ... l-par(cxy)[2]*par(tcl) ... is ... l-par(cin)[2]/par(pin)[1]*diff(par(usr)[1:2])*par(tcl) ... but that still needs par(cex) and a par(mex) multipliers to be (possibly) fully par() compliant. This general replicate-par()-in-R-code route is likely to be a recipe for unhappiness. Some sort of overplotting trick is probably a better choice if you can cope with the compromise. The following variation on Marc's suggestion might provide a slight improvement: plot(1:5, axes = FALSE) axis(1, col.axis = white, col = red, tcl = 1) axis(2, col.axis = white, col = red, tcl = 1) box(col=white) Something like box(col=white, lwd=1.1) could be used to allay fears of axes peeking through from behind. Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Re:Plotting to A4 and replacing x-axis with actual years.
I think you need to read the posting guide (see the bottom of each post made) and once you have done this take some time to compose your message. The issue is that I have too little information about what you have done. It looks to me as if you are using postscript, but I am not sure if you have plotted your 3 x 3 array to the device and used the command parameter or if your reference to written commands is actually the 'postscript' command. Specifically the posting guide notes that a small reproducible example of the issue that you are facing will make it much easier for people to help you. It also talks about the need to identify the hardware that you are using as for certain processes the answer is quite different in Windows than it is in some flavour of Unix. The same is true of your second inquiry. Dummy code would make it easier to see what you are doing. Tom -Original Message- From: Marshall Mdoka [mailto:[EMAIL PROTECTED] Sent: Wednesday, 30 March 2005 10:47 PM To: r-help@stat.math.ethz.ch Subject: [R] Re:Plotting to A4 and replacing x-axis with actual years. Hie, I have written before and probably missed the reply. 1.) I have my figures in a 3X3 array and want to fit them onto a A4 size page. I have written commands to try a represent them in eps format but still their cutting out information. 2.) I have an odd number of years and wanted to represent them say 1980 1985 1990 1995 2000 instead of 1 5 10 etc. However, the years are not overwritting in the year I want since the first year in my x-axis is 1979 which is year 1 and year 5 being 1984. Could you please help especially on the first problem. Thanking you in advance, Marshall Mdoka __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] 2d plotting and colours
Thank you very much. the code plot(x, col = s) points(cl$centers, col = s, pch = 8, cex=2) does not plot the points according to the group colors. The plots are used to identify the groups by colors That could be done by plot(x, col = cl$cluster) This means that we need to set the default colours , say col = cl$cluster = a set of group numbers say 1...10 should produce 10 distinct colours points grouped by colour. how to do this when you have more than 8 group colours to plot From: Mulholland, Tom [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch,Asha Jayanthi [EMAIL PROTECTED] Subject: RE: [R] 2d plotting and colours Date: Wed, 30 Mar 2005 15:59:46 +0800 And getting back to your question about the palette there are a lot of ways to do this assuming you have just started a session palette() # will give #[1] black red green3 bluecyan #[6] magenta yellow gray palette(rainbow(24)) # There's also 'heat.colors' 'topo.colors' palette() # [1] red #FF4000 #FF8000 # [4] #FFBF00 yellow #BFFF00 # [7] #80FF00 #40FF00 green #[10] #00FF40 #00FF80 #00FFBF #[13] cyandeepskyblue #0080FF #[16] #0040FF blue#4000FF #[19] #8000FF #BF00FF magenta #[22] #FF00BF #FF0080 #FF0040 palette(rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.))) palette() # [1] black #11 #22 #33 #44 # [6] #55 #66 #77 #88 #99 #[11] #AA #BB #CC #DD red2 #[16] red If you are looking to use colours that take account of colour blindness you could try the package dichromat. (I think 2.1 will have some of this inbuilt) Once you look through the help files associated with some of these options you will find the way that best suits your method of working. Tom -Original Message- From: Uwe Ligges [mailto:[EMAIL PROTECTED] Sent: Wednesday, 30 March 2005 3:18 PM To: TEMPL Matthias Cc: r-help@stat.math.ethz.ch; Asha Jayanthi Subject: Re: [R] 2d plotting and colours TEMPL Matthias wrote: Hi! There are more than 8 colors. Yes, e.g. for rgb space there are 16777216, see ?rgb. Uwe Ligges x - rbind(matrix(rnorm(100, sd = 0.3), ncol = 2), matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2)) (cl - kmeans(x, i, 20)) s - c(tomato4, turquoise, slateblue, wheat, snow, skyblue, peru, pink) # see at: colors() plot(x, col = s) points(cl$centers, col = s, pch = 8, cex=2) Best, Matthias Hi! I am new to R just 3 days in it and i apologize if my questions seem very trivial and consumed your valuable time. I am coding in perl and i stumbled upon R regarding plotting good statistical graphs. I tried the kmean clustering for a large matrix ,say 150 * 150 . I tried the example code given in the tutorial to perform 2d plot # i ranges from 2 to 10 cl - kmeans(x, i, 20) plot(x, col = cl$cluster) points(cl$centers, col = 1:i ) I see that there are only 8 colours defined , namely black,red,green,blue,cyan,magenta,yello,gray. How should i set my colour preferences to obtain my palette of colours? I checked in the totorial which talks about R.colors and palatte , but i failed to understand how to set it. Thank You Asha MSN Messenger! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Cinema! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] NA's?
I have a large matrix of data . The size of the matrix ranges from 100 x 100 to 1000 x 1000 Now i have to do computations on that. And should not consider the diagonal elements. I tried setting diag(M) = NA and M = na.omit(M). But this omits all the rows. I only want to omit that diagonal elements only but consider the whole row. diag(M) = 0 seems like a good option but this will affect my result. How to proceed with this. How to just ignore some specific values. what if i want to consider only the upper / lower triangular matrix Asha http://adfarm.mediaplex.com/ad/ck/4686-26272-10936-31?ck=RegSell Start your business. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Contingency table: logistic regression
Hi, I am analyzing a data set with greater than 1000 independent cases (collected in an unrestricted manner), where each case has 3 variables associated with it: one, a factor variable with 0/1 levels (called XX), another factor variable with 8 levels (X) and a third response variable with two levels (Y: 0/1). I am trying to see if X1 has an effect on the relationship between X2 and the proportion of 1-s in Y. I have three questions: a) I have never used glm-s for this or any other sort of analysis before today, so am I interpreting the output correctly ? After setting options(contrasts=c(contr.treatment,contr.poly)) I did: ~~Begin R output~~ Call: glm(formula = Y ~ X * Fac, family = binomial, data = mat, subset = sactype 3 numstim == 16) Deviance Residuals: Min 1Q Median 3Q Max -2.232 -0.901 0.416 0.985 1.656 Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept)2.405 0.209 11.52 2e-16 *** X2-2.511 0.293 -8.57 2e-16 *** X3-3.283 0.286 -11.47 2e-16 *** X4-2.009 0.302 -6.653e-11 *** X5-3.098 0.276 -11.22 2e-16 *** X6-2.580 0.288 -8.97 2e-16 *** X7-3.484 0.288 -12.09 2e-16 *** X8-2.811 0.328 -8.56 2e-16 *** Fac -1.558 0.721 -2.16 0.03071 * X2:Fac 2.133 0.9422.26 0.02351 * X3:Fac 1.848 0.9321.98 0.04748 * X4:Fac 2.836 0.9822.89 0.00386 ** X5:Fac 3.263 0.9453.45 0.00056 *** X6:Fac 3.630 0.9713.74 0.00018 *** X7:Fac 3.256 0.8833.69 0.00023 *** X8:Fac 3.350 1.0003.35 0.00081 *** --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 1619.4 on 1178 degrees of freedom Residual deviance: 1271.2 on 1163 degrees of freedom AIC: 1303 Number of Fisher Scoring iterations: 5 End R output~~~ I am reading this like this: each of the X2X8 terms tell me whether the proportions associated with those factors at level 0 of Fac, are different from the proportion associated with factor X1 for level 0 of Fac. And each of the terms associated with Fac (X2:Fac,...X8:Fac) is telling me whether the difference between X2...X8 and X1 is different for Fac=0 and Fac=1; and this is the same thing as whether the proportion associated with X2..X8 are different for the two levels of Fac. So these X2...X8:Fac terms are like performing a simple 2x2 analysis of the effect of Fac on Y, given X2 (X8). How much of this is incorrect ? My other two questions are: b) Is this the right way to approach this analysis in R ? Or am I better off reading about multi-way contingency table analyses and using them ? and c) How do I incorporate a correction for multiple-testing into the above analysis ? The effect of Fac on the relationship between X and Y was planned. I would greatly, and respectfully appreciate all pointers, tips and admonitions. Thank you Suresh __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re: Contingency table: logistic regression
Oops, I corrected some errors in the first paragraph; sorry for the repeated posting. Suresh ~~ Hi, I am analyzing a data set with greater than 1000 independent cases (collected in an unrestricted manner), where each case has 3 variables associated with it: one, a factor variable with 0/1 levels (called Fac), another factor variable with 8 levels (X) and a third response variable with two levels (Y: 0/1). I am trying to see if Fac has an effect on the relationship between X and the proportion of 1-s in Y. I have three questions: a) I have never used glm-s for this or any other sort of analysis before today, so am I interpreting the output correctly ? After setting options(contrasts=c(contr.treatment,contr.poly)) I did: ~~Begin R output~~ Call: glm(formula = Y ~ X * Fac, family = binomial, data = mat, subset = sactype 3 numstim == 16) Deviance Residuals: Min 1Q Median 3Q Max -2.232 -0.901 0.416 0.985 1.656 Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept)2.405 0.209 11.52 2e-16 *** X2-2.511 0.293 -8.57 2e-16 *** X3-3.283 0.286 -11.47 2e-16 *** X4-2.009 0.302 -6.653e-11 *** X5-3.098 0.276 -11.22 2e-16 *** X6-2.580 0.288 -8.97 2e-16 *** X7-3.484 0.288 -12.09 2e-16 *** X8-2.811 0.328 -8.56 2e-16 *** Fac -1.558 0.721 -2.16 0.03071 * X2:Fac 2.133 0.9422.26 0.02351 * X3:Fac 1.848 0.9321.98 0.04748 * X4:Fac 2.836 0.9822.89 0.00386 ** X5:Fac 3.263 0.9453.45 0.00056 *** X6:Fac 3.630 0.9713.74 0.00018 *** X7:Fac 3.256 0.8833.69 0.00023 *** X8:Fac 3.350 1.0003.35 0.00081 *** --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 1619.4 on 1178 degrees of freedom Residual deviance: 1271.2 on 1163 degrees of freedom AIC: 1303 Number of Fisher Scoring iterations: 5 End R output~~~ I am reading this like this: each of the X2X8 terms tell me whether the proportions associated with those factors at level 0 of Fac, are different from the proportion associated with factor X1 for level 0 of Fac. And each of the terms associated with Fac (X2:Fac,...X8:Fac) is telling me whether the difference between X2...X8 and X1 is different for Fac=0 and Fac=1; and this is the same thing as whether the proportion associated with X2..X8 are different for the two levels of Fac. So these X2...X8:Fac terms are like performing a simple 2x2 analysis of the effect of Fac on Y, given X2 (X8). How much of this is incorrect ? My other two questions are: b) Is this the right way to approach this analysis in R ? Or am I better off reading about multi-way contingency table analyses and using them ? and c) How do I incorporate a correction for multiple-testing into the above analysis ? The effect of Fac on the relationship between X and Y was planned. I would greatly, and respectfully appreciate all pointers, tips and admonitions. Thank you Suresh __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html