Re: [R] Matrix Multiplication, Floating-Point, etc.
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Talbot Katz Sent: Monday, July 30, 2007 10:55 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Subject: Re: [R] Matrix Multiplication, Floating-Point, etc. Thank you for responding! I realize that floating point operations are often inexact, and indeed, the difference between the two answers is within the all.equal tolerance, as mentioned in FAQ 7.31 (cited by Charles): (as.numeric(ev1%*%ev2))==(sum(ev1*ev2)) [1] FALSE all.equal((as.numeric(ev1%*%ev2)),(sum(ev1*ev2))) [1] TRUE I suppose that's good enough for numerical computation. But I was still surprised to see that matrix multiplication (ev1%*%ev2) doesn't give the exact right answer, whereas sum(ev1*ev2) does give the exact answer. I would've expected them to perform the same two multiplications and one addition. But I guess that's not the case. However, I did find that if I multiplied the two vectors by 10, making the entries integers (although the class was still numeric rather than integer), both computations gave equal answers of 0: xf1-10*ev1 xf2-10*ev2 (as.numeric(xf1%*%xf2))==(sum(xf1*xf2)) [1] TRUE Perhaps the moral of the story is that one should exercise caution and keep track of significant digits. -- TMK -- 212-460-5430 home 917-656-5351 cell There may other issues involved here besides R version, floating point precision, and OS version. On my WinXP system running R-2.5.1 binary from CRAN, I get what you expected: ev2-c(0.8,-0.6) ev1-c(0.6,0.8) ev1%*%ev2 [,1] [1,]0 There could be differences in OS release, service packs installed, cpu, etc. But the moral you draw is probably a reasonable one. Dan Daniel Nordlund Bothell, WA __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] zoo, ts and data.frames
zoo already can handle multivariate data so you can just use that directly rather than using data frames. See the examples in ?plot.zoo and ?xyplot.zoo On 7/30/07, Edna Bell [EMAIL PROTECTED] wrote: Hi R gurus: I have some zoo objects that I have put into a data.frame. However, when I try to plot the objects from the data frame, the x axis is now Index rather than time Is there a sort of zoo data frame or a multiple zoo object, please? Thanks for any help! Sincerely, Edna [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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Call R program from C++ code
Hi Feng, You cannot compile R scripts as a shared library. You can compile the R engine itself (interpreter and some basic functions) as .dll (or .so), dynamically load it during run time of your application and call its low level functions. All details are in the Writing R extensions manual, installed with R (%R_HOME%/doc/R-exts.pdf). Searching Google with embedding R gives the following (outdated) link http://developer.r-project.org/embedded.html This says basic things and references the Writing R Extensions manual. You can see the Rgnome sources for example. Monday, July 30, 2007, 10:25:16 PM, you wrote: K Hi Vladimir: K Thank you very much! I'm very interested in this sentence: R can K be compiled as a shared library object, that you can dynamically load from K your application and use its functions. That's would be great if R programs K can be compiled as shared library object(.lib? or .dll ? ) Can you please K give more details about that? K Best, K Feng K -Original Message- K From: [EMAIL PROTECTED] K [mailto:[EMAIL PROTECTED] On Behalf Of Vladimir Eremeev K Sent: 2007年7月30日 5:16 K To: r-help@stat.math.ethz.ch K Subject: Re: [R] Call R program from C++ code K Writing R Extensions manual contains chapters dedicated to parsing and K evaluating of the R extensions from C. K Also, I vaguely remember I've seen something like Embedding R somewhere in K manuals. K R can be compiled as a shared library object, that you can dynamically load K from your application and use its functions. K R doesn't have a compiler, it's the interpreted language. K However, it can parse a character string representing an expresstion and K transform it into the internal form, ready for evaluation. K Feng Qiu wrote: Hi All: I'm developing an application program using C++. From my C++ code, I would call some R program I have written. I' wondering if R provide some compiler that can compile R program into executable program. I searched R-help, there are a lot of posts talking about writing C++ code in R program, but few about calling R from C++. I might be wrong that R doesn't have complier. What I'm trying to do is to call R program from C++ code. Any help is highly appreciated! -- Best regards, Vladimirmailto:[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Prompt comes too late
Using print() for a 'prompt' is rather unusual: people normally use message() or cat(). You haven't told us your OS, but if this is Windows, see rw-FAQ Q7.1. On Sun, 29 Jul 2007, Ralf Finne wrote: Hi R fans I am trying to make a program to ask the user to choose data file: print(Choose data file please !) matr=read.table(file.choose(),dec=.,header=TRUE) The problem is that the prompt Choose data file please ! comes after I have chosen the file. What am doing wrong? Thanks in advance Ralf Finne __ 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 and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with ROC curve
Hi Ritesh, may be i can help, but yeah i will try ? you can reach help to ROCR package by help.search(ROCR) What is the structure of your data ? can you give some sample i.e. few lines of your dataset ? To build ROC curve using only PSA(variable) alone of the original cohort against the ROC of the Model of the original cohort. what do you intend to do, please clarify more ? it sounds like you have been given tutorial, or you are working this for corporate ? :) cheers Rithesh M. Mohan [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 07/30/2007 01:06 PM To r-help@stat.math.ethz.ch cc Subject [R] help with ROC curve Hi I'm new to stats and R, so can you please help me or guide me building ROC curve in an elaborate way with codes I loaded ROCR package, but I'm not sure how to use it. Requirement To build ROC curve using only PSA(variable) alone of the original cohort against the ROC of the Model of the original cohort. It would be really great if you could help me with this. Thanks Rithesh M Mohan [[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 and provide commented, minimal, self-contained, reproducible code. DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}} __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] deseasonalizing package?
Hi all- I am looking for a way to calculate and subtract out a seasonal trend (i.e. carbon dioxide). Does anyone know if there is a package that does something similar? thanks! sherri __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Reading T and F as strings
Hi, I am trying to read a series of stock tickers into R, and I'm running into trouble with Ford (F) and the old ATT (T). Read.table seems to interpret these as boolean values instead of strings, even when I set colColumns to a vector of character(0)'s. Is there a way to convince it to read them as strings? Thanks in advance for the help, David __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to combine data of several csv-files
Hi Jim, that's exactly what I'm looking for. Thank you so much. I think, I should look for some further documentation on list handling. Many thanks also to [EMAIL PROTECTED] ;) for spending time in finding a solution... Have a nice day! Antje jim holtman schrieb: This should do it: v1 - NA v2 - rnorm(6) v3 - rnorm(6) v4 - rnorm(6) v5 - rnorm(6) v6 - rnorm(6) v7 - rnorm(6) v8 - rnorm(6) v8 - NA list - list(v1,v2,v3,v4,v5,v6,v7,v8) categ - c(NA,cat1,cat1,cat1,cat2,cat2,cat2,NA) # create partitioned list list.cat - split(list, categ) # combine each partition into a matrix list.mat - lapply(list.cat, function(x) do.call('rbind', x)) # now take the means of each column lapply(list.mat, colMeans) $cat1 [1] -0.5699080 0.3855693 1.1051809 0.2379324 0.6684713 0.3240003 $cat2 [1] 0.38160462 -0.10559496 -0.40963090 -0.09507354 0.95021406 -0.31491450 On 7/30/07, Antje [EMAIL PROTECTED] wrote: okay, I played a bit around and now I have some kind of testcase for you: v1 - NA v2 - rnorm(6) v3 - rnorm(6) v4 - rnorm(6) v5 - rnorm(6) v6 - rnorm(6) v7 - rnorm(6) v8 - rnorm(6) v8 - NA list - list(v1,v2,v3,v4,v5,v6,v7,v8) categ - c(NA,cat1,cat1,cat1,cat2,cat2,cat2,NA) list [[1]] [1] NA [[2]] [1] -0.6442149 -0.2047012 -1.1986041 -0.2097442 -0.7343465 -1.3888750 [[3]] [1] 0.02354036 -1.36186952 -0.42197792 1.50445971 -1.76763996 0.53722404 [[4]] [1] -1.40362589 0.13045724 -0.84651458 1.57005071 0.06961015 0.25269771 [[5]] [1] -1.1829260 2.1411553 -0.1327081 -0.1053442 -0.8179396 -1.2342698 [[6]] [1] 1.17099178 0.49248118 -0.18690065 1.50050976 -0.65552410 -0.01243247 [[7]] [1] -0.046778203 -0.233788840 0.443908897 -1.649740180 0.003991354 -0.228020092 [[8]] [1] NA now, I need the means (and sd) of element 1 of list[2],list[3],list[4] (because they belong to cat1) and = mean(-0.6442149, 0.02354036, -1.40362589) the same for element 2 up to element 6 (-- I would the get a vector containing the means for cat1) the same for the vectors belonging to cat2. does anybody now understand what I mean? Antje __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading T and F as strings
Try this: Lines - Stock + T + F + DF - read.table(textConnection(Lines), header = TRUE, +colClasses = character) class(DF$Stock) [1] character On 7/30/07, David Rowntree [EMAIL PROTECTED] wrote: Hi, I am trying to read a series of stock tickers into R, and I'm running into trouble with Ford (F) and the old ATT (T). Read.table seems to interpret these as boolean values instead of strings, even when I set colColumns to a vector of character(0)'s. Is there a way to convince it to read them as strings? Thanks in advance for the help, David __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Prompt comes too late
You can use choose.files(caption=Choose data file please!,multi=FALSE,filters=Filters[All]) This will show the prompt in the file selection dialog and also allows you to restrict the list of possible choises with a filter. Ralf Finne wrote: I am trying to make a program to ask the user to choose data file: print(Choose data file please !) matr=read.table(file.choose(),dec=.,header=TRUE) The problem is that the prompt Choose data file please ! comes after I have chosen the file. -- View this message in context: http://www.nabble.com/Prompt-comes-too-late-tf4178913.html#a11919327 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Kombination Regression mit AR/MA Prozess?
Sehr geehrte Damen und Herren Im Rahmen meiner Lizentiatsarbeit am Lehrstuhl Wirtschaftsgeschichte von Prof. Woitek arbeite ich mit der R Software um Einkommenselastizitäten zu schätzen (log-log regressionen). ich habe zuerst eine Elastizitätenschätzung gemacht lm(lM~lPfPx+lY). Dank dwtest(lM~lPfPx+lY) wurde ich gewahr, dass die Residuen zu stark autokorelliert sind. Nach der Betrachtung der ACF und PACF Funktionen erscheint mir ein AR(1) am passendsten. deshalb hab ich arima(x = lM, order = c(1, 0, 0)) geschätzt. *Mit welchem Befehl* kann ich nun aber beides (log-log Regression und AR-oder MA-Prozess) kombinieren und folgende Regressionsgleichung schätzen: LogM~b0*Log(alpha)+b1*Log(Pf/Px)+b2*Log(Y)+b3*AR(1) ??? Besten Dank für Ihre prompte Hilfe. Freundliche Grüsse Raphael Illi __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] deseasonalizing package?
On Mon, 30 Jul 2007, Sherri Heck wrote: Hi all- I am looking for a way to calculate and subtract out a seasonal trend (i.e. carbon dioxide). Does anyone know if there is a package that does something similar? Yes, package 'stats'. Try help.search(seasonal). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading T and F as strings
On Mon, 30 Jul 2007, David Rowntree wrote: Hi, I am trying to read a series of stock tickers into R, and I'm running into trouble with Ford (F) and the old ATT (T). Read.table seems to interpret these as boolean values instead of strings, even when I set colColumns to a vector of character(0)'s. Is there a way to convince it to read them as strings? Set 'colClasses' to a vector of character, just as the help file for read.table says. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBUGS more updates after model did not converge
[EMAIL PROTECTED] wrote: After running a model for a while and seeing that it did not converge yet, how can I continue to run, ie not starting anew, the model? I know if I manually/interactively use winbugs, this is possible anytime, but how can I do this in r2winbugs, so that my existing sim$sims.array and other stuff in the object that bugs() returns gets extended? This is not possible with R2WinBUGS. But you can use BRugs, which is much more flexible, has an improved interface and uses OpenBUGS. It's CRAN version is based on OpenBUGS 2.x.y, but we (i.e. currently mainly Insightful people and myself) are on the way to release a new version based on OpenBUGS 3.x.y. Uwe Ligges Thanks Toby __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Odp: array loop
Hi as you say that the computing is part of a function than the best way to see what is hapenning is to use debug(your.function) see ?debug for options. Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 31.07.2007 00:11:00: Dear all, here are two arrays: region(26,31,8), nation(8) I tried to get a new array, say, giGi(26,31,8) giGi - array(0,dim = c(region_dim)) for (i in (1:region_dim[3])) { giGi[,,i] = region[,,i]-nation[,i] } As the above is part of function, but results shows only giGi[,,1] has the right answers, all the others (giGi[,,2],..giGi[..8]) are zeros. I have checked array of region and nation, they are not zeros at all when I do manually, it is not the case, giGi has meanful numbers. can some one tell me the trick in this process?? Many thanks in advance. Dong [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to combine data of several csv-files
Hi Jim, that's exactly what I'm looking for. Thank you so much. I think, I should look for some further documentation on list handling. I think I will do the same... Thanks to Jim I learned textConnection and rowMeans. Jim, could you please go a step further and tell me how to use lapply to calculate the sd instead of the mean of the same items? I mean sd(-0.6442149 0.02354036 -1.40362589) sd(-1.1829260 1.17099178 -0.046778203) sd(-0.2047012 -1.36186952 0.13045724) etc x - read.table(textConnection( v1 v2 v3 v4 v5 v6 v7 v8 NA -0.6442149 0.02354036 -1.40362589 -1.1829260 1.17099178 -0.046778203 NA NA -0.2047012 -1.36186952 0.13045724 2.1411553 0.49248118 -0.233788840 NA NA -1.1986041 -0.42197792 -0.84651458 -0.1327081 -0.18690065 0.443908897 NA NA -0.2097442 1.50445971 1.57005071 -0.1053442 1.50050976 -1.649740180 NA NA -0.7343465 -1.76763996 0.06961015 -0.8179396 -0.65552410 0.003991354 NA NA -1.3888750 0.53722404 0.25269771 -1.2342698 -0.01243247 -0.228020092 NA), header=TRUE) __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Extracting random parameters from summary lme and lmer
LS, I'm estimating multilevel regression models, using the lme-function from the nlme-package. Let's say that I estimated a model and stored it inside the object named 'model'. The summary of that model is shown below: Using summary(model)$tTable , I receive the following output: summary(model)$tTable Value Std.Error DF t-value p-value (Intercept)0.23268607 0.09350662 3990 2.4884449 1.287080e-02 sexM -0.15338225 0.03169762 3990 -4.8389206 1.354802e-06 standLRT 0.38593558 0.01677195 3990 23.0107762 4.005182e-110 vrmid 50% 0.07606394 0.09389376 61 0.8101064 4.210281e-01 vrtop 25% 0.24561327 0.10483374 61 2.3428838 2.241317e-02 intakemid 50% -0.41469716 0.03177240 3990 -13.0521199 3.698344e-38 intaketop 25% -0.75920783 0.05357980 3990 -14.1696648 1.666780e-44 typeSngl 0.15680532 0.07173835 61 2.1857949 3.267903e-02 All looks fine to me. The output above is simply a section from the full summary shown below. Now, I want to extract from the summary (or the full model) the part stating the random parameters. More specifically, I want to extract from the summary the following: (Intercept) 0.2869401 (Intr) typeSngl0.2791040 -0.617 Residual0.7302233 How could this be done, and how can the same be done using the lmer- function from the lme4-package? Thanks for the effort, Rense Nieuwenhuis Linear mixed-effects model fit by REML Data: Exam AIC BIC logLik 9158.56 9234.241 -4567.28 Random effects: Formula: ~type | school Structure: General positive-definite, Log-Cholesky parametrization StdDevCorr (Intercept) 0.2869401 (Intr) typeSngl0.2791040 -0.617 Residual0.7302233 Fixed effects: normexam ~ sex + standLRT + vr + intake + type Value Std.Error DFt-value p-value (Intercept)0.2326861 0.09350662 3990 2.488445 0.0129 sexM -0.1533822 0.03169762 3990 -4.838921 0. standLRT 0.3859356 0.01677195 3990 23.010776 0. vrmid 50% 0.0760639 0.09389376 61 0.810106 0.4210 vrtop 25% 0.2456133 0.10483374 61 2.342884 0.0224 intakemid 50% -0.4146972 0.03177240 3990 -13.052120 0. intaketop 25% -0.7592078 0.05357980 3990 -14.169665 0. typeSngl 0.1568053 0.07173835 61 2.185795 0.0327 Correlation: (Intr) sexM stnLRT vrm50% vrt25% int50% int25% sexM -0.201 standLRT -0.125 0.028 vrmid 50% -0.742 0.028 -0.035 vrtop 25% -0.652 0.051 -0.065 0.649 intakemid 50% -0.246 -0.011 0.541 -0.002 0.007 intaketop 25% -0.218 -0.018 0.676 0.014 0.013 0.660 typeSngl -0.421 0.080 0.007 0.033 -0.027 -0.001 0.001 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -3.59074329 -0.63776965 0.03829878 0.67303837 3.33952680 Number of Observations: 4059 Number of Groups: 65 [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Getting variable name used in function...
Dear Users, I am using functions for calculations in my study. I have two functions and one is calling the other two times one after another. But the called function deals with two different data object (matrix, data frame, etc.), so I could not make the second function output data object-free (for example, Ý would like to write csv files but could not give different file names) and I would like to get object name. Is it possible to get data object's name. And if it is possible, how can I assign this name as an new data object name with an extra addition, for example, data objects name+2. Thanks for your help. Example: function1(var1,var2) function2(var1) function2(var2) ... With my best regards, Levent TERLEMEZ. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] A simple question about summary.glm
michal33 wrote: Hello, I am new to R and have tried to search similar questions but could not find exactly what I am looking for, but I apologize if the question was already asked. I have 10 different treatments and want to know whether they affect the sex ratios of insect emergence. After running the glms I got this table: Df Deviance Resid. Df Resid. Dev F Pr(F) NULL133 9250.3 sex1481.5 132 8768.9 7.7212 0.006314 ** trt9 1099.1 123 7669.7 1.9585 0.049780 * But now I would like to know WHICH of the treatments was significant. I tried to use Tukey test but for some reason it does not work. My question is: I used the following function: summary(file.name, corr=F) and got the following table: Deviance Residuals: Min 1Q Median 3Q Max -14.118 -4.808 -1.4662.033 33.882 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 8.696e+00 1.893e+00 4.594 1.06e-05 *** sexm-3.791e+00 1.364e+00-2.779 0.00631 ** trtccc -1.050e+00 4.325e+00-0.243 0.80859 trtcga3 2.450e+00 4.325e+00 0.566 0.57211 trtcga4 -2.300e+00 4.325e+00-0.532 0.59584 trtg 1.550e+00 2.497e+00 0.621 0.53593 trtga4 -5.550e+00 4.325e+00-1.283 0.20183 trtp 5.422e+00 2.566e+00 2.113 0.03658 * trtpg -1.850e+00 2.497e+00-0.741 0.46019 trtw-3.634e-17 2.497e+00 -1.46e-17 1.0 trtwg -3.750e+00 2.497e+00-1.502 0.13573 What do the stars mean? Well, you omitted the last lines from the output which include: Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 i.e. *** for values 0.001; * for values in [0.01, 0.05) etc. Uwe Ligges Is it the same as Tukey test that tells me which treatment is different from which? i.e. is trtp (with *) significantly different to the control (which, by the way do not appear in this list and I do not know why)? Thanks Michal __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'non-standard' folder names in R package
Tao Shi wrote: Hi list, I use a .xml file for a function's demo in the R package I'm creating. Since it doesn't belong to any of the 'standard' folders, i.e. those mentioned in the 'Writing R Extension', I put it in a folder call myXML, much like the 'iris.xl' file in 'xls' folder from 'gdata' package, for example. After running R CMD build, I could see the .xml file is in the ..tar.gz file. However, after running R CMD INSTALL -build, the file and the folder disappeared in both the .zip file and the installed package. (R CMD CHECK, of course, failed too before that, as myXML can't be installed.) Could anybody tell me what's the tricks to keep those folders in my installation? I'm using R-2.5.1 under WinXP. Thank you very much! If you want it to be in mypackage/myXML after installation, put it into mypackage/inst/myXML in the source package, as the manual you cited suggests. Uwe Ligges Tao _ Need a brain boost? Recharge with a stimulating game. Play now! __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Getting variable name used in function...
Levent TERLEMEZ wrote: Dear Users, I am using functions for calculations in my study. I have two functions and one is calling the other two times one after another. But the called function deals with two different data object (matrix, data frame, etc.), so I could not make the second function output data object-free (for example, Ý would like to write csv files but could not give different file names) and I would like to get object name. Is it possible to get data object's name. And if it is possible, how can I assign this name as an new data object name with an extra addition, for example, data objects name+2. Thanks for your help. Example: function1(var1,var2) function2(var1) function2(var2) ... Can you explain what you want in an example, please? I do not really undertsand what you are trying to do. Uwe Ligges With my best regards, Levent TERLEMEZ. [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] the large dataset problem
(Ted Harding) wrote: On 30-Jul-07 11:40:47, Eric Doviak wrote: [...] Sympathies for the constraints you are operating in! The Introduction to R manual suggests modifying input files with Perl. Any tips on how to get started? Would Perl Data Language (PDL) be a good choice? http://pdl.perl.org/index_en.html I've not used SIPP files, but itseems that they are available in delimited format, including CSV. For extracting a subset of fields (especially when large datasets may stretch RAM resources) I would use awk rather than perl, since it is a much lighter program, transparent to code for, efficient, and it will do that job. On a Linux/Unix system (see below), say I wanted to extract fields 1, 1000, 1275, , 5678 from a CSV file. Then the 'awk' line that would do it would look like awk ' BEGIN{FS=,}{print $(1) , $(1000) , $(1275) , ... $(5678) ' sippfile.csv newdata.csv Awk reads one line at a tine, and does with it what you tell it to do. Yes, but notice that there are also options within R. If you use a carefully constructed colClasses= argument to read.table()/read.csv()/etc or what= argument to scan(), you don't get more columns than you ask for. The basic trick is to use NULL for each of the columns that you do NOT want, and preferably numeric or character or whatever for those that you want (NA lets read.table do it's usual trickery of guessing type from contents). However... I wrote a script which loads large datasets a few lines at a time, writes the dozen or so variables of interest to a CSV file, removes the loaded data and then (via a for loop) loads the next few lines I managed to get it to work with one of the SIPP core files, but it's SLW. See above ... Looking at the actual data files and data dictionaries (we're talking about http://www.bls.census.gov/sipp_ftp.html, right?), it looks like SIPP files are in a fixed-width format, which suggests that you might want to employ read.fwf(). If you want to get really smart about it, extract the 'D' fields from the dictionary files Try this dict - readLines(ftp://www.sipp.census.gov/pub/sipp/2004/l04puw1d.txt;) D.lines - grep(^D , dict) vdict - read.table(con - textConnection(dict[D.lines])); close(con) head(vdict) a little bit of further fiddling and you have the list of field widths and variable names to feed to read.fwf(). Just subset the name list and set the field width negative for those variables that you wish to skip. Extracting value labels from the V fields looks like it could be done, but requires more thinking, especially where they straddle multiple lines (but hey, it's your job, not mine...) -Peter D. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with code
Shawndelle Noble wrote: Hi I am having the following Warning message with this code: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file- reason 'No such file or directory' in: file(file, r) The files are present on a CD and USB key- I tried opening all the files-then running the script but, it makes no difference. Then you are trying to open non-existing files or your mistyped the filenames. Simply check the filenames again. Basically How do I ensure that R reads my files to perform functions- I have some files on CD and other on my a USB key. By specifying the correct names. Also if I am using script that was already written, for new data - how do I know which info. in the existing script should be updated? If the script (= function ?) is well written, you just have to give the filenames as arguments to the functions. If not, you have to look into the sources and generalize ... Uwe Ligges Thanks faith1 [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] deriv; loop
francogrex wrote: Hi, 2 questions: Question 1: example of what I currently do: for(i in 1:6){sink(temp.txt,append=TRUE) dput(i+0) sink()} x=scan(file=temp.txt) print(prod(x)) file.remove(C:/R-2.5.0/temp.txt) But how to convert the output of the loop to a vector that I can manipulate (by prod or sum etc), without having to write and append to a file? So, do you want the file at the end or not? If not: x - 1:6 prod(x) and if this is really the solution you want, the please read the posting guide and the manuals before posting again. Question 2: deriv(~gamma(x),x) expression({ .expr1 - gamma(x) .value - .expr1 .grad - array(0, c(length(.value), 1), list(NULL, c(x))) .grad[, x] - .expr1 * psigamma(x) attr(.value, gradient) - .grad .value }) BUT deriv3(~gamma(x),x) Error in deriv3.formula(~gamma(x), x) : Function 'psigamma' is not in the derivatives table What I want is the expression for the second derivative (which I believe is trigamma(x), or psigamma(x,1)), how can I obtain that? By using some algebraic software (rather than a numeric one) or contributing complete derivatives tables for the next R release. Uwe Ligges __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fwd: Package manual examples - 'unexpected$undefined' errors
David Pain wrote: Bounced first time! -- Forwarded message -- From: David Pain [EMAIL PROTECTED] Date: 28-Jul-2007 11:03 Subject: Package manual examples - 'unexpected$undefined' errors To: r-help@stat.math.ethz.ch Trying out an unfamiliar package, the natural thing is to use the examples given in the package's manual - hopefully, the writers of the package wouldn't include examples which didn't work! Recently, though, I've been getting 'unexpected$undefined' error messages when doing this, despite having copy/pasted the text from the manual (taking out hard breaks on the way). Well, we cannot know if the package does make problems (you haven't stated which one). Moreover, I've had error messages for commands which I've previously had work fine. For instance, this from Zelig z.out zelig(vote ~ race + educate, model = logit, data = turnout) has at different times worked fine and thrown up the error message. So you tell us the some package influences Zelig's functionality, but how can we help if you do not tell us which one it is? Uwe Ligges Any help gratefully received. __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix Multiplication, Floating-Point, etc.
On Mon, 30 Jul 2007, Moshe Olshansky wrote: After multiplication by 10 you get 6*8 = 48 - the result is an exact machine number so there is no roundoff, while 0.6*0.8 = 0.48, where neither of the 3 numbers (0.6, 0.8, 0.48) is an exact machine mumber. However, (-0.6)*0.8 should be equal EXACTLY to -(0.6*0.8), and in fact you get that sum(ev1*ev2) is exactly 0. What is strange is that you are not getting this result from ev1 %*% ev2. This means that either %^% uses some non-straightforward algorithm or it somehow sets the rounding control to something different from round to nearest. In the later case (-0.6) does not necessarily equal to -(0.6) and the rounding after multiplication is not necessarily symetric. Mr Olshansky seems unaware of the effects of extended-precision intermediate arithmetic on ix86 CPUs. sum() does use a higher-precision accumulator (where available, including on Windows), but ev1*ev2 is done in R and so stored to basic precision. OTOH, %*% (sic) calls the BLAS routine dgemm and hence may accumulate in 80-bit floating-point registers. What result you get will depend on what compiler, compiler flags and BLAS is in use, but with the default reference BLAS it is very likely that some of the intermediate results are stored in FP registers to extended precision. It is a simple experiment to confirm this: recompile the BLAS with -fforce-store and you do get 0 (at least on my Windows build system). Let's see less speculation and more homework in future. Regards, Moshe. --- Talbot Katz [EMAIL PROTECTED] wrote: Thank you for responding! I realize that floating point operations are often inexact, and indeed, the difference between the two answers is within the all.equal tolerance, as mentioned in FAQ 7.31 (cited by Charles): (as.numeric(ev1%*%ev2))==(sum(ev1*ev2)) [1] FALSE all.equal((as.numeric(ev1%*%ev2)),(sum(ev1*ev2))) [1] TRUE I suppose that's good enough for numerical computation. But I was still surprised to see that matrix multiplication (ev1%*%ev2) doesn't give the exact right answer, whereas sum(ev1*ev2) does give the exact answer. I would've expected them to perform the same two multiplications and one addition. But I guess that's not the case. However, I did find that if I multiplied the two vectors by 10, making the entries integers (although the class was still numeric rather than integer), both computations gave equal answers of 0: xf1-10*ev1 xf2-10*ev2 (as.numeric(xf1%*%xf2))==(sum(xf1*xf2)) [1] TRUE Perhaps the moral of the story is that one should exercise caution and keep track of significant digits. -- TMK -- 212-460-5430 home 917-656-5351 cell From: Charles C. Berry [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] Matrix Multiplication, Floating-Point, etc. Date: Mon, 30 Jul 2007 09:27:42 -0700 7.31 Why doesn't R think these numbers are equal? On Fri, 27 Jul 2007, Talbot Katz wrote: Hi. I recently tried the following in R 2.5.1 on Windows XP: ev2-c(0.8,-0.6) ev1-c(0.6,0.8) ev1%*%ev2 [,1] [1,] -2.664427e-17 sum(ev1*ev2) [1] 0 (I got the same result with R 2.4.1 on a different Windows XP machine.) I expect this issue is very familiar and probably has been discussed in this forum before. Can someone please point me to some documentation or discussion about this? Is there some standard way to get the correct answer from %*%? Thanks! -- TMK -- 212-460-5430 home 917-656-5351 cell -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] line widths of plotting symbols in the lattice
Stephen Tucker wrote: Dear List, Sorry, this is very simple but I can't seem to find any information regarding line widths of plotting symbols in the lattice package. For instance, in traditional graphics: plot(1:10,lwd=3) points(10:1,lwd=2,col=3) 'lwd' allows control of plotting symbol line widths. 'lwd' is documented in ?gpar (the help page does not show up for me, I'll take a closer look why) and works for me: xyplot(1:10 ~ 1:10, type = l, lwd = 5) Uwe Ligges I've tried looking through the documentation for xyplot, panel.points, trellis.par.set, and the R-help archives. Maybe it goes by another name? Thanks in advance, Stephen __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Cox model with interaction
Dear R users, I am trying to fit a Cox model such as: Surv(time,event) ~ X1+X1:X2 or Surv(time,event) ~ X1*X2 -X2, This code is working with coxph but not with cph (nor with psm), and the error message is: Error in if (!length(fname) || !any(fname == zname)) { : missing value where TRUE/FALSE is required Any idea about the cause of the problem and how to manage it within the Design library? Thanks a lot for your help. Rosalba Dr. Rosalba Miceli Unità di Statistica Medica e Biometria Fondazione IRCCS Istituto Nazionale Tumori Via G. Venezian, 1 20133 Milan (Italy) Tel: +39 2 23903198 / 23902456 Fax: +39 2 23902095 E-Mail: [EMAIL PROTECTED] www.istitutotumori.mi.it/biometria __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Plotting a smooth curve from predict
Probably a very simple query: When I try to plot a curve from a fitted polynomial, it comes out rather jagged, not smooth like fitted curves in other stats software. Is there a way of getting a smooth curve in R? What I'm doing at the moment (for the sake of example) is: x - c(1,2,3,4,5,6,7,8,9,10) y - c(10,9,8,7,6,6.5,7,8,9,10) b - data.frame(cbind(x,y)) w - gls(y ~ I(x)+I(x^2),correlation=corARMA(p=1),method=ML,data=b) plot(predict(w),type=l) Many thanks, Andrew Wilson __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to combine data of several csv-files
Here is the modified script for computing the 'sd': v1 - NA v2 - rnorm(6) v3 - rnorm(6) v4 - rnorm(6) v5 - rnorm(6) v6 - rnorm(6) v7 - rnorm(6) v8 - rnorm(6) v8 - NA list - list(v1,v2,v3,v4,v5,v6,v7,v8) categ - c(NA,cat1,cat1,cat1,cat2,cat2,cat2,NA) # create partitioned list list.cat - split(list, categ) # combine each partition into a matrix list.mat - lapply(list.cat, function(x) do.call('rbind', x)) # now take the means of each column lapply(list.mat, colMeans) # compute the 'sd' by using 'apply' on the columns lapply(list.mat, apply, 2, sd) On 7/31/07, 8rino-Luca Pantani [EMAIL PROTECTED] wrote: Hi Jim, that's exactly what I'm looking for. Thank you so much. I think, I should look for some further documentation on list handling. I think I will do the same... Thanks to Jim I learned textConnection and rowMeans. Jim, could you please go a step further and tell me how to use lapply to calculate the sd instead of the mean of the same items? I mean sd(-0.6442149 0.02354036 -1.40362589) sd(-1.1829260 1.17099178 -0.046778203) sd(-0.2047012 -1.36186952 0.13045724) etc x - read.table(textConnection( v1 v2 v3 v4 v5 v6 v7 v8 NA -0.6442149 0.02354036 -1.40362589 -1.1829260 1.17099178 -0.046778203 NA NA -0.2047012 -1.36186952 0.13045724 2.1411553 0.49248118 -0.233788840 NA NA -1.1986041 -0.42197792 -0.84651458 -0.1327081 -0.18690065 0.443908897 NA NA -0.2097442 1.50445971 1.57005071 -0.1053442 1.50050976 -1.649740180 NA NA -0.7343465 -1.76763996 0.06961015 -0.8179396 -0.65552410 0.003991354 NA NA -1.3888750 0.53722404 0.25269771 -1.2342698 -0.01243247 -0.228020092 NA), header=TRUE) -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Overlaying a single contour from a new data array in levelplot
Dear Deepayan, Thank you once again. I needed to install the latest versions of R and lattice and now it all works fine and the border is in white, which is perfect. Thank you for all the support you offer users of lattice, Best Wishes, Jenny That should have been fixed by now. Is there anything that's not working as you expect? My code had: lapply(add.cl, panel.polygon, border = 'red') which should have made the borders red. If it doesn't, you probably need to upgrade to a recent version of R/lattice. If it does, changing it to border='white' should suffice. If that doesn't work, please provide a reproducible example. -Deepayan On 7/30/07, Jenny Barnes [EMAIL PROTECTED] wrote: Dear Deepayan Thank you for your response - it has proved very very helpful, I can't thank you enough! I have another question for you if you have time to reply. I know you have been asked about the colour of the polygon outline before (27 April 2007) and you replied that is a bug and the border can only be black or transparent... I was wondering if you have found a way to change the colour of the outline since this correspondence? If not please can you tell me how to get around this myself? You mentioned writing a replacement to lpolygon - I do not know how to do this - would it be possible for you to guide me further? I would really benefit from having the border of the polygon in white as it goes over the sea which is also white and would therefore only be seen over the land, much neater! Many thanks, Jenny On 7/24/07, Jenny Barnes jmb_at_mssl.ucl.ac.uk wrote: Dear R-Help community, I am trying to overlay a single contour line over a correlation plot using levelplot in the lattice package. These are the two arrays: 1) a correlation plot over Africa - so each grid square is a different colour dependent on correlation - this is in an array: result_cor with dim[465,465] 2) a single contour line from a ***different data source*** - this is from data related to the p-values for the above correlation plot - I want to overlay only the 95% confidence contour. The p-values are stored in an array: result.p.values with same dimensions as above. I have read about using panel.levelplot and panel.contourplot in the R-help mailing list but I don't know the right way to call two different data arrays, can anybody help me please? I appreciate your time and help with this question. I can think of a couple of different ways, but the simplest will probably be to compute the single contour beforehand and add it after the standard levelplot using a panel function. E.g., using the 'volcano' data for both matrices: ## you need the explicit x and y arguments because ## the default is different from levelplot. vcl - contourLines(x = seq_len(nrow(volcano)), y = seq_len(ncol(volcano)), z = volcano, levels = c(172, 182)) levelplot(volcano, add.cl = vcl, panel = function(..., add.cl) { panel.levelplot(...) lapply(add.cl, panel.polygon, border = 'red') }) -Deepayan ~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Web: http://climate.mssl.ucl.ac.uk ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to combine data of several csv-files
Hey, I had the same question concerning the sd calculation and I got the following solution: list - split(list, class_vec) list - lapply(list, function(x) do.call('rbind', x)) my.mean - lapply(ret, FUN = function(x) { t - as.matrix(x) rm - as.matrix(apply( t, 1, FUN = function(w) { length(which(is.na(w) == TRUE)) } )) t - matrix(t[rm == 0,], ncol=7) # I had to do the 2 lines above to remove rows belonging to a class but containing NA values... (cannot exclude) if(nrow(t) 1) { apply(t, 2, mean) } else { if(nrow(t) == 1) { as.vector(t) } else { NA } } }) Probably, there is a simpler solution to remove the NA rows, but it works ;); also with sd. Ciao, Antje 8rino-Luca Pantani schrieb: Hi Jim, that's exactly what I'm looking for. Thank you so much. I think, I should look for some further documentation on list handling. I think I will do the same... Thanks to Jim I learned textConnection and rowMeans. Jim, could you please go a step further and tell me how to use lapply to calculate the sd instead of the mean of the same items? I mean sd(-0.6442149 0.02354036 -1.40362589) sd(-1.1829260 1.17099178 -0.046778203) sd(-0.2047012 -1.36186952 0.13045724) etc x - read.table(textConnection( v1 v2 v3 v4 v5 v6 v7 v8 NA -0.6442149 0.02354036 -1.40362589 -1.1829260 1.17099178 -0.046778203 NA NA -0.2047012 -1.36186952 0.13045724 2.1411553 0.49248118 -0.233788840 NA NA -1.1986041 -0.42197792 -0.84651458 -0.1327081 -0.18690065 0.443908897 NA NA -0.2097442 1.50445971 1.57005071 -0.1053442 1.50050976 -1.649740180 NA NA -0.7343465 -1.76763996 0.06961015 -0.8179396 -0.65552410 0.003991354 NA NA -1.3888750 0.53722404 0.25269771 -1.2342698 -0.01243247 -0.228020092 NA), header=TRUE) __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting a smooth curve from predict
Wilson, Andrew wrote: Probably a very simple query: When I try to plot a curve from a fitted polynomial, it comes out rather jagged, not smooth like fitted curves in other stats software. Is there a way of getting a smooth curve in R? What I'm doing at the moment (for the sake of example) is: x - c(1,2,3,4,5,6,7,8,9,10) y - c(10,9,8,7,6,6.5,7,8,9,10) b - data.frame(cbind(x,y)) w - gls(y ~ I(x)+I(x^2),correlation=corARMA(p=1),method=ML,data=b) plot(predict(w),type=l) Make predictions for more than 10 values of x: x - c(1,2,3,4,5,6,7,8,9,10) y - c(10,9,8,7,6,6.5,7,8,9,10) b - data.frame(cbind(x,y)) library(nlme) w - gls(y ~ I(x)+I(x^2), correlation=corARMA(p=1), method=ML, data=b) plot(seq(1,10,len=100), predict(w, data.frame(x = seq(1,10, len=100))), xlab=x, ylab=Predicted y, type=l) Many thanks, Andrew Wilson __ 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 and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting a smooth curve from predict
On Tue, 2007-07-31 at 11:21 +0100, Wilson, Andrew wrote: Probably a very simple query: When I try to plot a curve from a fitted polynomial, it comes out rather jagged, not smooth like fitted curves in other stats software. Is there a way of getting a smooth curve in R? What I'm doing at the moment (for the sake of example) is: x - c(1,2,3,4,5,6,7,8,9,10) y - c(10,9,8,7,6,6.5,7,8,9,10) b - data.frame(cbind(x,y)) w - gls(y ~ I(x)+I(x^2),correlation=corARMA(p=1),method=ML,data=b) plot(predict(w),type=l) replace the line above with the following: pred.dat - data.frame(x = seq(min(x), max(x), length.out = 100)) plot(predict(w, pred.dat), type = l) The general idea is to produce predictions over the range of x, so we produce a new data frame with component x, that contains 100 values from min(x) to max(x). We then get predicted values for each of these new values of the predictor in pred.dat, and plot them Increase/decrease length.out to get something suitably smooth without sending your computer into meltdown. HTH G Many thanks, Andrew Wilson __ 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 and provide commented, minimal, self-contained, reproducible code. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extracting random parameters from summary lme and lmer
Rense Nieuwenhuis wrote: LS, I'm estimating multilevel regression models, using the lme-function from the nlme-package. Let's say that I estimated a model and stored it inside the object named 'model'. The summary of that model is shown below: Using summary(model)$tTable , I receive the following output: summary(model)$tTable Value Std.Error DF t-value p-value (Intercept)0.23268607 0.09350662 3990 2.4884449 1.287080e-02 sexM -0.15338225 0.03169762 3990 -4.8389206 1.354802e-06 standLRT 0.38593558 0.01677195 3990 23.0107762 4.005182e-110 vrmid 50% 0.07606394 0.09389376 61 0.8101064 4.210281e-01 vrtop 25% 0.24561327 0.10483374 61 2.3428838 2.241317e-02 intakemid 50% -0.41469716 0.03177240 3990 -13.0521199 3.698344e-38 intaketop 25% -0.75920783 0.05357980 3990 -14.1696648 1.666780e-44 typeSngl 0.15680532 0.07173835 61 2.1857949 3.267903e-02 All looks fine to me. The output above is simply a section from the full summary shown below. Now, I want to extract from the summary (or the full model) the part stating the random parameters. More specifically, I want to extract from the summary the following: (Intercept) 0.2869401 (Intr) typeSngl0.2791040 -0.617 Residual0.7302233 How could this be done, and how can the same be done using the lmer- function from the lme4-package? ?VarCorr library(nlme) fm1 - lme(distance ~ age, data = Orthodont) # random is ~ age summary(fm1) Linear mixed-effects model fit by REML Data: Orthodont AIC BIClogLik 454.6367 470.6173 -221.3183 Random effects: Formula: ~age | Subject Structure: General positive-definite StdDevCorr (Intercept) 2.3270339 (Intr) age 0.2264276 -0.609 Residual1.3100399 Fixed effects: distance ~ age Value Std.Error DF t-value p-value (Intercept) 16.76 0.7752461 80 21.620375 0 age 0.660185 0.0712533 80 9.265334 0 Correlation: (Intr) age -0.848 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -3.223106017 -0.493760867 0.007316632 0.472151090 3.916032743 Number of Observations: 108 Number of Groups: 27 VarCorr(fm1) Subject = pdSymm(age) Variance StdDevCorr (Intercept) 5.41508688 2.3270339 (Intr) age 0.05126947 0.2264276 -0.609 Residual1.71620459 1.3100399 library(lme4) (fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy)) Linear mixed-effects model fit by REML Formula: Reaction ~ Days + (Days | Subject) Data: sleepstudy AIC BIC logLik MLdeviance REMLdeviance 1754 1770 -871.8 1752 1744 Random effects: Groups NameVariance Std.Dev. Corr Subject (Intercept) 610.835 24.7151 Days 35.056 5.9208 0.067 Residual 655.066 25.5943 number of obs: 180, groups: Subject, 18 Fixed effects: Estimate Std. Error t value (Intercept) 251.405 6.820 36.86 Days 10.467 1.5466.77 Correlation of Fixed Effects: (Intr) Days -0.137 VarCorr(fm1) $Subject 2 x 2 Matrix of class dpoMatrix (Intercept) Days (Intercept) 610.834546 9.738707 Days 9.738707 35.056337 attr(,sc) scale 25.59426 Thanks for the effort, Rense Nieuwenhuis Linear mixed-effects model fit by REML Data: Exam AIC BIC logLik 9158.56 9234.241 -4567.28 Random effects: Formula: ~type | school Structure: General positive-definite, Log-Cholesky parametrization StdDevCorr (Intercept) 0.2869401 (Intr) typeSngl0.2791040 -0.617 Residual0.7302233 Fixed effects: normexam ~ sex + standLRT + vr + intake + type Value Std.Error DFt-value p-value (Intercept)0.2326861 0.09350662 3990 2.488445 0.0129 sexM -0.1533822 0.03169762 3990 -4.838921 0. standLRT 0.3859356 0.01677195 3990 23.010776 0. vrmid 50% 0.0760639 0.09389376 61 0.810106 0.4210 vrtop 25% 0.2456133 0.10483374 61 2.342884 0.0224 intakemid 50% -0.4146972 0.03177240 3990 -13.052120 0. intaketop 25% -0.7592078 0.05357980 3990 -14.169665 0. typeSngl 0.1568053 0.07173835 61 2.185795 0.0327 Correlation: (Intr) sexM stnLRT vrm50% vrt25% int50% int25% sexM -0.201 standLRT -0.125 0.028 vrmid 50% -0.742 0.028 -0.035 vrtop 25% -0.652 0.051 -0.065 0.649 intakemid 50% -0.246 -0.011 0.541 -0.002 0.007 intaketop 25% -0.218 -0.018 0.676 0.014 0.013 0.660 typeSngl -0.421 0.080 0.007 0.033 -0.027 -0.001 0.001 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -3.59074329 -0.63776965 0.03829878 0.67303837 3.33952680 Number of Observations: 4059 Number of Groups: 65 [[alternative HTML version deleted]]
Re: [R] Plotting a smooth curve from predict
You are using fitted() implicitly here, so you are not plotting a smooth curve but a set of fitted values. You need to really predict at a suitable range of data points, e.g. xx - seq(1, 10, len=500) plot(xx, predict(w, list(x=xx)), type=l) BTW, why are you not using poly()? On Tue, 31 Jul 2007, Wilson, Andrew wrote: Probably a very simple query: When I try to plot a curve from a fitted polynomial, it comes out rather jagged, not smooth like fitted curves in other stats software. Is there a way of getting a smooth curve in R? What I'm doing at the moment (for the sake of example) is: x - c(1,2,3,4,5,6,7,8,9,10) y - c(10,9,8,7,6,6.5,7,8,9,10) b - data.frame(cbind(x,y)) w - gls(y ~ I(x)+I(x^2),correlation=corARMA(p=1),method=ML,data=b) plot(predict(w),type=l) Many thanks, Andrew Wilson __ 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 and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting a smooth curve from predict
What you need is b - data.frame(x = 1:10, y = c(10,9,8,7,6,6.5,7,8,9,10)) w - gls(y ~ I(x)+I(x^2),correlation=corARMA(p=1),method=ML,data=b) Newdata - data.frame(x = seq(1, 10, length = 41)) plot(predict(w, newdata = Newdata), type=l) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Wilson, Andrew Verzonden: dinsdag 31 juli 2007 12:22 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] Plotting a smooth curve from predict Probably a very simple query: When I try to plot a curve from a fitted polynomial, it comes out rather jagged, not smooth like fitted curves in other stats software. Is there a way of getting a smooth curve in R? What I'm doing at the moment (for the sake of example) is: x - c(1,2,3,4,5,6,7,8,9,10) y - c(10,9,8,7,6,6.5,7,8,9,10) b - data.frame(cbind(x,y)) w - gls(y ~ I(x)+I(x^2),correlation=corARMA(p=1),method=ML,data=b) plot(predict(w),type=l) Many thanks, Andrew Wilson __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] line widths of plotting symbols in the lattice
On Tue, 31 Jul 2007, Uwe Ligges wrote: Stephen Tucker wrote: Dear List, Sorry, this is very simple but I can't seem to find any information regarding line widths of plotting symbols in the lattice package. For instance, in traditional graphics: plot(1:10,lwd=3) points(10:1,lwd=2,col=3) 'lwd' allows control of plotting symbol line widths. 'lwd' is documented in ?gpar (the help page does not show up for me, I'll take a closer look why) and works for me: xyplot(1:10 ~ 1:10, type = l, lwd = 5) lattice imports grid, but you will need library(grid) to see the help pages. The link to gpar on ?xyplot should work (and does for me). Uwe Ligges I've tried looking through the documentation for xyplot, panel.points, trellis.par.set, and the R-help archives. Maybe it goes by another name? Thanks in advance, Stephen __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting a smooth curve from predict
Wilson, Andrew wrote: Probably a very simple query: When I try to plot a curve from a fitted polynomial, it comes out rather jagged, not smooth like fitted curves in other stats software. Is there a way of getting a smooth curve in R? What I'm doing at the moment (for the sake of example) is: x - c(1,2,3,4,5,6,7,8,9,10) y - c(10,9,8,7,6,6.5,7,8,9,10) b - data.frame(cbind(x,y)) w - gls(y ~ I(x)+I(x^2),correlation=corARMA(p=1),method=ML,data=b) plot(predict(w),type=l) predict() predicts at all locations in x and you are drawing straight lines between these points. Hence you need to predict in another resolution, e.g.: dat - data.frame(x = seq(1, 10, by = 0.1)) plot(predict(w, newdata = dat), type=l) Uwe Ligges Many thanks, Andrew Wilson __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] remove NA rows and columns
Hello, I guess, it's a rather simple thing but I cannot find a short way to reduce a matrix, removing all rows and columns having just NA elements. testmatrix - matrix(nrow=6, ncol=4) testmatrix[2:5,2:3] - seq(2) testmatrix [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA11 NA [3,] NA22 NA [4,] NA11 NA [5,] NA22 NA [6,] NA NA NA NA the new matrix should look like this (by the way, I don't know which rows and columns are the one to be deleted... testmatrix [,1] [,2] [1,] 11 [2,] 22 [3,] 11 [4,] 22 Ciao, Antje __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] remove NA rows and columns
testmatrix [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA11 NA [3,] NA22 NA [4,] NA11 NA [5,] NA22 NA [6,] NA NA NA NA tm1-testmatrix[,-which(apply(testmatrix,2,function(x)all(is.na(x] tm1 [,1] [,2] [1,] NA NA [2,]11 [3,]22 [4,]11 [5,]22 [6,] NA NA tm2-tm1[-which(apply(testmatrix,1,function(x)all(is.na(x,] tm2 [,1] [,2] [1,]11 [2,]22 [3,]11 [4,]22 Antje wrote: I guess, it's a rather simple thing but I cannot find a short way to reduce a matrix, removing all rows and columns having just NA elements. testmatrix - matrix(nrow=6, ncol=4) testmatrix[2:5,2:3] - seq(2) testmatrix [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA11 NA [3,] NA22 NA [4,] NA11 NA [5,] NA22 NA [6,] NA NA NA NA the new matrix should look like this (by the way, I don't know which rows and columns are the one to be deleted... testmatrix [,1] [,2] [1,] 11 [2,] 22 [3,] 11 [4,] 22 -- View this message in context: http://www.nabble.com/remove-NA-rows-and-columns-tf4192605.html#a11923002 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] remove NA rows and columns
Or, these operations can be called in one command: testmatrix[-which(apply(testmatrix,1,function(x)all(is.na(x,-which(apply(testmatrix,2,function(x)all(is.na(x] [,1] [,2] [1,]11 [2,]22 [3,]11 [4,]22 Vladimir Eremeev wrote: testmatrix [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA11 NA [3,] NA22 NA [4,] NA11 NA [5,] NA22 NA [6,] NA NA NA NA tm1-testmatrix[,-which(apply(testmatrix,2,function(x)all(is.na(x] tm1 [,1] [,2] [1,] NA NA [2,]11 [3,]22 [4,]11 [5,]22 [6,] NA NA tm2-tm1[-which(apply(testmatrix,1,function(x)all(is.na(x,] tm2 [,1] [,2] [1,]11 [2,]22 [3,]11 [4,]22 Antje wrote: I guess, it's a rather simple thing but I cannot find a short way to reduce a matrix, removing all rows and columns having just NA elements. testmatrix - matrix(nrow=6, ncol=4) testmatrix[2:5,2:3] - seq(2) testmatrix [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA11 NA [3,] NA22 NA [4,] NA11 NA [5,] NA22 NA [6,] NA NA NA NA the new matrix should look like this (by the way, I don't know which rows and columns are the one to be deleted... testmatrix [,1] [,2] [1,] 11 [2,] 22 [3,] 11 [4,] 22 -- View this message in context: http://www.nabble.com/remove-NA-rows-and-columns-tf4192605.html#a11923066 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] the large dataset problem
Just a note of thanks for all the help I have received. I haven't gotten a chance to implement any of your suggestions because I'm still trying to catalog all of them! Thank you so much! Just to recap (for my own benefit and to create a summary for others): Bruce Bernzweig suggested using the R.huge package. Ben Bolker pointed out that my original message wasn't clear and asked what I want to do with the data. At this point, just getting a dataset loaded would be wonderful, so I'm trying to trim variables (and if possible, I would also like to trim observations). He also provided an example of vectorizing. Ted Harding suggested that I use AWK to process the data and provided the necessary code. He also tested his code on older hardware running GNU-Linux (or Unix?) and showed that AWK can process the data even when the computer has very little memory and processing power. Jim Holtman had similar success when he used Cygwin's UNIX utilities on a machine running MS Windows. They both used the following code: gawk 'BEGIN{FS=,}{print $(1) , $(1000) , $(1275) , $(5678)}' tempxx.txt newdata.csv Fortunately, there is a version of GAWK for MS Windows. ... Not that I like MS Windows. It's just that I'm forced to use that 19th century operating system on the job. (After using Debian at home and happily running RKWard for my dissertation, returning to Windows World is downright depressing). Roland Rau suggested that I use a database with RSQLite and pointed out that RODBC can work with MS Access. He also pointed me to a sub-chapter in Venables and Ripley's _S Programming_ and The Whole-Object View pages in John Chamber's _Programming with Data_. Greg Snow recommended biglm for regression analysis with data that is too large to fit into memory. Last, but not least, Peter Dalgaard pointed out that there are options within R. He suggests using the colClasses= argument for when reading data and the what= argument for scanning data, so that you don't load more columns than necessary. He also provided the following script: dict - readLines(ftp://www.sipp.census.gov/pub/sipp/2004/l04puw1d.txt;) D.lines - grep(^D , dict) vdict - read.table(con - textConnection(dict[D.lines])); close(con) head(vdict) I'll try these solutions and report back on my success. Thanks again! - Eric __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] durbin-watson of a arima estimation?
to whom it may concern I estimated arima(x = lM, order = c(1, 0, 0),xreg=cbind(lPfPx,lY)). how can i now run the durbin-watson test (dwtest())??? Thanx for your prompt response! Raphael Illi Graduate writing his thesis in economics on the growth performance in Subsaharan Africa __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Looping through all possible combinations of cases
Here is another (simpler?) solution: # your 1 column data is actually a vector myvalues - 1:10 names(myvalues) - LETTERS[1:10] # use the QCA package library(QCA) aa - createMatrix(rep(2, length(myvalues))) # set the number of combinations: 2, 3, 4 or whatever combinations - 2 sub.aa - aa[rowSums(aa) == combinations, ] result - apply(sub.aa, 1, function(x) sum(myvalues[x == 1])) names(result) - apply(sub.aa, 1, function(x) paste(names(myvalues)[x == 1], collapse=)) HTH, Adrian On Friday 27 July 2007, Dimitri Liakhovitski wrote: Hello! I have a regular data frame (DATA) with 10 people and 1 column ('variable'). Its cases are people with names ('a', 'b', 'c', 'd', 'e', 'f', etc.). I would like to write a function that would sum up the values on 'variable' of all possible combinations of people, i.e. 1. I would like to write a loop - in such a way that it loops through each possible pair of cases (i.e., ab, ac, ad, etc.) and sums up their respective values on 'variable' 2. I would like to write a loop - in such a way that it loops through each possible trio of cases (i.e., abc, abd, abe, etc.) and sums up their respective values on 'variable'. 3. I would like to write a loop - in such a way that it loops through each possible quartet of cases (i.e., abcd, abce, abcf, etc.) and sums up their respective values on 'variable'. etc. Then, at the end I want to capture all possible combinations that were considered (i.e., what elements were combined in it) and get the value of the sum for each combination. How should I do it? Thanks a lot! Dimitri -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] remove NA rows and columns
Antje wrote: Hello, I guess, it's a rather simple thing but I cannot find a short way to reduce a matrix, removing all rows and columns having just NA elements. testmatrix - matrix(nrow=6, ncol=4) testmatrix[2:5,2:3] - seq(2) testmatrix [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA11 NA [3,] NA22 NA [4,] NA11 NA [5,] NA22 NA [6,] NA NA NA NA the new matrix should look like this (by the way, I don't know which rows and columns are the one to be deleted... testmatrix [,1] [,2] [1,] 11 [2,] 22 [3,] 11 [4,] 22 testmatrix[!apply(is.na(testmatrix), 1, all), !apply(is.na(testmatrix), 2, all)] [,1] [,2] [1,]11 [2,]22 [3,]11 [4,]22 Ciao, Antje __ 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 and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] reading and storing files in the workspace
R-help, I have a vector containing (test) some file names. The files contents are matrixes. test [1] aaOki.txtaOki.txt bOki.txt c1Oki.txt c2Oki.txtc3Oki.txtcOki.txt dOki.txt dyp100.txt dyp200.txt [11] dyp300.txt dyp400.txt dyp500.txt dyp600.txt dyp700.txt dyp800.txt eOki.txt FBdyp100.txt FBdyp150.txt FBdyp200.txt. What I want to do is to import to R using the same file name and remove the .txt extension out of the object name. Something like this: for(i in test) gsub(\\., , paste(i, sep = )) - read.table(file = paste(i, sep = ), header = TRUE) But I get the following message: Error in gsub(\\., , paste(i, sep = )) - read.table(file = paste(i, : target of assignment expands to non-language object Thanks in advance. version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 5.1 year 2007 month 06 day27 svn rev42083 language R version.string R version 2.5.1 (2007-06-27) __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] randomSurvivalForest 3.0.0 now available
Dear useRs: Release 3.0.0 of the randomSurvivalForest, an ensemble tree method for the analysis of right censored survival data, package is now available. - CHANGES TO RELEASE 3.0.0 Release 3.0.0 represents a major upgrade in the functionality of the 2.x releases. Key changes are as follows: o Missing data can be imputed in both grow and predict mode. This applies to variables as well as time and censoring outcome values. Values are imputed dynamically as the tree is grown using a new tree imputation methodology. This produces an imputed forest which can be used for prediction purposes on test data sets with missing data. o Importance values for variables are returned in predict mode when test data contains outcomes as well as variables. o Fixed some bugs in plot.variable(). Thanks to Andy J. Minn for pointing this out. o Minor modification of PMML representation of RSF forest output to accomodate imputation. The method of random seed chain recovery has been altered. Note that forests produced with prior releases will have to be regenerated using this release. We apologize for the inconvenience. - Thanks. ubk [EMAIL PROTECTED] Udaya B. Kogalur, Ph.D. Kogalur Shear Corporation 5425 Nestleway Drive, Suite L1 Clemmons, NC 27012 ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] array loop
Thanks, Petr. I changed the equation mark from = to -, then, it works fine. Dont know what difference it has made between the = and -.. Regards, Dong On 7/31/07, Petr PIKAL [EMAIL PROTECTED] wrote: Hi as you say that the computing is part of a function than the best way to see what is hapenning is to use debug(your.function) see ?debug for options. Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 31.07.2007 00:11:00: Dear all, here are two arrays: region(26,31,8), nation(8) I tried to get a new array, say, giGi(26,31,8) giGi - array(0,dim = c(region_dim)) for (i in (1:region_dim[3])) { giGi[,,i] = region[,,i]-nation[,i] } As the above is part of function, but results shows only giGi[,,1] has the right answers, all the others (giGi[,,2],..giGi[..8]) are zeros. I have checked array of region and nation, they are not zeros at all when I do manually, it is not the case, giGi has meanful numbers. can some one tell me the trick in this process?? Many thanks in advance. Dong [[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 and provide commented, minimal, self-contained, reproducible code. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] error in using R2WinBUGS on Ubuntu 6.10 Linux
J. Patrick Meyer meyerjp at jmu.edu writes: I'm using Wine 0.9.41, and the patched version of WinBUGS. Everything seems to run correctly. I get the right output from WinBUGS. I'm not sure to what the error message refers. I also get this messages, but that is comming from wine and can be safely ignored. Gregor __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Data mining tools
Hello there, apologies for cross-posting my question is not an S/R question but there is so much knowledge concentrated in those lists that I thought someone could point me in the right direction. A few months ago I read an article in a referenced journal comparing some data mining programs, among which there was Insightful's I Miner, SAS' Entreprise Miner, SPSS' Clementine (I think) and a few others. Unfortunately I can't remember in which journal was the article published or who was the author? I have been Googling a lot to try to locate the article but to no avail! Would someone know who published the article and in which journal? By the way, any serious, published comparisons of data mining programs would be welcomed as the company I work for is planning to add a data mining program to our tool box soon. Thanks for any leads, Gérald Jean Conseiller senior en statistiques, Actuariat télephone: (418) 835-4900 poste (7639) télecopieur : (418) 835-6657 courrier électronique: [EMAIL PROTECTED] In God we trust, all others must bring data W. Edwards Deming Le message ci-dessus, ainsi que les documents l'accompagnant, sont destinés uniquement aux personnes identifiées et peuvent contenir des informations privilégiées, confidentielles ou ne pouvant être divulguées. Si vous avez reçu ce message par erreur, veuillez le détruire. This communication (and/or the attachments) is intended for named recipients only and may contain privileged or confidential information which is not to be disclosed. If you received this communication by mistake please destroy all copies. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] problems saving and loading (PLMset) objects
Hi Quin, First off, you should ask questions about Bioconductor packages on the BioC listserv rather than R-help. Anyway, I don't think your PLMset objects are coming out all wrong - it doesn't appear that you are loading the affyPLM package first, which is required for R to know anything about the PLMset object (this object is defined in affyPLM, so without the package R has no idea what it is). Best, Jim Quin Wills wrote: Hi I'm running the latest R on a presumably up to date Linux server. 'Doing something silly I'm sure, but can't see why my saved PLMset objects come out all wrong. To use an example: Setting up an example PLMset (I have the same problem no matter what example I use) library(affyPLM) data(Dilution) # affybatch object Dilution = updateObject(Dilution) options(width=36) expr - fitPLM(Dilution) This works, and I'm able to get the probeset coefficients with coefs(expr). until I save and try reloading: save(expr, file=expr.RData) rm(expr) # just to be sure expr - load(expr.RData) Now, running coefs(expr) says: Error in function (classes, fdef, mtable) : unable to find an inherited method for function coefs, for signature character Trying str(exp) just gives the following: chr exp expr.Rdata appears to save properly (in that there is an actual file with notable size in my working directory). Thanks in advance, Quin [[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 and provide commented, minimal, self-contained, reproducible code. -- James W. MacDonald, M.S. Biostatistician Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] remove NA rows and columns
Hello, thank you both very much! It is as easy as expected... (I think I still have to learn a lot!) Have a nice day! Antje Vladimir Eremeev schrieb: Or, these operations can be called in one command: testmatrix[-which(apply(testmatrix,1,function(x)all(is.na(x,-which(apply(testmatrix,2,function(x)all(is.na(x] [,1] [,2] [1,]11 [2,]22 [3,]11 [4,]22 Vladimir Eremeev wrote: testmatrix [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA11 NA [3,] NA22 NA [4,] NA11 NA [5,] NA22 NA [6,] NA NA NA NA tm1-testmatrix[,-which(apply(testmatrix,2,function(x)all(is.na(x] tm1 [,1] [,2] [1,] NA NA [2,]11 [3,]22 [4,]11 [5,]22 [6,] NA NA tm2-tm1[-which(apply(testmatrix,1,function(x)all(is.na(x,] tm2 [,1] [,2] [1,]11 [2,]22 [3,]11 [4,]22 Antje wrote: I guess, it's a rather simple thing but I cannot find a short way to reduce a matrix, removing all rows and columns having just NA elements. testmatrix - matrix(nrow=6, ncol=4) testmatrix[2:5,2:3] - seq(2) testmatrix [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA11 NA [3,] NA22 NA [4,] NA11 NA [5,] NA22 NA [6,] NA NA NA NA the new matrix should look like this (by the way, I don't know which rows and columns are the one to be deleted... testmatrix [,1] [,2] [1,] 11 [2,] 22 [3,] 11 [4,] 22 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] problems saving and loading (PLMset) objects
Erm, Jim I am loading in the affyPLM package first (when needed) and this was a question based on loading/saving R objects. PLMset was an example. Many thanks, Quin -Original Message- From: James W. MacDonald [mailto:[EMAIL PROTECTED] Sent: 31 July 2007 14:54 To: Quin Wills Cc: r-help@stat.math.ethz.ch Subject: Re: [R] problems saving and loading (PLMset) objects Hi Quin, First off, you should ask questions about Bioconductor packages on the BioC listserv rather than R-help. Anyway, I don't think your PLMset objects are coming out all wrong - it doesn't appear that you are loading the affyPLM package first, which is required for R to know anything about the PLMset object (this object is defined in affyPLM, so without the package R has no idea what it is). Best, Jim Quin Wills wrote: Hi I'm running the latest R on a presumably up to date Linux server. 'Doing something silly I'm sure, but can't see why my saved PLMset objects come out all wrong. To use an example: Setting up an example PLMset (I have the same problem no matter what example I use) library(affyPLM) data(Dilution) # affybatch object Dilution = updateObject(Dilution) options(width=36) expr - fitPLM(Dilution) This works, and I'm able to get the probeset coefficients with coefs(expr). until I save and try reloading: save(expr, file=expr.RData) rm(expr) # just to be sure expr - load(expr.RData) Now, running coefs(expr) says: Error in function (classes, fdef, mtable) : unable to find an inherited method for function coefs, for signature character Trying str(exp) just gives the following: chr exp expr.Rdata appears to save properly (in that there is an actual file with notable size in my working directory). Thanks in advance, Quin [[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 and provide commented, minimal, self-contained, reproducible code. -- James W. MacDonald, M.S. Biostatistician Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Piecewise Regression with a known slope
Dear Jarrett, If I understand correctly your post, your constraints may be achieved straightforwardly in segmented. See the code below. The error is also most likely gamma distributed..[SNIP] The 'error' component can be specified in the 'initial' model by means of the family argument in the glm() function I have attempted to use the segmented package, specifying something close to the visually estimated breakpoint as the value of psi, but it continues to return fits with a breakpoint that occurs somewhere in the middle of the linear portion of the line, ..[SNIP] Mhmm..you can specify different starting values and to assess the differences in the 'final' estimates. However if you says ..it continues to return fits with a breakpoint that occurs somewhere in the middle.. probably the ML estimate of the breakpoint is really in the middle. Hope this helps you, best, vito simulate data n-50 x-1:n/n y- 0-pmin(x-.5,0)+rnorm(50)*.03 plot(x,y) #This should be your scatterplot.. abline(0,0,lty=2) o-lm(y~x) #or glm(y~x,family=..) o1-segmented(o,seg.Z=~x,psi=list(x=.3)) slope(o1) #get the slope points(x,fitted(o1),col=2) #a parsimonious modelling: constrain right slope=0 o-lm(y~1) xx- -x o2-segmented(o,seg.Z=~xx,psi=list(xx=-.3)) slope(o2) points(x,fitted(o2),col=2) #now constrain \hat{\mu}(x)=0 for xpsi o-lm(y~0) o3-segmented(o,seg.Z=~xx,psi=list(xx=-.3)) slope(o3) points(x,fitted(o3),col=3) Hey, all. I'm working on a data set with a broken stick linear regression where I know one of the two slopes. It is a negative linear function until the line intersects with the x-axis, at which point it becomes 0. It is not a nonlinear asymptotic function, and, indeed, using negative exponential or logistic types of fits as an approximation has tended to lead to an under or overestimation of values. I am also very interested to know just what the breakpoint in the data is. Essentially if xpsi y = a + bx + error, where b is negative else y=0+error and I want to know the value of psi, as well as a and b. The error is also most likely gamma distributed, as values0 are not possible (nutrient concentrations). I have attempted to use the segmented package, specifying something close to the visually estimated breakpoint as the value of psi, but it continues to return fits with a breakpoint that occurs somewhere in the middle of the linear portion of the line, and the slope and intercept of the second half of the regression is not 0. Is there either a package that exists that will allow me to estimate such a model, or a function that I can use for optim or nlm (I admit, I am a rank novice at coding such functions). Thanks so much! -Jarrett __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] problems saving and loading (PLMset) objects
library(affyPLM) data(Dilution) pset - fitPLM(Dilution) save(pset, file=tmp.Rdata) q() ## restart R library(affyPLM) load(tmp.Rdata) ## use load() correctly class(pset) [1] PLMset attr(,package) [1] affyPLM erm - load(tmp.Rdata) ## use load() incorrectly class(erm) [1] character Best, Jim Quin Wills wrote: Erm, Jim I am loading in the affyPLM package first (when needed) and this was a question based on loading/saving R objects. PLMset was an example. Many thanks, Quin -Original Message- From: James W. MacDonald [mailto:[EMAIL PROTECTED] Sent: 31 July 2007 14:54 To: Quin Wills Cc: r-help@stat.math.ethz.ch Subject: Re: [R] problems saving and loading (PLMset) objects Hi Quin, First off, you should ask questions about Bioconductor packages on the BioC listserv rather than R-help. Anyway, I don't think your PLMset objects are coming out all wrong - it doesn't appear that you are loading the affyPLM package first, which is required for R to know anything about the PLMset object (this object is defined in affyPLM, so without the package R has no idea what it is). Best, Jim Quin Wills wrote: Hi I'm running the latest R on a presumably up to date Linux server. 'Doing something silly I'm sure, but can't see why my saved PLMset objects come out all wrong. To use an example: Setting up an example PLMset (I have the same problem no matter what example I use) library(affyPLM) data(Dilution) # affybatch object Dilution = updateObject(Dilution) options(width=36) expr - fitPLM(Dilution) This works, and I'm able to get the probeset coefficients with coefs(expr). until I save and try reloading: save(expr, file=expr.RData) rm(expr) # just to be sure expr - load(expr.RData) Now, running coefs(expr) says: Error in function (classes, fdef, mtable) : unable to find an inherited method for function coefs, for signature character Trying str(exp) just gives the following: chr exp expr.Rdata appears to save properly (in that there is an actual file with notable size in my working directory). Thanks in advance, Quin [[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 and provide commented, minimal, self-contained, reproducible code. -- James W. MacDonald, M.S. Biostatistician Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Error message when running lm() with na.action=NULL
Hi there, I am trying to run a liner regression using lm with na.action = NULL, but I am getting an error message. Any ideas as to why this may be happening? Please see code and error message below: reg_test-lm(yy~.,data=test,na.action=NULL) Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : NA/NaN/Inf in foreign function call (arg 4) This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person. Nothing contained in the attached email shall be regarded as an offer to sell or as a solicitation of an offer to buy any services, funds or products or an expression of any opinion or views of the firm or its employees. Nothing contained in the attached email shall be deemed to be an advise of, or recommendation by, the firm or its employees. No representation is made as to accuracy, completeness, reliability or appropriateness of the information contained in the attached email. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] stop criteria when L-BFGS-B needs finite values of 'fn' in optim
Dae-Jin Lee dae-jin.lee at uc3m.es writes: I would like to know how to include and if condition when this happen, could it be something like: myfun - optim() # run my function if(myfun == ERROR) . # when the error message is L-BFGS-B needs finite values of 'fn' See ?try : e.g. myfun - try(optim(...)) if (class(myfun)==try-error) { ... whatever ... } else { ... success ... } or tryCatch this is FAQ 7.32 ... cheers Ben Bolker __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] simple coding question
I know that some ICD9 codes contain letters, so I suspect that they are stored as character. Here is a function that just pads zeros on to the end to make the string five characters long. format - function(icd9) { len - length(strsplit(icd9, )[[1]]) pad - if (num - 5-len) pad - paste(rep(0, times=num), collapse=) paste(icd9, pad , sep=, collapse=) } Then use sapply() on the vector that contains the codes. Probably not too hard to stick a . in there if you really want one. Darin On Tue, Jul 31, 2007 at 05:17:29PM +1200, Peter Alspach wrote: Kirsten One way to do this: kirsten - c(123, 1234, 12345) 100*as.numeric(paste(substring(kirsten, 1, 3), substring(kirsten, 4, 5), sep='.')) HTH Peter Alspach -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kirsten Beyer Sent: Tuesday, 31 July 2007 9:31 a.m. To: r-help@stat.math.ethz.ch Subject: [R] simple coding question I have a list of ICD9 (disease) codes with various formats - 3 digit, 4 digit, 5 digit. The first three digits of these codes are what I am most interested in. I would like to either add zeros to the 3 and 4 digit codes to make them 5 digit codes or add decimal points to put them all in the format ###.##. I did not see a function that allows me to do this in the formatting command. This seems simple - can someone help? Thanks, K.Beyer __ 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 and provide commented, minimal, self-contained, reproducible code. __ The contents of this e-mail are privileged and/or confidenti...{{dropped}} __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Q: obtaining non-transparent background in png
I am not understanding something about generating PNG plots. I have tried several ways to obtain something other than a transparent background, but nothing I've done seems to change the background. For example: dev.print(png, width=800, height=600, bg='red', filename='example.png') which I thought would give a red background, simply gives the same transparent background I always get. And I also don't understand why the default background is transparent, when the documentation seems to say that it's white: png(filename = Rplot%03d.png, width = 480, height = 480, pointsize = 12, bg = white, res = NA,...) (This is on a Kubuntu dapper 64-bit system.) [I looked through the mail archives, and there seem to be a few very old postings talking about the opposite problem, but nothing recent; so I conclude that I'm doing something wrong.] __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Q: obtaining non-transparent background in png
Both of these work for me: par(bg=red) plot(1:10) dev.print(png, width=800, height=600, filename=tmp.png) and png(tmp.png, width=800, height=600, bg=red) plot(1:10) dev.off() Best, Jim D. R. Evans wrote: I am not understanding something about generating PNG plots. I have tried several ways to obtain something other than a transparent background, but nothing I've done seems to change the background. For example: dev.print(png, width=800, height=600, bg='red', filename='example.png') which I thought would give a red background, simply gives the same transparent background I always get. And I also don't understand why the default background is transparent, when the documentation seems to say that it's white: png(filename = Rplot%03d.png, width = 480, height = 480, pointsize = 12, bg = white, res = NA,...) (This is on a Kubuntu dapper 64-bit system.) [I looked through the mail archives, and there seem to be a few very old postings talking about the opposite problem, but nothing recent; so I conclude that I'm doing something wrong.] __ 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 and provide commented, minimal, self-contained, reproducible code. -- James W. MacDonald, M.S. Biostatistician Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Q: obtaining non-transparent background in png
On Tue, 2007-07-31 at 10:22 -0600, D. R. Evans wrote: I am not understanding something about generating PNG plots. I have tried several ways to obtain something other than a transparent background, but nothing I've done seems to change the background. For example: dev.print(png, width=800, height=600, bg='red', filename='example.png') which I thought would give a red background, simply gives the same transparent background I always get. ?dev.print says: 'dev.print' copies the graphics contents of the current device to a new device which has been created by the function specified by 'device' and then shuts the new device. Note copies - given that you've already drawn a figure with a white background, should this then produce one that is red? However, you are correct that it does produce a plot with a transparent background. I find it easier to wrap my plotting commands in the relevant device, e.g. this works with the desired background: png(mypng.png, height = 400, width = 400, bg = red, pointsize = 12) plot(1:10) dev.off() Whereas these do not give red backgrounds as one might have expected, but transparent ones: plot(1:10) dev.print(png, height = 400, width = 400, bg = red, pointsize = 12, filename = mypng2.png) X11 2 dev.copy(png, height = 400, width = 400, bg = red, pointsize = 12, filename = mypng3.png) PNG 3 dev.off() X11 2 Not sure whether this is as intentional or not, but it does not appear to be passing the bg argument on to the 'device', or if it does, it is not being used/respected - perhaps all that is need is clarification as to what can be specified in '...' in ?dev.print version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status Patched major 2 minor 5.1 year 2007 month 07 day05 svn rev42131 language R version.string R version 2.5.1 Patched (2007-07-05 r42131) G And I also don't understand why the default background is transparent, when the documentation seems to say that it's white: png(filename = Rplot%03d.png, width = 480, height = 480, pointsize = 12, bg = white, res = NA,...) (This is on a Kubuntu dapper 64-bit system.) [I looked through the mail archives, and there seem to be a few very old postings talking about the opposite problem, but nothing recent; so I conclude that I'm doing something wrong.] __ 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 and provide commented, minimal, self-contained, reproducible code. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-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 and provide commented, minimal, self-contained, reproducible code.
[R] legend()
Hi Sir How can I use legend() outside th e plot. Please guid in this regard. Thanks -- AMINA SHAHZADI Department of Statistics GC University Lahore, Pakistan. Email: [EMAIL PROTECTED] [EMAIL PROTECTED] [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 and provide commented, minimal, self-contained, reproducible code.
[R] italic greek symbols
Hi Folks, I am using R 2.5.1 on a Mac OS X 10.4.9, via ESS. I would like to try to get an italic mu onto a plot axis label. I note that in a previous email, (Thu, 4 May 2006 19:41:41 +0100 (BST)), Brian Ripley wrote, There is no italic symbol font available on most devices. So unless you try to plot Greek (not math symbol Greek) you are out of luck. How does one plot Greek, or is there now another solution? Thanks, Hank Dr. Hank Stevens, Associate Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ E Pluribus Unum __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Q: obtaining non-transparent background in png
On 31/07/07, Gavin Simpson [EMAIL PROTECTED] wrote: On Tue, 2007-07-31 at 10:22 -0600, D. R. Evans wrote: I am not understanding something about generating PNG plots. I have tried several ways to obtain something other than a transparent background, but nothing I've done seems to change the background. For example: dev.print(png, width=800, height=600, bg='red', filename='example.png') which I thought would give a red background, simply gives the same transparent background I always get. ?dev.print says: 'dev.print' copies the graphics contents of the current device to a new device which has been created by the function specified by 'device' and then shuts the new device. Note copies - given that you've already drawn a figure with a white background, should this then produce one that is red? Well, I wondered about that, so the first thing I did was to test it by changing a different parameter. I created an X11 plot with the default size (480, I think?) and then printed it to a png with a width of 800. That indeed created a PNG file of width 800, so I deduced from that that it was OK to change the parameters of the plot in the destination device. Not sure whether this is as intentional or not, but it does not appear to be passing the bg argument on to the 'device', or if it does, it is not being used/respected - perhaps all that is need is clarification as to what can be specified in '...' in ?dev.print I think so. Either that or it seems to be a bug (I obviously don't know enough about how things are supposed to work to make that determination; but it does seem rather bug-like behaviour, especially since one can certainly change some of the parameters associated with the plot). Anyway, it seems like I need an explicit par(bg='red') before performing any graphical operations. That seems to do the trick. Although it's still not clear how one would solve the general problem in which one has an X11 plot with background colour A, but wants to copy it to a PNG with background colour B... Weirdly (at least it seems weird to me) I just tried the following with an unexpected result: I created the following function: to.png - function(FILENAME = 'Rplot%03d.png') { par(bg='blue') dev.print(png, width=800, height=600, filename=FILENAME) } par(bg='red') plot(1:10)# ok, I get a red plot to.png('should-be-blue.png') # png is red, not blue plot(1:10) # now it's blue (as I sort-of expected) So it isn't obvious that there's anything one can put in the to.png() function that will control the colour of the background for the PNG output. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] extract columns of a matrix/data frame
Hello all, I have a matrix whose column names look like a1 a2 b1 b2 b3 c1 c2 1 23713 2 4 67814 3 Now, I can have any number of a's. not just two as shown above and same goes for b's and c's. I need to extract all the a's columns and put them in another matrix, extract all b's columns and put them in some matrix and same goes for c. How can I identify such pattern and get subsets of this matrix depending on columns names? I will appreciate a quick reply. Thanks a lot. - [[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 and provide commented, minimal, self-contained, reproducible code.
[R] how to sort dataframe levels
Hi everyone, I've been bashing my head against this for days now, and can't figure out what to do. I have the following dataframe headerappetitive stimulusaversive stimuluschaining contingencydiscriminative stimulusextinctionintermittent reinforcementnegative reinforceroperant responseplace learningpositive reinforcerpunishmentreinforcement schedules response ratesecondary reinforcementspontaneous recoveryvariance spontaneous recovery-3-20-3-3-16-5116 -171-111-2049.73 negative reinforcer-1-154-182-10-5 2-614-1-22038.80 appetitive stimulus02-12110-2-64 -14049-1124.13 aversive stimulus-4002911-1203 2-7022121.20 discriminative stimulus-350101-17-8 -3-2102-3-6020.80 intermittent reinforcement32-300-300 -7-271-4-79419.73 place learning33-2-4-2-22-2-40 7-311-6-1019.07 extinction455020-30-1303 -4-2-1-1116.00 chaining-1-40-30037-1-6-1 9-501115.33 positive reinforcer-11-410-1-11-2-1 501340514.80 response rate460-2-1-2-4-1210 -2-70-2813.60 punishment0-760-3-13702-2 0-3-31012.00 operant response-100-102-4-603 -51-252610.80 secondary reinforcement-2-113-5-18-1 -602110009.87 contingency11-60-1130-353 -1-4-2-148.67 reinforcement schedules12020-3-440 3200-5-206.13 which is ordered according to the variance column (I manually ordered this in excel and wrote the data to file as a csv). I need to enforce this order on the levels of $header and I don't know how to do that. levels(related.differences$header) [1] appetitive stimulusaversive stimulus chaining contingencydiscriminative stimulus [6] extinction intermittent reinforcement negative reinforceroperant response place learning [11] positive reinforcerpunishment reinforcement schedulesresponse rate secondary reinforcement [16] spontaneous recovery I've tried levels(related.differences$header) - as.vector(related.differences$header) levels(related.differences$header) [1] spontaneous recovery negative reinforcerappetitive stimulusaversive stimulus discriminative stimulus [6] intermittent reinforcement place learning extinction chaining positive reinforcer [11] response rate punishment operant response secondary reinforcementcontingency [16] reinforcement schedules which looks right, but when I print the dataframe to screen, the order of $header is pooched, while the data is still in the correct order or if I submit the dataframe to ggplot2 via qplot(), the headers are in the correct order, but the data is in order as though the levels were alphabetical. :( qplot(appetitive.stimulus, header, data=related.differences, size=variance, colour=Appetitive Stimulus, xlim=c(-20,20), main=title, xlab=Differences, ylab=Header Concepts) At the end of the day, all I want to do is order the dataframe and headers and levels according to the variance, so that when I graph all the variables, the size of the dots either gets bigger or smaller depending on the variance as opposed to the alphabetical order which makes it appear random. If you can tell me what i'm doing wrong please let me know. many thanks, emilio [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] extract columns of a matrix/data frame
You can use the grep function to obtain the column indices matching your specified criteria. For example, r1-c(1,2,3,7,1,3,2) r2-c(4,5,7,8,1,4,3) test-matrix(c(r1,r2),byrow=TRUE) colnames(test)-c(a1,a2,b1,b2,b3,c1,c2) test a1 a2 b1 b2 b3 c1 c2 [1,] 1 2 3 7 1 3 2 [2,] 4 5 7 8 1 4 3 grep(a,(colnames(test))) [1] 1 2 test.a-test[,grep(a,(colnames(test)))] test.a a1 a2 [1,] 1 2 [2,] 4 5 On Jul 31, 2007, at 10:35 AM, yuvika wrote: Hello all, I have a matrix whose column names look like a1 a2 b1 b2 b3 c1 c2 1 23713 2 4 67814 3 Now, I can have any number of a's. not just two as shown above and same goes for b's and c's. I need to extract all the a's columns and put them in another matrix, extract all b's columns and put them in some matrix and same goes for c. How can I identify such pattern and get subsets of this matrix depending on columns names? I will appreciate a quick reply. Thanks a lot. - [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] extract columns of a matrix/data frame
Sorry. There was a mistake in my previous code. Please disregard it and use the following: r1=c(1,2,3,7,1,3,2) r2=c(4,5,7,8,1,4,3) test=matrix(c(r1,r2),nrow=2,ncol=7,byrow=TRUE) colnames(test)-c(a1,a2,b1,b2,b3,c1,c2) test [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,]1237132 [2,]4578143 grep(a,(colnames(test))) [1] 1 2 test.a-test[,grep(a,(colnames(test)))] test.a a1 a2 [1,] 1 2 [2,] 4 5 Kyle H. Ambert Graduate Student, Dept. Behavioral Neuroscience Oregon Health Science University [EMAIL PROTECTED] On Jul 31, 2007, at 10:35 AM, yuvika wrote: Hello all, I have a matrix whose column names look like a1 a2 b1 b2 b3 c1 c2 1 23713 2 4 67814 3 Now, I can have any number of a's. not just two as shown above and same goes for b's and c's. I need to extract all the a's columns and put them in another matrix, extract all b's columns and put them in some matrix and same goes for c. How can I identify such pattern and get subsets of this matrix depending on columns names? I will appreciate a quick reply. Thanks a lot. - [[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 and provide commented, minimal, self-contained, reproducible code. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] extract columns of a matrix/data frame
yuvika wrote: Hello all, I have a matrix whose column names look like a1 a2 b1 b2 b3 c1 c2 1 23713 2 4 67814 3 Now, I can have any number of a's. not just two as shown above and same goes for b's and c's. I need to extract all the a's columns and put them in another matrix, extract all b's columns and put them in some matrix and same goes for c. How can I identify such pattern and get subsets of this matrix depending on columns names? I will appreciate a quick reply. Thanks a lot. mymat - matrix(runif(60), ncol=6) colnames(mymat) - c(a1,a2,b1,b2,c1,c2) mymat a1 a2 b1 b2 c1 c2 [1,] 0.73623481 0.25204019 0.332436396 0.36629507 0.39517285 0.62491949 [2,] 0.48867382 0.20933245 0.511805497 0.03142542 0.82168732 0.20550784 [3,] 0.89198874 0.24477456 0.629644977 0.23442137 0.17828551 0.29640615 [4,] 0.99222414 0.49044514 0.571213786 0.91068115 0.09484414 0.78108139 [5,] 0.66615787 0.13183354 0.004350679 0.32443025 0.38742483 0.76044740 [6,] 0.06642704 0.96257552 0.189716240 0.83969989 0.53470898 0.28319039 [7,] 0.31172264 0.20201281 0.577353264 0.62082694 0.31649255 0.40977000 [8,] 0.52890283 0.46576510 0.107363256 0.72534897 0.12038182 0.06295499 [9,] 0.55292555 0.76459699 0.212533012 0.73275529 0.98008863 0.85302931 [10,] 0.84320369 0.09958472 0.158443155 0.92321443 0.50935938 0.08514859 mymat[,grep(^a, colnames(mymat))] a1 a2 [1,] 0.73623481 0.25204019 [2,] 0.48867382 0.20933245 [3,] 0.89198874 0.24477456 [4,] 0.99222414 0.49044514 [5,] 0.66615787 0.13183354 [6,] 0.06642704 0.96257552 [7,] 0.31172264 0.20201281 [8,] 0.52890283 0.46576510 [9,] 0.55292555 0.76459699 [10,] 0.84320369 0.09958472 ?grep - [[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 and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] extract columns of a matrix/data frame
On Tue, 2007-07-31 at 10:35 -0700, yuvika wrote: Hello all, I have a matrix whose column names look like a1 a2 b1 b2 b3 c1 c2 1 23713 2 4 67814 3 Now, I can have any number of a's. not just two as shown above and same goes for b's and c's. I need to extract all the a's columns and put them in another matrix, extract all b's columns and put them in some matrix and same goes for c. How can I identify such pattern and get subsets of this matrix depending on columns names? I will appreciate a quick reply. Thanks a lot. If 'MAT' is your matrix: MAT a1 a2 b1 b2 b3 c1 c2 [1,] 1 2 3 7 1 3 2 [2,] 4 6 7 8 1 4 3 You can use: sapply(letters[1:3], function(x) MAT[, grep(x, colnames(MAT))]) $a a1 a2 [1,] 1 2 [2,] 4 6 $b b1 b2 b3 [1,] 3 7 1 [2,] 7 8 1 $c c1 c2 [1,] 3 2 [2,] 4 3 which returns a list containing the three matrices as a consequence of subsetting 'MAT based upon the colnames. This uses sapply() to loop over letters[1:3], which is: letters[1:3] [1] a b c and then uses grep() to get the indices of the colnames matching the individual letters, passed as 'x' in each iteration of the sapply() loop. For example: grep(a, colnames(MAT)) [1] 1 2 You can then manipulate each sub-matrix in the list as you require. See ?sapply, ?grep and ?letters 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Q: obtaining non-transparent background in png
You are *copying* the plot, and that means copying the background too (it *is* part of the plot). Almost certainly the plot you are copying had a transparent background: that is the default for X11. All the confusion seems to be over misreadings of this. On Tue, 31 Jul 2007, Gavin Simpson wrote: On Tue, 2007-07-31 at 10:22 -0600, D. R. Evans wrote: I am not understanding something about generating PNG plots. I have tried several ways to obtain something other than a transparent background, but nothing I've done seems to change the background. For example: dev.print(png, width=800, height=600, bg='red', filename='example.png') which I thought would give a red background, simply gives the same transparent background I always get. ?dev.print says: 'dev.print' copies the graphics contents of the current device to a new device which has been created by the function specified by 'device' and then shuts the new device. Note copies - given that you've already drawn a figure with a white background, should this then produce one that is red? However, you are correct that it does produce a plot with a transparent background. I find it easier to wrap my plotting commands in the relevant device, e.g. this works with the desired background: png(mypng.png, height = 400, width = 400, bg = red, pointsize = 12) plot(1:10) dev.off() Whereas these do not give red backgrounds as one might have expected, but transparent ones: plot(1:10) dev.print(png, height = 400, width = 400, bg = red, pointsize = 12, filename = mypng2.png) X11 2 dev.copy(png, height = 400, width = 400, bg = red, pointsize = 12, filename = mypng3.png) PNG 3 dev.off() X11 2 Not sure whether this is as intentional or not, but it does not appear to be passing the bg argument on to the 'device', or if it does, it is not being used/respected - perhaps all that is need is clarification as to what can be specified in '...' in ?dev.print version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status Patched major 2 minor 5.1 year 2007 month 07 day05 svn rev42131 language R version.string R version 2.5.1 Patched (2007-07-05 r42131) G And I also don't understand why the default background is transparent, when the documentation seems to say that it's white: png(filename = Rplot%03d.png, width = 480, height = 480, pointsize = 12, bg = white, res = NA,...) (This is on a Kubuntu dapper 64-bit system.) [I looked through the mail archives, and there seem to be a few very old postings talking about the opposite problem, but nothing recent; so I conclude that I'm doing something wrong.] __ 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 and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
[R] choosing between Poisson regression models: no interactions vs. interactions
R gurus, I'm working on data analysis for a small project. My response variable is total vines per tree (median = 0, mean = 1.65, min = 0, max = 24). My predictors are two categorical variables (four sites and four species) and one continuous (tree diameter at breast height (DBH)). The main question I'm attempting to answer is whether or not the species identity of a tree has any effects on the number of vines clinging to the trunk. Given that the response variable is count data, I decided to use Poisson regression, even though I'm not as familiar with it as linear or logit regression. My problem is deciding which model to use. I have created several, one without interaction terms (Total.vines~Site+Species+DBH), one with an interaction term between Site and Species (Total.vines~Site*Species+DBH), and one with interactions between all variables (Total.vines~Site*Species*DBH). Here is my output from R for the first two models (the last model has the same number (and identity) of significant variables as the second model, even though the last model had more interaction terms overall): % Call: glm(formula = Total.vines ~ Site + Species + DBH, family = poisson) Deviance Residuals: Min 1Q Median 3Q Max -5.2067 -1.2915 -0.7095 -0.3525 6.3756 Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept) -2.987695 0.231428 -12.910 2e-16 *** SiteHuffman Dam 2.725193 0.249423 10.926 2e-16 *** SiteNarrows 1.902987 0.227599 8.361 2e-16 *** SiteSugar Creek 1.752754 0.242186 7.237 4.58e-13 *** SpeciesFRAM 0.955468 0.157423 6.069 1.28e-09 *** SpeciesPLOC 1.187903 0.141707 8.383 2e-16 *** SpeciesULAM 0.340792 0.184615 1.846 0.0649 . DBH 0.020708 0.001292 16.026 2e-16 *** --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 1972.3 on 544 degrees of freedom Residual deviance: 1290.0 on 537 degrees of freedom AIC: 1796.0 Number of Fisher Scoring iterations: 6 Call: glm(formula = Total.vines ~ Site * Species + DBH, family = poisson, data = sycamores.1) Deviance Residuals: Min 1Q Median 3Q Max -4.9815 -1.2370 -0.6339 -0.3403 6.5664 Coefficients: (3 not defined because of singularities) Estimate Std. Error z value Pr(|z|) (Intercept) -2.788243 0.303064 -9.200 2e-16 *** SiteHuffman Dam 1.838952 0.354127 5.193 2.07e-07 *** SiteNarrows 2.252716 0.323184 6.970 3.16e-12 *** SiteSugar Creek -12.961519 519.152077 -0.025 0.980082 SpeciesFRAM 13.938716 519.152230 0.027 0.978580 SpeciesPLOC 0.240223 0.540676 0.444 0.656824 SpeciesULAM 1.919586 0.540246 3.553 0.000381 *** DBH 0.019984 0.001337 14.946 2e-16 *** SiteHuffman Dam:SpeciesFRAM -11.513823 519.152294 -0.022 0.982306 SiteNarrows:SpeciesFRAM -13.593127 519.152268 -0.026 0.979111 SiteSugar Creek:SpeciesFRAM NA NA NA NA SiteHuffman Dam:SpeciesPLOC NA NA NA NA SiteNarrows:SpeciesPLOC 0.397503 0.555218 0.716 0.474028 SiteSugar Creek:SpeciesPLOC 15.640450 519.152277 0.030 0.975966 SiteHuffman Dam:SpeciesULAM -0.102841 0.610027 -0.169 0.866124 SiteNarrows:SpeciesULAM -2.809092 0.606804 -4.629 3.67e-06 *** SiteSugar Creek:SpeciesULAM NA NA NA NA --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 1972.3 on 544 degrees of freedom Residual deviance: 1178.7 on 531 degrees of freedom AIC: 1696.6 Number of Fisher Scoring iterations: 13 As you can see, the two models give very different output, especially in regards to whether or not the individual species are significant. In the no-interaction model, the only species that was not significant was ULAM. In the one-way interaction model, ULAM was the only significant species. My question is this: which model should I use when I present this analysis? I know that the one-way interaction model has the lower AIC. Should I base my choice solely on AIC? The reasons I'm asking is that the second model has only one significant interaction term, fewer significant terms overall, and three undefined terms. Thanks for any guidance you can give to someone running his first Poisson regression. Jim Milks Graduate Student Environmental Sciences Ph.D. Program 136 Biological Sciences Wright State University 3640 Colonel Glenn Hwy Dayton, OH 45435 [[alternative HTML version deleted]] __
Re: [R] italic greek symbols
On Tue, 2007-07-31 at 13:22 -0400, Martin Henry H. Stevens wrote: Hi Folks, I am using R 2.5.1 on a Mac OS X 10.4.9, via ESS. I would like to try to get an italic mu onto a plot axis label. I note that in a previous email, (Thu, 4 May 2006 19:41:41 +0100 (BST)), Brian Ripley wrote, There is no italic symbol font available on most devices. So unless you try to plot Greek (not math symbol Greek) you are out of luck. How does one plot Greek, or is there now another solution? Thanks, Hank You might want to look at the links in this post by Paul Murrell: http://tolstoy.newcastle.edu.au/R/e2/help/06/12/7083.html 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] italic greek symbols
On Tue, 31 Jul 2007, Martin Henry H. Stevens wrote: Hi Folks, I am using R 2.5.1 on a Mac OS X 10.4.9, via ESS. I would like to try to get an italic mu onto a plot axis label. I note that in a previous email, (Thu, 4 May 2006 19:41:41 +0100 (BST)), Brian Ripley wrote, There is no italic symbol font available on most devices. So unless you try to plot Greek (not math symbol Greek) you are out of luck. How does one plot Greek, or is there now another solution? Use the appropriate Unicode characters. Lower case mu is \u03bc. Whether this works depends on the device and locale (as I said before) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] legend()
On Tue, 2007-07-31 at 10:21 -0700, amna khan wrote: Hi Sir How can I use legend() outside th e plot. Please guid in this regard. Thanks Create a plot, specifying outer margins to make space for the legend. Then move the legend to the open region. # Set 'xpd' to NA so that the legend is not clipped # at the plot region, which it is by default par(xpd = NA) # Make some room at the right hand side par(oma = c(0, 0, 0, 10)) # Do the plot plot(1:5) # Do the legend and use 'inset' to move the legend to # the right hand outer margin legend(topright, legend = 1:5, inset = c(-.4, .0)) You can adjust the outer margin settings and the 'inset' value as you may require to make room for the legend on the side required. See ?par and ?legend for more information. Another option would be to use layout() to create more than one plot region, perhaps adjusting the heights and/or widths of the plot regions, such that the data plot goes into one region and the legend into the other. See ?layout for more information. 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 and provide commented, minimal, self-contained, reproducible code.
[R] contrasts error message in lm
Dear all, I would like to find a linear regression model for a rather large dataset (27 independent variables). However, when I run lm the following error is reported: out - lm(Result ~ AppealA + AppealsB + AppealC + AppealD + AppealE + Apply + ApplyAmount + Aprove + Closecase + Decidelocally + Healthassessment + HealthassessmentHealth + Postponedecision + Propertyassessment + PropertyassessmentPropertyvalue + RejectA + RejectB + RejectC + RejectD + RejectE + Reportacceptance + + ReportrejectionA + ReportrejectionB + ReportrejectionC + ReportrejectionD + + ReportrejectionE + Timeout) Error in `contrasts-`(`*tmp*`, value = contr.treatment) : contrasts can be applied only to factors with 2 or more levels I've checked the documenation but somehow I fail to find an explanation what does it mean... Thanks in advance, Alexander Serebrenik __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] generating symmetric matrices
At 16:29 30/07/2007, Gregory Gentlemen wrote: Douglas Bates [EMAIL PROTECTED] wrote: On 7/27/07, Gregory Gentlemen wrote: Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: p - 6 Rmat - diag(p) dat.cor - rnorm(p*(p-1)/2) Rmat[outer(1:p, 1:p, )] - Rmat[outer(1:p, 1:p, )] - dat.cor However, the problem is that the matrix is filled by column and so the resulting matrix is not symmetric. Could you provide more detail on the properties of the symmetric matrices that you would like to generate? It seems that you are trying to generate correlation matrices. Is that the case? Do you wish the matrices to be a random sample from a specific distribution. If so, what distribution? Yes, my goal is to generate correlation matrices whose entries have been sampled independently from a normal with a specified mean and variance. Would it sufficient to use one of the results of RSiteSearch(random multivariate normal, restrict = functions) or have I completely misunderstood what you want? (I appreciate this is not exactly what you say you want.) Thanks for the help. Greg - [[alternative HTML version deleted]] Michael Dewey http://www.aghmed.fsnet.co.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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] reading and storing files in the workspace
try: for (i in test){ assign(gsub(.txt$, , i), read.table(i, header=TRUE)) } On 7/31/07, Luis Ridao Cruz [EMAIL PROTECTED] wrote: R-help, I have a vector containing (test) some file names. The files contents are matrixes. test [1] aaOki.txtaOki.txt bOki.txt c1Oki.txt c2Oki.txtc3Oki.txtcOki.txt dOki.txt dyp100.txt dyp200.txt [11] dyp300.txt dyp400.txt dyp500.txt dyp600.txt dyp700.txt dyp800.txt eOki.txt FBdyp100.txt FBdyp150.txt FBdyp200.txt. What I want to do is to import to R using the same file name and remove the .txt extension out of the object name. Something like this: for(i in test) gsub(\\., , paste(i, sep = )) - read.table(file = paste(i, sep = ), header = TRUE) But I get the following message: Error in gsub(\\., , paste(i, sep = )) - read.table(file = paste(i, : target of assignment expands to non-language object Thanks in advance. version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 5.1 year 2007 month 06 day27 svn rev42083 language R version.string R version 2.5.1 (2007-06-27) __ 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 and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] italic greek symbols
Thank you for this simple solution. It works well in R.app (R 2.5.1 GUI 1.20 (4535) (4535)), but I can't figure out how to make it work in my Aquamacs+ESS. When I attempt to set the locale, I get an error message. Any thoughts are appreciated. Sys.setlocale(LC_CTYPE, greek) [1] Warning message: OS reports request to set locale to greek cannot be honored in: Sys.setlocale(LC_CTYPE, greek) Cheers, Hank On Jul 31, 2007, at 3:00 PM, Prof Brian Ripley wrote: On Tue, 31 Jul 2007, Martin Henry H. Stevens wrote: Hi Folks, I am using R 2.5.1 on a Mac OS X 10.4.9, via ESS. I would like to try to get an italic mu onto a plot axis label. I note that in a previous email, (Thu, 4 May 2006 19:41:41 +0100 (BST)), Brian Ripley wrote, There is no italic symbol font available on most devices. So unless you try to plot Greek (not math symbol Greek) you are out of luck. How does one plot Greek, or is there now another solution? Use the appropriate Unicode characters. Lower case mu is \u03bc. Whether this works depends on the device and locale (as I said before) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 Dr. Hank Stevens, Associate Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ E Pluribus Unum __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] extract columns of a matrix/data frame
On Tue, 2007-07-31 at 11:47 -0700, yuvika wrote: Hello, Thanks for the immediate help. However, I have a question for you. let's say the matrix looks like this name a1 a2 b1 b2 c1 c2 04 2 7 8 1 2 03 6 9 2 29 12 7 92 4 2 13 2 2 6 7 8 22 7 8 34 2 3 4 6 8 9 0 2 3 6 8 9 3 6 7 Now, what i want to do is still make submatrices but now make 3 matrices(based on a,b,c just like before) for name=0, 3 matrices for name=1 and so on.. how can i do this? looking forward for your help. thanks yuvika Yuvika, Please be sure to 'reply to all' so that the list thread stays intact and can be of benefit to others in the archive. Otherwise knowledge transfer is lost... In this case, we can split() the initial matrix based upon the 'name' column and then still use the initial solution, with modifications. In effect, we end up with 'nested' loops: MAT name a1 a2 b1 b2 c1 c2 [1,]0 4 2 7 8 1 2 [2,]0 3 6 9 2 2 9 [3,]1 2 7 9 2 4 2 [4,]1 3 2 2 6 7 8 [5,]2 2 7 8 3 4 2 [6,]3 4 6 8 9 0 2 [7,]3 6 8 9 3 6 7 We first need to coerce the matrix to a data frame to use this approach: DF - as.data.frame(MAT) DF name a1 a2 b1 b2 c1 c2 10 4 2 7 8 1 2 20 3 6 9 2 2 9 31 2 7 9 2 4 2 41 3 2 2 6 7 8 52 2 7 8 3 4 2 63 4 6 8 9 0 2 73 6 8 9 3 6 7 # split() DF by the 'name' column # strip the 'name' column while we are at it DF.split - split(DF[, -1], DF$name) DF.split $`0` a1 a2 b1 b2 c1 c2 1 4 2 7 8 1 2 2 3 6 9 2 2 9 $`1` a1 a2 b1 b2 c1 c2 3 2 7 9 2 4 2 4 3 2 2 6 7 8 $`2` a1 a2 b1 b2 c1 c2 5 2 7 8 3 4 2 $`3` a1 a2 b1 b2 c1 c2 6 4 6 8 9 0 2 7 6 8 9 3 6 7 Now use lapply() to navigate the above list, then use the initial solution with lapply() instead of sapply() on each data frame within the list: RES - lapply(DF.split, function(x) sapply(letters[1:3], function(i) x[, grep(i, colnames(x))])) RES $`0` $`0`[[1]] a1 a2 1 4 2 2 3 6 $`0`[[2]] b1 b2 1 7 8 2 9 2 $`0`[[3]] c1 c2 1 1 2 2 2 9 $`1` $`1`[[1]] a1 a2 3 2 7 4 3 2 $`1`[[2]] b1 b2 3 9 2 4 2 6 $`1`[[3]] c1 c2 3 4 2 4 7 8 $`2` $`2`[[1]] a1 a2 5 2 7 $`2`[[2]] b1 b2 5 8 3 $`2`[[3]] c1 c2 5 4 2 $`3` $`3`[[1]] a1 a2 6 4 6 7 6 8 $`3`[[2]] b1 b2 6 8 9 7 9 3 $`3`[[3]] c1 c2 6 0 2 7 6 7 HTH, Marc __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Linear model without an intercept
I would like to run a regression analysis without a constant (intercept) or a special one-way within-subject (repeated-measures) ANOVA. I'm not sure if the following command lines are correct or not: m1 - lme(Resp ~ Cond - 1, random = ~ Cond - 1 | Subj, TestData) or, m2 - lmer(Resp ~ Cond - 1 +( Cond - 1 | Subj), TestData) Also I notice that both lme and lmer provide the correlation matrix of the fixed effects. So if there are more than 2 levels in the fixed effect of condition (Cond), how can I correct for sphericity violation in lme and lmer if I want to get an F test for condition effect? Thanks, Gang __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Naming rows/columns in a 3 dimensional array/dataframe
Can I assign names to rows/columns in a i x k x j matrix / dataframe? This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person. Nothing contained in the attached email shall be regarded as an offer to sell or as a solicitation of an offer to buy any services, funds or products or an expression of any opinion or views of the firm or its employees. Nothing contained in the attached email shall be deemed to be an advise of, or recommendation by, the firm or its employees. No representation is made as to accuracy, completeness, reliability or appropriateness of the information contained in the attached email. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error message when running lm() with na.action=NULL
Sorry, I forgot to reply to all. See Patrick suggestion below. I also got another idea from Julian Faraway's book on R res - rep(NA,153) res[as.numeric(row.names(na.omit(airquality)))] - gl$res where gl was a regression and airquality the data. Thanks, Fabian -Original Message- From: Patrick Burns [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 31, 2007 12:55 PM To: Garavito,Fabian Subject: Re: [R] Error message when running lm() with na.action=NULL Garavito,Fabian wrote: I was trying to get a vector of residuals where NA would be assigned to the lm residual vector (in this case reg_test$residuals) whenever NA was present in the sample. For instance, Obs fitted residual O1 f1 r1 O2 f2 r2 NA NA NA All I am getting is residual vectors for Non Missing observations (i.e. the dimension of the residual vector could be different from that of the response vector) Makes sense. I think you need to do it yourself. Perhaps something like (untested): test.nona - na.omit(test) mod - lm(y | ., data=test.nona) allresids - rep(NA, nrow(test)) allresids[-attr(test.nona, 'na.action')] - residuals(mod) Putting this into a function would probably be the way to go. Thank you very much for your help. I used to use R a few years ago, but I have not used it in a long while. Moreover, I had been using SAS in the last year and going back to R has been quite difficult. I was actually looking for a good book in R. Any ideas? 'good' is questionable and not exactly about R, but S Poetry is at least free. Venables and Ripley is a common citation. Peter Dalgaard's book is given good reviews. There is a book that is aimed more towards finance (which I'm assuming you are in) but I've forgotten what it is nor have I seen it. Searching Amazon should probably show you a lot of your choices, and I haven't heard of any books that generate aversion. Pat Fabian -Original Message- From: Patrick Burns [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 31, 2007 11:39 AM To: Garavito,Fabian Subject: Re: [R] Error message when running lm() with na.action=NULL Doing na.action=NULL means that you need to get rid of missing values yourself from your data, which I'm guessing you haven't done. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Garavito,Fabian wrote: Hi there, I am trying to run a liner regression using lm with na.action = NULL, but I am getting an error message. Any ideas as to why this may be happening? Please see code and error message below: reg_test-lm(yy~.,data=test,na.action=NULL) Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : NA/NaN/Inf in foreign function call (arg 4) This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person. Nothing contained in the attached email shall be regarded as an offer to sell or as a solicitation of an offer to buy any services, funds or products or an expression of any opinion or views of the firm or its employees. Nothing contained in the attached email shall be deemed to be an advise of, or recommendation by, the firm or its employees. No representation is made as to accuracy, completeness, reliability or appropriateness of the information contained in the attached email. [[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 and provide commented, minimal, self-contained, reproducible code. This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person. Nothing contained in the attached email shall be regarded as an offer to sell or as a solicitation of an offer to buy any services, funds or products or an expression of any opinion or views of the firm or its employees. Nothing contained in the attached email shall be deemed to be an advise of, or recommendation by, the firm or its employees. No representation is made as to accuracy, completeness, reliability or appropriateness of the information contained in the attached
Re: [R] contrasts error message in lm
On Tue, 2007-07-31 at 21:28 +0200, A Serebrenik wrote: Dear all, I would like to find a linear regression model for a rather large dataset (27 independent variables). However, when I run lm the following error is reported: out - lm(Result ~ AppealA + AppealsB + AppealC + AppealD + AppealE + Apply + ApplyAmount + Aprove + Closecase + Decidelocally + Healthassessment + HealthassessmentHealth + Postponedecision + Propertyassessment + PropertyassessmentPropertyvalue + RejectA + RejectB + RejectC + RejectD + RejectE + Reportacceptance + + ReportrejectionA + ReportrejectionB + ReportrejectionC + ReportrejectionD + + ReportrejectionE + Timeout) Error in `contrasts-`(`*tmp*`, value = contr.treatment) : contrasts can be applied only to factors with 2 or more levels I've checked the documenation but somehow I fail to find an explanation what does it mean... Thanks in advance, Alexander Serebrenik One or more of your IV's has a single factor level. In other words for example, instead of having Yes and No values, it only has one of the two. Treatment contrasts are predicated on having a base or reference level, against which the other levels for the factor are compared. This can occur either natively in the source dataset, or as a consequence of removing rows in your dataset that have missing values. In the latter case, a factor with multiple levels may end up having a single level as a consequence of the removal of all rows with the other levels of that factor. By default, R (and many other statistical applications) will remove records containing missing values prior to applying regression techniques on the dataset. See ?lm and ?na.action (referenced in the former) for more information. You can use: DF.tmp - na.omit(DF) where 'DF' is your source dataset, to remove rows with missing values. Then use: summary(DF.tmp) to review the residual dataset created and see what you have left. In looking at your formula above, it may be that your variables are not in a single data frame (I don't see a 'data' argument). In which case, you can achieve a similar result by using: DF - model.frame(Result ~ TheRestOfYourFormulaHere..) and then using: summary(DF) See ?model.frame 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 and provide commented, minimal, self-contained, reproducible code.
[R] aggregate.data.frame - prevent conversion to factors? show statistics for NA values of by variable?
I have a two question regarding the aggregate.data.frame method of the aggregate function. My situation: a. My x variable is a data.frame (mydf) with two columns, both columns of type/format numeric. b. My by variable is a data.frame(mybys) with two columns, both columns of type/format character. c. Some of the values contained in mybys are originally NA. Prior to submitting the by variables to the aggregate function, I convert the NA values to the text-string is_na. ( I do this because I want to understand the statistics of variables where their by value is NA, and want this information in the results of the aggregate function.) My questions: 1. Is there a better way, (other then converting NA's to some text-string), to see the statistics (mean, etc.) of the variables where the by is NA? (i.e to have them included within the results of the aggregate function) 2. When I run the aggregate function, the two column that contain the by variables are always formatted as factors. Is there a way to prevent this, and to instead have them retain the format in the original mybys data.frame (i.e to have them come back formatted as character? Or do I just need to re-format them once I have my results? mydf=data.frame(testvar1=c(1,3,5,7,8,3,5,NA,4,5,7,9), testvar2=c(11,33,55,77,88,33,55,NA,44,55,77,99) ) str(mydf) # myby1=c('red','blue',1,2,NA,'big',1,2,'red',1,NA,12) myby2=c('wet','dry',99,95,NA,'damp',95,99,'red',99,NA,NA) myby1.new = ifelse(is.na(myby1)==T,is_na,myby1) myby2.new = ifelse(is.na(myby2)==T,is_na,myby2) str(myby1.new) str(myby2.new) mybys=data.frame(mbn1=myby1.new,mbn2=myby2.new , stringsAsFactors =F) str(mybys) # myagg1 = aggregate(x=mydf, by=mybys, FUN='mean') str(myagg1) myagg2 = myagg1 myagg2[1:ncol(mybys)] = as.character(unlist(myagg1[1:ncol(mybys)])) str(myagg2) myagg1 myagg2 - [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] contrasts error message in lm
On Tue, 31 Jul 2007, A Serebrenik wrote: Dear all, I would like to find a linear regression model for a rather large dataset (27 independent variables). However, when I run lm the following error is reported: out - lm(Result ~ AppealA + AppealsB + AppealC + AppealD + AppealE + Apply + ApplyAmount + Aprove + Closecase + Decidelocally + Healthassessment + HealthassessmentHealth + Postponedecision + Propertyassessment + PropertyassessmentPropertyvalue + RejectA + RejectB + RejectC + RejectD + RejectE + Reportacceptance + + ReportrejectionA + ReportrejectionB + ReportrejectionC + ReportrejectionD + + ReportrejectionE + Timeout) Error in `contrasts-`(`*tmp*`, value = contr.treatment) : contrasts can be applied only to factors with 2 or more levels I've checked the documenation but somehow I fail to find an explanation what does it mean... So one of your 'variables' isn't: it is a factor with only one level? -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] italic greek symbols
On Tue, 31 Jul 2007, Martin Henry H. Stevens wrote: Thank you for this simple solution. It works well in R.app (R 2.5.1 GUI 1.20 (4535) (4535)), but I can't figure out how to make it work in my Aquamacs+ESS. When I attempt to set the locale, I get an error message. Any thoughts are appreciated. Sys.setlocale(LC_CTYPE, greek) [1] Warning message: OS reports request to set locale to greek cannot be honored in: Sys.setlocale(LC_CTYPE, greek) You need to set a UTF-8 locale (and I believe that is all there are on MacOS, but of course it uses non-standard locale names: our MacOS box seems to be switched off so I cannot check easily). Cheers, Hank On Jul 31, 2007, at 3:00 PM, Prof Brian Ripley wrote: On Tue, 31 Jul 2007, Martin Henry H. Stevens wrote: Hi Folks, I am using R 2.5.1 on a Mac OS X 10.4.9, via ESS. I would like to try to get an italic mu onto a plot axis label. I note that in a previous email, (Thu, 4 May 2006 19:41:41 +0100 (BST)), Brian Ripley wrote, There is no italic symbol font available on most devices. So unless you try to plot Greek (not math symbol Greek) you are out of luck. How does one plot Greek, or is there now another solution? Use the appropriate Unicode characters. Lower case mu is \u03bc. Whether this works depends on the device and locale (as I said before) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 Dr. Hank Stevens, Associate Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ E Pluribus Unum __ 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 and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Naming rows/columns in a 3 dimensional array/dataframe
On Tue, 2007-07-31 at 19:03 +0100, Garavito,Fabian wrote: Can I assign names to rows/columns in a i x k x j matrix / dataframe? You can use an array: ARR - array(1:18, c(3, 3, 3), dimnames = list(LETTERS[1:3], LETTERS[4:6], LETTERS[7:9])) ARR , , G D E F A 1 4 7 B 2 5 8 C 3 6 9 , , H D E F A 10 13 16 B 11 14 17 C 12 15 18 , , I D E F A 1 4 7 B 2 5 8 C 3 6 9 ARR[B, E, H] [1] 14 See ?array By definition, matrices and dataframes are two dimensional, though you can have a list containing N of them. 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Data mining tools
Hi Gérald, I can't help you directly, but you haven't yet had a reply, so... Googling, as you have found, will waste your time if you know more that you Google for. Clementine's quite unusual --- in the field of statistical methods --- so target that. Take the main Stats methods journals and search them; or try something like CiteSeer: http://citeseer.ist.psu.edu/cis?q=clementinecs=1 Motto: Always write it down, even if that's all you...end up spending your time doing. Hope this helps, Regards, Mark. gerald.jean wrote: Hello there, apologies for cross-posting my question is not an S/R question but there is so much knowledge concentrated in those lists that I thought someone could point me in the right direction. A few months ago I read an article in a referenced journal comparing some data mining programs, among which there was Insightful's I Miner, SAS' Entreprise Miner, SPSS' Clementine (I think) and a few others. Unfortunately I can't remember in which journal was the article published or who was the author? I have been Googling a lot to try to locate the article but to no avail! Would someone know who published the article and in which journal? By the way, any serious, published comparisons of data mining programs would be welcomed as the company I work for is planning to add a data mining program to our tool box soon. Thanks for any leads, Gérald Jean Conseiller senior en statistiques, Actuariat télephone: (418) 835-4900 poste (7639) télecopieur : (418) 835-6657 courrier électronique: [EMAIL PROTECTED] In God we trust, all others must bring data W. Edwards Deming Le message ci-dessus, ainsi que les documents l'accompagnant, sont destinés uniquement aux personnes identifiées et peuvent contenir des informations privilégiées, confidentielles ou ne pouvant être divulguées. Si vous avez reçu ce message par erreur, veuillez le détruire. This communication (and/or the attachments) is intended for named recipients only and may contain privileged or confidential information which is not to be disclosed. If you received this communication by mistake please destroy all copies. __ 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 and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Data-mining-tools-tf4193959.html#a11935911 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] MTBF Reliability calculations
I'm working on a project involving reliability values (known failure rates) for a system with approximately 700 components with a set cconfiguration. I'm looking to compute a parts-count MTBF (mean time between failures) for the system. (See also MIL-HDBK-217) Is there anything in R that can help me with this? Thanks, Eric Jennings QA Technical Assistant Crane Electronics --Redmond 10301 Willows Road P.O. Box 97005 Redmond, WA 98073 PH 425.895.5039 e-mail [EMAIL PROTECTED] Attention: The information contained in this email message may be privileged and is confidential information intended only for the use of the recipient, or any employee or agent responsible to deliver it to the intended recipient. Any unauthorized use, distribution or copying of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender immediately and destroy the original message and all attachments from your electronic files. -- This message has been scanned for viruses and\ dangerous con...{{dropped}} __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'non-standard' folder names in R package
Oops, somehow I missed that part. Thank you very much! Tao From: Uwe Ligges [EMAIL PROTECTED] To: Tao Shi [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] 'non-standard' folder names in R package Date: Tue, 31 Jul 2007 11:52:10 +0200 Tao Shi wrote: Hi list, I use a .xml file for a function's demo in the R package I'm creating. Since it doesn't belong to any of the 'standard' folders, i.e. those mentioned in the 'Writing R Extension', I put it in a folder call myXML, much like the 'iris.xl' file in 'xls' folder from 'gdata' package, for example. After running R CMD build, I could see the .xml file is in the ..tar.gz file. However, after running R CMD INSTALL -build, the file and the folder disappeared in both the .zip file and the installed package. (R CMD CHECK, of course, failed too before that, as myXML can't be installed.) Could anybody tell me what's the tricks to keep those folders in my installation? I'm using R-2.5.1 under WinXP. Thank you very much! If you want it to be in mypackage/myXML after installation, put it into mypackage/inst/myXML in the source package, as the manual you cited suggests. Uwe Ligges Tao _ Need a brain boost? Recharge with a stimulating game. Play now! __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Nonlinear optimization with constraints
Hello R community, I am using R for creating a model using optimization. I would like to ask if there is R-function/package for solving the problem below: Minimize sum(abs(exp^(Ai1 x1 + Ai2 x2 + ... + Aim xm - bi) - 1)), for each i = 1, ..., n. subject to Ai1 x1 + Ai2 x2 + ... + Ajm xm - bi = c, where c is a scalar. (x is a vector of variables, A is nxm matrix, b is a vector) [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Nonlinear optimization with constraints
Hello R community, I am sorry for the previous accidental posting as I pressed a wrong key. I am using R for creating a model using optimization. I would like to ask if there is R-function/package for solving the problem below: Minimize sum(abs(exp^(Ai1 x1 + Ai2 x2 + ... + Aim xm - bi) - 1)), for each i = 1, ..., n. subject to Ai1 x1 + Ai2 x2 + ... + Ajm xm - bi = c, where c is a scalar. (x is a vector of variables, A is nxm matrix, b is a vector) I tried to use optim(), nlm(), and constrOptim, but they do not allow a kind of the constraint in the problem above. Thanks for your help. Regards, Vu - Original Message From: Vu Nguyen [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Tuesday, July 31, 2007 3:50:52 PM Subject: Nonlinear optimization with constraints Hello R community, I am using R for creating a model using optimization. I would like to ask if there is R-function/package for solving the problem below: Minimize sum(abs(exp^(Ai1 x1 + Ai2 x2 + ... + Aim xm - bi) - 1)), for each i = 1, ..., n. subject to Ai1 x1 + Ai2 x2 + ... + Ajm xm - bi = c, where c is a scalar. (x is a vector of variables, A is nxm matrix, b is a vector) [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Solve matrix with constraints using sum of squares
I'm trying to solve a system of equations for A and B: 37.07*A + 0.07*B - 36.73*C ~= 0 2.68*A + 24.75*B - 275.77*C ~= 0 The LHS is the product of 2*3 and 3*1 matrices. Constraints: A+B=1 0=A,B=1 C=1 I want to minimise the sum of squares of the equations together. The R function solve can solve matrices but not with these constraints. Lp solves equations with these constraints but doesn't use sum of squares; just a linear solution which minimises EQN1 to ~-36.66 by the solution [0,1,1] for example. I know from the help file and previous postings that QR.solve, solve.QP (quadprog) or Optim are able to do this or something similar, but I can't follow the application of these functions. I could use Excel solver but my endgame is to run this solution for many many equations. Would appreciate your help. Scott. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] line widths of plotting symbols in the lattice
On 7/31/07, Uwe Ligges [EMAIL PROTECTED] wrote: Stephen Tucker wrote: Dear List, Sorry, this is very simple but I can't seem to find any information regarding line widths of plotting symbols in the lattice package. For instance, in traditional graphics: plot(1:10,lwd=3) points(10:1,lwd=2,col=3) 'lwd' allows control of plotting symbol line widths. 'lwd' is documented in ?gpar (the help page does not show up for me, I'll take a closer look why) and works for me: xyplot(1:10 ~ 1:10, type = l, lwd = 5) I think the point is that lwd doesn't work for _points_, and that is a bug (lplot.xy doesn't pass on lwd to grid.points). I'll fix it, meanwhile a workaround is to use grid.points directly, e.g. library(grid) xyplot(1:10 ~ 1:10, cex = 2, lwd = 3, panel = function(x, y, ...) grid.points(x, y, gp = gpar(...))) -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 and provide commented, minimal, self-contained, reproducible code.
[R] R on QNX
Hi, Has anyone attempted to compile R on QNX 4.x or 6.x ? It would be particularly cool if there is a precompiled version somewhere on the QNX software archives. Thank you very much !! Suresh ps. Please cc replies to my address if possible... __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] New R package sqldf
sqldf is an R package for running SQL select statements on one or more R data frames. It is optimized for convenience making it useful for ad hoc queries against R data frames. Given an SQL select statement whose tables are the names of R data frames it: - sets up the database (by default it transparently sets up an in memory SQLite database using RSQLite; however, MySQL via RMySQL, can be specified as an alternative. MySQL has not been tested.) - imports the data frames found in SQL select statement into the database - runs the SQL select statement - outputs the result back to a data frame - uses a heuristic to assign the appropriate column classes to the result - removes the database so that all the user has to do is issue a one line function call with one argument, the select statement. Here is an example which processes an SQL select statement whose functionality is similar to the R aggregate function. Note that although the iris dataset (which is built into R) uses the name Sepal.Length the R database interface, DBI, converts that to Sepal_Length. Just install the sqldf package from CRAN and type these two lines into R without the prompts: library(sqldf) sqldf(select Species, avg(Sepal_Length) from iris group by Species) Species avg(Sepal_Length) 1 setosa 5.006 2 versicolor 5.936 3 virginica 6.588 As can be seen from the example, there is: - no database setup - no importing and exporting into the database - no coercing of the returned columns to the appropriate class (in most cases) It can be used: - as an alternate syntax for data frame manipulation - learning SQL if you know R - learning R if you know SQL The sqldf package has a single function, sqldf. More information is available by issuing the command ?sqldf from within R. More examples and useful links are available at the sqldf home page: http://code.google.com/p/sqldf/ ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot
A simple example of using image to plot a grid of values is: library(cluster) image( 1:50, seq(1856, 1976, 4), as.matrix(votes.repub) ) Even better is to group the states so similar states are closer to each other: agn1 - agnes(votes.repub, metric = manhattan, stand = TRUE) image( 1:50, seq(1850, 1976, 4), as.matrix(votes.repub)[agn1$order,]) Horizontal stripes show years that were very republican or very-non-republican, verticle stripes show states or groups of states that are very republican or non-republican. light blocks in dark areas or dark blocks in light areas show outliers that may be of interest. From: Dong GUO ?? [mailto:[EMAIL PROTECTED] Sent: Sat 7/28/2007 10:19 PM To: Greg Snow Cc: r-help@stat.math.ethz.ch Subject: Re: [R] plot Thanks again, Greg, It really helps. Would you please let me know more reference of plot in R? how to use the image function to create the grid??? Thanks much. Dong On 7/27/07, Greg Snow [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Can you really see much of the data in a 26*31 3d barplot? It seems like most info would be hidden behind the first few rows and it would be so cluttered that you would not be able to make out much of anything from it. It is true that with too much info in such a 3d graph, it would be not informative. Why not try a line plot instead (year as the x axis, each region a different year). Here is a quick example: data(votes.repub, package='cluster') matplot( t(votes.repub[1:31, 1:26]), type='l') Even better would be to group some of the regions together and use xyplot from the lattice package and have a panel for each group of regions (fewer lines per panel should be easier to see detail). You could also use the image function (or levelplot from lattice) to create a 26*31 grid with colors used for the 3rd dimension (can be good for overall patterns, not so good for looking at detail). Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: Dong GUO ?? [mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] ] Sent: Friday, July 27, 2007 12:09 PM To: Greg Snow Cc: r-help@stat.math.ethz.ch Subject: Re: [R] plot Many thanks, Greg and Justin. The matrix is just a 26*31 matrix - 26 years, 31 regions. I am know to R, just dont know how to attach the data here yet.. As I have such matrices for nine indicators for all regions, so i could show some differences by 3D plot, which I did similar things in Excel. I am sure there is a way to do it in R On 7/27/07, Greg Snow [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Graphs that rely on 3-d effects tend to distort the data rather than enlighten the viewer. If your goal is to distort the data (which I doubt), then most of us don't want to help. On the other hand, if you really do want to enlighten the viewer (even if that is just you), then tell us what your data is like and what you want to learn from it, and we will be happy to give you advice on creating useful graphs. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] ] On Behalf Of Dong GUO ?? Sent: Friday, July 27, 2007 8:45 AM To: r-help@stat.math.ethz.ch Subject: [R] plot Greetings to the group, I would like to know if some one could help me with plot 3-d column graph of a matrix (3-d column graph in Excel). Many thanks in advance. Regards, Dong __ 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 and provide commented, minimal, self-contained, reproducible code. [[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 and provide commented, minimal, self-contained, reproducible code.
[R] mfrow heatmap
I'd like to plot a heatmap along with a silhouette plot and clusterView plot in the same graphic window however both heatmap and heatmap.2 create a new window and will not work with the par(mfrow= ) option. Does anyone have an alternative which would put these plots together in a single window? Many thanks, Joe [[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 and provide commented, minimal, self-contained, reproducible code.