[R] Why the factor levels returned by cut() are not ordered?
What is the reason, that the levels of the factor returned by cut() are not marked as ordered levels? is.ordered( cut( breaks=3, sample(10 ) ) ) FALSE help(factor) ... If 'ordered' is 'TRUE', the factor levels are assumed to be ordered. ... Wolfram __ R-help@stat.math.ethz.ch 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] Aggregating data
Similar answer as last time aggregate, tapply, by or ppackage doBy HTH PS. If you want to add some other text then subject in your post do not use HTML posting as recommended in posting guide. Petr On 28 Nov 2006 at 22:04, David Kaplan wrote: Date sent: Tue, 28 Nov 2006 22:04:09 -0600 From: David Kaplan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Aggregating data __ R-help@stat.math.ethz.ch 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. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] GAMS and Knots
The number of knots is really one of the modelling assumptions. Provided you don't make it restrictively small then the results should not be very sensitive to this assumption, since the actual degrees of freedom of each smooth are determined by how heavily the smooth is penalized, rather than simply being the number of knots. The degree of penalization is selected automatically by GCV or AIC/UBRE. See ?choose.k in the `mgcv' help files for more information on this, as well as information on checking whether the assumed number of knots was large enough. Simon On Tuesday 28 November 2006 22:40, Kathryn Baldwin wrote: Hi I was wondering if anyone knew how to work out the number of knots that should be applied to each variable when using gams in the mgcv library? Any help or references would be much appreciated. Thanks Kathryn Baldwin __ R-help@stat.math.ethz.ch 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. -- Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK +44 1225 386603 www.maths.bath.ac.uk/~sw283 __ R-help@stat.math.ethz.ch 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] R2.4 xyplot + panel.number problem
As requested on last line of every message to r-help please provide self contained reproducible code. Also please space it properly since its very difficult to read in your post. I have used the models defined in example(Puromycin) in place of your undefined ones and made some changes to keep the example short and easier to read: example(Puromycin) # defines fm1 and fm2 xyplot(rate ~ conc | state, Puromycin, panel = function(x, y, ...) { panel.xyplot(x, y, ...) fm - list(fm1, fm2)[[ panel.number() ]] panel.lines(conc, predict(fm, list(conc = conc))) } ) On 11/28/06, Pedro Mardones [EMAIL PROTECTED] wrote: Hi all; I'm trying to display a 2 panel plot for the Puromycin data from R with 2 different non-linear models fitted to each group. The problem is that as far as I know panel.number doesn't work in the latest version of R. Can anyone give a hint how to solve this? Here is the code that I used before and now doesn't work xyplot(rate ~conc| state,Puromycin, panel=function(x,y,panel.number,...){ panel.xyplot(x,y,...) x.temp-seq(0, 1.2, len = 101) if (panel.number==1) { y.temp-(coef(m2.nls)[1]+coef(m2.nls)[2]) * x.temp/ (coef(m2.nls)[3] + x.temp) panel.lines(x.temp,y.temp,col=2)} if (panel.number==2) { y.temp-coef(m2.nls)[1] * x.temp/ (coef(m2.nls)[3] + x.temp) panel.lines(x.temp,y.temp,col=2)} }, ylab=Rate of reaction, xlab=Substrate concentration, main = Puromycin---comparison bt. treated and untreated ) thanks for any idea __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why the factor levels returned by cut() are not ordered?
Hi it is not stated that the cut shall return ordered factor. If you want you can use ordered(cut( breaks=3, sample(10 ) )) or modify code for cut.default to accept ordered switch. HTH Petr On 29 Nov 2006 at 9:59, Wolfram Fischer wrote: Date sent: Wed, 29 Nov 2006 09:59:36 +0100 From: Wolfram Fischer [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Why the factor levels returned by cut() are not ordered? What is the reason, that the levels of the factor returned by cut() are not marked as ordered levels? is.ordered( cut( breaks=3, sample(10 ) ) ) FALSE help(factor) ... If 'ordered' is 'TRUE', the factor levels are assumed to be ordered. ... Wolfram __ R-help@stat.math.ethz.ch 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. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why the factor levels returned by cut() are not ordered?
Wolfram Fischer wrote: What is the reason, that the levels of the factor returned by cut() are not marked as ordered levels? I don't know, but you can always make it ordered with ordered(cut(breaks = 3, sample(10))) help(factor) ... If 'ordered' is 'TRUE', the factor levels are assumed to be ordered. ... The help file for factor() probably doesn't tell you much about how cut() works. :-) -- Bjørn-Helge Mevik __ R-help@stat.math.ethz.ch 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] comma delimiter comma in text
1, A, 24, The Red House 2, A, 25, King's Home, by the Sea ... Is there a way i can specify to R that King's Home, by the Sea is one word? Yes: It needs to be quoted in the file: 2, A, 25, King's Home, by the Sea cu Philipp -- Dr. Philipp PagelTel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich __ R-help@stat.math.ethz.ch 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] comma delimiter comma in text
Alexander Nervedi wrote: Hi I have data like 1, A, 24, The Red House 2, A, 25, King's Home, by the Sea ... I'd like to read this in as three variables. I first tried temp -read.csv(addresses, sep = , ) it worked but line 2 was broken after King's Home, and by the Sea as placed in another line. and so i eneded up with more number of rows than in the data. when i tried temp -read.csv(addresses, sep = , , flush = TRUE) i got things right number of rows, but column 3 was truncated till the 3rd comma. Is there a way i can specify to R that King's Home, by the Sea is one word? u r pal, al Hi, If you know that the guilty column will be the last one, you can always try to make up your own read function using readLines : do.call( rbind, lapply( strsplit(readLines(data.txt), , ), function(x) { gsub(^[[:space:]]|[[:space:]]$, ,# just removing leading and trailing spaces c( head(x,3), paste(tail(x, -3), collapse=,))) } ) ) Cheers, Romain -- Mango Solutions Tel +44 1249 467 467 Fax +44 1249 467 468 Mob +44 7813 526 123 data analysis that delivers __ R-help@stat.math.ethz.ch 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] Why the factor levels returned by cut() are not ordered?
Wolfram Fischer wrote: What is the reason, that the levels of the factor returned by cut() are not marked as ordered levels? is.ordered( cut( breaks=3, sample(10 ) ) ) FALSE It would arguably be the Right Thing, but there would be complications in modeling, where ordered factors result in polynomial contrast coding. (This, in my opinion, is a design mistake inherited from S, but it's not easy to change at this stage.) help(factor) ... If 'ordered' is 'TRUE', the factor levels are assumed to be ordered. ... Wolfram __ R-help@stat.math.ethz.ch 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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] OT: P(Z = -1.46).
In the days when tables were calculated laboriously, it was common practice to introduce several deliberate rounding errors in every table. These were used to catch infringements of copyright (and recover reproduction fees). Because tables came (and probably still do come) from a very few sources, published tables in textbooks will be far from independent data points. I found several pointing back to Lindgren. I checked my and my Dept's tables. Most are for positive x: the Biometrika tables have 0.9278550, Fisher and Yates do not have pnorm (only qnorm), Hald has 0.92785, and Lindley Scott have 0.9279. All the tables in Lindgren (1960) are credited apart from this one, and I surmise that may be a deliberate error in that table (but it may of course also be a computational inaccuracy: if it were a rounding of Hald I would expect it to be credited as such). On Sat, 25 Nov 2006, [EMAIL PROTECTED] wrote: In checking over the solutions to some homework that I had assigned I observed the fact that in R (version 2.4.0) pnorm(-1.46) gives 0.07214504. The tables in the text book that I am using for the course give the probability as 0.0722. Fascinated, I scanned through 5 or 6 other text books (amongst the dozens of freebies from publishers that lurk on my shelf) and found that some agree with R (giving P(Z = -1.46) = 0.0721) and some agree with the first text book, giving 0.0722. It is clearly of little-to-no practical import, but I'm curious as to how such a discrepancy would arise in this era. Has anyone any idea? Is there any possibility that the algorithm(s) used to calculate this probability is/are not accurate to 4 decimal places? Could two algorithms ``reasonably'' disagree in the 4th decimal place? cheers, Rolf Turner [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] need help with barplot
Hello, I do this a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2) b=matrix(a,nrow=4) rownames(b)=c(20/04/2002,21/04/2002,22/04/2002,23/04/2002) colnames(b)=c(p1,p2,p3) barplot(b,beside=T,col=(c(red,orange,yellow))) then I have http://www.mif.vu.lt/~roka5178/barplot1.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot1.JPG but I need to have http://www.mif.vu.lt/~roka5178/barplot.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot.JPG how can i do this? i need to to change axis x whit y -- Robertas [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] need help with barplot
You need the transpose of the matrix (or create it differently in the first place!). Changing the last line to barplot(t(b),beside=T,col=(c(red,orange,yellow))) should do the trick. On 29/11/06, Robertas Kavaliūnas [EMAIL PROTECTED] wrote: Hello, I do this a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2) b=matrix(a,nrow=4) rownames(b)=c(20/04/2002,21/04/2002,22/04/2002,23/04/2002) colnames(b)=c(p1,p2,p3) barplot(b,beside=T,col=(c(red,orange,yellow))) then I have http://www.mif.vu.lt/~roka5178/barplot1.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot1.JPG but I need to have http://www.mif.vu.lt/~roka5178/barplot.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot.JPG how can i do this? i need to to change axis x whit y -- Robertas [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch 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] 1D 2D response plots from RSM models
Hello R experts I am looking for: - advice - sample commands - pointers in MASS 4E - packages That help to produce 1D and 2D response plots from quadratic RSM linear regression models that have been produced in R. Let me explain a little what I mean. For 1D plots I mean the variable range (either scaled or actual) on the X axis and the Y axis showing the model prediction (preferably with confidence intervals) for that variable with the other 4 variables held fixed at a certain value (the models have 5 variables). As a starting point this could be their centre value but it would also be useful to be able to specify them as any value within the design range. The 2D plots would be similar but: - image, surface or contour instead of line plot - confidence interval less important (unless there's a clear way of showing) - only 3 external variables to specify I have searched the R help archive without much success. I am a relative newcomer to R so although some of the information in MASS certainly looks relevant I am finding it hard to put something useful and robust together. I'm sure there are people out there in R-land who can help me up the learning curve a little - or maybe have already done what I am trying to do here. Thanks in advance Michael _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ _/_/ _/_/_/ Hopkins Research Ltd _/_/ _/_/ _/_/_/_/ _/_/_/ http://www.hopkins-research.com/ _/_/ _/ _/ _/_/ _/ _/ 'touch the future' __ R-help@stat.math.ethz.ch 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] --max-vsize option
The R memory docs say that the --*-vsize option takes an integer argument and then 'G', 'M', 'K', or 'k'. When I start R using R --max-vsize=10G I receive the warning: WARNING: --max-vsize=10G=10'M': too large and ignored The system that I'm working on is a 64-bit Sun server with 40G of memory. What is the correct syntax for this command? Daniel Gatti UNC-CH __ R-help@stat.math.ethz.ch 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] showing available environment variables
I have searched through the mailing lists and the docs, and I seem completely unable to find a way to make R list all available environment variables that it uses. The reason that I want to do this is the following: The default program for reading files when using openVignettes on my system is ggv. ggv is broken. I would therefore like to use a different program, and I found the variable R_PDFVIEWER which should do the trick. However, so far no luck. Therefore, how do I ask R what variables are available, and how do I get it to show what it is currently set to. Thanks! Karin, who is most likely going blind -- Karin Lagesen, PhD student [EMAIL PROTECTED] http://folk.uio.no/karinlag __ R-help@stat.math.ethz.ch 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] Block clustering and largest square block in binary matrix
Hi I have a large binary square matrix (about 2500 x 2500) obtained from a distance matrix on x (smaller simulation below), in which I want to find the largest square block of 1's for all permutations of the rows and columns. I then want to remove the rows and columns corresponding to this block and repeat the process, so that finally all the rows of data in x are assigned to a particular square block or are isolates. Does anyone know of a function or algorithm that can do this? I have looked at the blockmodel function in the sna package but this does not appear to find the largest block and then the next largest block etc. I have also search the email archives without success. rm(list=ls()) set.seed(1) x-rnorm(100,10,1) d.mat-as.matrix(dist(x)) d.mat[d.mat=0.2]- -1 d.mat[d.mat0.2]-0 d.mat-d.mat*-1 ## I have tried sorting by row and col sums does not identify the largest squate block in every situation rs-rowSums(d.mat) cs-colSums(d.mat) d.mat1-d.mat[order(rs), order(cs)] Any help would be much appreciated Thanks Mike White __ R-help@stat.math.ethz.ch 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] String question
Hi to all I would to determinate whether bits is a binary code and I would to find out the which bit is set to 1 bits -00110110 I found to detect whether there are only numbers all.digits(bits) but is there any function to detect whether there are only 0 and 1 in the string And how could I get the f.e the third bit from the right hand side With regards Carmen __ R-help@stat.math.ethz.ch 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] comma delimiter comma in tex
Preprocess the file surrounding the last field with quotes. The xx - line is for purposes of making it self contained here and in reality would be replaced with the commented line above it. It simply reads the text in. The yy - line then surrounds the fourth field with double quotes assuming at least a space separates the fields as in your example. Finally read.table reads it now that the fourth field has been protected with quotes and closeAllConnections closes the dangling connections. # test data Lines - 1, A, 24, The Red House 2, A, 25, King's Home, by the Sea # xx - readLines(myfile.dat) xx - readLines(textConnection(Lines)) yy - gsub('^( *[^ ]+ [^ ]+ [^ ]+ )(.*)', '\\1\\2', xx) read.table(textConnection(yy), sep = ,) closeAllConnections() On 11/29/06, Alexander Nervedi [EMAIL PROTECTED] wrote: Hi I have data like 1, A, 24, The Red House 2, A, 25, King's Home, by the Sea ... I'd like to read this in as three variables. I first tried temp -read.csv(addresses, sep = , ) it worked but line 2 was broken after King's Home, and by the Sea as placed in another line. and so i eneded up with more number of rows than in the data. when i tried temp -read.csv(addresses, sep = , , flush = TRUE) i got things right number of rows, but column 3 was truncated till the 3rd comma. Is there a way i can specify to R that King's Home, by the Sea is one word? u r pal, al _ All-in-one security and maintenance for your PC. Get a free 90-day trial! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] String question
Carmen Meier wrote: Hi to all I would to determinate whether bits is a binary code and I would to find out the which bit is set to 1 bits -00110110 I found to detect whether there are only numbers all.digits(bits) but is there any function to detect whether there are only 0 and 1 in the string And how could I get the f.e the third bit from the right hand side With regards Carmen Hi, R nc - nchar(bits) R substring(bits,1:nc,1:nc) == 1 R which( substring(bits,1:nc,1:nc) == 1 ) Cheers, Romain -- Mango Solutions Tel +44 1249 467 467 Fax +44 1249 467 468 Mob +44 7813 526 123 data analysis that delivers __ R-help@stat.math.ethz.ch 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] String question
Dear Carmen, length(grep([^01], bits)) == 0 should do the trick, returning TRUE if the string contains only 0's and 1's. I hope this helps, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Carmen Meier Sent: Wednesday, November 29, 2006 9:06 AM To: R-help Subject: [R] String question Hi to all I would to determinate whether bits is a binary code and I would to find out the which bit is set to 1 bits -00110110 I found to detect whether there are only numbers all.digits(bits) but is there any function to detect whether there are only 0 and 1 in the string And how could I get the f.e the third bit from the right hand side With regards Carmen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why the factor levels returned by cut() are not ordered?
On 29 Nov 2006 at 12:08, Peter Dalgaard wrote: Date sent: Wed, 29 Nov 2006 12:08:21 +0100 From: Peter Dalgaard [EMAIL PROTECTED] To: Wolfram Fischer [EMAIL PROTECTED] Copies to: r-help@stat.math.ethz.ch Subject:Re: [R] Why the factor levels returned by cut() are not ordered? Wolfram Fischer wrote: What is the reason, that the levels of the factor returned by cut() are not marked as ordered levels? is.ordered( cut( breaks=3, sample(10 ) ) ) FALSE It would arguably be the Right Thing, but there would be complications in modeling, where ordered factors result in polynomial contrast coding. (This, in my opinion, is a design mistake inherited from S, but it's not easy to change at this stage.) Well what about to change cut.default if (codes.only) code else factor(code, seq(labels), labels) to if (codes.only) code else factor(code, seq(labels), labels, ...) which enables to use ordered switch is.ordered( cut( breaks=3, sample(10 ), ordered=T ) ) [1] TRUE Without this the result is same as before (I believe :-) Petr help(factor) ... If 'ordered' is 'TRUE', the factor levels are assumed to be ordered. ... Wolfram __ R-help@stat.math.ethz.ch 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. -- O__ Peter Dalgaard Řster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] String question
Hi gregexpr can be used bits -0011011aaa0 gregexpr([01], bits) [[1]] [1] 1 2 3 4 5 6 7 11 attr(,match.length) [1] 1 1 1 1 1 1 1 1 or grep([^01], bits) if you want to know that there is any other character then 0 or 1 gregexpr(1, bits) if you want to know location of 1's HTH Petr On 29 Nov 2006 at 15:06, Carmen Meier wrote: Date sent: Wed, 29 Nov 2006 15:06:08 +0100 From: Carmen Meier [EMAIL PROTECTED] To: R-help r-help@stat.math.ethz.ch Subject:[R] String question Hi to all I would to determinate whether bits is a binary code and I would to find out the which bit is set to 1 bits -00110110 I found to detect whether there are only numbers all.digits(bits) but is there any function to detect whether there are only 0 and 1 in the string And how could I get the f.e the third bit from the right hand side With regards Carmen __ R-help@stat.math.ethz.ch 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. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] String question
Try: # TRUE if all 0 and 1 regexpr(^[01]*$, bits) 0 # positions of 1s gregexpr(1, bits)[[1]] On 11/29/06, Carmen Meier [EMAIL PROTECTED] wrote: Hi to all I would to determinate whether bits is a binary code and I would to find out the which bit is set to 1 bits -00110110 I found to detect whether there are only numbers all.digits(bits) but is there any function to detect whether there are only 0 and 1 in the string And how could I get the f.e the third bit from the right hand side With regards Carmen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] need help with barplot
--- Robertas Kavaliûnas [EMAIL PROTECTED] wrote: Hello, I do this a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2) b=matrix(a,nrow=4) rownames(b)=c(20/04/2002,21/04/2002,22/04/2002,23/04/2002) colnames(b)=c(p1,p2,p3) barplot(b,beside=T,col=(c(red,orange,yellow))) then I have http://www.mif.vu.lt/~roka5178/barplot1.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot1.JPG but I need to have http://www.mif.vu.lt/~roka5178/barplot.JPGhttp://www.mif.vu.lt/%7Eroka5178/barplot.JPG how can i do this? i need to to change axis x whit y Robertas This is dirty code but it works. Just transpose the matrix before you plot it. a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2) b= matrix(a,nrow=4) rownames(b)=c(20/04/2002,21/04/2002,22/04/2002,23/04/2002) colnames(b)=c(p1,p2,p3) b1 - t(b)# Transpose of 'b' barplot(b1,beside=T,col=(c(red,orange,yellow))) __ R-help@stat.math.ethz.ch 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] Lmer, P-values and mixed logistic regression
Hi I know that p-values doesn't appear anymore in the summary of a linear mixed-model with lmer. However, if I do a mixed logistic regression with lmer using family=binomial, the summary includes a p-values for fixed effects. Is it normal, could I use those p-values to interpret the fixed effects or should I use mcmcsamp to obtain 95% confidence interval? Thanks Julien __ R-help@stat.math.ethz.ch 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] simple R question
Hi, I am new to this, can anyone help. I am working with matrices, with stocknames as colNames and dates as rowNames. The data coontains percentile ranking for the stocks. Date IBM MSFT 20061122 12 4 20061115 12 4 20061108 12 4 20061101 12 4 20061025 12 4 20061018 12 4 20061011 11 3 20061004 12 3 20060927 10 3 I would like to calculate the rolling-rate-of-change of these ranking. I tried searching for second-derivative/slope/trend/etc to no avail. thanks in advance. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] showing available environment variables
These retrieve and set environment variables: ?Sys.getenv ?Sys.putenv On 11/29/06, Karin Lagesen [EMAIL PROTECTED] wrote: I have searched through the mailing lists and the docs, and I seem completely unable to find a way to make R list all available environment variables that it uses. The reason that I want to do this is the following: The default program for reading files when using openVignettes on my system is ggv. ggv is broken. I would therefore like to use a different program, and I found the variable R_PDFVIEWER which should do the trick. However, so far no luck. Therefore, how do I ask R what variables are available, and how do I get it to show what it is currently set to. Thanks! Karin, who is most likely going blind -- Karin Lagesen, PhD student [EMAIL PROTECTED] http://folk.uio.no/karinlag __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] --max-vsize option
On Wed, 29 Nov 2006, Daniel Gatti wrote: The R memory docs say that the --*-vsize option takes an integer argument and then 'G', 'M', 'K', or 'k'. When I start R using R --max-vsize=10G I receive the warning: WARNING: --max-vsize=10G=10'M': too large and ignored The system that I'm working on is a 64-bit Sun server with 40G of memory. What is the correct syntax for this command? But is this a 64-bit build of R? (Solaris is 32-bit by default.) R --max-vsize=10G works on 64-bit Solaris build for me, but I get that (somewhat garbled) message on a 32-bit build. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] building R 2.4.0 on aix
Roy and others, I'm also trying to build R 2.4.0 on aix 5 (5.3 in my case, on an Intellistation Power 285) and I have not had luck yet. I notice that the only mentions of AIX on this list in the past two months are people not having luck building it. So far there don't seem to be any responses, and I don't know if it's from lack of information in the questions, or because this isn't the right place to ask the questions. Does anyone know a good place to ask such questions? If this is the right place, please let me know what information you need. I am unfortunately very new to this business of compiling and linking on Unix, so I have trouble knowing what information to provide. Here's my stab at troubleshooting, which is basically trial-and-error: === tried just to type ./configure (I can always dream, right? :-) ) Failed with the following problem in config.log configure:26491: checking how to get verbose linking output from f95 configure:26502: f95 -c conftest.f 5 f95: 1501-218 file conftest.f contains an incorrect file suffix configure:26508: $? = 1 configure: failed program was: | program main | | end configure:26587: WARNING: compilation failed configure:26593: result: config.log (93%) === A little playing around shows me that f95 doesn't like to compile files ending in .f, so I try doing ./configure F77=f77 In this case, the configure script completes successfully. Now I try make but make exits early with errors. make check gives make: 1254-002 Cannot find a rule to create target ../../src/library/base/all.R from dependencies. Stop. and a few other 1254-004 errors. === There are some examples in http://cran.r-project.org/doc/manuals/R-admin.html , particularly in the AIX platform notes (C.9 AIX). However, the second paragraph says The rest of this section is historical, as the default *_LDFLAGS were changed in R 2.4.0. so evidently the examples don't apply to the current version of R. I tried some frankenstein combinations of the options given in the examples, using the xl*_* compilers since I don't have gfortran on my system, but this kind of thing is time-consuming when I'm essentially making random changes. I'm hoping that someone with more experience than I can at least help me sort through the Cannot find a rule to create target error, and that maybe I can proceed somehow one error at a time and finally end up with something that works. BTW, I did try to google the Cannot find a rule to create target from dependencies, but I don't get much that I can understand. One message said something about this means make can't find the source code. If this is the problem, how can I figure out what source code make is looking for, where it's looking for it, and how to tell it the right place to look? Or perhaps there's something else I'm missing? Thanks, Eric Harley On 11/20/06, Roy Heimbach [EMAIL PROTECTED] wrote: I'm trying to build R 2.4.0 on aix 5 and not having much luck. If anyone on the list has built 2.3 or 2.4 on AIX and would be willing pass along some hints, I would be grateful. So would the research group that's waiting to use R. Thanks, Roy Heimbach -- Roy Heimbach [EMAIL PROTECTED] / 505-277-8348 User Services / Center for High Performance Computing University of New Mexico __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reformulação do site
Boa tarde, Meu nome é Wesley Alves, sou Designer Interativo há 5 anos visitei o site desta empresa. A principio, achei interessante as informações e a disposições da mesma, mas acredito que posso melhorar ainda mais o web site de vocês,estruturando melhor a parte de design e disposição geral das informações do site. Caso interesse segue link do meu site www.criativedesign.com.br para que vocês possam dar uma olhada nos projetos que já desenvolvi, e quem sabe fecharmos negócios. Atenciosamente Wesley Alves Designer Interative [EMAIL PROTECTED] www.criativedesign.com.br Tel: (11) 6527.3307 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lmer, P-values and mixed logistic regression
On 11/29/06, Julien [EMAIL PROTECTED] wrote: Hi I know that p-values doesn't appear anymore in the summary of a linear mixed-model with lmer. However, if I do a mixed logistic regression with lmer using family=binomial, the summary includes a p-values for fixed effects. Is it normal, could I use those p-values to interpret the fixed effects or should I use mcmcsamp to obtain 95% confidence interval? Those p-values are calculated from the standard normal quantile function, which is likely to be a worse (more anti-conservative) though less controversial approximation that the p-values that were reported for linear models. I would recommend using a chain from mcmcsamp for more precise evaluation of the variability of the parameter estimates except that mcmcsamp for generalized linear mixed models isn't working very well right now. The mcmcsamp function uses exact sampling in each stage of the Gibbs sampling for linear mixed models. For generalized linear mixed models there is one stage where I must use a Metropolis-Hastings step and the surrogate distribution that I chose is less successful than I had hoped it would be. The result is that fixed-effects parameter values can get stuck at the same position for long periods in the chain. I plan to fix this but there are several other tasks to finish first. __ R-help@stat.math.ethz.ch 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] Skip NA and alter length
Hi, This is my first post. Problem: I have a matrix 5 by 5 and it has 3 NAs in them. Now, when i use length () for a particular column which has NA it returns 5. I know this is true, but how do i change my matrix such that the length becomes 5 minus the number of NAs i have. I know NA has a length of 1, but then how do i convert the NA into NULL whose length is 0. Thanks in advance. abid __ R-help@stat.math.ethz.ch 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] showing available environment variables
On Wed, 29 Nov 2006, Karin Lagesen wrote: I have searched through the mailing lists and the docs, and I seem completely unable to find a way to make R list all available environment variables that it uses. The reason that I want to do this is the following: The default program for reading files when using openVignettes on my system is ggv. ggv is broken. I would therefore like to use a different program, and I found the variable R_PDFVIEWER which should do the trick. However, so far no luck. Therefore, how do I ask R what variables are available, and how do I get it to show what it is currently set to. In this specific case you need to look at the R-admin manual for what various variables do, and Sys.getenv(R_PDFVIEWER) or Sys.getenv() for the current value or list of values. R_PDFVIEWER is set in R_HOME/etc/Renviron, and you can override the setting via ~/.Renviron (see ?Startup). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Skip NA and alter length
try this: mat - matrix(1:25, 5, 5) mat[sample(25, 3)] - NA # mat colSums(!is.na(mat)) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Syed Abid Hussaini [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Wednesday, November 29, 2006 4:58 PM Subject: [R] Skip NA and alter length Hi, This is my first post. Problem: I have a matrix 5 by 5 and it has 3 NAs in them. Now, when i use length () for a particular column which has NA it returns 5. I know this is true, but how do i change my matrix such that the length becomes 5 minus the number of NAs i have. I know NA has a length of 1, but then how do i convert the NA into NULL whose length is 0. Thanks in advance. abid __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] --max-vsize option
Prof Brian Ripley wrote: But is this a 64-bit build of R? (Solaris is 32-bit by default.) R --max-vsize=10G works on 64-bit Solaris build for me, but I get that (somewhat garbled) message on a 32-bit build. Thanks. That was it. Apparently they had compiled R with 32-bit settings. They had just gotten R 2.4.0 compiled for 64-bits and asked me to try it out. It works. Dan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] simple R question
Try creating a zoo object from your data frame # data from your post DF - structure(list(Date = as.integer(c(20061122, 20061115, 20061108, 20061101, 20061025, 20061018, 20061011, 20061004, 20060927)), IBM = as.integer(c(12, 12, 12, 12, 12, 12, 11, 12, 10)), MSFT = as.integer(c(4, 4, 4, 4, 4, 4, 3, 3, 3))), .Names = c(Date, IBM, MSFT), class = data.frame, row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9)) library(zoo) # create zoo object z from DF z - zoo(as.matrix(DF[-1]), as.Date(as.character(DF$Date), %Y%m%d)) diff(z, arith = FALSE)-1 # or perhaps diff(log(z)) Check out the zoo vignette vignette(zoo) On 11/29/06, iqbal hussain [EMAIL PROTECTED] wrote: Hi, I am new to this, can anyone help. I am working with matrices, with stocknames as colNames and dates as rowNames. The data coontains percentile ranking for the stocks. Date IBM MSFT 20061122 12 4 20061115 12 4 20061108 12 4 20061101 12 4 20061025 12 4 20061018 12 4 20061011 11 3 20061004 12 3 20060927 10 3 I would like to calculate the rolling-rate-of-change of these ranking. I tried searching for second-derivative/slope/trend/etc to no avail. thanks in advance. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Aggregating data
The problem is that this doesn't seem to give what I want. I did look at this. Perhaps doBy will work - haven't tried it yet. But, any other suggestions are much appreciated. === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Petr Pikal wrote: Similar answer as last time aggregate, tapply, by or ppackage doBy HTH PS. If you want to add some other text then subject in your post do not use HTML posting as recommended in posting guide. Petr On 28 Nov 2006 at 22:04, David Kaplan wrote: Date sent:Tue, 28 Nov 2006 22:04:09 -0600 From: David Kaplan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Aggregating data __ R-help@stat.math.ethz.ch 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. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] An example of using rJava
I have received a few private emails asking for some simple demonstration of calling Java code from R using the rJava package (which can be installed directly inside R). Here is one example for convolving two vectors (an example in the R manual about linking C with R). First write a Java program public class my_convolve { public static double[] convolve(double[] a, double[] b) { int n1 = a.length; int n2 = b.length; int n3 = n1+n1-1; double[] c = new double[n3]; for(int i=0; in1; i++) for(int j=0; jn2; j++) c[i+j] += a[i]*b[j]; return c; } } Compile the Java code. now inside R library(rJava) #load the rJava library .jinit(classpath=c:/liao_all/importance_sampling/java, parameters=-Xmx512m) #the above is to load the Java virtual machine, c:/liao_all/importance_sampling/java is where the java code is. x = runif(1000) y = runif(1000) #the above are two vectors to convolve #now you can call the Java method as z=.jcall(my_convolve, [D, convolve, x,y) #z stores the result Hope this helps. Jason Liao, http://www.geocities.com/jg_liao Associate Professor of Biostatistics Drexel University School of Public Health 245 N. 15th Street, Mail Stop 660 Philadelphia, PA 19102-1192 phone 215-762-3934 Cheap talk? __ R-help@stat.math.ethz.ch 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] An example of using rJava
On Wed, 2006-11-29 at 08:48 -0800, Jason Liao wrote: I have received a few private emails asking for some simple demonstration of calling Java code from R using the rJava package (which can be installed directly inside R). One could also examine the sources of the rcdk package which provides access to the CDK cheminformatics library within R --- Rajarshi Guha [EMAIL PROTECTED] GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- A beer delayed is a beer denied. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] legend in lattice densityplot
Hi, I have a densityplot like this: x = c(rnorm(100,1,2),rnorm(100,2,4),rnorm(100,3,6)) f = sample(c(A,B,C,D,E),300,replace=TRUE) df=data.frame(x,f) library(lattice) attach(df) densityplot(~x, groups=f) And I want to add a legend with the colours for the factors. How can I do that? How can I not have the dots of the distribution at the bottom, or at least, make them occupy less vertical space? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] legend in lattice densityplot
Albert Vilella wrote: Hi, I have a densityplot like this: x = c(rnorm(100,1,2),rnorm(100,2,4),rnorm(100,3,6)) f = sample(c(A,B,C,D,E),300,replace=TRUE) df=data.frame(x,f) library(lattice) attach(df) densityplot(~x, groups=f) And I want to add a legend with the colours for the factors. How can I do that? How can I not have the dots of the distribution at the bottom, or at least, make them occupy less vertical space? Change the last line to the following: densityplot(~x, groups=f, plot.points=FALSE, auto.key=TRUE) See ?panel.densityplot . __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] random binary trees in R
Hello! I wish to generate random binary trees in R. Unfortunately recursive code like: t - function(p) { list(ifelse(runif(1)p,t(p),0), ifelse(runif(1)p,t(p),0)) } does not seem to work. Has anyone ever performed such a simulation? I would like to see their code. Maybe this is not feasible in R. Please e-mail me at the below address (since I am not yet a subscriber to this list). Thank you! Steve Finch [EMAIL PROTECTED] _ MSN Shopping has everything on your holiday list. Get expert picks by style, age, and price. Try it! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] legend in lattice densityplot
Are this legend colors correlated to the plot? If I do a: densityplot(~x, groups=f, plot.points=FALSE, auto.key=TRUE,col=heat.colors(5)) I get different colors in the legend than the plot... On 11/29/06, Chuck Cleland [EMAIL PROTECTED] wrote: Albert Vilella wrote: Hi, I have a densityplot like this: x = c(rnorm(100,1,2),rnorm(100,2,4),rnorm(100,3,6)) f = sample(c(A,B,C,D,E),300,replace=TRUE) df=data.frame(x,f) library(lattice) attach(df) densityplot(~x, groups=f) And I want to add a legend with the colours for the factors. How can I do that? How can I not have the dots of the distribution at the bottom, or at least, make them occupy less vertical space? Change the last line to the following: densityplot(~x, groups=f, plot.points=FALSE, auto.key=TRUE) See ?panel.densityplot . __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] random binary trees in R
Steven Finch wrote: Hello! I wish to generate random binary trees in R. Unfortunately recursive code like: t - function(p) { list(ifelse(runif(1)p,t(p),0), ifelse(runif(1)p,t(p),0)) } ifelse() is vectorized and evaluates for both cases! Instead, try: t - function(p) list(if(runif(1) p) t(p) else 0, if(runif(1) p) t(p) else 0) Uwe Ligges does not seem to work. Has anyone ever performed such a simulation? I would like to see their code. Maybe this is not feasible in R. Please e-mail me at the below address (since I am not yet a subscriber to this list). Thank you! Steve Finch [EMAIL PROTECTED] _ MSN Shopping has everything on your holiday list. Get expert picks by style, age, and price. Try it! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] legend in lattice densityplot
Try specifying it at the par.settings= level since that is where both the plot and the legend get it from: set.seed(1) DF - data.frame(x = c(rnorm(100,1,2),rnorm(100,2,4),rnorm(100,3,6)), f = sample(c(A,B,C,D,E),300,replace=TRUE)) library(lattice) densityplot(~ x, DF, groups = f, auto.key = TRUE, plot.points = FALSE, par.settings = list(superpose.line = list(col = heat.colors(5 On 11/29/06, Albert Vilella [EMAIL PROTECTED] wrote: Are this legend colors correlated to the plot? If I do a: densityplot(~x, groups=f, plot.points=FALSE, auto.key=TRUE,col=heat.colors(5)) I get different colors in the legend than the plot... On 11/29/06, Chuck Cleland [EMAIL PROTECTED] wrote: Albert Vilella wrote: Hi, I have a densityplot like this: x = c(rnorm(100,1,2),rnorm(100,2,4),rnorm(100,3,6)) f = sample(c(A,B,C,D,E),300,replace=TRUE) df=data.frame(x,f) library(lattice) attach(df) densityplot(~x, groups=f) And I want to add a legend with the colours for the factors. How can I do that? How can I not have the dots of the distribution at the bottom, or at least, make them occupy less vertical space? Change the last line to the following: densityplot(~x, groups=f, plot.points=FALSE, auto.key=TRUE) See ?panel.densityplot . __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch 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] reshape command is (stats) dropping instances
I would really appreciate it if anyone could determine what is going on with the following command. It is only half-working and is losing lots of data. For the life of me I cannot even see the pattern of what it is losing and what it is not. I am attaching the R data set which you can use with the Load Workspace menu function. WideICA-reshape(ICA,v.names=c(OD,Thickness,Surface.Cover),idvar=c(Strain,ica,Rep,Locations),drop=Growth,timevar=Time,direction=wide) The following two commands should give the same data (other than the missing values) but they do not. ICA[ICA$Time==6,Surface.Cover] WideICA$Surface.Cover.6 -- Farrel Buchinsky Pediatric Otolaryngologist Allegheny General Hospital Pittsburgh, PA USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] legend in lattice densityplot
Albert Vilella wrote: Are this legend colors correlated to the plot? They are if you rely on the colors in trellis.par.get(superpose.line)$col If you want different colors you might use trellis.par.set() to temporarily change the colors: x - c(rnorm(100,-2,1),rnorm(100,0,1),rnorm(100,2,1)) f - rep(c(A,B,C), each=100) df - data.frame(x,f) library(lattice) oldpar - trellis.par.get(superpose.line)$col trellis.par.set(superpose.line = list(col = heat.colors(3))) densityplot(~ x, groups = f, data = df, plot.points=FALSE, auto.key=TRUE) trellis.par.set(superpose.line = list(col = oldpar)) If you don't require points or lines in the key, you also could do something like this: densityplot(~ x, groups = f, data = df, plot.points=FALSE, key = simpleKey(levels(df$f), lines=FALSE, points=FALSE, col=heat.colors(3)), col=heat.colors(3)) To use your own colors without changing the trellis settings and to get lines or points in the key, you probably need at least to use key = simpleKey() rather than the auto.key argument, and you may need to look into draw.key(). Other people on the list might know simpler approaches for using your own colors in this situation. If I do a: densityplot(~x, groups=f, plot.points=FALSE, auto.key=TRUE,col=heat.colors(5)) I get different colors in the legend than the plot... On 11/29/06, Chuck Cleland [EMAIL PROTECTED] wrote: Albert Vilella wrote: Hi, I have a densityplot like this: x = c(rnorm(100,1,2),rnorm(100,2,4),rnorm(100,3,6)) f = sample(c(A,B,C,D,E),300,replace=TRUE) df=data.frame(x,f) library(lattice) attach(df) densityplot(~x, groups=f) And I want to add a legend with the colours for the factors. How can I do that? How can I not have the dots of the distribution at the bottom, or at least, make them occupy less vertical space? Change the last line to the following: densityplot(~x, groups=f, plot.points=FALSE, auto.key=TRUE) See ?panel.densityplot . __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Aggregating data
Chuck and others. Here is the problem I need help on. Thanks. I want to follow-up on a question I had a week or so ago. I want to aggregate a very large data set. Generally in a program such as SPSS, one chooses a so-called break variable that is the variable, and then the remaining variables are aggregated by that variable with some summary statistic calculated - such as the mean. I played with aggregate in R and found that it requires a by statement listing the variables. But I don't see how I can aggregate on one variable and create the summary statistics on the remaining variables. I hope that was clear. Thanks for an advice in advance. David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Chuck Cleland wrote: David Kaplan wrote: The problem is that this doesn't seem to give what I want. I did look at this. Perhaps doBy will work - haven't tried it yet. But, any other suggestions are much appreciated. David: Your posts on aggregating came to the list without any text in the body of the message (I believe Petr sent a response based only on the subject). You might get more specific and helpful suggestions if you send a small example of what you are trying to do and why aggregate() does not work for you. Also, be sure to send messages in plain text rather than HTML. hope this helps, Chuck Cleland === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Petr Pikal wrote: Similar answer as last time aggregate, tapply, by or ppackage doBy HTH PS. If you want to add some other text then subject in your post do not use HTML posting as recommended in posting guide. Petr On 28 Nov 2006 at 22:04, David Kaplan wrote: Date sent: Tue, 28 Nov 2006 22:04:09 -0600 From: David Kaplan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Aggregating data __ R-help@stat.math.ethz.ch 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. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Aggregating data
Using the builtin data set CO2: aggregate(CO2[4:5], CO2[1], mean) calculates the means of variables 4 and 5 based combinations of the levels of variable 1. Is that what you want? On 11/29/06, David Kaplan [EMAIL PROTECTED] wrote: Chuck and others. Here is the problem I need help on. Thanks. I want to follow-up on a question I had a week or so ago. I want to aggregate a very large data set. Generally in a program such as SPSS, one chooses a so-called break variable that is the variable, and then the remaining variables are aggregated by that variable with some summary statistic calculated - such as the mean. I played with aggregate in R and found that it requires a by statement listing the variables. But I don't see how I can aggregate on one variable and create the summary statistics on the remaining variables. I hope that was clear. Thanks for an advice in advance. David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Chuck Cleland wrote: David Kaplan wrote: The problem is that this doesn't seem to give what I want. I did look at this. Perhaps doBy will work - haven't tried it yet. But, any other suggestions are much appreciated. David: Your posts on aggregating came to the list without any text in the body of the message (I believe Petr sent a response based only on the subject). You might get more specific and helpful suggestions if you send a small example of what you are trying to do and why aggregate() does not work for you. Also, be sure to send messages in plain text rather than HTML. hope this helps, Chuck Cleland === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Petr Pikal wrote: Similar answer as last time aggregate, tapply, by or ppackage doBy HTH PS. If you want to add some other text then subject in your post do not use HTML posting as recommended in posting guide. Petr On 28 Nov 2006 at 22:04, David Kaplan wrote: Date sent: Tue, 28 Nov 2006 22:04:09 -0600 From: David Kaplan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Aggregating data __ R-help@stat.math.ethz.ch 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. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch 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] Aggregating data
I meant: calculates the means of variables 4 and 5 based on the levels of variable 1. Is that what you want? On 11/29/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Using the builtin data set CO2: aggregate(CO2[4:5], CO2[1], mean) calculates the means of variables 4 and 5 based combinations of the levels of variable 1. Is that what you want? On 11/29/06, David Kaplan [EMAIL PROTECTED] wrote: Chuck and others. Here is the problem I need help on. Thanks. I want to follow-up on a question I had a week or so ago. I want to aggregate a very large data set. Generally in a program such as SPSS, one chooses a so-called break variable that is the variable, and then the remaining variables are aggregated by that variable with some summary statistic calculated - such as the mean. I played with aggregate in R and found that it requires a by statement listing the variables. But I don't see how I can aggregate on one variable and create the summary statistics on the remaining variables. I hope that was clear. Thanks for an advice in advance. David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Chuck Cleland wrote: David Kaplan wrote: The problem is that this doesn't seem to give what I want. I did look at this. Perhaps doBy will work - haven't tried it yet. But, any other suggestions are much appreciated. David: Your posts on aggregating came to the list without any text in the body of the message (I believe Petr sent a response based only on the subject). You might get more specific and helpful suggestions if you send a small example of what you are trying to do and why aggregate() does not work for you. Also, be sure to send messages in plain text rather than HTML. hope this helps, Chuck Cleland === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Petr Pikal wrote: Similar answer as last time aggregate, tapply, by or ppackage doBy HTH PS. If you want to add some other text then subject in your post do not use HTML posting as recommended in posting guide. Petr On 28 Nov 2006 at 22:04, David Kaplan wrote: Date sent: Tue, 28 Nov 2006 22:04:09 -0600 From: David Kaplan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Aggregating data __ R-help@stat.math.ethz.ch 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. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch 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] Aggregating data
David: Is this what you are looking for? set.seed(10) tmp - data.frame(group = gl(3,10), something = rnorm(30)) with(tmp, tapply(something, group, mean)) 1 2 3 -0.4906568 0.3695915 -0.9129640 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Kaplan Sent: Wednesday, November 29, 2006 2:16 PM To: Chuck Cleland; r-help@stat.math.ethz.ch Subject: Re: [R] Aggregating data Chuck and others. Here is the problem I need help on. Thanks. I want to follow-up on a question I had a week or so ago. I want to aggregate a very large data set. Generally in a program such as SPSS, one chooses a so-called break variable that is the variable, and then the remaining variables are aggregated by that variable with some summary statistic calculated - such as the mean. I played with aggregate in R and found that it requires a by statement listing the variables. But I don't see how I can aggregate on one variable and create the summary statistics on the remaining variables. I hope that was clear. Thanks for an advice in advance. David == = David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 == = Chuck Cleland wrote: David Kaplan wrote: The problem is that this doesn't seem to give what I want. I did look at this. Perhaps doBy will work - haven't tried it yet. But, any other suggestions are much appreciated. David: Your posts on aggregating came to the list without any text in the body of the message (I believe Petr sent a response based only on the subject). You might get more specific and helpful suggestions if you send a small example of what you are trying to do and why aggregate() does not work for you. Also, be sure to send messages in plain text rather than HTML. hope this helps, Chuck Cleland = == David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 = == Petr Pikal wrote: Similar answer as last time aggregate, tapply, by or ppackage doBy HTH PS. If you want to add some other text then subject in your post do not use HTML posting as recommended in posting guide. Petr On 28 Nov 2006 at 22:04, David Kaplan wrote: Date sent:Tue, 28 Nov 2006 22:04:09 -0600 From: David Kaplan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Aggregating data __ R-help@stat.math.ethz.ch 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. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch 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] filled.contour and NA's
Hi, I'm trying to do a filled.contour plot where some points are labelled as NA. How do I could plot this kind of graphics, so NA points are coloured black, keeping the levels of remaining points. NA's values represent land points (meaningless), and what I want to plot is the levels of a variable over the sea. x-seq(length=21, from=-10, by=.25) y-seq(length=8, from=36, by=.25) filled.contour(x,y,t(ene)) dput(ene,control=all) structure(c(0.941176470588235, 0.705882352941177, 0.588235294117647, 0.470588235294118, 0.588235294117647, 0.588235294117647, 0.588235294117647, 0.705882352941177, 0.647058823529412, 0.823529411764706, 0.588235294117647, 0.588235294117647, 0.529411764705882, 0.647058823529412, 0.588235294117647, 0.764705882352941, 0.823529411764706, 0.764705882352941, 0.647058823529412, 0.705882352941177, 0.529411764705882, 0.647058823529412, 0.529411764705882, 0.529411764705882, 0.705882352941177, 0.647058823529412, 0.764705882352941, 0.705882352941177, 0.529411764705882, 0.705882352941177, 0.647058823529412, 0.411764705882353, 0.88235294117647, 0.823529411764706, 0.764705882352941, 0.764705882352941, 0.705882352941177, 0.647058823529412, 0.529411764705882, 0.529411764705882, 0.764705882352941, 0.941176470588235, 0.941176470588235, 0.88235294117647, 0.722, 0.588235294117647, 0.5625, 0.5, 0.823529411764706, 0.823529411764706, 0.833, 1, 0.529411764705882, 0.909090909090909, 0.818181818181818, 1.33, 0.941176470588235, 0.88235294117647, 0.823529411764706, 0.833, 0.6, NA, NA, NA, 0.705882352941177, 0.88235294117647, 0.823529411764706, 0.722, 0.75, NA, NA, NA, 0.647058823529412, 0.705882352941177, 0.764705882352941, 0.722, 0.5, 1.67, NA, NA, 0.529411764705882, 0.647058823529412, 0.647058823529412, 0.588235294117647, 1.17, 1.5, NA, NA, 0.529411764705882, 0.470588235294118, 0.588235294117647, 0.428571428571429, 1.33, 1.5, NA, NA, 0.470588235294118, 0.470588235294118, 0.529411764705882, 0.727272727272727, 1.67, 1.5, NA, NA, 0.470588235294118, 0.556, 0.588235294117647, 1.17, 1.67, 1.67, NA, NA, 0.611, 0.529411764705882, 0.583, 1.17, 1.17, NA, NA, NA, 0.428571428571429, 0.875, 1.33, 1, 1.33, NA, NA, NA, 0.833, 0.833, 1.5, 1.33, NA, NA, NA, NA, 2.17, 1.67, NA, NA, NA, NA, NA, NA, 1.5, 0.833, 0.5, NA, NA, NA, NA, NA, 0.667, 0.667, 1.17, NA, NA, NA, NA, NA, 0.667, 0.667, 0.667, NA, NA, NA, NA, NA), .Dim = as.integer(c(8, 21))) __ R-help@stat.math.ethz.ch 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] Aggregating data
David Kaplan wrote: Chuck and others. Here is the problem I need help on. Thanks. I want to follow-up on a question I had a week or so ago. I want to aggregate a very large data set. Generally in a program such as SPSS, one chooses a so-called break variable that is the variable, and then the remaining variables are aggregated by that variable with some summary statistic calculated - such as the mean. I played with aggregate in R and found that it requires a by statement listing the variables. But I don't see how I can aggregate on one variable and create the summary statistics on the remaining variables. I hope that was clear. Thanks for an advice in advance. Another example similar to Gabor's and Harold's: library(nlme) # to get Orthodont data aggregate(Orthodont[,1:2], by = list(Subject = Orthodont$Subject), FUN = mean) David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Chuck Cleland wrote: David Kaplan wrote: The problem is that this doesn't seem to give what I want. I did look at this. Perhaps doBy will work - haven't tried it yet. But, any other suggestions are much appreciated. David: Your posts on aggregating came to the list without any text in the body of the message (I believe Petr sent a response based only on the subject). You might get more specific and helpful suggestions if you send a small example of what you are trying to do and why aggregate() does not work for you. Also, be sure to send messages in plain text rather than HTML. hope this helps, Chuck Cleland === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Petr Pikal wrote: Similar answer as last time aggregate, tapply, by or ppackage doBy HTH PS. If you want to add some other text then subject in your post do not use HTML posting as recommended in posting guide. Petr On 28 Nov 2006 at 22:04, David Kaplan wrote: Date sent: Tue, 28 Nov 2006 22:04:09 -0600 From: David Kaplan [EMAIL PROTECTED] To:r-help@stat.math.ethz.ch Subject: [R] Aggregating data __ R-help@stat.math.ethz.ch 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. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] matrix comparison, and cbind issues.
Hello, This should be a fairly simple question. I have 2 matrix's and I want to get the difference between them and then remove the difference from one of them. So A vs B, anything I see in B I want to remove from A, and then print out the final matrix. I have some code here but at the moment I'm getting stuck on the creating a matrix, cbind problems. clean - function (A, B, rt=10, mass=0.01, pval=0.01){ i -0 j -0 d.A -dim(A) d.B -dim(B) clean -0 for (i in i:d.A[1]){ for (j in j:d.B[1]){ if(any((A[i,6] - B[j,6]) = mass)){ if (any((A[i,9] - B[j,9])= rt)){ if (B[j,5] = pval){ clean-cbind(clean,A[i,]) } } } } } return (clean) } I hope that I have explained myself well. If not please let me know and I'll try to explain more. Cheers, PB Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] showing available environment variables
Karin Lagesen karin.lagesen at medisin.uio.no writes: ... The default program for reading files when using openVignettes on my system is ggv. ggv is broken. I would therefore like to use a different program, and I found the variable R_PDFVIEWER which should do the trick. However, so far no luck. Therefore, how do I ask R what variables are available, and how do I get it to show what it is currently set to. Try options(pdfviewer=something) Gregor __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Aggregating data
Actually, I think this is a much better variation on Gabor's excellent example: library(nlme) aggregate(Orthodont[c(distance,age)], by = list(Subject = Orthodont[Subject]), FUN =mean) Chuck Cleland wrote: David Kaplan wrote: Chuck and others. Here is the problem I need help on. Thanks. I want to follow-up on a question I had a week or so ago. I want to aggregate a very large data set. Generally in a program such as SPSS, one chooses a so-called break variable that is the variable, and then the remaining variables are aggregated by that variable with some summary statistic calculated - such as the mean. I played with aggregate in R and found that it requires a by statement listing the variables. But I don't see how I can aggregate on one variable and create the summary statistics on the remaining variables. I hope that was clear. Thanks for an advice in advance. Another example similar to Gabor's and Harold's: library(nlme) # to get Orthodont data aggregate(Orthodont[,1:2], by = list(Subject = Orthodont$Subject), FUN = mean) David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Chuck Cleland wrote: David Kaplan wrote: The problem is that this doesn't seem to give what I want. I did look at this. Perhaps doBy will work - haven't tried it yet. But, any other suggestions are much appreciated. David: Your posts on aggregating came to the list without any text in the body of the message (I believe Petr sent a response based only on the subject). You might get more specific and helpful suggestions if you send a small example of what you are trying to do and why aggregate() does not work for you. Also, be sure to send messages in plain text rather than HTML. hope this helps, Chuck Cleland === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Petr Pikal wrote: Similar answer as last time aggregate, tapply, by or ppackage doBy HTH PS. If you want to add some other text then subject in your post do not use HTML posting as recommended in posting guide. Petr On 28 Nov 2006 at 22:04, David Kaplan wrote: Date sent:Tue, 28 Nov 2006 22:04:09 -0600 From: David Kaplan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Aggregating data __ R-help@stat.math.ethz.ch 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. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] matrix comparison, and cbind issues.
Mark, A and B will probably be different sizes. Won't 'C-A-B' just do the subtraction of matrix A by matrix B? So What I was thinking was that it would find 2 numbers one at position 6 and the other at position 9. If it finds roughtly these numbers in matrix B then it will identify this and remove that row from matrix A. Paul -Original Message- From: Leeds, Mark (IED) [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 12:12 PM To: H. Paul Benton Subject: RE: [R] matrix comparison, and cbind issues. If A and B are the same size ( I can't tell ),then you can C-A-B to get the dfiference but that might Be simplifying things too much. If it isn't simplifying thigns too, then let me know and I think I can show you how to do the rest. If it is, then my bad and I apologize. __ R-help@stat.math.ethz.ch 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] control for frame color in cloud()
I am trying to construct a cloud plot viewable in 3D with the classic 3D glasses (one red lens, one bluish lens). I've figured out how to overlay two printings of cloud() (from the lattice package) with appropriate colors, however the box frame seems to only print in black. Is there any way to control the color for the frame? How about the background color (gray)? See http://www.crustose.net/~nnhp/3Dview.pdf for a sample of what I'm doing. Thanks, -Eric --- Eric B. Peterson Vegetation Ecologist Nevada Natural Heritage Program [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Dummies multiplied with other variable
Hi, I would like to estimate something like y = a + b*d2*y + c*d3*y where the dummies are created from some vector d with three (actually many more) levels using factor(). But either there is included the variable y or d1*y. How could I get rid of these? Example: x = c(1,2,3,4,5,6,7,8) y = c(3,6,2,8,7,6,2,4) d = c(1,1,1,2,3,2,3,3) fd = factor(d) lm(x ~ fd*y) gives: Coefficients: (Intercept) fd2 fd3 y fd2:y fd3:y 2.4231 9.5769 6.1822 -0.1154 -0.8846 -0.3320 lm(x ~ fd*y - y) gives: Coefficients: (Intercept) fd2 fd3 fd1:y fd2:y fd3:y 2.4231 9.5769 6.1822 -0.1154 -1. -0.4474 What I would like to get is: Coefficients: (Intercept) fd2 fd3 fd2:y fd3:y Is there an easy way to achieve this? Maybe it's obvious how to do it, but I'm new to R did quite some searching without finding the solution. Thanks a lot in advance! Andreas Goesele -- Andreas Gösele __ R-help@stat.math.ethz.ch 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] Dummies multiplied with other variable
Is this what you want? lm(y ~ fd + fd:y) On 29/11/06, Andreas Goesele [EMAIL PROTECTED] wrote: Hi, I would like to estimate something like y = a + b*d2*y + c*d3*y where the dummies are created from some vector d with three (actually many more) levels using factor(). But either there is included the variable y or d1*y. How could I get rid of these? Example: x = c(1,2,3,4,5,6,7,8) y = c(3,6,2,8,7,6,2,4) d = c(1,1,1,2,3,2,3,3) fd = factor(d) lm(x ~ fd*y) gives: Coefficients: (Intercept) fd2 fd3 y fd2:y fd3:y 2.4231 9.5769 6.1822 -0.1154 -0.8846 -0.3320 lm(x ~ fd*y - y) gives: Coefficients: (Intercept) fd2 fd3 fd1:y fd2:y fd3:y 2.4231 9.5769 6.1822 -0.1154 -1. -0.4474 What I would like to get is: Coefficients: (Intercept) fd2 fd3 fd2:y fd3:y Is there an easy way to achieve this? Maybe it's obvious how to do it, but I'm new to R did quite some searching without finding the solution. Thanks a lot in advance! Andreas Goesele -- Andreas Gösele __ R-help@stat.math.ethz.ch 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. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch 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 solve differential equations with a delay (time lag)?
Hi, I would like to solve a system of coupled ordinary differential equations, where there is a delay (time lag) term. I would like to use the lsoda function odesolve package. However, I am not sure how to specify the delay term using the syntax allowed by odesolve. Here is an example of the kind of problem that I am trying to solve: library(odesolve) yprime - function(t, y, p) { # this function yd1 - p[k1] *(t = p[T]) - p[k2] * y[2] yd2 - p[k3] * y[1](t - p[delay]) - p[k4] * y[2] # this is not syntactically valid, but it is what I would like to do list(c(yd1,yd2)) } times - seq(0,30,by=0.1) y0 - c(0,0) parms - c(k1=0.7, k2=0.5, k3=0.2, k4=0.8, T=10, delay=5) Is there a way to incorporate delay in odesolve? Any hints would be much appreciated. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem with indexing a zoo object
My problem is the following : I create 2 zoo objects and then I try to subset one of them using logic. indicesthatpass is a vector of trues and falses but when I send it into bckret, it returns an empty bckret. Obviously it has something to do with bckret being a zoo object and if I do the same subsctripting off of coredata(bckret), I'm confident it will work. But, I need to keep the minute days of bckret. So, I have two questions : 1) is there a way around this ? 2) even if the answer to 1) is yes, there could be some other way better than what I am doing ? It took me a while to even get to this point because I was taking is.infinite of fwdret and abs of bckret rather than their respective coredatas and that was really causing a mess because of the different indexing that was getting returned. Thanks. # SET SEED set.seed(1) # CREATE 2 ZOO OBJECTS, bckkret and fwdret OF MINUTE DATA OVER THE WHOLE DAY x.date-as.Date(paste(2003,01,01,sep=-)) allminutes-as.POSIXct(format(x.date,%Y-%m-%d)) + 60 * seq(1, 24 * 60) bckret-zoo(matrix(abs(rnorm(1440)),nc=1),allminutes) fwdret-zoo(matrix(abs(rnorm(1440)),nc=1),allminutes) indicesthatpass-!is.infinite(coredata(fwdret)) !(abs(coredata(bckret)) 1.00) #SUBSET bckret bckret-bckret[indicesthatpass,drop=FALSE] This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] packages about discriminant analysis
Hi guys: I'm testing some statistic discriminant analysis methods in R. But I couldn't find the package for these methods: 1. Discriminant analysis implemented with nearest neighbor method, 2. logistic discriminant analysis 3. POLYCLASS algorithm( there is such a function in S-Plus, namely poly.fit from polyclass library. Is there a corresponding library in R? ) Any kind of help is highly appreciated! Best, Feng __ R-help@stat.math.ethz.ch 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] better define: matrix comparison and cbind issue
Hello, Sorry to all for the lack of communication, and thanks to those with the suggestions. So I have two matrixes which are different sizes, same column number but different row number. What I would like to do is to compare A to B. In the 6 and 9th column there are ref numbers (molecular masses to be exact). I would like to check A and B by these columns. If I find that the number in A[9,x] and B[9, x] are the same then I want to remove the row that it is comparing from A. So overall, if something appears in B then I remove it from A. Cheers, Paul Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with indexing a zoo object
On Wed, 29 Nov 2006, Leeds, Mark (IED) wrote: My problem is the following : I create 2 zoo objects and then I try to subset one of them using logic. indicesthatpass is a vector of trues and Nope, it's a matrix (because you want the coredata to be a matrix) but should be a vector. (Maybe we could extend [.zoo here...) 2) even if the answer to 1) is yes, there could be some other way better than what I am doing ? It took me a while to even get to this point because I was taking is.infinite of fwdret and abs of bckret rather than their respective coredatas and that was really causing a mess because of the different indexing that was getting returned. Logical comparisons on zoo objects return zoo objects as documented in various places (which you should know about by now) including ?zoo and the package vignette. The documentation suggests various strategies (including using coredata). Z __ R-help@stat.math.ethz.ch 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 solve differential equations with a delay (time lag)?
Hi, I would like to add an additional piece of information to my previous posting: y[1](t) = 0, for all t in the interval (-delay, 0) This completes the specification of the problem. Thanks, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ravi Varadhan Sent: Wednesday, November 29, 2006 4:45 PM To: r-help@stat.math.ethz.ch Subject: [R] How to solve differential equations with a delay (time lag)? Hi, I would like to solve a system of coupled ordinary differential equations, where there is a delay (time lag) term. I would like to use the lsoda function odesolve package. However, I am not sure how to specify the delay term using the syntax allowed by odesolve. Here is an example of the kind of problem that I am trying to solve: library(odesolve) yprime - function(t, y, p) { # this function yd1 - p[k1] *(t = p[T]) - p[k2] * y[2] yd2 - p[k3] * y[1](t - p[delay]) - p[k4] * y[2] # this is not syntactically valid, but it is what I would like to do list(c(yd1,yd2)) } times - seq(0,30,by=0.1) y0 - c(0,0) parms - c(k1=0.7, k2=0.5, k3=0.2, k4=0.8, T=10, delay=5) Is there a way to incorporate delay in odesolve? Any hints would be much appreciated. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] control for frame color in cloud()
On 11/29/06, Eric Peterson [EMAIL PROTECTED] wrote: I am trying to construct a cloud plot viewable in 3D with the classic 3D glasses (one red lens, one bluish lens). I've figured out how to overlay two printings of cloud() (from the lattice package) with appropriate colors, however the box frame seems to only print in black. Is there any way to control the color for the frame? How about the background color (gray)? You are most likely using an old (1 yr) version of R/lattice, or you wouldn't be seeing the grey background unless you wanted to. In recent versions (and probably in old versions as well), the box.3d setting controls the box, so you could add 'box.3d = list(col = col1)' to par.set1, etc. Similarly, '[xyz]lab = list(col = col1)' for the axis labels. See http://www.crustose.net/~nnhp/3Dview.pdf for a sample of what I'm doing. Cool. -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] tests for NULL objects
Hi Everyone, After searching the subject and not being successful, I was wondering if any you could explain me the idea behind the following fact: all(NULL == 2) ## TRUE any(NULL == 2) ## FALSE Thanks a lot, Benilton -- Benilton Carvalho PhD Candidate Department of Biostatistics Johns Hopkins University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to solve differential equations with a delay (time lag)?
lsoda does not solve delay differential equations, which is what you need to be able to do. A quick search on netlib (netlib.org) turned up one match for delay differential equations: ode/ddverk.f, which might help (though not in R). R. Woodrow Setzer, Ph. D. National Center for Computational Toxicology US Environmental Protection Agency Mail Drop B205-01/US EPA/RTP, NC 27711 Ph: (919) 541-0128Fax: (919) 541-1194 Ravi Varadhan [EMAIL PROTECTED] eduTo Sent by: r-help@stat.math.ethz.ch [EMAIL PROTECTED]cc tat.math.ethz.ch Subject [R] How to solve differential 11/29/2006 04:44 equations with a delay (time PM lag)? Hi, I would like to solve a system of coupled ordinary differential equations, where there is a delay (time lag) term. I would like to use the lsoda function odesolve package. However, I am not sure how to specify the delay term using the syntax allowed by odesolve. Here is an example of the kind of problem that I am trying to solve: library(odesolve) yprime - function(t, y, p) { # this function yd1 - p[k1] *(t = p[T]) - p[k2] * y[2] yd2 - p[k3] * y[1](t - p[delay]) - p[k4] * y[2] # this is not syntactically valid, but it is what I would like to do list(c(yd1,yd2)) } times - seq(0,30,by=0.1) y0 - c(0,0) parms - c(k1=0.7, k2=0.5, k3=0.2, k4=0.8, T=10, delay=5) Is there a way to incorporate delay in odesolve? Any hints would be much appreciated. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Removing terms from formula
R-help, Given a simple linear model, say lm(x ~ y + z), I would like to remove model terms that are factors with only one level. Thus, if 'z' were a factor with only one level, lm(x ~ y + z) becomes lm(x ~ y + 1). Likewise, if both 'y' and 'z' are one-level factors, then the resulting calculation is simply lm(x ~ 1). Unfortunately, I have not been able to come up with an elegant solution to this. Any suggestions would be greatly appreciated. Thanks, Robert Robert McGehee, CFA Quantitative Analyst Geode Capital Management, LLC One Post Office Square, 28th Floor | Boston, MA | 02109 Tel: 617/392-8396Fax:617/476-6389 mailto:[EMAIL PROTECTED] This e-mail, and any attachments hereto, are intended for us...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] better define: matrix comparison and cbind issue
Ok so something like this. A 1 2 3 4 5 A v w x z G x z y w C y v z x D x v w z B 1 2 3 4 5 F z x y z D x z w v E x z w v So here I would just be comparing col 1. I would compare A[1,] to B[1,] and then I would see that A[1,4] has the same element as B[1,2], so I would remove A[,4]. Making A: A 1 2 3 4 5 A v w x z G x z y w C y v z x :) Cheers, Paul Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute -Original Message- From: Leeds, Mark (IED) [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 2:19 PM To: H. Paul Benton Subject: RE: [R] better define: matrix comparison and cbind issue paul : it honestly might be me ( seriously ) but you say 6th and 9th column but then You say A[9,x] and B[9,x] which are all the elements in the 9th row of A and 9th row of B respectively. Could you make 2 small sample matrices and the result matrix and explain it that way ? Honestly though, someone else may understand so maybe wait to see if someone else responds with an answer/suggestion. Good luck. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of H. Paul Benton Sent: Wednesday, November 29, 2006 5:09 PM To: r-help@stat.math.ethz.ch Subject: [R] better define: matrix comparison and cbind issue Hello, Sorry to all for the lack of communication, and thanks to those with the suggestions. So I have two matrixes which are different sizes, same column number but different row number. What I would like to do is to compare A to B. In the 6 and 9th column there are ref numbers (molecular masses to be exact). I would like to check A and B by these columns. If I find that the number in A[9,x] and B[9, x] are the same then I want to remove the row that it is comparing from A. So overall, if something appears in B then I remove it from A. Cheers, Paul Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This is not an offer (or solicitation of an offer) to buy/sell the securities/instruments mentioned or an official confirmation. Morgan Stanley may deal as principal in or own or act as market maker for securities/instruments mentioned or may advise the issuers. This is not research and is not from MS Research but it may refer to a research analyst/research report. Unless indicated, these views are the author's and may differ from those of Morgan Stanley research or others in the Firm. We do not represent this is accurate or complete and we may not update this. Past performance is not indicative of future returns. For additional information, research reports and important disclosures, contact me or see https://secure.ms.com/servlet/cls. You should not use e-mail to request, authorize or effect the purchase or sale of any security or instrument, to send transfer instructions, or to effect any other transactions. We cannot guarantee that any such requests received via e-mail will be processed in a timely manner. This communication is solely for the addressee(s) and may contain confidential information. We do not waive confidentiality by mistransmission. Contact me if you do not wish to receive these communications. In the UK, this communication is directed in the UK to those persons who are market counterparties or intermediate customers (as defined in the UK Financial Services Authority's rules). __ R-help@stat.math.ethz.ch 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] strptime - %p format doesn't seem to be working
Hi there, Am I missing something? The %p format, which should match against AM/PM, seems to be broken in R 2.3.1 running on Windows XP SP2. For example, the following fails strptime(10AM, %I%p) [1] NA whereas the this works as you would expect, but is ambiguous strptime(10, %I) [1] 2006-11-30 10:00:00 Does this error reproduce on other machines, or is it something wrong with my setup? Cheers, Edward __ R-help@stat.math.ethz.ch 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] Dummies multiplied with other variable
David Barron [EMAIL PROTECTED] writes: Is this what you want? lm(y ~ fd + fd:y) Thanks for you fast reply. But it's not what I wanted. To make it clearer I have to correct the first part of what I wrote: On 29/11/06, Andreas Goesele [EMAIL PROTECTED] wrote: I would like to estimate something like y = a + b*d2*y + c*d3*y where the dummies are created from some vector d with three (actually many more) levels using factor(). But either there is included the variable y or d1*y. How could I get rid of these? This should have been something like: x = a + b1*d2 + b2*d3 + c1*d2*y + c1*d3*y When I change your suggestion to lm(x ~ fd + fd:y) I get the same as for lm(x ~ fd*y - y), namely: Coefficients: (Intercept) fd2 fd3 fd1:y fd2:y fd3:y 2.4231 9.5769 6.1822 -0.1154 -1. -0.4474 What I want is: Coefficients: (Intercept) fd2 fd3 fd2:y fd3:y Thanks a lot again! Andreas Goesele -- Andreas Gösele Omnis enim res, quae dando non deficit, Inst. f. Gesellschaftspolitikdum habetur et non datur, Kaulbachstr. 31a, 80539 München nondum habetur, quomodo habenda est. E-mail: [EMAIL PROTECTED] (Augustinus) __ R-help@stat.math.ethz.ch 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 solve differential equations with a delay (time lag)?
Thanks, Woodrow. I also found a DDE solver called dde23 in Matlab written by L.F. Shampine. I will see if I can use it in Scilab, since I don't have Matlab. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 5:26 PM To: Ravi Varadhan Cc: r-help@stat.math.ethz.ch Subject: Re: [R] How to solve differential equations with a delay (time lag)? lsoda does not solve delay differential equations, which is what you need to be able to do. A quick search on netlib (netlib.org) turned up one match for delay differential equations: ode/ddverk.f, which might help (though not in R). R. Woodrow Setzer, Ph. D. National Center for Computational Toxicology US Environmental Protection Agency Mail Drop B205-01/US EPA/RTP, NC 27711 Ph: (919) 541-0128Fax: (919) 541-1194 Ravi Varadhan [EMAIL PROTECTED] eduTo Sent by: r-help@stat.math.ethz.ch [EMAIL PROTECTED]cc tat.math.ethz.ch Subject [R] How to solve differential 11/29/2006 04:44 equations with a delay (time PM lag)? Hi, I would like to solve a system of coupled ordinary differential equations, where there is a delay (time lag) term. I would like to use the lsoda function odesolve package. However, I am not sure how to specify the delay term using the syntax allowed by odesolve. Here is an example of the kind of problem that I am trying to solve: library(odesolve) yprime - function(t, y, p) { # this function yd1 - p[k1] *(t = p[T]) - p[k2] * y[2] yd2 - p[k3] * y[1](t - p[delay]) - p[k4] * y[2] # this is not syntactically valid, but it is what I would like to do list(c(yd1,yd2)) } times - seq(0,30,by=0.1) y0 - c(0,0) parms - c(k1=0.7, k2=0.5, k3=0.2, k4=0.8, T=10, delay=5) Is there a way to incorporate delay in odesolve? Any hints would be much appreciated. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with PPC packages on Intel Mac
Hi all I have recently moved to an Intel Mac and installed the latest R (2.4.0) but I am having trouble with a number of packages. When I try to load them I often get the following message: Error: package 'pspline' was built for powerpc-apple-darwin6.8 I have tried to update all the packages I use with Package Manager but this doesn't appear to help. Is there some way of either updating packages so that they are all Intel native or otherwise (presumably if there isn't an Intel native binary available) allowing PPC-only packages to run under Rosetta emulation? A less common error message goes like this: Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/Users/mwh/Library/R/library/mvtnorm/libs/i386/mvtnorm.so': dlopen(/Users/mwh/Library/R/library/mvtnorm/libs/i386/mvtnorm.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/2.3/Resources/lib/libgfortran.0.dyl ib Referenced from: /Users/mwh/Library/R/library/mvtnorm/libs/i386/mvtnorm.so Reason: image not found Maybe my library paths or preferences are messed up somehow? I'm not sure how to check this much less rectify it. Thanks in advance Michael _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ _/_/ _/_/_/ Hopkins Research Ltd _/_/ _/_/ _/_/_/_/ _/_/_/ http://www.hopkins-research.com/ _/_/ _/ _/ _/_/ _/ _/ 'touch the future' __ R-help@stat.math.ethz.ch 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] tests for NULL objects
Merely convention. NULL == 2 == logical(0), that is, a logical vector of length 0. It makes sense (at least to me) that any(logical(0)) is FALSE, since no elements of the vector are TRUE. all(logical(0)) is TRUE since no elements of the vector are FALSE. I think these are reasonable and fairly standard conventions, but even if you disagree, they are certainly not worth making a fuss over and certainly cannot be changed without breaking a lot of code, I'm sure. Bert Gunter Nonclinical Statistics 7-7374 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Benilton Carvalho Sent: Wednesday, November 29, 2006 2:21 PM To: R-Mailingliste Subject: [R] tests for NULL objects Hi Everyone, After searching the subject and not being successful, I was wondering if any you could explain me the idea behind the following fact: all(NULL == 2) ## TRUE any(NULL == 2) ## FALSE Thanks a lot, Benilton -- Benilton Carvalho PhD Candidate Department of Biostatistics Johns Hopkins University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshape command is (stats) dropping instances
The attached file never went through. How does one attach a R workskpace (or two dataframes) Farrel Buchinsky [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I would really appreciate it if anyone could determine what is going on with the following command. It is only half-working and is losing lots of data. For the life of me I cannot even see the pattern of what it is losing and what it is not. I am attaching the R data set which you can use with the Load Workspace menu function. WideICA-reshape(ICA,v.names=c(OD,Thickness,Surface.Cover),idvar=c(Strain,ica,Rep,Locations),drop=Growth,timevar=Time,direction=wide) The following two commands should give the same data (other than the missing values) but they do not. ICA[ICA$Time==6,Surface.Cover] WideICA$Surface.Cover.6 -- Farrel Buchinsky Pediatric Otolaryngologist Allegheny General Hospital Pittsburgh, PA USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ML fit of gamma distribution to grouped data
Thomas, The Gamma distr. can be fitted via ML using: Library(MASS) GF - fitdistr(given_data,gamma) sh - GF$estimate[1] ra - GF$estimate[2] Fitting via Moments, m: var - m[2] - m[1]*m[1] sh - m[1]*m[1]/var sc - m[1]/var ra - 1/sc G_pdf - dgamma(breaks,shape=sh,rate=ra,scale=1/ra) Hope it helps, Augusto Augusto Sanabria. MSc, PhD. Mathematical Modeller Risk Research Group Geospatial Earth Monitoring Division Geoscience Australia (www.ga.gov.au) Cnr. Jerrabomberra Av. Hindmarsh Dr. Symonston ACT 2601 Ph. (02) 6249-9155 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Petzoldt Sent: Tuesday, 28 November 2006 10:26 To: r-help@stat.math.ethz.ch Subject: [R] ML fit of gamma distribution to grouped data Hello, we have a set of biological cell-size data, which are only available as frequencies of discrete size classes, because of the high effort of manual microscopic measurements. The lengths are approximately gamma distributed, however the shape of the distribution is relatively variable between different samples (maybe it's a mixture in reality). Is there any ML fitting (or moment-based) procedure for the gamma distribution and grouped data already available in R? Here is a small example: breaks - c(0, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150) mids - c(10, 25, 35, 45, 55, 65, 75, 85, 95, 125) counts - c(87, 5, 2, 2, 1, 1, 0, 0, 1, 1) Any help is highly appreciated Thomas P. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tests for NULL objects
Bert Gunter [EMAIL PROTECTED] writes: Merely convention. There's a similar thread in the R-devel newgroup about 'prod(numeric(0)) surprise' started by Ben Bolker, 09 Jan 2006, (https://stat.ethz.ch/pipermail/r-devel/2006-January/036041.html) and the post by Andy Liaw (https://stat.ethz.ch/pipermail/r-devel/2006-January/036057.html) proved particularly helpful to me (mathematical reasons, in addition to convention): From: Liaw, Andy andy_liaw_at_merck.com Date: Mon 09 Jan 2006 - 18:27:41 GMT If you haven't seen this in your math courses, perhaps this would help: http://en.wikipedia.org/wiki/Empty_set which says, in part: Operations on the empty set Operations performed on the empty set (as a set of things to be operated upon) can also be confusing. (Such operations are nullary operations.) For example, the sum of the elements of the empty set is zero, but the product of the elements of the empty set is one (see empty product). This may seem odd, since there are no elements of the empty set, so how could it matter whether they are added or multiplied (since they do not exist)? Ultimately, the results of these operations say more about the operation in question than about the empty set. For instance, notice that zero is the identity element for addition, and one is the identity element for multiplication. Andy 'any' is like 'sum', 'all' is like 'prod'. Martin NULL == 2 == logical(0), that is, a logical vector of length 0. It makes sense (at least to me) that any(logical(0)) is FALSE, since no elements of the vector are TRUE. all(logical(0)) is TRUE since no elements of the vector are FALSE. I think these are reasonable and fairly standard conventions, but even if you disagree, they are certainly not worth making a fuss over and certainly cannot be changed without breaking a lot of code, I'm sure. Bert Gunter Nonclinical Statistics 7-7374 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Benilton Carvalho Sent: Wednesday, November 29, 2006 2:21 PM To: R-Mailingliste Subject: [R] tests for NULL objects Hi Everyone, After searching the subject and not being successful, I was wondering if any you could explain me the idea behind the following fact: all(NULL == 2) ## TRUE any(NULL == 2) ## FALSE Thanks a lot, Benilton -- Benilton Carvalho PhD Candidate Department of Biostatistics Johns Hopkins University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Martin T. Morgan Bioconductor / Computational Biology http://bioconductor.org __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tests for NULL objects
Thank you Bert, Sorry if it sounded like a complain, this is not what I meant. The situation I had was: given a vector v containing integers or NA's, I wanted to know if after excluding the NA's all the remaining observations were 2's. Naively, I assumed that: all(na.omit(v) == 2) would do the work, but now I see that it fails if, for example, v = rep(NA, 10) But that's okay, just a matter of adding an extra test (already done). When I asked for clarification about the reasons for this, I assumed that: if all(v) is TRUE == any(v) is TRUE; for all (logical) v... When actually: if all(v) is TRUE == any(v) is TRUE; for all (logical) v of length = 1. Thank you, benilton On Nov 29, 2006, at 6:35 PM, Bert Gunter wrote: Merely convention. NULL == 2 == logical(0), that is, a logical vector of length 0. It makes sense (at least to me) that any(logical(0)) is FALSE, since no elements of the vector are TRUE. all(logical(0)) is TRUE since no elements of the vector are FALSE. I think these are reasonable and fairly standard conventions, but even if you disagree, they are certainly not worth making a fuss over and certainly cannot be changed without breaking a lot of code, I'm sure. Bert Gunter Nonclinical Statistics 7-7374 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Benilton Carvalho Sent: Wednesday, November 29, 2006 2:21 PM To: R-Mailingliste Subject: [R] tests for NULL objects Hi Everyone, After searching the subject and not being successful, I was wondering if any you could explain me the idea behind the following fact: all(NULL == 2) ## TRUE any(NULL == 2) ## FALSE Thanks a lot, Benilton -- Benilton Carvalho PhD Candidate Department of Biostatistics Johns Hopkins University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tests for NULL objects
On Nov 29, 2006, at 7:54 PM, Martin Morgan wrote: http://en.wikipedia.org/wiki/Empty_set which says, in part: Operations on the empty set ... 'any' is like 'sum', 'all' is like 'prod'. Martin Thank you very much Martin. It's clear now. Benilton __ R-help@stat.math.ethz.ch 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] better define: matrix comparison and cbind issue
Ok, so columns are fixed and my apologizes, for the incorrect subscripting. So I have the matching down because I'm matching a number so I've used an if statement with some fuzz. At the moment my code from my earlier post gets me a long vector with the data in it but not a nice matrix that is readable. Also this matrix is only the stuff which was found to be in both A and B. I would like to get A - B as shown before. Cheers, Paul PS. Thx to mark, but don't miss your deadline. -- Mark wrote: I understand better now but I just have 1 question and 1 comment. 1) how do you know which columns to compare ? Is that fixed, like parameters x an y where in the case below X = 1 and y = 1 ? Or does it somehow depend on the matrix ? 2) your email was still really confusing because you are subscripting incorrectly when you Refers to rows and columns. You have it backwards : A[1,] is the first row. A[,1] is the first column. -Original Message- From: jim holtman [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 2:40 PM To: H. Paul Benton Subject: Re: [R] better define: matrix comparison and cbind issue match(a[9,], b[9,]) will tell you which elements in 'a' match 'b' On 11/29/06, H. Paul Benton [EMAIL PROTECTED] wrote: Hello, Sorry to all for the lack of communication, and thanks to those with the suggestions. So I have two matrixes which are different sizes, same column number but different row number. What I would like to do is to compare A to B. In the 6 and 9th column there are ref numbers (molecular masses to be exact). I would like to check A and B by these columns. If I find that the number in A[9,x] and B[9, x] are the same then I want to remove the row that it is comparing from A. So overall, if something appears in B then I remove it from A. Cheers, Paul Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] better define: matrix comparison and cbind issue
Paul : I haven't tested this but try it and let me know. Let x be the # of the col in A and y be the # of the column in B. colinA-A[,x] colinB-B[,y] matchingrows-B[(colinB %in% colinA),colinB] C-A[-1.0*c(matchingrows),] I think C should be the resulting matrix that you want but it's untested so check it. I'm notorious for missing unforeseen problems unless I test things. When I have time later tonight, I'll test it myself. Maybe someone else will help you now if it doesn't work so I'll include the list. -Original Message- From: H. Paul Benton [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 8:43 PM To: 'jim holtman'; Leeds, Mark (IED) Cc: r-help@stat.math.ethz.ch Subject: RE: [R] better define: matrix comparison and cbind issue Ok, so columns are fixed and my apologizes, for the incorrect subscripting. So I have the matching down because I'm matching a number so I've used an if statement with some fuzz. At the moment my code from my earlier post gets me a long vector with the data in it but not a nice matrix that is readable. Also this matrix is only the stuff which was found to be in both A and B. I would like to get A - B as shown before. Cheers, Paul PS. Thx to mark, but don't miss your deadline. -- Mark wrote: I understand better now but I just have 1 question and 1 comment. 1) how do you know which columns to compare ? Is that fixed, like parameters x an y where in the case below X = 1 and y = 1 ? Or does it somehow depend on the matrix ? 2) your email was still really confusing because you are subscripting incorrectly when you Refers to rows and columns. You have it backwards : A[1,] is the first row. A[,1] is the first column. -Original Message- From: jim holtman [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 2:40 PM To: H. Paul Benton Subject: Re: [R] better define: matrix comparison and cbind issue match(a[9,], b[9,]) will tell you which elements in 'a' match 'b' On 11/29/06, H. Paul Benton [EMAIL PROTECTED] wrote: Hello, Sorry to all for the lack of communication, and thanks to those with the suggestions. So I have two matrixes which are different sizes, same column number but different row number. What I would like to do is to compare A to B. In the 6 and 9th column there are ref numbers (molecular masses to be exact). I would like to check A and B by these columns. If I find that the number in A[9,x] and B[9, x] are the same then I want to remove the row that it is comparing from A. So overall, if something appears in B then I remove it from A. Cheers, Paul Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] better define: matrix comparison and cbind issue
Is this what you want? A - read.table(textConnection(A v w x z + G x z y w + C y v z x + D x v w z + ), as.is=T) B - read.table(textConnection(F z x y z + D x z w v + E x z w v + ), as.is=T) A V1 V2 V3 V4 V5 1 A v w x z 2 G x z y w 3 C y v z x 4 D x v w z B V1 V2 V3 V4 V5 1 F z x y z 2 D x z w v 3 E x z w v # create logical vector of matching values index - is.na(match(A[,1], B[,1])) A[index,] V1 V2 V3 V4 V5 1 A v w x z 2 G x z y w 3 C y v z x On 11/29/06, H. Paul Benton [EMAIL PROTECTED] wrote: Ok so something like this. A 1 2 3 4 5 A v w x z G x z y w C y v z x D x v w z B 1 2 3 4 5 F z x y z D x z w v E x z w v So here I would just be comparing col 1. I would compare A[1,] to B[1,] and then I would see that A[1,4] has the same element as B[1,2], so I would remove A[,4]. Making A: A 1 2 3 4 5 A v w x z G x z y w C y v z x :) Cheers, Paul Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute -Original Message- From: Leeds, Mark (IED) [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 2:19 PM To: H. Paul Benton Subject: RE: [R] better define: matrix comparison and cbind issue paul : it honestly might be me ( seriously ) but you say 6th and 9th column but then You say A[9,x] and B[9,x] which are all the elements in the 9th row of A and 9th row of B respectively. Could you make 2 small sample matrices and the result matrix and explain it that way ? Honestly though, someone else may understand so maybe wait to see if someone else responds with an answer/suggestion. Good luck. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of H. Paul Benton Sent: Wednesday, November 29, 2006 5:09 PM To: r-help@stat.math.ethz.ch Subject: [R] better define: matrix comparison and cbind issue Hello, Sorry to all for the lack of communication, and thanks to those with the suggestions. So I have two matrixes which are different sizes, same column number but different row number. What I would like to do is to compare A to B. In the 6 and 9th column there are ref numbers (molecular masses to be exact). I would like to check A and B by these columns. If I find that the number in A[9,x] and B[9, x] are the same then I want to remove the row that it is comparing from A. So overall, if something appears in B then I remove it from A. Cheers, Paul Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This is not an offer (or solicitation of an offer) to buy/sell the securities/instruments mentioned or an official confirmation. Morgan Stanley may deal as principal in or own or act as market maker for securities/instruments mentioned or may advise the issuers. This is not research and is not from MS Research but it may refer to a research analyst/research report. Unless indicated, these views are the author's and may differ from those of Morgan Stanley research or others in the Firm. We do not represent this is accurate or complete and we may not update this. Past performance is not indicative of future returns. For additional information, research reports and important disclosures, contact me or see https://secure.ms.com/servlet/cls. You should not use e-mail to request, authorize or effect the purchase or sale of any security or instrument, to send transfer instructions, or to effect any other transactions. We cannot guarantee that any such requests received via e-mail will be processed in a timely manner. This communication is solely for the addressee(s) and may contain confidential information. We do not waive confidentiality by mistransmission. Contact me if you do not wish to receive these communications. In the UK, this communication is directed in the UK to those persons who are market counterparties or intermediate customers (as defined in the UK Financial Services Authority's rules). __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
Re: [R] better define: matrix comparison and cbind issue
Jim, Is there a way to make match fuzzy? I had a look at ?match but couldn't see anything about it so I thought I would as the guru. Also can I do something like index - is.na(match(A[,1 2], B[,1 2])) ? index - is.na(match(A[,1 2], B[,1 2])) index [1] TRUE TRUE TRUE TRUE TRUE A[index,] V1 V2 V3 V4 V5 1 Avwxz 2 Gxzyw 3 Cyvzx 4 Dxvwz NA NA NA NA NA NA Thanks again, PB -Original Message- From: jim holtman [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 6:19 PM To: H. Paul Benton Cc: Leeds, Mark (IED); r-help@stat.math.ethz.ch Subject: Re: [R] better define: matrix comparison and cbind issue Is this what you want? A - read.table(textConnection(A v w x z + G x z y w + C y v z x + D x v w z + ), as.is=T) B - read.table(textConnection(F z x y z + D x z w v + E x z w v + ), as.is=T) A V1 V2 V3 V4 V5 1 A v w x z 2 G x z y w 3 C y v z x 4 D x v w z B V1 V2 V3 V4 V5 1 F z x y z 2 D x z w v 3 E x z w v # create logical vector of matching values index - is.na(match(A[,1], B[,1])) A[index,] V1 V2 V3 V4 V5 1 A v w x z 2 G x z y w 3 C y v z x On 11/29/06, H. Paul Benton [EMAIL PROTECTED] wrote: Ok so something like this. A 1 2 3 4 5 A v w x z G x z y w C y v z x D x v w z B 1 2 3 4 5 F z x y z D x z w v E x z w v So here I would just be comparing col 1. I would compare A[1,] to B[1,] and then I would see that A[1,4] has the same element as B[1,2], so I would remove A[,4]. Making A: A 1 2 3 4 5 A v w x z G x z y w C y v z x :) Cheers, Paul Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute -Original Message- From: Leeds, Mark (IED) [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 2:19 PM To: H. Paul Benton Subject: RE: [R] better define: matrix comparison and cbind issue paul : it honestly might be me ( seriously ) but you say 6th and 9th column but then You say A[9,x] and B[9,x] which are all the elements in the 9th row of A and 9th row of B respectively. Could you make 2 small sample matrices and the result matrix and explain it that way ? Honestly though, someone else may understand so maybe wait to see if someone else responds with an answer/suggestion. Good luck. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of H. Paul Benton Sent: Wednesday, November 29, 2006 5:09 PM To: r-help@stat.math.ethz.ch Subject: [R] better define: matrix comparison and cbind issue Hello, Sorry to all for the lack of communication, and thanks to those with the suggestions. So I have two matrixes which are different sizes, same column number but different row number. What I would like to do is to compare A to B. In the 6 and 9th column there are ref numbers (molecular masses to be exact). I would like to check A and B by these columns. If I find that the number in A[9,x] and B[9, x] are the same then I want to remove the row that it is comparing from A. So overall, if something appears in B then I remove it from A. Cheers, Paul Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This is not an offer (or solicitation of an offer) to buy/sell the securities/instruments mentioned or an official confirmation. Morgan Stanley may deal as principal in or own or act as market maker for securities/instruments mentioned or may advise the issuers. This is not research and is not from MS Research but it may refer to a research analyst/research report. Unless indicated, these views are the author's and may differ from those of Morgan Stanley research or others in the Firm. We do not represent this is accurate or complete and we may not update this. Past performance is not indicative of future returns. For additional information, research reports and important disclosures, contact me or see https://secure.ms.com/servlet/cls. You should not use e-mail to request, authorize or effect the purchase or sale of any security or instrument, to send transfer instructions, or to effect any other transactions. We cannot guarantee that any such requests received via e-mail will be processed in a timely manner. This communication is solely for the addressee(s) and may contain confidential information. We do not waive confidentiality by mistransmission. Contact me if you do not wish to receive
Re: [R] better define: matrix comparison and cbind issue
So I guess I was thinking like a fuzzy if. I'm matching a number in my matrix and I would like to see if the numbers are the same to 0.1 accuracy. So in an if statement I would do something like: if(any((A[i,6] - B[j,6]) = 0.1)) is this possible with match? Sorry for my lack of R knowledge. -Original Message- From: jim holtman [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 7:17 PM To: H. Paul Benton Subject: Re: [R] better define: matrix comparison and cbind issue What do you mean by 'fuzzy'? If you want to compare multiple columns, you can compare each one separately and then use boolean AND/OR to combine them in whatever way you desire. col1 - is.na(match(A[,1], B[,1])) col2 - is.na(match(A[,2], B[,2])) A[col1 col2,] # rows with no matches A[col1 | col2,] # rows with none or one match On 11/29/06, H. Paul Benton [EMAIL PROTECTED] wrote: Jim, Is there a way to make match fuzzy? I had a look at ?match but couldn't see anything about it so I thought I would as the guru. Also can I do something like index - is.na(match(A[,1 2], B[,1 2])) ? index - is.na(match(A[,1 2], B[,1 2])) index [1] TRUE TRUE TRUE TRUE TRUE A[index,] V1 V2 V3 V4 V5 1 Avwxz 2 Gxzyw 3 Cyvzx 4 Dxvwz NA NA NA NA NA NA Thanks again, PB __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with the plm package (2)
I haven't seen any replies to this, so I will offer some suggestions even though I'm not familiar with 'plm'. 1. The standard formula syntax in S-Plus and R is that y ~ x is a request to estimate b0 and b1 in y = b0+b1*x+error. Since this already includes 1, it is essentially equivalent to y~1+x. To estimate a noconstant model, use something like y~x-1. 2. Have you tried an email directly to the official plm maintainer? An email address for this can be found using help(package=plm). 3. Panel data is a special case of mixed effects data. The best software I know for that the 'nlme' package, which is part of the standard R distribution. The best book on the subject that I know is Pinheiro and Bates (2000) Mixed-Effects Models in S and S-Plus (Springer). The ~R\library\nlme\scripts subdirectory of your R installation directory contains files with names like ch01.R, ch02.R, etc. These provide R scripts for producing the analyses in the book. You can make local copies of these scripts and work through them line by line, trying different things, etc. The R syntax is slightly different from that in the book, e.g., x^2 in a formula must be specified as I(x^2). These differences are overall very minor and easy to learn. However, using exactly what appears in the book without modification will in a few cases be misinterpreted, leading to very different results. I had a difficult time understanding what was happening until I found this. Hope this helps. Spencer Graves Giangiacomo Bravo wrote: Thanks a lot for the quick answerd I received and that helped me to solve my first (simple) problem with the plm package. Unfortunatley, here's another one: I do not know why, but I'm unable to estimate a simple model in the form y ~ 1 + x When I try zz - plm(y ~ 1 + x , data=mydata) I obtain Errore in X.m[, coef.within, drop = F] : numero di dimensioni errato which means that the number of dimensions is wrong in X.m[, coef.within, drop = F]. However, I have no problem to estimate a more complex model, e.g. zz - plm(y ~ 1 + x + I(x^2), data=mydata) in this case everything is ok. What's wrong? Thank you, Giangiacomo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tests for NULL objects
On Nov 29, 2006, at 7:58 PM, Benilton Carvalho wrote: But that's okay, just a matter of adding an extra test (already done). I'm guessing it would be something like: all(is.na(v) | v==2) When I asked for clarification about the reasons for this, I assumed that: if all(v) is TRUE == any(v) is TRUE; for all (logical) v... When actually: if all(v) is TRUE == any(v) is TRUE; for all (logical) v of length = 1. I like to think of it as: in order for the statement all elements of v are TRUE to be false, one would need to provide an element of v which is false. Since that is not possible if v has no elements, then the statement all elements of v are TRUE can't be false, hence has to be true. Similarly, the statement any(v) is TRUE translates to there is an element of v that is true. Since there are no elements in v, this can't possibly happen. So this statement is false. As for the sums and products, the explanation that Martin linked to sums it up nicely. Basically, suppose we have two vectors, v,w, and v is actually numeric(0). Then sum(c(v,w)) ought to be sum(v) + sum(w) (since that would be the case for any other honest vectors). But since c(v,w) is really w, the only way this will happen is if sum(v) = 0. Same for products, since in that case prod(c(v,w))=prod(v) times prod(w). Thank you, benilton Haris __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error in latex() : n.group : RESOLVED
that was trivial and logical ... You just have to download the source from the repository and then use the function source() with it in your script ... 2006/11/24, Ben [EMAIL PROTECTED]: When I was running the function latex() I got an error about a not found object : n.rgroup ... I searched the archive of this (great!) list and found a solution (http://tolstoy.newcastle.edu.au/R/e2/help/06/10/3995.html) : source('http://biostat.mc.vanderbilt.edu/tmp/getLatestSource.s' http://biostat.mc.vanderbilt.edu/tmp/getLatestSource.s%27); getLatestSource('latex'); It works very well ! except when I don't have an internet connection (of course) ... Does someone know how to fix this permanently ? Cordially, [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] packages about discriminant analysis
On Wed, 29 Nov 2006, Feng Qiu wrote: Hi guys: I'm testing some statistic discriminant analysis methods in R. But I couldn't find the package for these methods: Where have you been looking? MASS (the book) has the first two of these, and using search.r-project.org would also give useful hits. 1. Discriminant analysis implemented with nearest neighbor method, I don't think there is such a thing, but knn() in package class seems to be what you intended (it is classification not discriminant analysis) 2. logistic discriminant analysis glm() and multinom() (in package nnet). 3. POLYCLASS algorithm( there is such a function in S-Plus, namely poly.fit from polyclass library. Is there a corresponding library in R? ) Package polspline. Any kind of help is highly appreciated! -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Removing terms from formula
Do you really want the 1? Normally the intercept is not explicitly given unless there are no other terms in the formula so assuming you only want it if you have otherwise removed all the variables then: zap1 - function(fo) { L - sapply(all.vars(fo[[length(fo)]]), function(x) nlevels(get(x)), simplify = FALSE) fo - eval.parent(do.call(substitute, list(fo, L[c(L) == 1]))) update(fo, . ~ .) } # test data x - y - 1:3 z - factor(0*x) fo - x ~ y + z # test zap1(fo) # x ~ y y - z zap1(fo) # x ~ 1 On 11/29/06, McGehee, Robert [EMAIL PROTECTED] wrote: R-help, Given a simple linear model, say lm(x ~ y + z), I would like to remove model terms that are factors with only one level. Thus, if 'z' were a factor with only one level, lm(x ~ y + z) becomes lm(x ~ y + 1). Likewise, if both 'y' and 'z' are one-level factors, then the resulting calculation is simply lm(x ~ 1). Unfortunately, I have not been able to come up with an elegant solution to this. Any suggestions would be greatly appreciated. Thanks, Robert Robert McGehee, CFA Quantitative Analyst Geode Capital Management, LLC One Post Office Square, 28th Floor | Boston, MA | 02109 Tel: 617/392-8396Fax:617/476-6389 mailto:[EMAIL PROTECTED] This e-mail, and any attachments hereto, are intended for us...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Removing terms from formula
One correction (to the get): Do you really want the 1? Normally the intercept is not explicitly given unless there are no other terms in the formula so assuming you only want it if you have otherwise removed all the variables then: zap1 - function(fo) { L - sapply(all.vars(fo[[length(fo)]]), function(x) nlevels(get(x, environment(fo))), simplify = FALSE) fo - eval.parent(do.call(substitute, list(fo, L[c(L) == 1]))) update(fo, . ~ .) } # test data x - y - 1:3 z - factor(0*x) fo - x ~ y + z # test zap1(fo) # x ~ y y - z zap1(fo) # x ~ 1 On 11/30/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Do you really want the 1? Normally the intercept is not explicitly given unless there are no other terms in the formula so assuming you only want it if you have otherwise removed all the variables then: zap1 - function(fo) { L - sapply(all.vars(fo[[length(fo)]]), function(x) nlevels(get(x)), simplify = FALSE) fo - eval.parent(do.call(substitute, list(fo, L[c(L) == 1]))) update(fo, . ~ .) } # test data x - y - 1:3 z - factor(0*x) fo - x ~ y + z # test zap1(fo) # x ~ y y - z zap1(fo) # x ~ 1 On 11/29/06, McGehee, Robert [EMAIL PROTECTED] wrote: R-help, Given a simple linear model, say lm(x ~ y + z), I would like to remove model terms that are factors with only one level. Thus, if 'z' were a factor with only one level, lm(x ~ y + z) becomes lm(x ~ y + 1). Likewise, if both 'y' and 'z' are one-level factors, then the resulting calculation is simply lm(x ~ 1). Unfortunately, I have not been able to come up with an elegant solution to this. Any suggestions would be greatly appreciated. Thanks, Robert Robert McGehee, CFA Quantitative Analyst Geode Capital Management, LLC One Post Office Square, 28th Floor | Boston, MA | 02109 Tel: 617/392-8396Fax:617/476-6389 mailto:[EMAIL PROTECTED] This e-mail, and any attachments hereto, are intended for us...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] strptime - %p format doesn't seem to be working
On Thu, 30 Nov 2006, Edward Abraham wrote: Hi there, Am I missing something? The %p format, which should match against AM/PM, seems to be broken in R 2.3.1 running on Windows XP SP2. For example, the following fails strptime(10AM, %I%p) [1] NA whereas the this works as you would expect, but is ambiguous strptime(10, %I) [1] 2006-11-30 10:00:00 Does this error reproduce on other machines, or is it something wrong with my setup? My Windows XP, R 2.4.0 in English gives strptime(10AM, %I%p) [1] 2006-11-30 10:00:00 So, it is a problem specific to you at least for R 2.4.0 (and the posting guide asked you to update before posting). However, the help both warns about this being locale-specific and also If the date string does not specify the date completely, the returned answer may be system-specific. The most common behaviour is to assume that unspecified seconds, minutes or hours are zero, and a missing year, month or day is the current one. If it specifies a date incorrectly, reliable implementations will give an error and the date is reported as 'NA'. so what you say should work is explicitly documented to not necessarily do so. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R_WinEdt question
if I want to put fig1plot to the left, figYPplot to the right figYAaplot on the bottom. How to modify the following cod to do these? \begin{figure}[H] \centering \begin{minipage}[t]{0.5\textwidth} \centering label=fig1plot,fig=TRUE,echo=FALSE= fig1plot @ %\caption{Caption 1} \end{minipage} \begin{minipage}[t]{0.5\textwidth} \centering label=figYPplot,fig=TRUE,echo=FALSE= figYPplot @ %\caption{Caption 1} \end{minipage} \begin{minipage}[t]{1.0\textwidth} \centering label=figYAaplot,fig=TRUE,echo=FALSE= figYAaplot @ %\caption{Caption 1} \end{minipage} \caption{The first look at the relationship between variables in data set} \label{fig:one} \end{figure} __ R-help@stat.math.ethz.ch 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.