[R] Cuetion abut dunn test
Hello, I wanted to know which are the commands to perform a Dunn test, and how must the data be entered. Thanks, Nicolás Tarjeta de crédito Yahoo! de Banco Supervielle. Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Creating Matrix
Hello, I have two data. x-c(1, 2, 1, 3, 2) y-c(3, 1, 2, 3, 5) How do i create matrix from this two. what i want is this x y 1 1 3 2 2 1 3 1 2 4 3 3 5 2 5 thanks Claire -- View this message in context: http://www.nabble.com/Creating-Matrix-tp17168173p17168173.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [RsR] function in nls argument -- robust estimation
Martin, Kate, Fernando, et al. Be careful bootstrapping robust estimators. The trouble is that when resampling is done with replacement, the outliers can be selected too many times which would ruin the standard error estimates. Martin is right that bootstrapping would be fine if there are not too many outliers. Otherwise, Jackknifing will likely work better, especially if you use a delete more than one version. For a zero weight for outliers M estimator, a high breakdown starting value like least trimmed squares would be a good idea. arny Arnold J. Stromberg Professor and Chair Department of Statistics University of Kentucky 817 Patterson Office Tower Lexington, KY 40506-0027 Phone: 859-257-6115 Fax: 859-323-1973 From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of Martin Maechler [EMAIL PROTECTED] Sent: Saturday, May 10, 2008 5:07 AM To: Katharine Mullen; elnano Cc: r-help@r-project.org; [EMAIL PROTECTED] Subject: Re: [RsR] [R] function in nls argument -- robust estimation Hi Kate and Fernando, I'm late into this thread, but from reading it I get the impression that Fernando really wants to do *robust* (as opposed to least-squares) non-linear model fitting. His proposal to set residuals to zero when they are outside a given bound is a very special case of an M-estimator, namely (if I'm not mistaken) the so-called Huber skipped-mean, an M-estimator with psi-function psi - function(x, k) ifelse(abs(x) = k, x, 0) It is known that this can be far from optimal, and either using Huber-psi or a redescender such as Tukey's biweight can be considerably better. Also note that the standard inference (std.errors, P-values, ...) that you'd get from summary(nlsfit) or anova(nls1, nl2) is *invalid* here, since you are effectively using *random* weighting. The nlrob() function in package 'robustbase' implements M-estimation of nonlinear models directly. Unfortunately, how to do correct inference in this situation is a hard problem, probably even an open research question in parts. I would expect that the bootstrap should work if you only have a few outliers. I don't have time at the moment to look at the example data and the model, and show you how to use it for nlrob(); if you find a way to you it for nls() , then the same should work for nlrob(). I'm CCing this to the specialists for Robust Stats with R mailing list, R-SIG-robust. Best regards, Martin Maechler ETH Zurich KateM == Katharine Mullen [EMAIL PROTECTED] on Fri, 9 May 2008 15:50:08 +0200 (CEST) writes: KateM You can take minpack.lm_1.1-0 (source code and MS Windows build, KateM respectively) from here: KateM http://www.nat.vu.nl/~kate/minpack.lm_1.1-0.tar.gz KateM http://www.nat.vu.nl/~kate/minpack.lm_1.1-0.zip KateM The bug that occurs when nprint = 0 is fixed. Also fixed is another KateM problem suggested your example: when the argument par is a list, calling KateM summary on the output of nls.lm was not working. KateM I'll submit the new version to CRAN soon. KateM This disscusion has been fruitful - thanks for it. KateM On Fri, 9 May 2008, Katharine Mullen wrote: You indeed found a bug. I can reproduce it (which I should have tried to do on other examples in the first place!). Thanks for finding it. It will be fixed in version 1.1-0 which I will submit to CRAN soon. On Fri, 9 May 2008, elnano wrote: Find the data (data_nls.lm_moyano.txt) here: ftp://ftp.bgc-jena.mpg.de/pub/outgoing/fmoyano Katharine Mullen wrote: Thanks for the details - it sounds like a bug. You can either send me the data in an email off-list or make it available on-line somewhere, so that I and other people can download it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/function-in-nls-argument-tp17108100p17146812.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. KateM
[R] Monty Hall simulation
Is it possible to simulate the Monty Hall problem using R? If so, could someone please show me how? Thanks for any help rendered. -- View this message in context: http://www.nabble.com/Monty-Hall-simulation-tp17169235p17169235.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating Matrix
See ?cbind and ?matrix. Gabor On Sat, May 10, 2008 at 03:21:26PM -0700, Claire_6700 wrote: Hello, I have two data. x-c(1, 2, 1, 3, 2) y-c(3, 1, 2, 3, 5) How do i create matrix from this two. what i want is this x y 1 1 3 2 2 1 3 1 2 4 3 3 5 2 5 thanks Claire -- View this message in context: http://www.nabble.com/Creating-Matrix-tp17168173p17168173.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Csardi Gabor [EMAIL PROTECTED]UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Random number generation
Dennis, I assume that there is a set.seed() somewhere in your script, possibly in something you source()d (hopefully not in anything library()d). Have you tried successively removing/commenting parts of the script before the sample() command until the problem goes away? That way you should be able to pinpoint the offending script command. Good luck, Stephan Dennis Fisher schrieb: Colleagues, I have encountered behavior of random number generation that eludes me. I generate a random integer in a particular range using the following code: sample(1000:, size=1) This code exists within a script that starts with the command: remove(list=ls()) Each time that I run the script, it yields the same random number: 6420. I thought that the problem might result from deleting the random seed. However, list=ls() does not include .RandomSeed. To my surprise, I can't replicate the problem with a 2-line script: remove(list-ls()) sample(1000:, size=1) Also, the same problem occurs if I use runif instead of sample. Thoughts? Dennis Dennis Fisher MD P (The P Less Than Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-415-564-2220 www.PLessThan.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Monty Hall simulation
cirrus74 [EMAIL PROTECTED] [Sun, May 11, 2008 at 03:44:46AM CEST]: Is it possible to simulate the Monty Hall problem using R? If so, could someone please show me how? Thanks for any help rendered. The kind of simulation, as any thinking about this seeingly paradoxical situation, depends on your mindset. To my mind, niter - 999 prize - sample(c(car, car, goat), niter, replace=TRUE) would be a perfect simulation. -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] loess and locpoly
Dear list, I've got a question concerning difference between loess and locpoly. I have to use a plug-in method to chose a bandwith so I take locpoly method to fit a curve. My problem is:I know how to get predicted values in loess: m=loess(y~x) y_fitted=predict(m). But how to get the same in locpoly? I computed like this: bw=dpill(x, y, blockmax = 5, divisor = 20,trim = 0.01, proptrun = 0.05, gridsize = n, range(x), truncate = FALSE) m=locpoly(x, y, drv = 0, degree = 1, gridsize= n, bandwidth=bw, bwdisc = 25, range(x), binned = FALSE) fitfn - approxfun(m$x, m$y) m_y - fitfn(x) but i'm not sure it is right? Thanks in advanced. Pawel Teisseyre. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is there in R a function equivalent to the mround, as found in most spreadsheets?
Hello Luca. Dr. Ottorino-Luca Pantani wrote: ... c(1803.02, 193.51, 3.47) Each solution is to be taken with 3 different pipettes (5000, 250 and 10 µL Volume max) and each of those delivers volumes in steps of 50 µL, 5 µL or 1µL, respectively Since the above values would eventually become c(1800, 195, 3) ... You find a complete solution at http://albertosantini.blogspot.com/2008/05/mround.html It checks the sign of the number and the multiple and it hacks the issue of rounding off a 5 respect IEC 60559 standard. The test cases are: mround(10, 3) # 9 mround(-10, -3) # -9 mround(1.3, 0.2) # 1.4 mround(5, -2) # error mround(1.7, 0.2) # 1.8 mround(321.123, 0.12) # 321.12 mround(1803.02, 50) # 1800 mround(193.51, 5) # 195 mround(3.47, 1) # 3 Regards, Alberto -- View this message in context: http://www.nabble.com/Is-there-in-R-a-function-equivalent-to-the-mround%2C-as-found-in-most-spreadsheets--tp17143519p17170296.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problems with blanks and umlauts in filenames with Rserve
Dear R developers, I'm trying to load files by means of Rserve. If the files have blanks in it names or german umlauts the loading failes(for example when using the rgdal lib with readGDAL() ). In the R application without Rserve this works. Is there a general encoding recipe or switch that this works in Rserve, too ? Any help is appreciated -- View this message in context: http://www.nabble.com/Problems-with-blanks-and-umlauts-in-filenames-with-Rserve-tp17170368p17170368.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bar Charts
hoogeebear wrote: Hi, I created some bar charts. My first one is concerned with males, and my second concerned with females. Is there a way I can put the charts into one chart? There is 2 different columns in each file. Here is my new file containing males and females: gender,familar Female,Yes Female,Yes Female,Yes Female,Yes Female,Yes Female,No Female,Yes Female,Yes Female,Yes Female,Yes Female,Yes Female,Yes Female,No Female,Yes Female,No Female,Yes Female,Yes Female,Yes Female,Yes Female,Yes Male,Yes Male,Yes Male,Yes Male,No Male,No Male,Yes Male,Yes Male,Yes Male,Yes Male,Yes Male,Yes Male,Yes Male,Yes Male,Yes Male,Yes Male,Yes Male,Yes Male,Yes Male,Yes Male,No Male,Yes Male,Yes Here is the code I use for creating a female chart: library(plotrix) library(prettyR) female_familar -read.table(C://females.csv, sep=,, header=TRUE) barp(rbind(rep(length(female_familar$gender),2),freq(female_familar$familar)[[1]]), ylab=20 Females participated in the survey, col=4:5,names.arg=c(FemalesNo(3),Females Yes(17))) legend(topright,c(Females,Familarity),fill=4:5) Does the above need to change much to include males and females in the one bar chart? Hi Jack, If your data frame is named hg: barp(table(hg),names.arg=levels(hg$familar), col=c(2,4),legend.lab=levels(hg$gender)) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Random number generation
Stephan Kolassa wrote: Have you tried successively removing/commenting parts of the script before the sample() command until the problem goes away? That way you should be able to pinpoint the offending script command. Hi, This brings up a question I have .. is there a way to do *block* comments with scripts? A la /* ... */ like it's done in Java or C/C++? Ie comment more than just one line at a time. From what I have read this is not possible in R (at least not easily), but I am eager for someone to contradict me :-) Thanks, Esmail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Random number generation
On Sun, 11 May 2008, Esmail Bonakdarian wrote: Stephan Kolassa wrote: Have you tried successively removing/commenting parts of the script before the sample() command until the problem goes away? That way you should be able to pinpoint the offending script command. Hi, This brings up a question I have .. is there a way to do *block* comments with scripts? A la /* ... */ like it's done in Java or C/C++? Ie comment more than just one line at a time. From what I have read this is not possible in R (at least not easily), but I am eager for someone to contradict me :-) if(FALSE) { ... } Any good editor can do block commenting, e.g. ESS. You didn't tell us what you read, but I have never seen this in a reputable source. Thanks, Esmail -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substitute in graphics - Uwe's help desk
Hello, I still have my problem. I couldn't make Uwe Ligges's example work. I wonder why :-( The following doesn't work : param.list=list(mu1=0,mu2=0,s1=3,s2=2,s3=2,s4=4) plot(1:8,type=n) text(8,3,adj=1,labels=substitute(with * mu == bgroup((,atop(mu1,mu2),)) * , * Sigma[x] == bgroup((,atop(s1~~s3,s2~~s4),)),param.list)) But this works : plot(1:8,type=n) text(8,3,adj=1,labels=substitute(with * mu == bgroup((,atop(mu1,mu2),)) * , * Sigma[x] * = * bgroup((,atop(s1~~s3,s2~~s4),)),param.list)) So like in my problem the problem seems to be ==. Thank you very much 2008/5/10 Gustave Lefou [EMAIL PROTECTED]: Thank to both of you. I found an interesting document by Uwe Ligges in Rnews December 2002 (Vol 2/3) The following seems encouraging x=seq(1,180,by=1) beta=10 eta=5 plot(x,log(x),type=p,xlab=x,ylab=h(x),main=substitute(Failure rate * eta==myeta * , * beta ,list(myeta=eta,mybeta=beta)) ) but then it fails : x=seq(1,180,by=1) beta=10 eta=5 plot(x,log(x),type=p,xlab=x,ylab=h(x),main=substitute(Failure rate from W( * eta==myeta * , * beta==mybeta , ) ,list(myeta=eta,mybeta=beta)) ) Any idea ? Thank you very much 2008/5/9 Henrique Dallazuanna [EMAIL PROTECTED]: Try this: plot(x, log(x), xlab = x, ylab = h(x), main = bquote(Failure~rate~from~W(eta == .(eta), beta == .(beta))) On Fri, May 9, 2008 at 11:31 AM, Gustave Lefou [EMAIL PROTECTED] wrote: Hello, I have to do a few graphics of the same function and this function is parametrized by two arguments. What I would like is to be able to change the value of these two arguments without changing the plot command. So as to copy paste. I tried the following : x=1:100 eta=10 beta=5 plot(x,h(x),xlab=x,ylab=h(x),main=substitute( expression( paste(Failure rate from,W(eta==myeta,beta==mybeta) ) ) ,list(myeta=eta,mybeta=beta) ) ) But it doesn't work. It's written expression ( Failure rate from W(eta=10,) ... on the plot with eta as a greek letter. Thank you very much ! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Random number generation
Hello there, Prof Brian Ripley wrote: On Sun, 11 May 2008, Esmail Bonakdarian wrote: Stephan Kolassa wrote: Have you tried successively removing/commenting parts of the script before the sample() command until the problem goes away? That way you should be able to pinpoint the offending script command. Hi, This brings up a question I have .. is there a way to do *block* comments with scripts? A la /* ... */ like it's done in Java or C/C++? Ie comment more than just one line at a time. From what I have read this is not possible in R (at least not easily), but I am eager for someone to contradict me :-) if(FALSE) { ... } Any good editor can do block commenting, e.g. ESS. You didn't tell us what you read, but I have never seen this in a reputable source. I don't remember the source as I was reading widely all over the place trying to get up to speed with R in a hurry (having found this group was one of the best sources). What I read doesn't seem to be incorrect however (it may even have been an archived message here), the *language* itself does not seem to support block *comments*. Using conditional constructs, or an IDE/editor to achieve similar results is a work around - but not the same. I don't mean to nitpick, but as a computer scientist I see this as different :-) I'll have to look at ESS though. Thanks, Esmail ps: Ah, I seem Meta-; works as a toggle in emacs/ESS .. thanks for encouraging me to look at that some more. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating Matrix
Here is how you can apply the mat function mentioned by Cassardi, x-c(1, 2, 1, 3, 2) y-c(3, 1, 2, 3, 5) mat-matrix(c(x,y),5,2) ##the first parameter gives the data vector wich is filled columnwise in the matrix, then comes the row and column dimensions) colnames(mat)-c(x,y) you can also use the dimnames() function and give a list of two vectors for the rownames and colnames; Best Claire_6700 [EMAIL PROTECTED] a écrit : Hello, I have two data. x-c(1, 2, 1, 3, 2) y-c(3, 1, 2, 3, 5) How do i create matrix from this two. what i want is this x y 1 1 3 2 2 1 3 1 2 4 3 3 5 2 5 thanks Claire -- View this message in context: http://www.nabble.com/Creating-Matrix-tp17168173p17168173.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating Matrix
how do i calculate the p-value of trend test power oquote author=Claire_6700 Hello, I have two data. x-c(1, 2, 1, 3, 2) y-c(3, 1, 2, 3, 5) 1. How do i create matrix from this two. what i want is this x y 1 1 3 2 2 1 3 1 2 4 3 3 5 2 5 2. what is the best way to use chisq.test to get the p.value thanks Claire -- View this message in context: http://www.nabble.com/Creating-Matrix-tp17168173p17170180.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Compact Indicator Matrices
On Sat, May 10, 2008 at 5:27 AM, amarkos [EMAIL PROTECTED] wrote: An indicator matrix is a binary matrix with orthogonal columns whose rows sum to 1. A row of this matrix could be [0 1 0 0]. My problem is to group the similar rows (profiles) so that to create a compact form of the matrix. I'm not sure exactly what you mean by a compact form of this matrix. Do you mean that you want to collapse similar rows into a single row and perhaps a count of the number of times that this row occurs? In R indicator matrices are typically generated from a factor and essentially you are asking for the tabulation of the factor, such as provided by the functions table and xtabs. Is there an R function that deals with this problem or do I have to write it from scratch? Thanks, Angelos Markos Dr. Applied Informatics, University of Macedonia, Greece __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] superscript text on graph legend
Is that possible to create superscript text on the graph legend, for example to put cm2 (centimeter square) on the legend. Please show me how to do it. Thanks. -- Agus Susanto [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset rows in two dataframes
Not exactly. I need something to subset ONLY rows common to both dataframes. In the provided example, dat1 and dat2 have no common rows so I would expect: [1] v1 v2 0 rows (or 0-length row.names) But I can´t do it... On Sun, 11 May 2008 10:07:25 -0400, Zhuanshi He [EMAIL PROTECTED] said: Dear Jim, Maybe u want this, subset(dat2, time1 %in% dat2$v1 time2 %in% dat2$v1) v1 v2 2 2006-05-09 7065.0 3 2006-05-04 3622.5 5 2006-07-14 3532.5 7 2006-05-12 6480.0 8 2006-05-17 4612.5 15 2006-07-05 4837.5 16 2006-07-06 3352.5 18 2006-07-24 6772.5 20 2006-07-18 5625.0 Warning message: In time1 %in% dat2$v1 time2 %in% dat2$v1 : longer object length is not a multiple of shorter object length However, it looks the length of time1 and time2 is different. -- On 5/11/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear list: I can now reproduce with a bit of my real data, the problem I asked for your help yestarday: time1- as.Date(c(2006-01-03, 2006-05-03, 2006-05-04, 2006-05-11, 2006-05-12, 2006-05-16, 2006-05-19, 2006-05-26, 2006-09-15, 2006-10-30, 2006-11-08, 2006-11-14, 2006-11-20)) volume1- c(7312.5, 3352.5, 4252.5, 3825.0, 2700.0, 585.0, 810.0, 3015.0, 2925.0, 1102.5, 2632.5, 652.5, 1417.5) dat1- data.frame(v1=time1, v2=volume1) time2- as.Date(c(2006-05-03, 2006-05-09, 2006-05-04, 2006-05-08, 2006-07-14, 2006-07-10, 2006-05-12, 2006-05-17, 2006-05-19, 2006-05-26, 2006-05-29, 2006-05-18, 2006-05-22, 2006-07-03, 2006-07-05, 2006-07-06, 2006-07-04, 2006-07-24, 2006-07-12, 2006-07-18)) volume2- c(4522.5, 7065.0, 3622.5, 7875.0, 3532.5, 3667.5, 6480.0, 4612.5, 4005.0, 10350.0, 5310.0, 6345.0, 7177.5, 5107.5, 4837.5, 3352.5, 4050.0, 6772.5, 7290.0, 5625.0) dat2- data.frame(v1=time2, v2=volume2) subset(dat1, v1 %in% dat2$v1 v2 %in% dat2$v2) v1 v2 2 2006-05-03 3352.5 This is not what I expect since this row is not present in dat2 and I just want records present in both dataframes. Help? J On Sat, 10 May 2008 18:42:51 -0400, jim holtman [EMAIL PROTECTED] said: This seems to work for me: set.seed(1) df1 - data.frame(v1=factor(sample(1:4,20,TRUE)), v2=factor(sample(1:3,20,TRUE)), v3=sample(1:3,20,TRUE)) df2 - data.frame(v1=factor(sample(1:2,20,TRUE)), v2=factor(sample(1:2,20,TRUE)), v3=sample(1:2,20,TRUE)) subset(df1, (df1$v1 %in% df2$v1) (df1$v2 %in% df2$v2) (df1$v3 %in% df2$v3)) v1 v2 v3 2 2 1 2 5 1 1 2 11 1 2 2 14 2 1 1 Exactly what problems are you having? A sample of your actual data would be useful. On Sat, May 10, 2008 at 6:31 PM, [EMAIL PROTECTED] wrote: Dear list: I have two dataframes, say dat1 and dat2. Each has several variables but 3 of each are common in both, (say v1, v2 and v3). v1 and v2 are factores while v3 is numeric. Now, I need a subset to extract the rows in which v1, v2 and v3 are the same in both dataframes. I tried: subset(dat1, dat1$v1 %in% dat2$v1 dat1$v2 %in% dat2$v2 dat1$v3 %in% dat2$v3) I dont know why, but this is not working as I was expecting. Any suggestion to improve my code? Thanks in advance Justin -- [EMAIL PROTECTED] -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? -- [EMAIL PROTECTED] -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Zhuanshi He / Z. He (PhD) Waterloo Centre for Atmospheric Sciences (WCAS) Department of Earth and Environmental Sciences Phy Bldg, Rm 2022 University of Waterloo, Waterloo, ON N2L 3G1 Canada Tel: +1-519-888-4567 ext 38053FAX: +1-519-746-0435 -- [EMAIL PROTECTED] -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] combining bar and column graphs?
Hi, I'm hoping to find out whether R, or an R add-on, can generate a particular type of graph. And, more basically, whether such a type of graph even makes sense. I'm looking for something resembling both a column chart and a bar chart, where the basic visual unit is a solid rectangle of color that can be extended either horizontally, vertically, or both. The data that needs to be graphed consists of the relative contributions of a number (6 or 8) of companies (entities, whatever) to a common fund, over the course of a number of years (say, 1990-2008). I'm picturing years on the X-axis, and dollar amounts on the Y-axis (say, $0-$100,000). From a temporal perspective, every year will have at least one contributor, starting with dollar zero, but some years will have multiple contributors. From a company perspective, some companies will contribute, e.g., dollars $1,001-$5,000 for several years running, visually forming a horizontal block riding on top of whatever happens to be below. So as a simple example, between the years 2000 and 2001, Company A might inhabit a solid block extending from dollar zero to dollar 1000, two years wide. In year 2000, Company B might contribute dollars $1,001-$2,000, while right next door in year 2001, a different Company C might contribute dollars $1,001-$10,000. Is it possible to have this sort of horizontal/vertical chart generated automatically, or is this impossible? Do I need to generate a year-on-year column graph and manually elide the boundaries between companies' contributions in successive years, thus forming the horizontal blocks I have in mind manually? Is there perhaps another software tool that would be good for this? Thanks very much - this is a long question... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset rows in two dataframes
It is giving you exactly what you are asking for. You asked first which of dat1$v1 were in dat2$v; you got a TRUE on the second value (2006-05-03): dat1$v1 %in% dat2$v1 [1] FALSE TRUE TRUE FALSE TRUE FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE You then asked for which of dat1$v2 were in dat2$v2 and got a TRUE on the second entry (3352.5): dat1$v2 %in% dat2$v2 [1] FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE The says that the second value in dat1 has values that are in dat2, but not necessarily at the same location. On Sun, May 11, 2008 at 9:50 AM, [EMAIL PROTECTED] wrote: Dear list: I can now reproduce with a bit of my real data, the problem I asked for your help yestarday: time1- as.Date(c(2006-01-03, 2006-05-03, 2006-05-04, 2006-05-11, 2006-05-12, 2006-05-16, 2006-05-19, 2006-05-26, 2006-09-15, 2006-10-30, 2006-11-08, 2006-11-14, 2006-11-20)) volume1- c(7312.5, 3352.5, 4252.5, 3825.0, 2700.0, 585.0, 810.0, 3015.0, 2925.0, 1102.5, 2632.5, 652.5, 1417.5) dat1- data.frame(v1=time1, v2=volume1) time2- as.Date(c(2006-05-03, 2006-05-09, 2006-05-04, 2006-05-08, 2006-07-14, 2006-07-10, 2006-05-12, 2006-05-17, 2006-05-19, 2006-05-26, 2006-05-29, 2006-05-18, 2006-05-22, 2006-07-03, 2006-07-05, 2006-07-06, 2006-07-04, 2006-07-24, 2006-07-12, 2006-07-18)) volume2- c(4522.5, 7065.0, 3622.5, 7875.0, 3532.5, 3667.5, 6480.0, 4612.5, 4005.0, 10350.0, 5310.0, 6345.0, 7177.5, 5107.5, 4837.5, 3352.5, 4050.0, 6772.5, 7290.0, 5625.0) dat2- data.frame(v1=time2, v2=volume2) subset(dat1, v1 %in% dat2$v1 v2 %in% dat2$v2) v1 v2 2 2006-05-03 3352.5 This is not what I expect since this row is not present in dat2 and I just want records present in both dataframes. Help? J On Sat, 10 May 2008 18:42:51 -0400, jim holtman [EMAIL PROTECTED] said: This seems to work for me: set.seed(1) df1 - data.frame(v1=factor(sample(1:4,20,TRUE)), v2=factor(sample(1:3,20,TRUE)), v3=sample(1:3,20,TRUE)) df2 - data.frame(v1=factor(sample(1:2,20,TRUE)), v2=factor(sample(1:2,20,TRUE)), v3=sample(1:2,20,TRUE)) subset(df1, (df1$v1 %in% df2$v1) (df1$v2 %in% df2$v2) (df1$v3 %in% df2$v3)) v1 v2 v3 2 2 1 2 5 1 1 2 11 1 2 2 14 2 1 1 Exactly what problems are you having? A sample of your actual data would be useful. On Sat, May 10, 2008 at 6:31 PM, [EMAIL PROTECTED] wrote: Dear list: I have two dataframes, say dat1 and dat2. Each has several variables but 3 of each are common in both, (say v1, v2 and v3). v1 and v2 are factores while v3 is numeric. Now, I need a subset to extract the rows in which v1, v2 and v3 are the same in both dataframes. I tried: subset(dat1, dat1$v1 %in% dat2$v1 dat1$v2 %in% dat2$v2 dat1$v3 %in% dat2$v3) I dont know why, but this is not working as I was expecting. Any suggestion to improve my code? Thanks in advance Justin -- [EMAIL PROTECTED] -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://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? -- [EMAIL PROTECTED] -- http://www.fastmail.fm - Send your email first class -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset rows in two dataframes
Here is one way to compare the entire rows between the data frames: x1 - do.call(paste, dat1) x2 - do.call(paste, dat2) dat1[x1 %in% x2,] [1] v1 v2 0 rows (or 0-length row.names) x1 [1] 2006-01-03 7312.5 2006-05-03 3352.5 2006-05-04 4252.5 2006-05-11 3825 [5] 2006-05-12 2700 2006-05-16 5852006-05-19 8102006-05-26 3015 [9] 2006-09-15 2925 2006-10-30 1102.5 2006-11-08 2632.5 2006-11-14 652.5 [13] 2006-11-20 1417.5 On Sun, May 11, 2008 at 10:27 AM, [EMAIL PROTECTED] wrote: Not exactly. I need something to subset ONLY rows common to both dataframes. In the provided example, dat1 and dat2 have no common rows so I would expect: [1] v1 v2 0 rows (or 0-length row.names) But I can´t do it... On Sun, 11 May 2008 10:07:25 -0400, Zhuanshi He [EMAIL PROTECTED] said: Dear Jim, Maybe u want this, subset(dat2, time1 %in% dat2$v1 time2 %in% dat2$v1) v1 v2 2 2006-05-09 7065.0 3 2006-05-04 3622.5 5 2006-07-14 3532.5 7 2006-05-12 6480.0 8 2006-05-17 4612.5 15 2006-07-05 4837.5 16 2006-07-06 3352.5 18 2006-07-24 6772.5 20 2006-07-18 5625.0 Warning message: In time1 %in% dat2$v1 time2 %in% dat2$v1 : longer object length is not a multiple of shorter object length However, it looks the length of time1 and time2 is different. -- On 5/11/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear list: I can now reproduce with a bit of my real data, the problem I asked for your help yestarday: time1- as.Date(c(2006-01-03, 2006-05-03, 2006-05-04, 2006-05-11, 2006-05-12, 2006-05-16, 2006-05-19, 2006-05-26, 2006-09-15, 2006-10-30, 2006-11-08, 2006-11-14, 2006-11-20)) volume1- c(7312.5, 3352.5, 4252.5, 3825.0, 2700.0, 585.0, 810.0, 3015.0, 2925.0, 1102.5, 2632.5, 652.5, 1417.5) dat1- data.frame(v1=time1, v2=volume1) time2- as.Date(c(2006-05-03, 2006-05-09, 2006-05-04, 2006-05-08, 2006-07-14, 2006-07-10, 2006-05-12, 2006-05-17, 2006-05-19, 2006-05-26, 2006-05-29, 2006-05-18, 2006-05-22, 2006-07-03, 2006-07-05, 2006-07-06, 2006-07-04, 2006-07-24, 2006-07-12, 2006-07-18)) volume2- c(4522.5, 7065.0, 3622.5, 7875.0, 3532.5, 3667.5, 6480.0, 4612.5, 4005.0, 10350.0, 5310.0, 6345.0, 7177.5, 5107.5, 4837.5, 3352.5, 4050.0, 6772.5, 7290.0, 5625.0) dat2- data.frame(v1=time2, v2=volume2) subset(dat1, v1 %in% dat2$v1 v2 %in% dat2$v2) v1 v2 2 2006-05-03 3352.5 This is not what I expect since this row is not present in dat2 and I just want records present in both dataframes. Help? J On Sat, 10 May 2008 18:42:51 -0400, jim holtman [EMAIL PROTECTED] said: This seems to work for me: set.seed(1) df1 - data.frame(v1=factor(sample(1:4,20,TRUE)), v2=factor(sample(1:3,20,TRUE)), v3=sample(1:3,20,TRUE)) df2 - data.frame(v1=factor(sample(1:2,20,TRUE)), v2=factor(sample(1:2,20,TRUE)), v3=sample(1:2,20,TRUE)) subset(df1, (df1$v1 %in% df2$v1) (df1$v2 %in% df2$v2) (df1$v3 %in% df2$v3)) v1 v2 v3 2 2 1 2 5 1 1 2 11 1 2 2 14 2 1 1 Exactly what problems are you having? A sample of your actual data would be useful. On Sat, May 10, 2008 at 6:31 PM, [EMAIL PROTECTED] wrote: Dear list: I have two dataframes, say dat1 and dat2. Each has several variables but 3 of each are common in both, (say v1, v2 and v3). v1 and v2 are factores while v3 is numeric. Now, I need a subset to extract the rows in which v1, v2 and v3 are the same in both dataframes. I tried: subset(dat1, dat1$v1 %in% dat2$v1 dat1$v2 %in% dat2$v2 dat1$v3 %in% dat2$v3) I dont know why, but this is not working as I was expecting. Any suggestion to improve my code? Thanks in advance Justin -- [EMAIL PROTECTED] -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://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? -- [EMAIL PROTECTED] -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substitute in graphics - Uwe's help desk
Gustave Lefou wrote: Hello, I still have my problem. I couldn't make Uwe Ligges's example work. I wonder why :-( The following doesn't work : param.list=list(mu1=0,mu2=0,s1=3,s2=2,s3=2,s4=4) plot(1:8,type=n) text(8,3,adj=1,labels=substitute(with * mu == bgroup((,atop(mu1,mu2),)) * , * Sigma[x] == bgroup((,atop(s1~~s3,s2~~s4),)),param.list)) But this works : plot(1:8,type=n) text(8,3,adj=1,labels=substitute(with * mu == bgroup((,atop(mu1,mu2),)) * , * Sigma[x] * = * bgroup((,atop(s1~~s3,s2~~s4),)),param.list)) So like in my problem the problem seems to be ==. Same as in my former mail: x == y == z is an invalid expression but you must specify a valid one, even for plotting. ;-) Best, Uwe Ligges Thank you very much 2008/5/10 Gustave Lefou [EMAIL PROTECTED]: Thank to both of you. I found an interesting document by Uwe Ligges in Rnews December 2002 (Vol 2/3) The following seems encouraging x=seq(1,180,by=1) beta=10 eta=5 plot(x,log(x),type=p,xlab=x,ylab=h(x),main=substitute(Failure rate * eta==myeta * , * beta ,list(myeta=eta,mybeta=beta)) ) but then it fails : x=seq(1,180,by=1) beta=10 eta=5 plot(x,log(x),type=p,xlab=x,ylab=h(x),main=substitute(Failure rate from W( * eta==myeta * , * beta==mybeta , ) ,list(myeta=eta,mybeta=beta)) ) Any idea ? Thank you very much 2008/5/9 Henrique Dallazuanna [EMAIL PROTECTED]: Try this: plot(x, log(x), xlab = x, ylab = h(x), main = bquote(Failure~rate~from~W(eta == .(eta), beta == .(beta))) On Fri, May 9, 2008 at 11:31 AM, Gustave Lefou [EMAIL PROTECTED] wrote: Hello, I have to do a few graphics of the same function and this function is parametrized by two arguments. What I would like is to be able to change the value of these two arguments without changing the plot command. So as to copy paste. I tried the following : x=1:100 eta=10 beta=5 plot(x,h(x),xlab=x,ylab=h(x),main=substitute( expression( paste(Failure rate from,W(eta==myeta,beta==mybeta) ) ) ,list(myeta=eta,mybeta=beta) ) ) But it doesn't work. It's written expression ( Failure rate from W(eta=10,) ... on the plot with eta as a greek letter. Thank you very much ! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problems installing rJava
Hello, I'm having trouble installing rJava on R-2.6.1 / Suse10.3. What could be wrong? Regards, Juan Pablo This is the output of install.packages(rJava, dependencies=T) --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done probando la URL 'http://cran.stat.ucla.edu/src/contrib/rJava_0.5-1.tar.gz' Content type 'application/x-tar' length 230806 bytes (225 Kb) URL abierta == downloaded 225 Kb /usr/lib/R/library * Installing *source* package 'rJava' ... checking for gcc... gcc -std=gnu99 checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc -std=gnu99 accepts -g... yes checking for gcc -std=gnu99 option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -std=gnu99 -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/wait.h that is POSIX.1 compatible... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for string.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking for unistd.h... (cached) yes checking for an ANSI C-conforming const... yes checking whether time.h and sys/time.h may both be included... yes configure: checking whether gcc -std=gnu99 supports static inline... yes checking Java support in R... present: interpreter : '/usr/bin/java' archiver: '/usr/bin/jar' compiler: '/usr/bin/javac' header prep.: '/usr/bin/javah' cpp flags : '-I/usr/lib/jvm/java-1.5.0-sun-1.5.0_update15/jre/../include -I/usr/lib/jvm/java-1.5.0-sun-1.5.0_update15/jre/../include/linux' java libs : '-L/usr/lib/jvm/java-1.5.0-sun-1.5.0_update15/jre/lib/i386/server -L/usr/lib/jvm/java-1.5.0-sun-1.5.0_update15/jre/lib/i386 -L/usr/lib/jvm/java-1.5.0-sun-1.5.0_update15/jre/../lib/i386 -ljvm' checking whether JNI programs can be compiled... yes checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this. ERROR: configuration failed for package 'rJava' ** Removing '/usr/lib/R/library/rJava' The downloaded packages are in /tmp/RtmpNOU9fz/downloaded_packages Updating HTML index of packages in '.Library' Warning message: In install.packages(rJava, dependencies = T) : installation of package 'rJava' had non-zero exit status __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset rows in two dataframes
Dear Jim, Maybe u want this, subset(dat2, time1 %in% dat2$v1 time2 %in% dat2$v1) v1 v2 2 2006-05-09 7065.0 3 2006-05-04 3622.5 5 2006-07-14 3532.5 7 2006-05-12 6480.0 8 2006-05-17 4612.5 15 2006-07-05 4837.5 16 2006-07-06 3352.5 18 2006-07-24 6772.5 20 2006-07-18 5625.0 Warning message: In time1 %in% dat2$v1 time2 %in% dat2$v1 : longer object length is not a multiple of shorter object length However, it looks the length of time1 and time2 is different. -- On 5/11/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear list: I can now reproduce with a bit of my real data, the problem I asked for your help yestarday: time1- as.Date(c(2006-01-03, 2006-05-03, 2006-05-04, 2006-05-11, 2006-05-12, 2006-05-16, 2006-05-19, 2006-05-26, 2006-09-15, 2006-10-30, 2006-11-08, 2006-11-14, 2006-11-20)) volume1- c(7312.5, 3352.5, 4252.5, 3825.0, 2700.0, 585.0, 810.0, 3015.0, 2925.0, 1102.5, 2632.5, 652.5, 1417.5) dat1- data.frame(v1=time1, v2=volume1) time2- as.Date(c(2006-05-03, 2006-05-09, 2006-05-04, 2006-05-08, 2006-07-14, 2006-07-10, 2006-05-12, 2006-05-17, 2006-05-19, 2006-05-26, 2006-05-29, 2006-05-18, 2006-05-22, 2006-07-03, 2006-07-05, 2006-07-06, 2006-07-04, 2006-07-24, 2006-07-12, 2006-07-18)) volume2- c(4522.5, 7065.0, 3622.5, 7875.0, 3532.5, 3667.5, 6480.0, 4612.5, 4005.0, 10350.0, 5310.0, 6345.0, 7177.5, 5107.5, 4837.5, 3352.5, 4050.0, 6772.5, 7290.0, 5625.0) dat2- data.frame(v1=time2, v2=volume2) subset(dat1, v1 %in% dat2$v1 v2 %in% dat2$v2) v1 v2 2 2006-05-03 3352.5 This is not what I expect since this row is not present in dat2 and I just want records present in both dataframes. Help? J On Sat, 10 May 2008 18:42:51 -0400, jim holtman [EMAIL PROTECTED] said: This seems to work for me: set.seed(1) df1 - data.frame(v1=factor(sample(1:4,20,TRUE)), v2=factor(sample(1:3,20,TRUE)), v3=sample(1:3,20,TRUE)) df2 - data.frame(v1=factor(sample(1:2,20,TRUE)), v2=factor(sample(1:2,20,TRUE)), v3=sample(1:2,20,TRUE)) subset(df1, (df1$v1 %in% df2$v1) (df1$v2 %in% df2$v2) (df1$v3 %in% df2$v3)) v1 v2 v3 2 2 1 2 5 1 1 2 11 1 2 2 14 2 1 1 Exactly what problems are you having? A sample of your actual data would be useful. On Sat, May 10, 2008 at 6:31 PM, [EMAIL PROTECTED] wrote: Dear list: I have two dataframes, say dat1 and dat2. Each has several variables but 3 of each are common in both, (say v1, v2 and v3). v1 and v2 are factores while v3 is numeric. Now, I need a subset to extract the rows in which v1, v2 and v3 are the same in both dataframes. I tried: subset(dat1, dat1$v1 %in% dat2$v1 dat1$v2 %in% dat2$v2 dat1$v3 %in% dat2$v3) I dont know why, but this is not working as I was expecting. Any suggestion to improve my code? Thanks in advance Justin -- [EMAIL PROTECTED] -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? -- [EMAIL PROTECTED] -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Zhuanshi He / Z. He (PhD) Waterloo Centre for Atmospheric Sciences (WCAS) Department of Earth and Environmental Sciences Phy Bldg, Rm 2022 University of Waterloo, Waterloo, ON N2L 3G1 Canada Tel: +1-519-888-4567 ext 38053FAX: +1-519-746-0435 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Compact Indicator Matrices
On May 11, 4:47 pm, Douglas Bates [EMAIL PROTECTED] wrote: Do you mean that you want to collapse similar rows into a single row and perhaps a count of the number of times that this row occurs? Let me rephrase the problem by providing an example. Input: A = [,1] [,2] [1,]11 [2,]13 [3,]21 [4,]12 [5,]21 [6,]12 [7,]11 [8,]12 [9,]13 [10,]21 # Indicator matrix A - data.frame(lapply(data.frame(obj), as.factor)) nocases - dim(obj)[1] novars - dim(obj)[2] # variable levels levels.n - sapply(obj, nlevels) n- cumsum(levels.n) # Indicator matrix calculations Z- matrix(0, nrow = nocases, ncol = n[length(n)]) newdat - lapply(obj, as.numeric) offset - (c(0, n[-length(n)])) for (i in 1:novars) Z[1:nocases + (nocases * (offset[i] + newdat[[i]] - 1))] - 1 ### Output: Z = [,1] [,2] [,3] [,4] [,5] [1,]10100 [2,]10001 [3,]01100 [4,]10010 [5,]01100 [6,]10010 [7,]10100 [8,]10010 [9,]10001 [10,]01100 Z is an indicator matrix in the Multiple Correspondence Analysis framework. My problem is to collapse identical rows (e.g. 2 and 9) into a single row and store the row ids. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset rows in two dataframes
Dear Jim, The following codes maybe helps. for (i in 1:length(dat1[,1])) { for (j in 1:length(dat2[,1])) { if (dat1[i,1] == dat2[j,1] dat1[i,2] == dat2[j,2]) print (j) } } time1- as.Date(c(2006-01-03, 2006-05-03, 2006-05-04, 2006-05-11, 2006-05-12, 2006-05-16, 2006-05-19, 2006-05-26, 2006-09-15, 2006-10-30, 2006-11-08, 2006-11-14, 2006-11-20)) volume1- c(7312.5, 3352.5, 4252.5, 3825.0, 2700.0, 585.0, 810.0, 3015.0, 2925.0, 1102.5, 2632.5, 652.5, 1417.5) dat1- data.frame(v1=time1, v2=volume1) time2- as.Date(c(2006-05-03, 2006-05-09, 2006-05-04, 2006-05-08, 2006-07-14, 2006-07-10, 2006-05-12, 2006-05-17, 2006-05-19, 2006-05-26, 2006-05-29, 2006-05-18, 2006-05-22, 2006-07-03, 2006-07-05, 2006-07-06, 2006-07-04, 2006-07-24, 2006-07-12, 2006-07-18)) volume2- c(4522.5, 7065.0, 3622.5, 7875.0, 3532.5, 3667.5, 6480.0, 4612.5, 4005.0, 10350.0, 5310.0, 6345.0, 7177.5, 5107.5, 4837.5, 3352.5, 4050.0, 6772.5, 7290.0, 5625.0) dat2- data.frame(v1=time2, v2=volume2) for (i in 1:length(dat1[,1])) { for (j in 1:length(dat2[,1])) { if (dat1[i,1] == dat2[j,1] dat1[i,2] == dat2[j,2]) print (j) } } On 5/11/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Not exactly. I need something to subset ONLY rows common to both dataframes. In the provided example, dat1 and dat2 have no common rows so I would expect: [1] v1 v2 0 rows (or 0-length row.names) But I can´t do it... On Sun, 11 May 2008 10:07:25 -0400, Zhuanshi He [EMAIL PROTECTED] said: Dear Jim, Maybe u want this, subset(dat2, time1 %in% dat2$v1 time2 %in% dat2$v1) v1 v2 2 2006-05-09 7065.0 3 2006-05-04 3622.5 5 2006-07-14 3532.5 7 2006-05-12 6480.0 8 2006-05-17 4612.5 15 2006-07-05 4837.5 16 2006-07-06 3352.5 18 2006-07-24 6772.5 20 2006-07-18 5625.0 Warning message: In time1 %in% dat2$v1 time2 %in% dat2$v1 : longer object length is not a multiple of shorter object length However, it looks the length of time1 and time2 is different. -- On 5/11/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear list: I can now reproduce with a bit of my real data, the problem I asked for your help yestarday: time1- as.Date(c(2006-01-03, 2006-05-03, 2006-05-04, 2006-05-11, 2006-05-12, 2006-05-16, 2006-05-19, 2006-05-26, 2006-09-15, 2006-10-30, 2006-11-08, 2006-11-14, 2006-11-20)) volume1- c(7312.5, 3352.5, 4252.5, 3825.0, 2700.0, 585.0, 810.0, 3015.0, 2925.0, 1102.5, 2632.5, 652.5, 1417.5) dat1- data.frame(v1=time1, v2=volume1) time2- as.Date(c(2006-05-03, 2006-05-09, 2006-05-04, 2006-05-08, 2006-07-14, 2006-07-10, 2006-05-12, 2006-05-17, 2006-05-19, 2006-05-26, 2006-05-29, 2006-05-18, 2006-05-22, 2006-07-03, 2006-07-05, 2006-07-06, 2006-07-04, 2006-07-24, 2006-07-12, 2006-07-18)) volume2- c(4522.5, 7065.0, 3622.5, 7875.0, 3532.5, 3667.5, 6480.0, 4612.5, 4005.0, 10350.0, 5310.0, 6345.0, 7177.5, 5107.5, 4837.5, 3352.5, 4050.0, 6772.5, 7290.0, 5625.0) dat2- data.frame(v1=time2, v2=volume2) subset(dat1, v1 %in% dat2$v1 v2 %in% dat2$v2) v1 v2 2 2006-05-03 3352.5 This is not what I expect since this row is not present in dat2 and I just want records present in both dataframes. Help? J On Sat, 10 May 2008 18:42:51 -0400, jim holtman [EMAIL PROTECTED] said: This seems to work for me: set.seed(1) df1 - data.frame(v1=factor(sample(1:4,20,TRUE)), v2=factor(sample(1:3,20,TRUE)), v3=sample(1:3,20,TRUE)) df2 - data.frame(v1=factor(sample(1:2,20,TRUE)), v2=factor(sample(1:2,20,TRUE)), v3=sample(1:2,20,TRUE)) subset(df1, (df1$v1 %in% df2$v1) (df1$v2 %in% df2$v2) (df1$v3 %in% df2$v3)) v1 v2 v3 2 2 1 2 5 1 1 2 11 1 2 2 14 2 1 1 Exactly what problems are you having? A sample of your actual data would be useful. On Sat, May 10, 2008 at 6:31 PM, [EMAIL PROTECTED] wrote: Dear list: I have two dataframes, say dat1 and dat2. Each has several variables but 3 of each are common in both, (say v1, v2 and v3). v1 and v2 are factores while v3 is numeric. Now, I need a subset to extract the rows in which v1, v2 and v3 are the same in both dataframes. I tried: subset(dat1, dat1$v1 %in% dat2$v1 dat1$v2 %in% dat2$v2 dat1$v3 %in% dat2$v3) I dont know why, but this is not working as I was expecting. Any suggestion to improve my code? Thanks in advance Justin -- [EMAIL PROTECTED]
[R] Robust Stepwise Regression
Hello, I am interested in performing a stepwise regression using the robust regression technique to estimate the models at each stage. At the moment I am using the lm code and the stepAIC code to select the best OLS model. This final model is then re-estimated using the rlm code. I am hoping there is a better was to do this, where at each step of the stepwise code the robust regression technique rather than OLS is used. I realise that an AIC statistic may not be available in rlm, but some other criteria is fine. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme nesting/interaction advice
On 10 May 2008, at 07:36, Kingsford Jones wrote: Federico, I think you'll be more likely to receive the type of response you're looking for if you formulate your question more clearly. The inclusion of commented, minimal, self-contained, reproducible code (as is requested at the bottom of every email sent by r-help) is an effective way to clarify the issues. Also, when asking a question about fitting a model it's helpful to describe the specific research questions you want the model to answer. snip I apprecciate that my description of the *full* model is not 100% clear, but my main beef was another. The main point of my question is, having a 3 way anova (or ancova, if you prefer), with *no* nesting, 2 fixed effects and 1 random effect, why is it so boneheaded difficult to specify a bog standard fully crossed model? I'm not talking about some rarified esoteric model here, we're talking about stuff tought in a first year Biology Stats course here[1]. Now, to avoid any chances of being misunderstood in my use of the words 'fully crossed model', what I mean is a simple y ~ effect1 * effect2 * effect3 with effect3 being random (all all the jazz that comes from this fact). I fully apprecciate that the only reasonable F-tests would be for effect1, effect2 and effect1:effect2, but there is no way I can use lme to specify such simple thing without getting the *wrong* denDF. I need light on this topic and I'd say it's a general enough question not to need much more handholding than this. Having said that, I did look at the mixed-effects mailing list before posting here, and it looks like it was *not* the right place to post anyway: 'This mailing list is primarily for useRs and programmeRs interested in *development* and beta-testing of the lme4 package.' although the R-Me is now CC'd in this. I fully apprecciate that R is developed for love, not money, and if I knew how to write an user friendly frontend for nlme and lme4 (and I knew how to actually get the model I want) I'd be pretty happy to do so and submit it as a library. In any case, I feel my complaint is pefectly valid, because specifying such basic model should ideally not such a chore, and I think the powers that be might actually find some use from user feedback. Once I have sorted how to specify such trivial model I'll face the horror of the nesting, in any case I attach a toy dataset I created especially to test how to specify the correct model (silly me). Best, Federico Calboli [1] So much bog standard that the Zar, IV ed, gives a nice table of how to compute the F-tests correctly, taking into account that one of the 3 effects is randon (I'll send the exact page and table number tomorrow, I don't have the book at home). selection linemales month block y L L1 1 a 1 13.8156357121188 L L1 1 a 1 12.5678496952169 L L1 1 a 1 17.1313698710874 L L1 1 a 1 3.87016302696429 L L1 1 a 1 13.2627072110772 L L2 1 a 1 17.835768135963 L L2 1 a 1 19.3615794742946 L L2 1 a 1 1.73416316602379 L L2 1 a 1 12.9440758333076 L L2 1 a 1 2.09191741654649 S S1 1 a 1 1.56137526640669 S S1 1 a 1 17.6580698778853 S S1 1 a 1 18.1417595115490 S S1 1 a 1 15.5621050691698 S S1 1 a 1 17.0240987658035 S S2 1 a 1 12.4378062419128 S S2 1 a 1 6.63962595071644 S S2 1 a 1 16.6060689473525 S S2 1 a 1 7.1222553497646 S S2 1 a 1 18.0590278783347 L L1 2 a 1 1.24710303940810 L L1 2 a 1 4.62720696791075 L L1 2 a 1 16.0327167815994 L L1 2 a 1 6.12926463945769 L L1 2 a 1 7.65810538828373 L L2 2 a 1 7.44077128893696 L L2 2 a 1 14.9197938004509 L L2 2 a 1 13.4244954204187 L L2 2 a 1 11.5361888066400 L L2 2 a 1 2.60056478204206 S S1 2 a 1 14.8965472229756 S S1 2 a 1 18.777876078384 S S1 2 a 1 6.80722737265751 S S1 2 a 1 13.1697203880176 S S1 2 a 1 3.74557441123761 S S2 2 a 1 5.41025308240205 S S2 2 a 1 19.8277674221899 S S2 2 a 1
[R] Fundamental formula and dataframe question.
There is a very useful and apparently fundamental feature of R (or of the package pls) which I don't understand. For datasets with many independent (X) variables such as chemometric datasets there is a convenient formula and dataframe construction that allows one to access the entire X matrix with a single term. Consider the gasoline dataset available in the pls package. For the model statement in the plsr function one can write: Octane ~ NIR NIR refers to a (wide) matrix which is a portion of a dataframe. The naming of the columns is of the form: 'NIR. nm' names(gasoline) returns... $names [1] octane NIR instead of... $names [1] octane NIR.1000 nm NIR.1001 nm ... How do I construct and manipulate such dataframes and the column names that go with? Does the use of these types of formulas and dataframes generalize to other modeling functions? Some specific clues on a help search might be enough, I've tried many. Regards, Brent [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] positioning of color key in levelplot
Is there a way of positioning the color key in levelplot when the axes are on a categorical (rather than numerical) scale? I've put some sample code below. I need to add a secondary y axis to the right side of my plot but then the labels interfere with the color key (which is currently on the right side). Is there a way to shift the color key over a bit more to the right? I've tried playing around with the arguments x, y, and cornerin the colorkey list, but it doesn't seem to change anything. I've also tried putting the colorkey on the left side instead, but then the secondary y axis labels are cut-off. Thanks for any help! group1 - c(rep(A1, 40), rep(A2, 40)) group2 -rep(c(rep(C1, 5), rep(C2, 5), rep(C3, 5), rep(C4, 5), rep(C5, 5), rep(C6, 5), rep(C7, 5), rep(C8, 5)),2) num - rnorm(80) group3 - rep(seq(0,4,1),16) data - data.frame(group1, group2, num, group3) levelplot(num ~ as.factor(group3) * group2|group1, data=data,col.regions=rev(heat.colors(25)), colorkey=list(space=right), region=T, layout=c(1,2), scales=list(y=list(alternating=c(1,1,1 trellis.focus(panel, 1, 2, clip.off=T) panel.axis(at=seq(1,8,1), labels=c(rep(Blah,8)), side=c(right), outside=T) trellis.focus(panel, 1, 1, clip.off=T) panel.axis(at=seq(1,8,1), labels=c(rep(Blah,8)), side=c(right), outside=T) trellis.unfocus() _ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fundamental formula and dataframe question.
On 11-May-08 18:58:45, Myers, Brent wrote: There is a very useful and apparently fundamental feature of R (or of the package pls) which I don't understand. For datasets with many independent (X) variables such as chemometric datasets there is a convenient formula and dataframe construction that allows one to access the entire X matrix with a single term. Consider the gasoline dataset available in the pls package. For the model statement in the plsr function one can write: Octane ~ NIR NIR refers to a (wide) matrix which is a portion of a dataframe. The naming of the columns is of the form: 'NIR. nm' names(gasoline) returns... $names [1] octane NIR instead of... $names [1] octane NIR.1000 nm NIR.1001 nm ... How do I construct and manipulate such dataframes and the column names that go with? Does the use of these types of formulas and dataframes generalize to other modeling functions? Some specific clues on a help search might be enough, I've tried many. Regards, Brent I don't have the 'gasoline' dataset to hand, but I can produce something to which your descrption applies as follows: C1 - c(1.1,1.2,1.3,1.4) C2 - c(2.1,2.2,2.3,2.4) M - cbind(M1=c(11.1,11.2,11.3,11.4), M2=c(12.1,12.2,12.3,12.4)) DF - data.frame(C1=C1,C2=C2,M=M) DF #C1 C2 M.M1 M.M2 # 1 1.1 2.1 11.1 12.1 # 2 1.2 2.2 11.2 12.2 # 3 1.3 2.3 11.3 12.3 # 4 1.4 2.4 11.4 12.4 so the two columns C1 and C2 have gone in as named, and the matrix M (with named columns M1 and M2) has gone in with columns M.M1, M.M2 Now let's fuzz the numbers a bit, so that the lm() fit makes sense: C1 - C1 + round(0.1*runif(4),2) C1 - C1 + round(0.1*runif(4),2) M - cbind(M1=c(11.1,11.2,11.3,11.4), M2=c(12.1,12.2,12.3,12.4)) + round(0.1*runif(8),2) DF - data.frame(C1=C1,C2=C2,M=M) DF # C1 C2 M.M1 M.M2 # 1 1.21 2.1 11.19 12.13 # 2 1.34 2.2 11.23 12.23 # 3 1.38 2.3 11.36 12.30 # 4 1.50 2.4 11.43 12.48 summary(lm(C1 ~ M),data=DF) # Call: # lm(formula = C1 ~ M) # Residuals: #1234 # -0.02422 0.02448 0.01309 -0.01335 # Coefficients: # Estimate Std. Error t value Pr(|t|) # (Intercept) -8.284352.48952 -3.3280.186 # MM1 -0.054110.66909 -0.0810.949 # MM2 0.834630.50687 1.6470.347 # Residual standard error: 0.03919 on 1 degrees of freedom # Multiple R-Squared: 0.9642, Adjusted R-squared: 0.8925 # F-statistic: 13.46 on 2 and 1 DF, p-value: 0.1893 In other words, a perfectly standard LM fit, equivalent to summary(lm(C1 ~ M[,1]+M[,2])) (as you can check). So all that looks straightforward. One thing, however, is not clear to me in this scenario. Suppose, for example, that the columns M1 and M2 of M were factors (and that you had more rows than I've used above, so that the fit is non-trivial). Then, in the standard specification of an LM, you could write summary(lm(C1 ~ M[,1]*M[,2])) and get the main effects and interactions. But how would you do that in the other type of specification: Where you used summary(lm(C1 ~ M, data=DF)) to get the equivalent of summary(lm(C1 ~ M[,1]+M[,2])) what would you use to get the equivalent of summary(lm(C1 ~ M[,1]*M[,2]))?? Would you have to spell out the interaction term[s] in additional columns of M? Hmmm, interesting! I hadn't been aware of this aspect of formula and dataframe construction for modellinng, until you pointed it out! Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 11-May-08 Time: 21:06:49 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] positioning of color key in levelplot
On 5/11/08, E C [EMAIL PROTECTED] wrote: Is there a way of positioning the color key in levelplot when the axes are on a categorical (rather than numerical) scale? I've put some sample code below. I need to add a secondary y axis to the right side of my plot but then the labels interfere with the color key (which is currently on the right side). Is there a way to shift the color key over a bit more to the right? I've tried playing around with the arguments x, y, and cornerin the colorkey list, but it doesn't seem to change anything. I've also tried putting the colorkey on the left side instead, but then the secondary y axis labels are cut-off. Thanks for any help! group1 - c(rep(A1, 40), rep(A2, 40)) group2 -rep(c(rep(C1, 5), rep(C2, 5), rep(C3, 5), rep(C4, 5), rep(C5, 5), rep(C6, 5), rep(C7, 5), rep(C8, 5)),2) num - rnorm(80) group3 - rep(seq(0,4,1),16) data - data.frame(group1, group2, num, group3) It has more to do with adding space for the axis, rather than anything to do with the legend directly. levelplot(num ~ as.factor(group3) * group2|group1, data=data, col.regions=rev(heat.colors(25)), colorkey=list(space=right), par.settings = list(layout.widths = list(axis.key.padding = 5)), region=T, layout=c(1,2), scales=list(y=list(alternating=c(1,1,1 trellis.focus(panel, 1, 2, clip.off=T, highlight = FALSE) panel.axis(at=seq(1,8,1), labels=c(rep(Blah,8)), side=c(right), outside=T) trellis.focus(panel, 1, 1, clip.off=T, highlight = FALSE) panel.axis(at=seq(1,8,1), labels=c(rep(Blah,8)), side=c(right), outside=T) trellis.unfocus() -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] howto import .xls and .ods
On Fri, May 02, 2008 at 07:35:37AM +0100, Prof Brian Ripley wrote: There is a *manual* on R Data Import/Export, not just an FAQ. This is the first request I have seen for .ods (whatever that is -- The most well-known application that uses this file format is the Calc (Spreadsheet) part of the Open Office Suite. Pasted from http://en.wikipedia.org/wiki/OpenDocument OpenDocument Spreadsheet Image:X File extension.ods application/vnd. Internet media type oasis.opendocument. spreadsheet Developed by Sun Microsystems, OASIS Type of formatSpreadsheet Extended fromXML -- Hans Ekbrand (http://sociologi.cjb.net) [EMAIL PROTECTED] GPG Fingerprint: 1408 C8D5 1E7D 4C9C C27E 014F 7C2C 872A 7050 614E signature.asc Description: Digital signature __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Finding unmatched data between two dataframe using several factors
Hi R users I am trying to find unmatched data from two dataframes. I would like to find unmatched data based on several factors. For the following data: dat1 - data.frame(x = paste(A, 1:6, sep=), y = c(andy,bob,ciaran,dan, eion, fred)) dat1 dat2 - data.frame(x = paste(A, c(1,2,3,5,6), sep=), y = c(andy, bob, ciaran, dan, zane),z=c(10,20,30,40,50)) dat2 I would like to know data that from dat2 that doesn't appear in dat1 based on both the x and y factors ie (A5, dan, 40) and (A6,zane, 50). I have tried two approaches but have not been successful ? nomatch - subset(dat1, is.element(?) == FALSE) ? setdiff(dat1$x,dat2$y) Any thoughts would be great Regards Andy Andrew McFadden MVS BVSc Incursion Investigator Investigation Diagnostic Centres - Wallaceville Biosecurity New Zealand Ministry of Agriculture and Forestry Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address: Investigation and Diagnostic Centre- Wallaceville Box 40742 Ward St Upper Hutt This email message and any attachment(s) is intended solely for the addressee(s) named above. The information it contains is confidential and may be legally privileged. Unauthorised use of the message, or the information it contains, may be unlawful. If you have received this message by mistake please call the sender immediately on 64 4 8940100 or notify us by return email and erase the original message and attachments. Thank you. The Ministry of Agriculture and Forestry accepts no responsibility for changes made to this email or to any attachments after transmission from the office. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme nesting/interaction advice
On Sun, May 11, 2008 at 07:52:50PM +0100, Federico Calboli wrote: The main point of my question is, having a 3 way anova (or ancova, if you prefer), with *no* nesting, 2 fixed effects and 1 random effect, why is it so boneheaded difficult to specify a bog standard fully crossed model? I'm not talking about some rarified esoteric model here, we're talking about stuff tought in a first year Biology Stats course here[1]. That may be so, but I've never needed to use one. If it's bog-standard and yet boneheaded difficult, then presumably someone else would have had this problem before you. Perhaps a search of the archives will help? If you try, you will find many qualifiers to the effect that lme isn't very well set up for crossed random effects. Now, to avoid any chances of being misunderstood in my use of the words 'fully crossed model', what I mean is a simple y ~ effect1 * effect2 * effect3 with effect3 being random (all all the jazz that comes from this fact). I fully apprecciate that the only reasonable F-tests would be for effect1, effect2 and effect1:effect2, but there is no way I can use lme to specify such simple thing without getting the *wrong* denDF. I need light on this topic and I'd say it's a general enough question not to need much more handholding than this. Perhaps there are some circumstances unique to your situation. I fully apprecciate that R is developed for love, not money, ... as is the R-help community ... and if I knew how to write an user friendly frontend for nlme and lme4 (and I knew how to actually get the model I want) I'd be pretty happy to do so and submit it as a library. In any case, I feel my complaint is pefectly valid, because specifying such basic model should ideally not such a chore, and I think the powers that be might actually find some use from user feedback. This is not feedback. It is a compliant. But, the complaint boils down to the fact that you don't know what you're doing, and you show no evidence of having searched the R-help archives. How is that helpful? Once I have sorted how to specify such trivial model I'll face the horror of the nesting, in any case I attach a toy dataset I created especially to test how to specify the correct model (silly me). Well, these data seem to differ. Is replica block? If not, then how can we reproduce your results? And, if I assume that it is, then the output df differ from what you sent in your original mail. So, I find this confusing. Then, from your original mail, The easiest model ignores the nested random effects and uses just selection, males and replica and the relative interactions. The model lme(y ~ selection * males, random = ~1|replica/selection/males, mydata) forgive me, but I seem to see nesting in the random statement. That is what happens when we separate factors with a '/'; they are nested. We would expect that statement to not provide the correct df for the bog-standard fully crossed design. Perhaps if you were to comply with the request at the bottom of each R-help email, and provide commented, minimal, self-contained, reproducible code, that actually ran, ideally with fewer value judgements, you might get more attention from the people who are smarter than you and me, but have less time than either of us. Andrew -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-6410 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Not to draw the xaxis ticks in ggplot2
Hi ronggui wrote: Thanks,Hadley. Another question is how can I know there is a grob path called xaxis::ticks? Is there any easy way to figure out? grid.ls() ? Paul Thanks in advance. On Wed, May 7, 2008 at 10:06 PM, hadley wickham [EMAIL PROTECTED] wrote: On Tue, May 6, 2008 at 11:44 PM, ronggui [EMAIL PROTECTED] wrote: library(ggplot2) (p- qplot(mpg, wt, data=mtcars)) What I am doing is to set color of the ticks to hide them. grid.gedit(gPath(xaxis, ticks), gp=gpar(col=white)) It should be a better way to achieve the purpose. Thanks. Agreed. I've added it to my ggplot2 customisation to do list. Thanks, Hadley -- http://had.co.nz/ -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme nesting/interaction advice
On 12/05/2008, at 9:45 AM, Andrew Robinson wrote: On Sun, May 11, 2008 at 07:52:50PM +0100, Federico Calboli wrote: The main point of my question is, having a 3 way anova (or ancova, if you prefer), with *no* nesting, 2 fixed effects and 1 random effect, why is it so boneheaded difficult to specify a bog standard fully crossed model? I'm not talking about some rarified esoteric model here, we're talking about stuff tought in a first year Biology Stats course here[1]. That may be so, but I've never needed to use one. So what? This is still a standard, common, garden-variety model that you will encounter in exercises in many (if not all!) textbooks on experimental design and anova. If it's bog-standard and yet boneheaded difficult, then presumably someone else would have had this problem before you. Perhaps a search of the archives will help? If you try, you will find many qualifiers to the effect that lme isn't very well set up for crossed random effects. But that avoids the question as to *why* it isn't very well set up for crossed random effects? What's the problem? What are the issues? The model is indeed bog-standard. It would seem not unreasonable to expect that it could be fitted in a straightforward manner, and it is irritating to find that it cannot be. If SAS and Minitab can do it at the touch of a button, why can't R do it? Now, to avoid any chances of being misunderstood in my use of the words 'fully crossed model', what I mean is a simple y ~ effect1 * effect2 * effect3 with effect3 being random (all all the jazz that comes from this fact). I fully apprecciate that the only reasonable F-tests would be for effect1, effect2 and effect1:effect2, but there is no way I can use lme to specify such simple thing without getting the *wrong* denDF. I need light on this topic and I'd say it's a general enough question not to need much more handholding than this. Perhaps there are some circumstances unique to your situation. Huh? I fully apprecciate that R is developed for love, not money, ... as is the R-help community ... and if I knew how to write an user friendly frontend for nlme and lme4 (and I knew how to actually get the model I want) I'd be pretty happy to do so and submit it as a library. In any case, I feel my complaint is pefectly valid, because specifying such basic model should ideally not such a chore, and I think the powers that be might actually find some use from user feedback. This is not feedback. It is a compliant. But, the complaint boils down to the fact that you don't know what you're doing That's rubbish. I think it's fairly clear that Federico does have a pretty good idea of what he's doing, but is flummoxed by the arcana of lme(). As am I. and you show no evidence of having searched the R-help archives. How is that helpful? It doesn't seem to me to be a complaint as such. It is a request for insight. I too would like some insight as to what on earth is going on. And why do you say Federico shows no evidence of having searched the archives? One can search till one is blue in the face and come away no wiser on this issue. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Finding unmatched data between two dataframe using severalfactors
Andrew Have you tried: dat2[!paste(dat2[,1], dat2[,2])%in%paste(dat1[,1], dat1[,2]),] ? HTH Peter Alspach -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew McFadden Sent: Monday, 12 May 2008 9:40 a.m. To: r-help@r-project.org Subject: [R] Finding unmatched data between two dataframe using severalfactors Hi R users I am trying to find unmatched data from two dataframes. I would like to find unmatched data based on several factors. For the following data: dat1 - data.frame(x = paste(A, 1:6, sep=), y = c(andy,bob,ciaran,dan, eion, fred)) dat1 dat2 - data.frame(x = paste(A, c(1,2,3,5,6), sep=), y = c(andy, bob, ciaran, dan, zane),z=c(10,20,30,40,50)) dat2 I would like to know data that from dat2 that doesn't appear in dat1 based on both the x and y factors ie (A5, dan, 40) and (A6,zane, 50). I have tried two approaches but have not been successful ? nomatch - subset(dat1, is.element(?) == FALSE) ? setdiff(dat1$x,dat2$y) Any thoughts would be great Regards Andy Andrew McFadden MVS BVSc Incursion Investigator Investigation Diagnostic Centres - Wallaceville Biosecurity New Zealand Ministry of Agriculture and Forestry Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address: Investigation and Diagnostic Centre- Wallaceville Box 40742 Ward St Upper Hutt ## ## This email message and any attachment(s) is intended solely for the addressee(s) named above. The information it contains is confidential and may be legally privileged. Unauthorised use of the message, or the information it contains, may be unlawful. If you have received this message by mistake please call the sender immediately on 64 4 8940100 or notify us by return email and erase the original message and attachments. Thank you. The Ministry of Agriculture and Forestry accepts no responsibility for changes made to this email or to any attachments after transmission from the office. ## ## [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. The contents of this e-mail are privileged and/or confidential to the named recipient and are not to be used by any other person and/or organisation. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Running external python script
Hi R users, I have a python script. Assume that I would like to run this external python script when executing a R script or command line R. I don't know how to this using R code. I really appreciate if you could help me. Thanks for your help Rostam [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Running external python script
On 12/05/2008, at 11:17 AM, rostam shahname wrote: Hi R users, I have a python script. Assume that I would like to run this external python script when executing a R script or command line R. I don't know how to this using R code. I really appreciate if you could help me. Thanks for your help ?system ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Running external python script
mac os X On Sun, May 11, 2008 at 8:24 PM, Rolf Turner [EMAIL PROTECTED] wrote: On 12/05/2008, at 11:17 AM, rostam shahname wrote: Hi R users, I have a python script. Assume that I would like to run this external python script when executing a R script or command line R. I don't know how to this using R code. I really appreciate if you could help me. Thanks for your help ?system ## Attention:This e-mail message is privileged and confidential. If you are not theintended recipient please delete the message and notify the sender.Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshal www.marshalsoftware.com ## [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Running external python script
On 12/05/2008, at 11:37 AM, rostam shahname wrote: mac os X No, no, no!!! That's what ***you*** type (in R)! :-) cheers, Rolf On Sun, May 11, 2008 at 8:24 PM, Rolf Turner [EMAIL PROTECTED] wrote: On 12/05/2008, at 11:17 AM, rostam shahname wrote: Hi R users, I have a python script. Assume that I would like to run this external python script when executing a R script or command line R. I don't know how to this using R code. I really appreciate if you could help me. Thanks for your help ?system ## Attention:This e-mail message is privileged and confidential. If you are not theintended recipient please delete the message and notify the sender.Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshalwww.marshalsoftware.com ## ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme nesting/interaction advice
On Mon, May 12, 2008 at 10:34:40AM +1200, Rolf Turner wrote: On 12/05/2008, at 9:45 AM, Andrew Robinson wrote: On Sun, May 11, 2008 at 07:52:50PM +0100, Federico Calboli wrote: The main point of my question is, having a 3 way anova (or ancova, if you prefer), with *no* nesting, 2 fixed effects and 1 random effect, why is it so boneheaded difficult to specify a bog standard fully crossed model? I'm not talking about some rarified esoteric model here, we're talking about stuff tought in a first year Biology Stats course here[1]. That may be so, but I've never needed to use one. So what? This is still a standard, common, garden-variety model that you will encounter in exercises in many (if not all!) textbooks on experimental design and anova. To reply in similar vein, so what? Why should R-core or the R community feel it necessary to reproduce every textbook example? How many times have *you* used such a model in real statistical work, Rolf? If it's bog-standard and yet boneheaded difficult, then presumably someone else would have had this problem before you. Perhaps a search of the archives will help? If you try, you will find many qualifiers to the effect that lme isn't very well set up for crossed random effects. But that avoids the question as to *why* it isn't very well set up for crossed random effects? What's the problem? What are the issues? The model is indeed bog-standard. It would seem not unreasonable to expect that it could be fitted in a straightforward manner, and it is irritating to find that it cannot be. If SAS and Minitab can do it at the touch of a button, why can't R do it? Bates has made no secret of the fact that lme was intended first and foremost for nested designs, and that support for crossed designs is not promised. He has said so on many occasions, as a search would find. He is now working on lme4, which will support crossed designs. It's not done yet. and you show no evidence of having searched the R-help archives. How is that helpful? It doesn't seem to me to be a complaint as such. It is a request for insight. I too would like some insight as to what on earth is going on. And why do you say Federico shows no evidence of having searched the archives? One can search till one is blue in the face and come away no wiser on this issue. At least one can know that there is an issue, which apparently Federico previously did not. Warm wishes Andrew -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-6410 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [Partial Summary] A fundamental formula and dataframe question.
Two very good responses to this question, but I wonder, Is there some more complete documentation on using this form of model and dataframe construction? I've been using R for ~5 years now and wasn't aware of it. Response 1: Insert a matrix as a column of the dataframe using I(). var-1:10 mat-matrix(101:200,10) mydf-data.frame(var,I(mat)) str(mydf) Response 2: An equvalent response plus a demonstration that this model construction technique generalizes at least to lm. But which ends with a question: C1 - c(1.1,1.2,1.3,1.4) C2 - c(2.1,2.2,2.3,2.4) M - cbind(M1=c(11.1,11.2,11.3,11.4), M2=c(12.1,12.2,12.3,12.4)) DF - data.frame(C1=C1,C2=C2,M=M) Would you have to spell out the interaction term[s] in additional columns of M? Hmmm, interesting! I hadn't been aware of this aspect of formula and dataframe construction for modellinng, until you pointed it out! This response had a very useful example, see excerpted below the initial question... Thanks responders, Brent There is a very useful and apparently fundamental feature of R (or of the package pls) which I don't understand. For datasets with many independent (X) variables such as chemometric datasets there is a convenient formula and dataframe construction that allows one to access the entire X matrix with a single term. Consider the gasoline dataset available in the pls package. For the model statement in the plsr function one can write: Octane ~ NIR NIR refers to a (wide) matrix which is a portion of a dataframe. The naming of the columns is of the form: 'NIR. nm' names(gasoline) returns... $names [1] octane NIR instead of... $names [1] octane NIR.1000 nm NIR.1001 nm ... How do I construct and manipulate such dataframes and the column names that go with? Does the use of these types of formulas and dataframes generalize to other modeling functions? Some specific clues on a help search might be enough, I've tried many. Regards, Brent I don't have the 'gasoline' dataset to hand, but I can produce something to which your descrption applies as follows: C1 - c(1.1,1.2,1.3,1.4) C2 - c(2.1,2.2,2.3,2.4) M - cbind(M1=c(11.1,11.2,11.3,11.4), M2=c(12.1,12.2,12.3,12.4)) DF - data.frame(C1=C1,C2=C2,M=M) DF #C1 C2 M.M1 M.M2 # 1 1.1 2.1 11.1 12.1 # 2 1.2 2.2 11.2 12.2 # 3 1.3 2.3 11.3 12.3 # 4 1.4 2.4 11.4 12.4 so the two columns C1 and C2 have gone in as named, and the matrix M (with named columns M1 and M2) has gone in with columns M.M1, M.M2 Now let's fuzz the numbers a bit, so that the lm() fit makes sense: C1 - C1 + round(0.1*runif(4),2) C1 - C1 + round(0.1*runif(4),2) M - cbind(M1=c(11.1,11.2,11.3,11.4), M2=c(12.1,12.2,12.3,12.4)) + round(0.1*runif(8),2) DF - data.frame(C1=C1,C2=C2,M=M) DF # C1 C2 M.M1 M.M2 # 1 1.21 2.1 11.19 12.13 # 2 1.34 2.2 11.23 12.23 # 3 1.38 2.3 11.36 12.30 # 4 1.50 2.4 11.43 12.48 summary(lm(C1 ~ M),data=DF) # Call: # lm(formula = C1 ~ M) # Residuals: #1234 # -0.02422 0.02448 0.01309 -0.01335 # Coefficients: # Estimate Std. Error t value Pr(|t|) # (Intercept) -8.284352.48952 -3.3280.186 # MM1 -0.054110.66909 -0.0810.949 # MM2 0.834630.50687 1.6470.347 # Residual standard error: 0.03919 on 1 degrees of freedom # Multiple R-Squared: 0.9642, Adjusted R-squared: 0.8925 # F-statistic: 13.46 on 2 and 1 DF, p-value: 0.1893 In other words, a perfectly standard LM fit, equivalent to summary(lm(C1 ~ M[,1]+M[,2])) (as you can check). So all that looks straightforward. One thing, however, is not clear to me in this scenario. Suppose, for example, that the columns M1 and M2 of M were factors (and that you had more rows than I've used above, so that the fit is non-trivial). Then, in the standard specification of an LM, you could write summary(lm(C1 ~ M[,1]*M[,2])) and get the main effects and interactions. But how would you do that in the other type of specification: Where you used summary(lm(C1 ~ M, data=DF)) to get the equivalent of summary(lm(C1 ~ M[,1]+M[,2])) what would you use to get the equivalent of summary(lm(C1 ~ M[,1]*M[,2]))?? Would you have to spell out the interaction term[s] in additional columns of M? Hmmm, interesting! I hadn't been aware of this aspect of formula and dataframe construction for modellinng, until you pointed it out! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to eliminate perticular date
Hi R-expert, I try to eliminate 29 Feb but I got an error message below: feb_data1 - Pooraka_data[Pooraka_data$Month==2,] feb_28days - feb_data1 [feb_data1$Day==28,] feb_29days - feb_data1 [feb_data1$Day==29,] ## delete 29 Feb feb_no_29 - feb_data1 [-(feb_29days),] feb_no_29 - feb_data1 [-(feb_29days),] Error in xj[i] : invalid subscript type 'list' Thank you so much for your attention. [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to eliminate perticular date
What you are getting back in 'feb_no_29' is a data frame which can not be used for indexing. Do 'str(feb_no_29)' and see what you set. What you probably want to do is to use 'which' to find out which rows match the criteria and then delete them: feb_29 - which((Pooraka_data$Month == 2) (Pooraka_data$Day == 29)) data_without_2_29 - Pooraka_data[-feb_29,] On Sun, May 11, 2008 at 8:54 PM, Roslina Zakaria [EMAIL PROTECTED] wrote: Hi R-expert, I try to eliminate 29 Feb but I got an error message below: feb_data1 - Pooraka_data[Pooraka_data$Month==2,] feb_28days - feb_data1 [feb_data1$Day==28,] feb_29days - feb_data1 [feb_data1$Day==29,] ## delete 29 Feb feb_no_29 - feb_data1 [-(feb_29days),] feb_no_29 - feb_data1 [-(feb_29days),] Error in xj[i] : invalid subscript type 'list' Thank you so much for your attention. [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://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? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem configuring package udunits
Hi R Users, I am new to running R on a Linux platform (I'm used to Windows) - I'm running R 2.7.0 on Ubuntu 7.10 (Gutsy) as sudo (without Emacs). My architecture is Pentium D (x86_64). I am having problems successsfully configuring the downloaded package 'udunits'. When I execute install.packages(udunits, lib=/usr/local/lib/R/library) I get the following result: trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/udunits_1.3.tar.gz' Content type 'application/x-gzip' length 29985 bytes (29 Kb) opened URL == downloaded 29 Kb * Installing *source* package 'udunits' ... creating cache ./config.cache checking how to run the C preprocessor... gcc -std=gnu99 -E checking for gcc... gcc -std=gnu99 checking whether the C compiler (gcc -std=gnu99 -g -O2 ) works... yes checking whether the C compiler (gcc -std=gnu99 -g -O2 ) is a cross-compiler... no checking whether we are using GNU C... yes checking whether gcc -std=gnu99 accepts -g... yes checking for /usr/local/include/udunits.h... no checking for /usr/include/udunits.h... no checking for /home/saleskalab/include/udunits.h... no checking for /usr/local/lib/libudunits.a... no checking for /usr/lib/libudunits.a... no checking for /lib/libudunits.a... no checking for /home/saleskalab/lib/libudunits.a... no *** *** NOTE: udunits package not found! Either install it in a standard place (/usr or /usr/local), or edit the file udunits_1.0/udunits/src/Makevars.in and put in the location where the package is installed. *** *** exit: 1162: Illegal number: -1 ERROR: configuration failed for package 'udunits' ** Removing '/usr/local/lib/R/library/udunits' The downloaded packages are in /tmp/RtmpmhqM2D/downloaded_packages Updating HTML index of packages in '.Library' Warning message: In install.packages(udunits, lib = /usr/local/lib/R/library) : installation of package 'udunits' had non-zero exit status I have tried downloading the package manually and running ./configure, but with the same result. As the error message suggested, I looked at the file udunits_1.0/udunits/src/Makevars.in, (contents below), but am not sure what to modify. ##PKG_CPPFLAGS=-I/path/to/udunits/header ##PKG_LIBS=-L/path/to/udunits/lib -ludunits [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ [[elided Hotmail spam]] Brad _ Get Free (PRODUCT) RED™ Emoticons, Winks and Display Pics. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Not to draw the xaxis ticks in ggplot2
Thanks. It is helpful. Best On Mon, May 12, 2008 at 4:34 AM, Paul Murrell [EMAIL PROTECTED] wrote: Hi ronggui wrote: Thanks,Hadley. Another question is how can I know there is a grob path called xaxis::ticks? Is there any easy way to figure out? grid.ls() ? Paul Thanks in advance. On Wed, May 7, 2008 at 10:06 PM, hadley wickham [EMAIL PROTECTED] wrote: On Tue, May 6, 2008 at 11:44 PM, ronggui [EMAIL PROTECTED] wrote: library(ggplot2) (p- qplot(mpg, wt, data=mtcars)) What I am doing is to set color of the ticks to hide them. grid.gedit(gPath(xaxis, ticks), gp=gpar(col=white)) It should be a better way to achieve the purpose. Thanks. Agreed. I've added it to my ggplot2 customisation to do list. Thanks, Hadley -- http://had.co.nz/ -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ -- HUANG Ronggui, Wincent Bachelor of Social Work, Fudan University, China Master of sociology, Fudan University, China Ph.D. Candidate, CityU of HK, http://www.cityu.edu.hk/sa/psa_web2006/students/rdegree/huangronggui.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating data.frames dynamically
Hi Worik: Is this what you want? Names - letters[1:5]; Dates- 1:20; d- data.frame(dates=Dates, a = vector(mode=numeric, length=length(Dates))); for(i in 2:5){d[,paste(sep=,Names[i])]-with(d,a)}; d dates a b c d e 1 1 0 0 0 0 0 2 2 0 0 0 0 0 3 3 0 0 0 0 0 4 4 0 0 0 0 0 5 5 0 0 0 0 0 6 6 0 0 0 0 0 7 7 0 0 0 0 0 8 8 0 0 0 0 0 9 9 0 0 0 0 0 1010 0 0 0 0 0 1111 0 0 0 0 0 1212 0 0 0 0 0 1313 0 0 0 0 0 1414 0 0 0 0 0 1515 0 0 0 0 0 1616 0 0 0 0 0 1717 0 0 0 0 0 1818 0 0 0 0 0 1919 0 0 0 0 0 2020 0 0 0 0 0 thanks y Worik R wrote: I have time series data in named vectors. They are all the same length for the same dates. The dates are in a separate vector. I want to create a vector of numeric data for every named series, associated with the dates in a data.frame. So if... Names - c(a, b, c) d - data.frame(dates=Dates, a=vector(mode=numeric, length=length(Dates), b=vector(mode=numeric, length=length(Dates), c=vector(mode=numeric, length=length(Dates)) Then I copy the processed data into d for(i in SomeVectorOfFactors){ for(N in Names){ d[[N]][i] - FunctionCallOfSomeSort(i) } } I want to create the data.frame, d, in the same style I access it. d - data.frame(dates=Dates, [[Names]]=vectors(.)) Then it is much simpler to add new columns. Worik ST [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - Yasir H. Kaheil Catchment Research Facility The University of Western Ontario -- View this message in context: http://www.nabble.com/Creating-data.frames-dynamically-tp17169662p17181259.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to eliminate perticular date
Why dont you use the rattle GUI for data selection ? Regards, Ajay On Mon, May 12, 2008 at 6:24 AM, Roslina Zakaria [EMAIL PROTECTED] wrote: Hi R-expert, I try to eliminate 29 Feb but I got an error message below: feb_data1 - Pooraka_data[Pooraka_data$Month==2,] feb_28days - feb_data1 [feb_data1$Day==28,] feb_29days - feb_data1 [feb_data1$Day==29,] ## delete 29 Feb feb_no_29 - feb_data1 [-(feb_29days),] feb_no_29 - feb_data1 [-(feb_29days),] Error in xj[i] : invalid subscript type 'list' Thank you so much for your attention. [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Insert a recorde into a table using SQL
Dear list, I want to insert a recorde into a SQLite table by dbGetQuery(), but there is a problem when the value contains quotation mark. dd-data.frame(txt=c(having both ' and \ in character.,OK)) library(RSQLite) Loading required package: DBI con-dbConnect(dbDriver(SQLite),:memory:) dbWriteTable(con,dd,dd,over=T) [1] TRUE dbGetQuery(con,sprintf(insert into dd (txt) values (\%s\),dd[2,1])) NULL dbGetQuery(con,sprintf(insert into dd (txt) values (\%s\),dd[1,1])) Error in sqliteExecStatement(con, statement, bind.data) : RS-DBI driver: (error in statement: unrecognized token: )) How can I insert a (key, value) pair into a table by dbGetQuery? Thanks. -- HUANG Ronggui, Wincent Bachelor of Social Work, Fudan University, China Master of sociology, Fudan University, China Ph.D. Candidate, CityU of HK. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.