Re: [R] how to write and read an array ?
Francisco J. Zagmutt a écrit : check ?dput and ?dget Thanks for the answer. dput and dget work well (even if the internal data writing is not as directly readable as with write.table()) (When I'll be grown-up with R, I'll write a write.3dtable() function.) Thanks. Vincent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] equal
using the same a and b, why solve(a,b) get a 1 by n matrix while solve(a)%*%b get a n by 1 matrix. I thought they should be equal to each other... __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] its dates masked by chron
Whit Armstrong wrote: Uwe, It was unclear whether you were referring to chron or its as being unmaintained. I still maintain its, and I'm actually releasing a new version tonight since Kurt has pointed out that the current version is failing package checking. Whit, that's great! I was waiting for an its update for quite some time now, you have never reacted to my automatically generated request to fix your package with R-2.2.0 release nor have you worked on the problem that causes a Warning in all current checks for R = 2.2.0, hence I thought the package is rather unmaintained. It seems that both its and chron use namespaces. I thought the intent of namespaces was to prevent problems like this. I have to apologize (see Brian Ripley's reply), because I haven't tested myself that library(its) in fact does not cause chron to be loaded. Hence Namespace stuff should be sufficient. I was just wondering why someone would use the same name for a function that is masked by a package that automatically is attached some microseconds after library(its) is called. Best, Uwe If there are namespace experts out there who can suggest a fix to this problem, I'm happy to put it into the next release. -Whit -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Uwe Ligges Sent: Thursday, October 27, 2005 4:07 PM To: Peter Dalgaard Cc: r-help@stat.math.ethz.ch Subject: Re: [R] its dates masked by chron Peter Dalgaard wrote: Omar Lakkis [EMAIL PROTECTED] writes: To redescribe the problem; I need to use dates from its its depends on Hmisc Hmisc depends chron dates in chron masks dates in its So use its::dates ... ... or ask the package maintainer (which might be a hard task: the package currently appears to be more or less unmaintained) to fix this probably unintended behaviour. Uwe Ligges -- Forwarded message -- From: Omar Lakkis [EMAIL PROTECTED] Date: Oct 27, 2005 11:47 AM Subject: its dates masked by chron To: r-help@stat.math.ethz.ch I built R 2.2.0 from source on my debian machine yesterday and updated all packages. My problem is that dates function from its, that my code heavely uses is now masked by dates from chron. How can I specify tehat I want to use dates from its or how can I prevent it from being masked? library(its) Loading required package: Hmisc Hmisc library by Frank E Harrell Jr Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview') to see overall documentation. NOTE:Hmisc no longer redefines [.factor to drop unused levels when subsetting. To get the old behavior of Hmisc type dropUnusedLevels(). Attaching package: 'Hmisc' The following object(s) are masked from package:stats : ecdf Attaching package: 'chron' The following object(s) are masked from package:its : dates __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] solve error
w [,1] [,2] [,3] [,4] 1:1 0.0 0.5 0.5 0.0 2:1 0.5 0.0 0.0 0.5 1:2 0.5 0.0 0.0 0.5 2:2 0.0 0.5 0.5 0.0 solve(w) Error in solve.default(w) : Lapack routine dgesv: system is exactly singular what does the error mean? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] solve error
it means that the matrix w is singular; check all.equal(w[, 1], w[, 4]) all.equal(w[, 2], w[, 3]) # or qr(w)$rank you need linearly independent columns! I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Sam R. Smith [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, October 28, 2005 9:06 AM Subject: [R] solve error w [,1] [,2] [,3] [,4] 1:1 0.0 0.5 0.5 0.0 2:1 0.5 0.0 0.0 0.5 1:2 0.5 0.0 0.0 0.5 2:2 0.0 0.5 0.5 0.0 solve(w) Error in solve.default(w) : Lapack routine dgesv: system is exactly singular what does the error mean? __ 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 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to manipulate an abitrary dimensioned array.
Mike Meyer [EMAIL PROTECTED] writes: Thanks for the suggestion. Perhaps I can see how to use apply to get the ratio, but say I also want to return X[1] in a general way. Maybe I am being dense but I just don't see it --- probably as a result of too much Perl/Python/Java recently that is clouding my mind. I think Berton was hinting at apply(X,5,[,1) (it does get trickier if you need X[,,2,,,1] or X[,,3:4,,,1:2] because dimensions tend to get lost on the way into and out of the apply FUN argument.) In general, you can use do.call constructs, with TRUE for the missing arguments (there seems to be no nice way to pass missing to do.call). So can someone suggest a general function that will give me the last layer of an arbitrary dimensioned array? Berton Gunter wrote: Why doesn't apply() already do what you want? -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Meyer Sent: Thursday, October 27, 2005 2:50 PM To: r-help@stat.math.ethz.ch Subject: [R] How to manipulate an abitrary dimensioned array. If I have an n1 x n1 x 2 array X I can calculate, say, X[,,1]/X[,,2]. If it is a 4 dimensional array then I want to be able to calculate X[,,,1]/X[,,,2], and similarly for higher dimensions. How can I write a function to do this in a general way without having to do a switch for each possible length(dim(X)). So I want a function g that will take an arbitrary dimensioned array, X, and return X[,,,1]/X[,,,2], etc. I know how to do this by turning X into a vector, then doing the division, then re-shaping as an array, but that doesn't seem very elegant. What I think I am missing is how to paste/substitute/eval a bunch of commas into an array selection. Thanks, --Mike -- Mike Meyer, Seattle 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 __ 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 -- Mike Meyer, Seattle 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 -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] outer-question
Dear all, a big thanks to Thomas Lumley, James Holtman and Tony Plate for their answers. They all pointed in the same direction = I need a vectorized function to be applied. Hence, I will try to work with a 'wrapper' function as described in the FAQ. Thanks again, Roland -Original Message- From: Thomas Lumley [mailto:[EMAIL PROTECTED] Sent: Thursday, October 27, 2005 11:39 PM To: Rau, Roland Cc: r-help@stat.math.ethz.ch Subject: Re: [R] outer-question You want FAQ 7.17 Why does outer() behave strangely with my function? -thomas On Thu, 27 Oct 2005, Rau, Roland wrote: Dear all, This is a rather lengthy message, but I don't know what I made wrong in my real example since the simple code works. I have two variables a, b and a function f for which I would like to calculate all possible combinations of the values of a and b. If f is multiplication, I would simply do: a - 1:5 b - 1:5 outer(a,b) ## A bit more complicated is this: f - function(a,b,d) { return(a*b+(sum(d))) } additional - runif(100) outer(X=a, Y=b, FUN=f, d=additional) ## So far so good. But now my real example. I would like to plot the ## log-likelihood surface for two parameters alpha and beta of ## a Gompertz distribution with given data ### I have a function to generate random-numbers from a Gompertz-Distribution ### (using the 'inversion method') random.gomp - function(n, alpha, beta) { return( (log(1-(beta/alpha*log(1-runif(n)/beta) } ## Now I generate some 'lifetimes' no.people - 1000 al - 0.1 bet - 0.1 lifetimes - random.gomp(n=no.people, alpha=al, beta=bet) ### Since I neither have censoring nor truncation in this simple case, ### the log-likelihood should be simply the sum of the log of the ### the densities (following the parametrization of Klein/Moeschberger ### Survival Analysis, p. 38) loggomp - function(alphas, betas, timep) { return(sum(log(alphas) + betas*timep + (alphas/betas * (1-exp(betas*timep) } ### Now I thought I could obtain a matrix of the log-likelihood surface ### by specifying possible values for alpha and beta with the given data. ### I was able to produce this matrix with two for-loops. But I thought ### I could use also 'outer' in this case. ### This is what I tried: possible.alphas - seq(from=0.05, to=0.15, length=30) possible.betas - seq(from=0.05, to=0.15, length=30) outer(X=possible.alphas, Y=possible.betas, FUN=loggomp, timep=lifetimes) ### But the result is: outer(X=possible.alphas, Y=possible.betas, FUN=loggomp, timep=lifetimes) Error in outer(X = possible.alphas, Y = possible.betas, FUN = loggomp, : dim- : dims [product 900] do not match the length of object [1] In addition: Warning messages: ... ### Can somebody give me some hint where the problem is? ### I checked my definition of 'loggomp' but I thought this looks fine: loggomp(alphas=possible.alphas[1], betas=possible.betas[1], timep=lifetimes) loggomp(alphas=possible.alphas[4], betas=possible.betas[10], timep=lifetimes) loggomp(alphas=possible.alphas[3], betas=possible.betas[11], timep=lifetimes) ### I'd appreciate any kind of advice. ### Thanks a lot in advance. ### Roland + This mail has been sent through the MPI for Demographic Rese...{{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 Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle + This mail has been sent through the MPI for Demographic Rese...{{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
[R] how to amend a table in R workspace?
hello I want in R workspace to amend a table that is the function 'as.table' object,how to amend? I tried 'edit' and 'fix',but they are useless [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] 3d bar plot
Hi, does anyone has a bar plot function that produces something like this (I hope attachments work) ? If not, I simply want to produce 3d bar plots. Thanks in advance, Jan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] MCMC in R
[EMAIL PROTECTED] wrote: Dear R-helpers, Hi! All. I'm doing a project which needs MCMC simulation. I wonder whether there exists related packages in R. The only one I know is a MCMCpack package. What I want to do is implementing gibbs sampling and Metropolis-Hastings Algorithm to get the posterior of hierarchical bayesian models. Thanks in advance. If you are on Windows, one idea might be to use CRAN package BRugs which in fact makes use of OpenBUGS - you have to use OpenBUGS syntax in your model file, though. There is also JAGS (which runs also under Linux) by Martyn Plummer: http://www-fis.iarc.fr/~martyn/software/jags/ Uwe Ligges Jun __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] axis scaling problem
On the attached figure, I had to use ylim (0,3) to have enough space for the labels to be plotted. However, the values on the y-axis are never bigger than 1, so the axis labeling does not make much sense. Can I only get y-axis tick marks at 0 and 1 but still have the additional plotting space for the labels? Thanks Andreas -- -- Andreas Zankl, MD Division of Molecular Pediatrics Clinique Infantile 02/50 CHUV Avenue Pierre Decker 2 CH-1011 Lausanne Switzerland Phone: +41-21-3143778 Fax: +41-21-3143546 Email: [EMAIL PROTECTED]__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] clustering
Hi everybody, I'm performing a cluster analysis (pkg cluster) on a dataset which includes 15 variables: is there a way to know how much each variable weighs on the final clustering output? Thanks Alessandro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Empirical distribution
Ce message est a l'attention exclusive des destinataires designes. Il peut contenir des informations confidentielles. Si vous n'etes pas destinataire du message, merci d'en avertir immediatement l'expediteur et de detruire ce message. Le contenu de ce message ne pourrait engager la responsabilite du Credit Foncier de France que s'il a ete emis par une personne dument habilitee agissant dans le strict cadre de ses fonctions et a des fins non etrangeres a ses attributions. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expediteur ne donne aucune garantie a cet egard et sa responsabilite ne saurait etre engagee pour tout dommage resultant d'un virus transmis. This message is intended exclusively for the designated addressee. It may contain confidential material. If you are not the correct addressee, please notify the sender immediately and destroy the message. The content of this message will engage the responsibility of Credit Foncier only if it has been sent by an authorized person acting in the strict scope of his functions and for purposes that are related to his competence. Although reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to make labels on my dendrogam look more clear and visible
On Thu, 27 Oct 2005 23:19:36 -0400 Charles Annis, P.E. [EMAIL PROTECTED] wrote: I feel a bit timid in asking this question: Why create the PS? Why not create the pdf directly? ?pdf You have lots of control over the size and other characteristics, and the pdf can be used by MiKTeX to create a TeX - pdf document containing your graphic. I'm running R 2.2.0 on a DELL WinXP machine. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com I'm even more timid in answering... I like to have .ps as my working files and .pdf as the finished(?) ones. I'm using pdflatex (TeTeX) here, so yes it's definitely an extra step. This way though, I can instantly see which files are part of a paper / presentation and (later, if needed) backtrack through the drafts to see why I chose those ones. jon b __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] aov() and lme() (repeated measures and ANOVA)
Hello, Subject: [R] aov() and lme() From: Jan Wiener [EMAIL PROTECTED] Date: Thu, 27 Oct 2005 13:14:59 +0200 Sorry for reposting, but even after extensive search I still did not find any answers. using: summary(aov(pointErrorAbs~noOfSegments*turnAngle+Error(subj/(noOfSegments+turnAngle)), data=anovaAllData )) with subj being a random factor and noOfSegments and turnAngle being fixed factors, I get the following results: [...] No I trying to fit the same data with lme and using the following call: anova(lme(fixed=pointErrorAbs~noOfSegments*turnAngle, random=~1|subj, data=anovaAllData)) Unfortunately the results are 'really' different from the aov() procedure (I guess I have the call wrong): Maybe the following post concerning repeated measures and ANOVA can help: (from http://tolstoy.newcastle.edu.au/~rking/R/help/03b/7663.html) $ anova(lme(DV ~ GROUP*TRIAL,random= ~1|SUB, correlation=corCompSymm() )) (TRIAL and GROUP are fixed factors) Actually, you do not need lme for to run a repeated measure anova. You could use the aov function: $ summary(aov(DV~GROUP*TRIAL+Error(SUB/TRIAL))) ... yields the same results (when data are balanced) Christophe Pallier www.pallier.org __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] tcltk package problems (R 2.2.0, SuSE 10)
i also had a problem getting 2.2.0 to work with tcltk on SuSE 10.0... and with compiling R from source on SuSE 10.0. on getting tcltk to work: i ended up taking source for tcl and tk from http://www.tcl.tk/software/tcltk/ and recompiling; once you unpack the tar.gz the install instructions are in the directory /unix for both programs. after that then capabilities() shows tcltk is TRUE and it works fine. i'm not sure if this was the easiest solution, but it worked. on getting SuSE 10 to compile R from source: i was unable to use Yast to get a fortran compiler and ended up recompiling gcc to include gfortran from the source (at e.g. http://gcc.fyxm.net/releases/gcc-4.0.2/ ) if you want some more detailed instructions feel free to mail me. best regards and good luck. Katharine Mullen Department of Physics and Astronomy Faculty of Sciences Vrije Universiteit de Boelelaan 1081 1081 HV Amsterdam The Netherlands room: T.1.06 tel: +31 205987870 fax: +31 205987992 e-mail: [EMAIL PROTECTED] http://www.nat.vu.nl/~kate/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] line vector plots
Hi, I'm looking for the way to make vector plot over a time line. This plot, similar to the feather plot in Matlab, is a line in which every thick (a time value) one vector is drawn with its length proportional to one variable (wind speed, for example) and its direction to another (wind direction, for example). Any ideas? Thanks, EKS -- Eduardo Klein Instituto de Tecnología y Ciencias Marinas Universidad Simón Bolívar Caracas, Venezuela ph/fax (58) (212) 906-3416 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] errors handling
Hi, I have an index i that varies from 1 to n. For each value of this index I open a connection, e.g. conness-url(...) conness-readLines(conness) For certain values of i it occurs an error (Warning message: cannot open: HTTP status was `0 (null)' ) and the program flow ends. How can I ignore these errors, allowing the program to go on? Thanks, Marco [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] inverse matrix
Sam R. Smith wrote: if solve(a,b) means to calculate an inverse matrix of a with b, and i wonder why solve(a)%%b will get different result? It does? Or perhaps your %% is not just a typo. It should be %*%. a - matrix(rnorm(16), 4, 4) b - matrix(rnorm(4), 4, 1) solve(a, b) [,1] [1,] -0.8005768 [2,] 0.5913755 [3,] -1.8256012 [4,] 0.8973716 solve(a) %*% b [,1] [1,] -0.8005768 [2,] 0.5913755 [3,] -1.8256012 [4,] 0.8973716 HTH, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Random effect models
Dear R-users, Sorry for reposting. I put it in another way : I want to test random effects in this random effect model : Rendement ~ Pollinisateur (random) + Lignee (random) + Pollinisateur:Lignee (random) Of course : summary(aov(Rendement ~ Pollinisateur * Lignee, data = mca2)) gives wrong tests for random effects. But : summary(aov1 - aov(Rendement ~ Error(Pollinisateur * Lignee), data = mca2)) gives no test at all, and I have to do it with mean squares lying in summary(aov1). With lme4 package (I did'nt succeed in writing a working formula with lme from nlme package), I can see standard deviations of random effects (I don't know how to find them) but I can't find F tests for random effects. I only want to know if there is an easy way (a function ?) to do F tests for random effects in random effect models. Thanks in advance. Best regards, Jacques VESLOT Data and output are as follows : head(mca2) Lignee Pollinisateur Rendement 1 L1P1 13.4 2 L1P1 13.3 3 L2P1 12.4 4 L2P1 12.6 5 L3P1 12.7 6 L3P1 13.0 names(mca2) [1] LigneePollinisateur Rendement dim(mca2) [1] 100 3 replications(Rendement ~ Lignee * Pollinisateur, data = mca2) LigneePollinisateur Lignee:Pollinisateur 20 102 summary(aov1 - aov(Rendement ~ Error(Pollinisateur * Lignee), data = mca2) Error: Pollinisateur Df Sum Sq Mean Sq F value Pr(F) Residuals 9 11.9729 1.3303 Error: Lignee Df Sum Sq Mean Sq F value Pr(F) Residuals 4 18.0294 4.5074 Error: Pollinisateur:Lignee Df Sum Sq Mean Sq F value Pr(F) Residuals 36 5.1726 0.1437 Error: Within Df Sum Sq Mean Sq F value Pr(F) Residuals 50 3.7950 0.0759 # F tests : Femp - c(tab1[1:3, 3]/tab1[c(3,3,4), 3]) names(Femp) - c(Pollinisateur, Lignee, Interaction) Femp PollinisateurLignee Interaction 9.258709 31.370027 1.893061 1 - pf(Femp, tab1[1:3,1], tab1[c(3,3,4),1]) PollinisateurLignee Interaction 4.230265e-07 2.773448e-11 1.841028e-02 # Standard deviation : variances - c(c(tab1[1:3, 3] - tab1[c(3,3,4), 3]) / c(2*5, 2*10, 2), tab1[4,3]) names(variances) - c(names(Femp), Residuelle) variances PollinisateurLignee InteractionResiduelle 0.118663890.218183330.033891670.0759 # Using lmer : library(lme4) lme1 - lmer(Rendement ~ (1|Pollinisateur) + (1|Lignee) + (1|Pollinisateur:Lignee), data = mca2)) summary(lme1) Linear mixed-effects model fit by REML Formula: Rendement ~ (1 | Pollinisateur) + (1 | Lignee) + (1 | Pollinisateur:Lignee) Data: mca2 AIC BIClogLik MLdeviance REMLdeviance 105.3845 118.4104 -47.69227 94.35162 95.38453 Random effects: Groups NameVariance Std.Dev. Pollinisateur:Lignee (Intercept) 0.033892 0.18410 Pollinisateur(Intercept) 0.118664 0.34448 Lignee (Intercept) 0.218183 0.46710 Residual 0.075900 0.27550 # of obs: 100, groups: Pollinisateur:Lignee, 50; Pollinisateur, 10; Lignee, 5 Fixed effects: Estimate Std. Error DF t value Pr(|t|) (Intercept) 12.601000.23862 99 52.808 2.2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 anova(lme1) Analysis of Variance Table Erreur dans ok[, -nc] : nombre de dimensions incorrect __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] inverse matrix
Sundar Dorai-Raj [EMAIL PROTECTED] writes: Sam R. Smith wrote: if solve(a,b) means to calculate an inverse matrix of a with b, and i wonder why solve(a)%%b will get different result? It does? Or perhaps your %% is not just a typo. It should be %*%. a - matrix(rnorm(16), 4, 4) b - matrix(rnorm(4), 4, 1) solve(a, b) [,1] [1,] -0.8005768 [2,] 0.5913755 [3,] -1.8256012 [4,] 0.8973716 solve(a) %*% b [,1] [1,] -0.8005768 [2,] 0.5913755 [3,] -1.8256012 [4,] 0.8973716 I think the issue is this: solve(a, b) [1] -0.7251033 -0.3903765 0.3212044 -1.2969697 solve(a)%*% b [,1] [1,] -0.7251033 [2,] -0.3903765 [3,] 0.3212044 [4,] -1.2969697 So b gets promoted to a column matrix in one case but not the other. This is slightly odd, but it's been that way forever and in S(-PLUS) too, so I think it is unchangeable (it's the sort of thing that there's a 99% chance that some people have actually been relying on). If you want a vector result from a matrix multiply, there's always drop(solve(a)%*% b) [1] -0.7251033 -0.3903765 0.3212044 -1.2969697 -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] errors handling
Marco Venanzi wrote: Hi, I have an index i that varies from 1 to n. For each value of this index I open a connection, e.g. conness-url(...) conness-readLines(conness) For certain values of i it occurs an error (Warning message: cannot open: HTTP status was `0 (null)' ) and the program flow ends. How can I ignore these errors, allowing the program to go on? Please read the FAQs, in particular How can I capture or ignore errors in a long simulation?! Uwe Ligges Thanks, Marco [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] clustering
alessandro carletti wrote: Hi everybody, I'm performing a cluster analysis (pkg cluster) on a dataset which includes 15 variables: is there a way to know how much each variable weighs on the final clustering output? What kind of cluster method? Most cluster methods are based on some distance between observations (or clusters), hence not related to weights of variables. Uwe Ligges Thanks Alessandro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Random effect models
Dear Jacques I think your question is a little confusing, but let me take a stab at what I think you're getting at. It seems you are trying to find the statistical significance of a variance component in your lme model, and not the significance of a fixed effect. If this is what you are looking for you will not find this as standard output in lme or lmer. Not in summary() or anova() I don't know what you mean by I can see the sd of ranodm effects but you do not know how to find them Other software programs for mixed linear models do indeed provide this as ouput, but not the mixed model functions in R. This topic has been discussed often on this list and the package developer, Doug Bates, has noted numerous times, with good empirical examples, why such a test may potentially be misleading. Use the archives to study this rationale and see the numerous threads on the topic. Note that the standard deviations of the random effects are *not* the standard errors of those variance components. I also noticed you are loading the lme4 library and using lmer. You should load Matrix, which has the most recent lmer function in that package. If I am mistaken, then please clarify and maybe someone else can help. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jacques VESLOT Sent: Friday, October 28, 2005 7:22 AM To: R-help@stat.math.ethz.ch Subject: [R] Random effect models Dear R-users, Sorry for reposting. I put it in another way : I want to test random effects in this random effect model : Rendement ~ Pollinisateur (random) + Lignee (random) + Pollinisateur:Lignee (random) Of course : summary(aov(Rendement ~ Pollinisateur * Lignee, data = mca2)) gives wrong tests for random effects. But : summary(aov1 - aov(Rendement ~ Error(Pollinisateur * Lignee), data = mca2)) gives no test at all, and I have to do it with mean squares lying in summary(aov1). With lme4 package (I did'nt succeed in writing a working formula with lme from nlme package), I can see standard deviations of random effects (I don't know how to find them) but I can't find F tests for random effects. I only want to know if there is an easy way (a function ?) to do F tests for random effects in random effect models. Thanks in advance. Best regards, Jacques VESLOT Data and output are as follows : head(mca2) Lignee Pollinisateur Rendement 1 L1P1 13.4 2 L1P1 13.3 3 L2P1 12.4 4 L2P1 12.6 5 L3P1 12.7 6 L3P1 13.0 names(mca2) [1] LigneePollinisateur Rendement dim(mca2) [1] 100 3 replications(Rendement ~ Lignee * Pollinisateur, data = mca2) LigneePollinisateur Lignee:Pollinisateur 20 102 summary(aov1 - aov(Rendement ~ Error(Pollinisateur * Lignee), data = mca2) Error: Pollinisateur Df Sum Sq Mean Sq F value Pr(F) Residuals 9 11.9729 1.3303 Error: Lignee Df Sum Sq Mean Sq F value Pr(F) Residuals 4 18.0294 4.5074 Error: Pollinisateur:Lignee Df Sum Sq Mean Sq F value Pr(F) Residuals 36 5.1726 0.1437 Error: Within Df Sum Sq Mean Sq F value Pr(F) Residuals 50 3.7950 0.0759 # F tests : Femp - c(tab1[1:3, 3]/tab1[c(3,3,4), 3]) names(Femp) - c(Pollinisateur, Lignee, Interaction) Femp PollinisateurLignee Interaction 9.258709 31.370027 1.893061 1 - pf(Femp, tab1[1:3,1], tab1[c(3,3,4),1]) PollinisateurLignee Interaction 4.230265e-07 2.773448e-11 1.841028e-02 # Standard deviation : variances - c(c(tab1[1:3, 3] - tab1[c(3,3,4), 3]) / c(2*5, 2*10, 2), tab1[4,3]) names(variances) - c(names(Femp), Residuelle) variances PollinisateurLignee InteractionResiduelle 0.118663890.218183330.033891670.0759 # Using lmer : library(lme4) lme1 - lmer(Rendement ~ (1|Pollinisateur) + (1|Lignee) + (1|Pollinisateur:Lignee), data = mca2)) summary(lme1) Linear mixed-effects model fit by REML Formula: Rendement ~ (1 | Pollinisateur) + (1 | Lignee) + (1 | Pollinisateur:Lignee) Data: mca2 AIC BIClogLik MLdeviance REMLdeviance 105.3845 118.4104 -47.69227 94.35162 95.38453 Random effects: Groups NameVariance Std.Dev. Pollinisateur:Lignee (Intercept) 0.033892 0.18410 Pollinisateur(Intercept) 0.118664 0.34448 Lignee (Intercept) 0.218183 0.46710 Residual 0.075900 0.27550 # of obs: 100, groups: Pollinisateur:Lignee, 50; Pollinisateur, 10; Lignee, 5 Fixed effects: Estimate Std. Error DF t value Pr(|t|) (Intercept) 12.601000.23862 99 52.808 2.2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 anova(lme1) Analysis of Variance Table Erreur dans ok[, -nc] : nombre de dimensions incorrect
Re: [R] Problems with source() function
Thank you for your answer :) I've tested your suggestion but without success. The remote load process is truncated silently using source(textConnection(readLines(url(http://...))) when look at the contents there's not a fixed point of break, is different each time I execute the command. Therefore the dropped lines are different every time. It seems the only constant is the time of the interruption (1 min 55 secs in my system). Loading the file in a browser (it loads always complete) and examining the text, there's no apparent malformation in the rupture points. The longest line is 669 chars and is perfectly loaded in remote and local mode: lineas - readLines(transcripts_moe430a.R) length(lineas) [1] 20347 max(nchar(lineas)) [1] 669 which(nchar(lineas)==669) [1] 3241 lineas - readLines(url (http://10.10.10.3:83/probefinder/scripts/probegrouper.php?chip=moe430amode=transcript;)) length(lineas) [1] 7471 max(nchar(lineas)) [1] 669 which(nchar(lineas)==669) [1] 3242 Apparently there's a timeout in the url() or some subordinated function. I will try to use the RCurl package but, for educational purposes, I prefer that the load process were managed in a simply way... with an source() for example, in order to not overload alumni with tricky methods... Thank you again. . Alberto de Luis Bioinformatics and Functional Genomics Lab Cancer Research Center Salamanca (Spain) . On Thu, 2005-10-27 at 12:35 -0700, Duncan Temple Lang wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Does source(textConnection(readLines(url(http://...))) give the correct answer. If not, what is being dropped when you just use readLines() and look at the contents of the download. And how long is the longest line? The RCurl package (http://www.omegahat.org/RCurl) gives you a lot of control in perform and processing HTTP requests, allowing you to control the request, and read the body and the header of the response. It may be worth a try if things are getting frustrating. D. Al wrote: Hello list members! I'm trying to enter some data in an R session using source() function with an URL as argument. The data source is a PHP script located in an apache web server and the data is a long list generated on-the-fly, these are the initial lines: groups-list() groups[['ENSMUST001']]=c(52611,483683,147952,132170,297514,469248,291525,364037,469915,55472,280220,314688,415650,486875,440898,6781,497785) groups[['ENSMUST003']]=c(416911,327120,425495,72272,297529,101933,371418,139034,318872,367204,237702) groups[['ENSMUST028']]=c(199311,325400,184761,241988,376845,75052,67724,404240,439543,391057,393816) groups[['ENSMUST031']]=c(402587,352900,139030,186068,463553,328881,74942,277085,301431,256149,410846) groups[['ENSMUST033']]=c(12700,23908,11140,122358,389908,390084,383903,354007,457965,106395,131876) groups[['ENSMUST049']]=c(59336,203239,101077,382882,327374,281549,212042,275594,361523,490934,240275) groups[['ENSMUST056']]=c(409571,304584,394332,379699,13785,4260,29,42538,304075,47734,485512,52501,328509,504846,334607,82566,250088,150240,16422,446551,314484,91878,124752,341638,379512,379890,319764,8019,59221,156508,362524,74001,149400) groups[['ENSMUST058']]=c(26511 ,4 5! 5190,466368,358528,268486,315461,149260,422804,137641,163718,352555) The problem: When I execute the command it apparently finish ok, without printed errors but when I test the consistency of the data entered using the command length() I always obtain different figures. More facts: When I source the data from a static file instead an url, the data is fully entered and the length is always the same (20346 list elements). It delays 30 secs to load. When I source the data from the dynamic way, from an url, it delays 2 min. and always data is truncated. Tried and miserably failed: - Changed .Options$timeout from 60 to 300 - Using R --verbose is of no help, the data is silently truncated. - Changed the expression in which data is entered: groups-list( 'ENSMUST001'=c(52611,483683,147952,132170,297514,469248,291525,364037,469915,55472,280220,314688,415650,486875,440898,6781,497785), 'ENSMUST003'=c(416911,327120,425495,72272,297529,101933,371418,139034,318872,367204,237702) ... ) Kind list members, is there some timeout I am missing? Some way to debug the process? Some suggestion? Sincerely, thank you! Alberto de Luis www.cicancer.org __ 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 - -- Duncan
Re: [R] 3d bar plot
On Fri, 2005-10-28 at 10:07 +0200, Jan Wiener wrote: Hi, does anyone has a bar plot function that produces something like this (I hope attachments work) ? If not, I simply want to produce 3d bar plots. Thanks in advance, Jan Other than perhaps the 'rgl' package I don't think so. In general, 3d barplots are a bad way to present data (almost as bad as 3d exploding pie charts...) More information on 'rgl' is here: http://rgl.neoscientists.org and is available via CRAN. 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
[R] multiple graphs in the same ps file ?
Dear all, I would like to be able to store multiple graphs in one ps or pdf file, but I cannot achieve this only if I don't shut the postscript device between the graphs. here is what I managed to do : postscript(file=test_graph.eps, onefile=TRUE) plot(1:10) plot(1:20) dev.off() --- but when I try : postscript(file=test_graph.eps, onefile=TRUE) plot(1:10) dev.off [execution of another part of the code and then:] plot(1:20) dev.print(postscript, onefile=TRUE) dev.off() I only have one page in my file test_graph.eps which only contains the last graphics. So I wonder : is it possible to reopen a ps or pdf file and to add data (I tried the append=TRUE option but without success) ? Thanks a lot Florence. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] multiple graphs in the same ps file ? -- with ref.
Sorry I put there the ref. : I am using R Version 2.0.1 on a Debian. Florence. -- Forwarded message -- From: Florence Combes [EMAIL PROTECTED] Date: Oct 28, 2005 2:48 PM Subject: multiple graphs in the same ps file ? To: r-help@stat.math.ethz.ch Dear all, I would like to be able to store multiple graphs in one ps or pdf file, but I cannot achieve this only if I don't shut the postscript device between the graphs. here is what I managed to do : postscript(file=test_graph.eps, onefile=TRUE) plot(1:10) plot(1:20) dev.off() --- but when I try : postscript(file=test_graph.eps, onefile=TRUE) plot(1:10) dev.off [execution of another part of the code and then:] plot(1:20) dev.print(postscript, onefile=TRUE) dev.off() I only have one page in my file test_graph.eps which only contains the last graphics. So I wonder : is it possible to reopen a ps or pdf file and to add data (I tried the append=TRUE option but without success) ? Thanks a lot Florence. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] axis scaling problem
On Fri, 2005-10-28 at 10:27 +0200, Andreas Zankl wrote: On the attached figure, I had to use ylim (0,3) to have enough space for the labels to be plotted. However, the values on the y-axis are never bigger than 1, so the axis labeling does not make much sense. Can I only get y-axis tick marks at 0 and 1 but still have the additional plotting space for the labels? Thanks Andreas Your attachment did not come through and without either reproducible code or the image, it would be difficult to provide specific recommendations. However, things to consider: 1. Reduce the size of the fonts for your axis labels to make more room. See ?par and note the cex.axis parameter. 2. Consider using meaningful abbreviations for your labels to shorten them. 3. Consider rotating the labels using par(las). You will likely need to adjust the plot margins using par(mar) as well to make room for the rotated labels. 4. See R FAQ 7.27 How can I create rotated axis labels? which is a method to enable axis labels rotated to something between horizontal and vertical (ie. 45 degrees). HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multiple graphs in the same ps file ?
On Fri, 2005-10-28 at 14:48 +0200, Florence Combes wrote: Dear all, I would like to be able to store multiple graphs in one ps or pdf file, but I cannot achieve this only if I don't shut the postscript device between the graphs. here is what I managed to do : postscript(file=test_graph.eps, onefile=TRUE) plot(1:10) plot(1:20) dev.off() --- but when I try : postscript(file=test_graph.eps, onefile=TRUE) plot(1:10) dev.off [execution of another part of the code and then:] plot(1:20) dev.print(postscript, onefile=TRUE) dev.off() I only have one page in my file test_graph.eps which only contains the last graphics. So I wonder : is it possible to reopen a ps or pdf file and to add data (I tried the append=TRUE option but without success) ? Thanks a lot Florence. As per ?postscript the 'append' argument is _disregarded_. Please review the help page more carefully. If you want more than one plot per PS file, do not use dev.off() between plots: postscript(file=test_graph.eps, onefile = TRUE) plot(1:5) barplot(1:5) dev.off() HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multiple graphs in the same ps file ? -- with ref.
On Fri, 2005-10-28 at 14:52 +0200, Florence Combes wrote: Sorry I put there the ref. : I am using R Version 2.0.1 on a Debian. Florence. Definitely time to upgrade, as you are several versions behind. The current version is 2.2.0. 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
Re: [R] multiple graphs in the same ps file ?
On Fri, 2005-10-28 at 08:01 -0500, Marc Schwartz wrote: On Fri, 2005-10-28 at 14:48 +0200, Florence Combes wrote: Dear all, I would like to be able to store multiple graphs in one ps or pdf file, but I cannot achieve this only if I don't shut the postscript device between the graphs. here is what I managed to do : postscript(file=test_graph.eps, onefile=TRUE) plot(1:10) plot(1:20) dev.off() --- but when I try : postscript(file=test_graph.eps, onefile=TRUE) plot(1:10) dev.off [execution of another part of the code and then:] plot(1:20) dev.print(postscript, onefile=TRUE) dev.off() I only have one page in my file test_graph.eps which only contains the last graphics. So I wonder : is it possible to reopen a ps or pdf file and to add data (I tried the append=TRUE option but without success) ? Thanks a lot Florence. As per ?postscript the 'append' argument is _disregarded_. Please review the help page more carefully. If you want more than one plot per PS file, do not use dev.off() between plots: postscript(file=test_graph.eps, onefile = TRUE) plot(1:5) barplot(1:5) dev.off() One more clarification which I forgot to mention here. If you want an EPS file (encapsulated postscript) for inclusion in another document (ie. LaTeX or importing into another application), you cannot have more than one page in the PS file and must use a postscript call the looks something like this: postscript(file=test_graph.eps, onefile = FALSE, horizontal = FALSE, paper = special, ...) See the Details section of ?postscript for more information. The three key arguments are 'onefile', 'horizontal' and 'paper'. 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
[R] splitting a character field in R
Dear R users, I have a dataframe with one character field, and I would like to create two new fields (columns) in my dataset, by spliting the existing character field into two using an existing substring. ... something that in SAS I could solve e.g. combining substr(which I am aware exist in R) and index for determining the position of the pattern within the string. e.g. if my dataframe is ... A B 1 dgabcrt 2 fgrtabc 3 sabcuuu Then by splitting by substring abc I would get ... A B B1B2 1 dgabcrt dgrt 2 fgrtabc fgrt 3 sabcuuu s uuu Do you know how to do this basic string(dataframe) manipulation in R Saludos, Manuel __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Missing Data?
I am using glmmPQL on a dataset which has no missing values: antgl-glmmPQL(SF~Proc*Min, random= ~1|Trial, family=binomial) I get the error message: iteration 1 Error in na.fail.default(list(invwt = c(1.36892171002990, 1.36680104392581, : missing values in object I also get this error if na.action is set na.fail. If I set na.action to na.omit to ignore the (mythical) missing values, I get other error messages. There are no missing values - I have used is.na(antgl) to check this. Can anyone explain why it seems to think there are? Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problems with source() function
On 28 Oct 2005, [EMAIL PROTECTED] wrote: Thank you for your answer :) I've tested your suggestion but without success. The remote load process is truncated silently using source(textConnection(readLines(url(http://...))) when look at the contents there's not a fixed point of break, is different each time I execute the command. Therefore the dropped lines are different every time. It seems the only constant is the time of the interruption (1 min 55 secs in my system). I'm not sure exactly what you are trying to accomplish, but I wonder if either of the following two ideas would help you: 1. Instead of source(), consider loading the R code on the server side and then using save(..., compres=TRUE) to create a binary image. You can then feed that to the clients and have them use load(). 2. What happens if you gzip the code before sending and gunzip on the client side. It may be less convenient, although supposedly there is a way to do the equivalent of gzfile(url(...)). HTH, + seth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] splitting a character field in R
x - 'dfabcxy' strsplit(x, 'abc') [[1]] [1] df xy On 10/28/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear R users, I have a dataframe with one character field, and I would like to create two new fields (columns) in my dataset, by spliting the existing character field into two using an existing substring. ... something that in SAS I could solve e.g. combining substr(which I am aware exist in R) and index for determining the position of the pattern within the string. e.g. if my dataframe is ... A B 1 dgabcrt 2 fgrtabc 3 sabcuuu Then by splitting by substring abc I would get ... A B B1 B2 1 dgabcrt dg rt 2 fgrtabc fgrt 3 sabcuuu s uuu Do you know how to do this basic string(dataframe) manipulation in R Saludos, Manuel __ 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 -- Jim Holtman Cincinnati, OH +1 513 247 0281 What the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Random effect models
Dear Jacques You may be interested in the answer of Doug Bates to another post. The question is different, but in the answer there is a part about testing if a variance component may be zero: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/51080.html Hope this helps. Best regards, Christoph Buser -- Christoph Buser [EMAIL PROTECTED] Seminar fuer Statistik, LEO C13 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-44-632-4673 fax: 632-1228 http://stat.ethz.ch/~buser/ -- Jacques VESLOT writes: Dear R-users, Sorry for reposting. I put it in another way : I want to test random effects in this random effect model : Rendement ~ Pollinisateur (random) + Lignee (random) + Pollinisateur:Lignee (random) Of course : summary(aov(Rendement ~ Pollinisateur * Lignee, data = mca2)) gives wrong tests for random effects. But : summary(aov1 - aov(Rendement ~ Error(Pollinisateur * Lignee), data = mca2)) gives no test at all, and I have to do it with mean squares lying in summary(aov1). With lme4 package (I did'nt succeed in writing a working formula with lme from nlme package), I can see standard deviations of random effects (I don't know how to find them) but I can't find F tests for random effects. I only want to know if there is an easy way (a function ?) to do F tests for random effects in random effect models. Thanks in advance. Best regards, Jacques VESLOT Data and output are as follows : head(mca2) Lignee Pollinisateur Rendement 1 L1P1 13.4 2 L1P1 13.3 3 L2P1 12.4 4 L2P1 12.6 5 L3P1 12.7 6 L3P1 13.0 names(mca2) [1] LigneePollinisateur Rendement dim(mca2) [1] 100 3 replications(Rendement ~ Lignee * Pollinisateur, data = mca2) LigneePollinisateur Lignee:Pollinisateur 20 102 summary(aov1 - aov(Rendement ~ Error(Pollinisateur * Lignee), data = mca2) Error: Pollinisateur Df Sum Sq Mean Sq F value Pr(F) Residuals 9 11.9729 1.3303 Error: Lignee Df Sum Sq Mean Sq F value Pr(F) Residuals 4 18.0294 4.5074 Error: Pollinisateur:Lignee Df Sum Sq Mean Sq F value Pr(F) Residuals 36 5.1726 0.1437 Error: Within Df Sum Sq Mean Sq F value Pr(F) Residuals 50 3.7950 0.0759 # F tests : Femp - c(tab1[1:3, 3]/tab1[c(3,3,4), 3]) names(Femp) - c(Pollinisateur, Lignee, Interaction) Femp PollinisateurLignee Interaction 9.258709 31.370027 1.893061 1 - pf(Femp, tab1[1:3,1], tab1[c(3,3,4),1]) PollinisateurLignee Interaction 4.230265e-07 2.773448e-11 1.841028e-02 # Standard deviation : variances - c(c(tab1[1:3, 3] - tab1[c(3,3,4), 3]) / c(2*5, 2*10, 2), tab1[4,3]) names(variances) - c(names(Femp), Residuelle) variances PollinisateurLignee InteractionResiduelle 0.118663890.218183330.033891670.0759 # Using lmer : library(lme4) lme1 - lmer(Rendement ~ (1|Pollinisateur) + (1|Lignee) + (1|Pollinisateur:Lignee), data = mca2)) summary(lme1) Linear mixed-effects model fit by REML Formula: Rendement ~ (1 | Pollinisateur) + (1 | Lignee) + (1 | Pollinisateur:Lignee) Data: mca2 AIC BIClogLik MLdeviance REMLdeviance 105.3845 118.4104 -47.69227 94.35162 95.38453 Random effects: Groups NameVariance Std.Dev. Pollinisateur:Lignee (Intercept) 0.033892 0.18410 Pollinisateur(Intercept) 0.118664 0.34448 Lignee (Intercept) 0.218183 0.46710 Residual 0.075900 0.27550 # of obs: 100, groups: Pollinisateur:Lignee, 50; Pollinisateur, 10; Lignee, 5 Fixed effects: Estimate Std. Error DF t value Pr(|t|) (Intercept) 12.601000.23862 99 52.808 2.2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 anova(lme1) Analysis of Variance Table Erreur dans ok[, -nc] : nombre de dimensions incorrect __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] splitting a character field in R
see sub() and gsub(), but it won't be straightforward as somethink like string(dataframe), ie you'll have to 1st treat the character object with sub() or gsub() and 2d rebuils a dataframe. hope this helps Florence. On 10/28/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear R users, I have a dataframe with one character field, and I would like to create two new fields (columns) in my dataset, by spliting the existing character field into two using an existing substring. ... something that in SAS I could solve e.g. combining substr(which I am aware exist in R) and index for determining the position of the pattern within the string. e.g. if my dataframe is ... A B 1 dgabcrt 2 fgrtabc 3 sabcuuu Then by splitting by substring abc I would get ... A B B1 B2 1 dgabcrt dg rt 2 fgrtabc fgrt 3 sabcuuu s uuu Do you know how to do this basic string(dataframe) manipulation in R Saludos, Manuel __ 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 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] splitting a character field in R
Hi Jim, Thanks for your post, I was aware of strsplit, but really could not find out how i could use it. I tried like in your example ... A-c(1,2,3) B-c(dgabcrt,fgrtabc,sabcuuu) C-strsplit(B,abc) C [[1]] [1] dg rt [[2]] [1] fgrt [[3]] [1] s uuu Which looks promissing, but here C is a list with three elements. But how to create the two vectors I need from here, that is (dg,fgrt, s) and (rt,,uuu) (or how to get access to the substrings rt or uuu). Greetings Manuel jim holtman [EMAIL PROTECTED]To: [EMAIL PROTECTED] [EMAIL PROTECTED] om cc: r-help@stat.math.ethz.ch Subject: Re: [R] splitting a character field in R 28.10.2005 16:00 x - 'dfabcxy' strsplit(x, 'abc') [[1]] [1] df xy On 10/28/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear R users, I have a dataframe with one character field, and I would like to create two new fields (columns) in my dataset, by spliting the existing character field into two using an existing substring. ... something that in SAS I could solve e.g. combining substr(which I am aware exist in R) and index for determining the position of the pattern within the string. e.g. if my dataframe is ... A B 1 dgabcrt 2 fgrtabc 3 sabcuuu Then by splitting by substring abc I would get ... A B B1B2 1 dgabcrt dgrt 2 fgrtabc fgrt 3 sabcuuu s uuu Do you know how to do this basic string(dataframe) manipulation in R Saludos, Manuel __ 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 -- Jim Holtman Cincinnati, OH +1 513 247 0281 What 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
[R] Uncensoring a dataset - resent
Does anyone know of an R package that I can use to uncensor a normal or log-normal dataset? I'm particularly interested in the MLE method of Cohen (1959), Simplified estimators for the normal distribution when samples are single censored or truncated, Technometrics, 1(3), 217-237. Of course, if there is anything better, I'd be glad to hear about that too. Thanks. Rick __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] splitting a character field in R
You could use: data.frame(First = sub(abc.*, , B), Second = sub(.*abc, , B)) or if you want to prevent conversion to factors: data.frame(First = I(sub(abc.*, , B)), Second = I(sub(.*abc, , B))) On 10/28/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi Jim, Thanks for your post, I was aware of strsplit, but really could not find out how i could use it. I tried like in your example ... A-c(1,2,3) B-c(dgabcrt,fgrtabc,sabcuuu) C-strsplit(B,abc) C [[1]] [1] dg rt [[2]] [1] fgrt [[3]] [1] s uuu Which looks promissing, but here C is a list with three elements. But how to create the two vectors I need from here, that is (dg,fgrt, s) and (rt,,uuu) (or how to get access to the substrings rt or uuu). Greetings Manuel jim holtman [EMAIL PROTECTED]To: [EMAIL PROTECTED] [EMAIL PROTECTED] om cc: r-help@stat.math.ethz.ch Subject: Re: [R] splitting a character field in R 28.10.2005 16:00 x - 'dfabcxy' strsplit(x, 'abc') [[1]] [1] df xy On 10/28/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear R users, I have a dataframe with one character field, and I would like to create two new fields (columns) in my dataset, by spliting the existing character field into two using an existing substring. ... something that in SAS I could solve e.g. combining substr(which I am aware exist in R) and index for determining the position of the pattern within the string. e.g. if my dataframe is ... A B 1 dgabcrt 2 fgrtabc 3 sabcuuu Then by splitting by substring abc I would get ... A B B1B2 1 dgabcrt dgrt 2 fgrtabc fgrt 3 sabcuuu s uuu Do you know how to do this basic string(dataframe) manipulation in R Saludos, Manuel __ 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 -- Jim Holtman Cincinnati, OH +1 513 247 0281 What 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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] numeric index of a matrix column name ?
Dear All, I have written the following small code in order to return the numeric index of a given matrix column ascii name. It works, but there is perhaps/probably a predefined function which does that ? If yes, thanks for pointing me to it. # input : a matrix M and a column ascii name # output : the numeric index of the column colnameindex = function(M , colname0) { colsnames = names(M[1,]); theindex = which(colsnames==colname0); return(theindex); } Thanks Vincent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Uncensoring a dataset - resent
On Fri, 28 Oct 2005, Richard Reiss wrote: Does anyone know of an R package that I can use to uncensor a normal or log-normal dataset? I'm particularly interested in the MLE method of Cohen (1959), Simplified estimators for the normal distribution when samples are single censored or truncated, Technometrics, 1(3), 217-237. Of course, if there is anything better, I'd be glad to hear about that too. survreg() in the survival package will fit censored normal and censored lognormal models. If you fit a model with only an intercept this will estimate the mean and variance. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] numeric index of a matrix column name ?
probably you need match(colname0, colnames(M)) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, October 28, 2005 4:50 PM Subject: [R] numeric index of a matrix column name ? Dear All, I have written the following small code in order to return the numeric index of a given matrix column ascii name. It works, but there is perhaps/probably a predefined function which does that ? If yes, thanks for pointing me to it. # input : a matrix M and a column ascii name # output : the numeric index of the column colnameindex = function(M , colname0) { colsnames = names(M[1,]); theindex = which(colsnames==colname0); return(theindex); } Thanks Vincent __ 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 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] numeric index of a matrix column name ?
Dimitris Rizopoulos a écrit : probably you need match(colname0, colnames(M)) I hope it helps. Best, Dimitris yes. (why do simple ...) Thanks Dimitris. Have a good we. Vincent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] replacing a factor value in a data frame
Hi All, I have the following problem, that's driving me mad. I have a dataframe of factors, from a genetic scan of SNPs. I DO have NAs in the dataframe, which would look like: V4 V5 V6 V7 V8 V9 V10 1 TT GG TT AC AG AG TT 2 AT CC TT AA AA AA TT 3 AT CC TT AC AA NA TT 4 TT CC TT AA AA AA TT 5 AT CG TT CC AA AA TT 6 TT CC TT AA AA AA TT 7 AT CC TT CC NA NA TT 8 TT CC TT AC AG AG TT 9 AT CC TT CC AG NA TT 10 TT CC TT CC GG GG TT In the dataframe I have 1 column where one factor has been erroneosly given alternative readings: CG and GC. I want to change the instances of GC to CG and I use the code: data[data[,30]==GC, 30] = CG but get the error: Error in [-.data.frame(`*tmp*`, all[, 30] == GC, 30 missing values are not allowed in subscripted as Any hints? Cheers, Federico -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.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
Re: [R] splitting a character field in R
x - c('dfabcxt','wwabc','abcyy','xyz') (y - strsplit(x, 'abc')) [[1]] [1] df xt [[2]] [1] ww [[3]] [1] yy [[4]] [1] xyz sapply(y, [, 1) # first column [1] df ww xyz sapply(y, [, 2) # second column [1] xt NA yy NA On 10/28/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi Jim, Thanks for your post, I was aware of strsplit, but really could not find out how i could use it. I tried like in your example ... A-c(1,2,3) B-c(dgabcrt,fgrtabc,sabcuuu) C-strsplit(B,abc) C [[1]] [1] dg rt [[2]] [1] fgrt [[3]] [1] s uuu Which looks promissing, but here C is a list with three elements. But how to create the two vectors I need from here, that is (dg,fgrt, s) and (rt,,uuu) (or how to get access to the substrings rt or uuu). Greetings Manuel jim holtman [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] om cc: r-help@stat.math.ethz.ch Subject: Re: [R] splitting a character field in R 28.10.2005 16:00 x - 'dfabcxy' strsplit(x, 'abc') [[1]] [1] df xy On 10/28/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear R users, I have a dataframe with one character field, and I would like to create two new fields (columns) in my dataset, by spliting the existing character field into two using an existing substring. ... something that in SAS I could solve e.g. combining substr(which I am aware exist in R) and index for determining the position of the pattern within the string. e.g. if my dataframe is ... A B 1 dgabcrt 2 fgrtabc 3 sabcuuu Then by splitting by substring abc I would get ... A B B1 B2 1 dgabcrt dg rt 2 fgrtabc fgrt 3 sabcuuu s uuu Do you know how to do this basic string(dataframe) manipulation in R Saludos, Manuel __ 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 -- Jim Holtman Cincinnati, OH +1 513 247 0281 What the problem you are trying to solve? -- Jim Holtman Cincinnati, OH +1 513 247 0281 What the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] replacing a factor value in a data frame
On Fri, 28 Oct 2005, Federico Calboli wrote: Hi All, I have the following problem, that's driving me mad. I have a dataframe of factors, from a genetic scan of SNPs. I DO have NAs in the dataframe, which would look like: V4 V5 V6 V7 V8 V9 V10 1 TT GG TT AC AG AG TT 2 AT CC TT AA AA AA TT 3 AT CC TT AC AA NA TT 4 TT CC TT AA AA AA TT 5 AT CG TT CC AA AA TT 6 TT CC TT AA AA AA TT 7 AT CC TT CC NA NA TT 8 TT CC TT AC AG AG TT 9 AT CC TT CC AG NA TT 10 TT CC TT CC GG GG TT In the dataframe I have 1 column where one factor has been erroneosly given alternative readings: CG and GC. I want to change the instances of GC to CG and I use the code: data[data[,30]==GC, 30] = CG but get the error: Error in [-.data.frame(`*tmp*`, all[, 30] == GC, 30 missing values are not allowed in subscripted as Any hints? 1) Use %in% not == 2) (Better) As this is a factor, use levels- to merge the levels. See ?levels. -- 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
Re: [R] Uncensoring a dataset - resent
Although it doesn't implement the MLE, if you are looking at environmental data, I'd suggest looking at the R package NADA (available from CRAN). You could also contact Ed Frome at [EMAIL PROTECTED] (http://www.csm.ornl.gov/~frome/index.html), and ask about his R functions for this -- not packaged, though. -Don At 10:41 AM -0400 10/28/05, Richard Reiss wrote: Does anyone know of an R package that I can use to uncensor a normal or log-normal dataset? I'm particularly interested in the MLE method of Cohen (1959), Simplified estimators for the normal distribution when samples are single censored or truncated, Technometrics, 1(3), 217-237. Of course, if there is anything better, I'd be glad to hear about that too. Thanks. Rick __ 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 -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problems with source() function
I'm trying to feed data generated on-the-fly by a PHP script using R function source(), passing the arguments in the URL, using GET method (http://someserver.com/script.php?a=343b=873;). If not on-the-fly, the user has to wait more and get the data in more than one step. I'm trying a one-step simple method but for some reason the source() function truncates silently the data. I will try your suggestion of a binary file if I can generate the gzip stream on-the-fly... Thank you! . Alberto de Luis Bioinformatics and Functional Genomics Lab Cancer Research Center Salamanca (Spain) . On Fri, 2005-10-28 at 06:57 -0700, Seth Falcon wrote: On 28 Oct 2005, [EMAIL PROTECTED] wrote: Thank you for your answer :) I've tested your suggestion but without success. The remote load process is truncated silently using source(textConnection(readLines(url(http://...))) when look at the contents there's not a fixed point of break, is different each time I execute the command. Therefore the dropped lines are different every time. It seems the only constant is the time of the interruption (1 min 55 secs in my system). I'm not sure exactly what you are trying to accomplish, but I wonder if either of the following two ideas would help you: 1. Instead of source(), consider loading the R code on the server side and then using save(..., compres=TRUE) to create a binary image. You can then feed that to the clients and have them use load(). 2. What happens if you gzip the code before sending and gunzip on the client side. It may be less convenient, although supposedly there is a way to do the equivalent of gzfile(url(...)). HTH, + seth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] replacing a factor value in a data frame
Federico, There doesn't appear to be an instance of the value you want to change in your example, so I had to improvise. Part of the problem may be that the dataframe is composed of factors, and it's not possible to convert the value of a factor to another value that's in the set of possible values, given by the levels() function. So, if you want to change GC to CG, but CG does not already exist in the set of possible values you'll have to add it. E.g. tmp - data levels(tmp[,30]) - c(levels(data[,30]),'CG') then, if the problem only occurs in one column it's an easy fix. tmp[data=='GC'] - 'CG' If GC occurs in multiple columns you'll either have to change the levels for each column as I did just above, or work with a single column. Since you don't have 30 columns in your example, let's pretend you want to change all the instances of 'CC' in data$V5 to 'XX' tmp - data levels(tmp$V5) - c(levels(data$V5),'XX') tmp$V5[data$V5=='CC'] - 'XX' tmp V4 V5 V6 V7 V8 V9 V10 1 TT GG TT AC AG AG TT 2 AT XX TT AA AA AA TT 3 AT XX TT AC AA NA TT 4 TT XX TT AA AA AA TT 5 AT CG TT CC AA AA TT 6 TT XX TT AA AA AA TT 7 AT XX TT CC NA NA TT 8 TT XX TT AC AG AG TT 9 AT XX TT CC AG NA TT 10 TT XX TT CC GG GG TT Notice that the instances of 'CC' in tmp$V7 did not change. HTH, Dave Roberts Federico Calboli wrote: Hi All, I have the following problem, that's driving me mad. I have a dataframe of factors, from a genetic scan of SNPs. I DO have NAs in the dataframe, which would look like: V4 V5 V6 V7 V8 V9 V10 1 TT GG TT AC AG AG TT 2 AT CC TT AA AA AA TT 3 AT CC TT AC AA NA TT 4 TT CC TT AA AA AA TT 5 AT CG TT CC AA AA TT 6 TT CC TT AA AA AA TT 7 AT CC TT CC NA NA TT 8 TT CC TT AC AG AG TT 9 AT CC TT CC AG NA TT 10 TT CC TT CC GG GG TT In the dataframe I have 1 column where one factor has been erroneosly given alternative readings: CG and GC. I want to change the instances of GC to CG and I use the code: data[data[,30]==GC, 30] = CG but get the error: Error in [-.data.frame(`*tmp*`, all[, 30] == GC, 30 missing values are not allowed in subscripted as Any hints? Cheers, Federico -- David W. Roberts office 406-994-4548 Professor and Head FAX 406-994-3190 Department of Ecology email [EMAIL PROTECTED] Montana State University Bozeman, MT 59717-3460 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Calling R functions from C
Dear R users, I read on the Introduction to the .C Interface to R by Peng Leeuw (http://www.biostat.jhsph.edu/~rpeng/docs/interface.pdf) that it is possible to use a few R functions (such as dnorm) within C by including the Rmath.h header file in your C code: e.g. #include R.h #include Rmath.h void kernel_smooth(double *x, int *n, double *xpts, int *nxpts, double *h, double *result) { int i, j; double d, ksum; for(i=0; i *nxpts; i++) { ksum = 0; for(j=0; j *n; j++) { d = xpts[i] - x[j]; ksum += dnorm(d / *h, 0, 1, 0); } result[i] = ksum / ((*n) * (*h)); } } In the manual Writing R extensions there is also a list of special functions which can be called in C. I was wondering whether there is a way to call any other R functions similarly. Is there any documented exemple available somewhere? Thanks a lot for your help, Florent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] lm type of sums of squares
I'm curious, I realize there are methods for Type II and III sums of squares, and yet, when I've been constructing models with lm, I've noticed that position of the term of the model has not mattered in terms of its p-value. Does lm use sequential Type I sums of squares, or something else? Thanks! -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
Re: [R] lm type of sums of squares
Dear Jarrett, anova() gives sequential sums of squares (as ?anova.lm says). See Anova() in the car package for something similar to Type II and III sums of squares. I hope this helps, John On Fri, 28 Oct 2005 10:05:39 -0700 Jarrett Byrnes [EMAIL PROTECTED] wrote: I'm curious, I realize there are methods for Type II and III sums of squares, and yet, when I've been constructing models with lm, I've noticed that position of the term of the model has not mattered in terms of its p-value. Does lm use sequential Type I sums of squares, or something else? Thanks! -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 John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lm type of sums of squares
anova.lm() gives the sequential tests: set.seed(1) dat - data.frame(y=rnorm(10), x1=runif(10), x2=runif(10)) anova(lm(y ~ x1 + x2, dat)) Analysis of Variance Table Response: y Df Sum Sq Mean Sq F value Pr(F) x1 1 1.1483 1.1483 2.0943 0.1911 x2 1 0.4972 0.4972 0.9068 0.3727 Residuals 7 3.8383 0.5483 anova(lm(y ~ x2 + x1, dat)) Analysis of Variance Table Response: y Df Sum Sq Mean Sq F value Pr(F) x2 1 0.5165 0.5165 0.9419 0.3641 x1 1 1.1291 1.1291 2.0592 0.1944 Residuals 7 3.8383 0.5483 The SS, F-stat, etc. would be invariant to order only if the terms are orthogonal. Andy From: Jarrett Byrnes I'm curious, I realize there are methods for Type II and III sums of squares, and yet, when I've been constructing models with lm, I've noticed that position of the term of the model has not mattered in terms of its p-value. Does lm use sequential Type I sums of squares, or something else? Thanks! -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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] splitting a character field in R
On 28 Oct 2005, [EMAIL PROTECTED] wrote: A-c(1,2,3) B-c(dgabcrt,fgrtabc,sabcuuu) C-strsplit(B,abc) C [[1]] [1] dg rt [[2]] [1] fgrt [[3]] [1] s uuu Which looks promissing, but here C is a list with three elements. But how to create the two vectors I need from here, that is (dg,fgrt, s) and (rt,,uuu) To convert a list to a matrix do.call (rbind, C) [,1] [,2] [1,] dg rt [2,] fgrt fgrt [3,] suuu is good trick. However, it doesn't work as intended here since the elements of C have difference lengths. It would be nice to have 'rbind' and 'cbind' allow different ways of padding the vectors into the same length. One work around is: sapply (C, function (x) x[1:2]) [,1] [,2] [,3] [1,] dg fgrt s [2,] rt NA uuu You may convert the NA's to if you want. Michael __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] multiple boxplots
Hello, I want to plot 3 boxplots [ par(mfrow=c(3,1)) ] but the first one has 8 groups, the 2nd has 7 and the third has 6. But I the groups to line up: 1 2 3 4 5 6 7 8 2 3 4 5 6 7 8 3 4 5 6 7 8 where the numbers actually refer to years. I suspect I have to manipulate the function bxp(). Is there a relatively simple way to do this? Thanks for any help. Jeff Breiwick NMFS, Seattle __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multiple boxplots
On Fri, 2005-10-28 at 10:26 -0700, J.M. Breiwick wrote: Hello, I want to plot 3 boxplots [ par(mfrow=c(3,1)) ] but the first one has 8 groups, the 2nd has 7 and the third has 6. But I the groups to line up: 1 2 3 4 5 6 7 8 2 3 4 5 6 7 8 3 4 5 6 7 8 where the numbers actually refer to years. I suspect I have to manipulate the function bxp(). Is there a relatively simple way to do this? Thanks for any help. Jeff Breiwick NMFS, Seattle Here is one approach. It is based upon using 2 principal concepts: 1. Create the first plot, save the plot region ranges from par(usr) and then use this information for the two subsequent plots, where we use the 'add = TRUE' argument. 2. Use the 'at' argument to specify the placement of the boxes in the second and third plots to line up with the first. So: # Create our data. dat - rnorm(80) years - rep(1991:1998, each = 10) # MyDF will be a data frame with two columns and we will use # this in the formula method for boxplot. # The second and third plots will use subset()s of MyDF MyDF - cbind(dat, years) # Set the plot matrix par(mfrow = c(3, 1)) # Create the first boxplot and save par(usr) boxplot(dat ~ years, MyDF) usr - par(usr) # Now open a new plot, setting it's par(usr) to # match the first plot. # Then use boxplot and set the boxes 'at' x pos 2:8 # and add it to the open plot plot.new() par(usr = usr) boxplot(dat ~ years, subset(MyDF, years %in% 1992:1998), at = 2:8, add = TRUE) # Rinse and repeat ;-) # Different subset and use 3:8 for 'at' plot.new() par(usr = usr) boxplot(dat ~ years, subset(MyDF, years %in% 1993:1998), at = 3:8, add = TRUE) Replace MyDF in the above with your actual datasets of course. This would of course be a bit easier if one could set an 'xlim' argument in boxplot(), but this is ignored by bxp(). HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] clustering
Assuming you don't end up with too many clusters, you could take the classification and use it as the target for a tree, random forest, discriminant analysis or multinomial logistic regression. The random forest may be the best option. -Original Message- From: alessandro carletti [mailto:[EMAIL PROTECTED] Sent: Friday, October 28, 2005 5:42 AM To: rHELP Subject: [R] clustering Hi everybody, I'm performing a cluster analysis (pkg cluster) on a dataset which includes 15 variables: is there a way to know how much each variable weighs on the final clustering output? Thanks Alessandro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] question about sm.density
Please read the documentation before posting a question. If you read the documentation for sm.density you will see that the argument props will do what you want. i.e. y - cbind(rnorm(50), rnorm(50)) sm.density(y, display = slice, props=95) Regards Francisco From: Cunningham Kerry [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] question about sm.density Date: Thu, 27 Oct 2005 18:47:28 -0700 (PDT) How can I draw a 95% contour in sm.density? For example, y - cbind(rnorm(50), rnorm(50)) sm.density(y, display = slice) will give 25%, 50% and 75% contours automatically, but no reference on other values. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] 3d bar plot
Le 28.10.2005 10:07, Jan Wiener a écrit : Hi, does anyone has a bar plot function that produces something like this (I hope attachments work) ? If not, I simply want to produce 3d bar plots. Thanks in advance, Jan Hi, I didn't get the attachment. Maybe you didn't follow the posting guide which tells what attachments are ok. scatterplot3d can generate somthing close to a 3D barplot. see : http://www.jstatsoft.org/v08/i11/JSSs3d.pdf page 11 http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=116 Romain -- visit the R Graph Gallery : http://addictedtor.free.fr/graphiques +---+ | Romain FRANCOIS - http://francoisromain.free.fr | | Doctorant INRIA Futurs / EDF | +---+ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to get colnames of a dataframe within a function called by 'apply'
Iterate over the column names rather than the columns themselves: par.or - par(mfrow=c(3,3)) nv - function(name, data) { qqnorm(data[,name], main=name) qqline(data[,name], col=red) invisible() } sapply(colnames(temp), nv, data = temp) par(par.or) On 10/28/05, Leo Gürtler [EMAIL PROTECTED] wrote: Hello alltogether, how is it possible to assign the colnames of a data.frame to a function called by apply, e.g. for labeling a plot? Example: I want to plot several qqnorm-plots side by side and there should be a maintitle for each qqnorm-plot which is identical to the respective colname. I checked, but the column which is processed by the function called by apply does not contain a colname (because by using str() it seems it is no column at this point, but just a e.g. numerical vector). I also tried with colnames() from within the function, but was not successful to get the apropriate colname - either the whole string or just the first one.Thus it lacks of a counter that contains the number of the row which is processed. Here is an example code: ---snip--- nv - function(xno.na) { par.or - par(mfrow=c(3,3)) qqnorm(xno.na, main=HERE SHOULD BE THE NAME OF THE COLUMN) qqline(xno.na, col=red) par(par.or) print(str(xno.na)) } temp # just a part of the whole data.frame klarb1klarb2 abarb laut skla1 skla2 a NA 13.068182 7.54 0.5 0.5 b NA 6.818182 9.06NA 0.5 c 15.11628 6.818182 10.04 1.0 1.5 d NA 18.181818 19.02 1.0 0.5 apply(temp,2,nv) /---snip--- Thanks a lot! best wishes, leo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html