Re: [R] matrix logic
Tom wrote: On Tue, 10 Jan 2006 20:25:23 -0500, r user [EMAIL PROTECTED] wrote: I have 2 dataframes, each with 5 columns and 20 rows. They are called data1 and data2.I wish to create a third dataframe called data3, also with 5 columns and 20 rows. I want data3 to contains the values in data1 when the value in data1 is not NA. Otherwise it should contain the values in data2. I have tried afew methids, but they do not seem to work as intended.: data3-ifelse(is.na(data1)=F,data1,data2) and data3[,]-ifelse(is.na(data1[,])=F,data1[,],data2[,]) Please suggest the “best” way. Better way is to have the Syntax correct: data3 - ifelse(is.na(data1), data2, data1) Please check the archives for almost millions of posts asking more or less this question...! Not sure about the bast but... a-c(1,2,3,NA,5) b-c(4,4,4,4,4) c-a c[which(is.na(a))]-b[which(is.na(a))] Why do you want to know which()? na - is.na(a) c[na] - b[na] Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] reading contigency tables
ronggui wrote: I think it can.But if you provide more information,you will be more help. for example,you had better give a reproducable example in you email. 2006/1/11, Naiara S. Pinto [EMAIL PROTECTED]: Hi all, I need some help using read.ftable to read a contingency table. My columns are organized as follows: order--family--species--location--number of individuals What is the problem with read.table()? Uwe Ligges I couldn't figure out how to change the data on my text file to be imported into R; and after you do that, is it possible to convert the table into a data frame? Any tips would be greatly appreciatted! Thanks a lot, Naiara. Naiara S. Pinto Ecology, Evolution and Behavior 1 University Station A6700 Austin, TX, 78712 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] graphics: axis label
Johannes Hüsing wrote: Hello, par(las=1) sets the orientation of the axis labels to horizontal. That is, the tick mark labels. How do I set the orientation of the axis label, which annotates the variable plotted along the axis, to horizontal? Sorry for asking such a basic question here, but I haven't found anything in the description of the pars. You have to use a call to text() and place it into the margins by specifying, e.g., par(xpd=TRUE) as in: plot(1:10, ylab=) par(xpd=TRUE, mar=c(4,8,0,0)+.1) text(0, 5.5, Hallo Johannes!, adj=1) Uwe Greetings Johannes __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Thunderbird misrepresents manuals
Hi there, I hope that I am in the right forum. I am using Exceed on a WinNT2000 machine, connected to Solaris SunOS fluke 5.9 Generic_118558-11 sun4u sparc SUNW,Sun-Fire-480R with Mozilla Firefox 1.0.7. Problem: Manuals like R-exts.html, R-lang.html, R-intro.html, R-admin.html, but *not* -- Dr. Christian W. Hoffmann, Swiss Federal Research Institute WSL Mathematics + Statistical Computing Zuercherstrasse 111 CH-8903 Birmensdorf, Switzerland Tel +41-44-7392-277 (office) -111(exchange) Fax +41-44-7392-215 (fax) [EMAIL PROTECTED] http://www.wsl.ch/staff/christian.hoffmann International Conference 5.-7.6.2006 Ekaterinburg Russia Climate changes and their impact on boreal and temperate forests http://ecoinf.uran.ru/conference/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Obtaining the adjusted r-square given the regression coefficients
Alexandra R. M. de Almeida wrote: Dear list I want to obtain the adjusted r-square given a set of coefficients (without the intercept), and I don't know if there is a function that does it. Exist I know that if you make a linear You can read the code of summary.lm and adapt it. Uwe Ligges regression, you enter the dataset and have in summary the adjusted r-square. But this is calculated using the coefficients that R obtained,and I want other coefficients that i calculated separately and differently (without the intercept term too). I have made a function based in the equations of the book Linear Regression Analisys (Wiley Series in probability and mathematical statistics), but it doesn't return values between 0 and 1. What is wrong The functions is given by: adjustedR2-function(Y,X,saM) { if(is.matrix(Y)==F) (Y-as.matrix(Y)) if(is.matrix(X)==F) (X-as.matrix(X)) if(is.matrix(saM)==F) (saM-as.matrix(saM)) RX-rent.matrix(X,1)$Rentabilidade.tipo RY-rent.matrix(Y,1)$Rentabilidade.tipo r2m-matrix(0,nrow=ncol(Y),ncol=1) RSS-matrix(0,ncol=ncol(Y),nrow=1) SYY-matrix(0,ncol=ncol(Y),nrow=1) for (i in 1:ncol(RY)) { RSS[,i]-(t(RY[,i])%*%RY[,i])-(saM[i,]%*%(t(RX)%*%RX)%*%t(saM)[,i]) SYY[,i]-sum((RY[,i]-mean(RY[,i]))^2) r2m[i,]-1-(RSS[,i]/SYY[,i])*((nrow(RY))/(nrow(RY)-ncol(saM)-1)) } dimnames(r2m)-list(colnames(Y),c(Adjusted R-square)) return(r2m) } Thanks! Alexandra Alexandra R. Mendes de Almeida - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matrix logic
The equality operator is == not =. So you need is.na(data1) == FALSE (F is a variable, and FALSE is the non-truth value), or, clearer, ifelse(!is.na(data1), data1, data2) Another way is data3 - data1 data3[is.na(data1)] - data2[is.na(data1)] which is more efficient but less clear. On Tue, 10 Jan 2006, r user wrote: I have 2 dataframes, each with 5 columns and 20 rows. They are called data1 and data2.I wish to create a third dataframe called data3, also with 5 columns and 20 rows. I want data3 to contains the values in data1 when the value in data1 is not NA. Otherwise it should contain the values in data2. I have tried afew methids, but they do not seem to work as intended.: data3-ifelse(is.na(data1)=F,data1,data2) and data3[,]-ifelse(is.na(data1[,])=F,data1[,],data2[,]) Please suggest the best way. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Correct way to test for exact dimensions of matrix or array
Gabor == Gabor Grothendieck [EMAIL PROTECTED] on Tue, 10 Jan 2006 14:47:57 -0500 writes: Gabor If its just succint you are after then this is slightly Gabor shorter: Gabor identical(dim(x)+0, c(3,5)) indeed, or, less succinct, but maybe more readable (and along the top-level function checks I had proposed yesterday): !is.null(d - dim(x)) all(d == c(3,5)) Gabor On 1/10/06, Gregory Jefferis [EMAIL PROTECTED] wrote: Thanks for suggestions. This is a simple question in principle, but there seem to be some wrinkles - I am always having to think quite carefully about how to test for equality in R. I should also have said that I would like the check to be efficient as well safe and succinct. One suggestion was: isTRUE(all.equal(dim(obj), c(3, 5))) But that is not so efficient because all.equal does lots of work esp if it the objects are not equal. Another suggestion was: all( dim( obj) == c(3,5) ) But that is not safe eg because dim(vector(10)) is NULL and all(NULL==c(3,5)) is actually TRUE (to my initial surprise) so vectors would pass through the net. So, so far the only way that is efficient, safe and succinct is: identical( dim( obj) , as.integer(c(3,5))) Martin Maechler pointed out that at the beginning of a function you might want to break down the test into something less succinct, that printed more specific error messages - a good suggestion for a top level function that is supposed to be user friendly. Any other suggestions? Many thanks, Greg Jefferis. On 10/1/06 15:13, Martin Maechler [EMAIL PROTECTED] wrote: Gregory == Gregory Jefferis [EMAIL PROTECTED] on Tue, 10 Jan 2006 14:47:43 + writes: Gregory Dear R Users, Gregory I want to test the dimensions of an incoming Gregory vector, matrix or array safely Gregory and succinctly. Specifically I want to check if Gregory the unknown object has exactly 2 dimensions with a Gregory specified number of rows and columns. Gregory I thought that the following would work: obj=matrix(1,nrow=3,ncol=5) identical( dim( obj) , c(3,5) ) Gregory [1] FALSE Gregory But it doesn't because c(3,5) is numeric and the dims are integer. I Gregory therefore ended up doing something like: identical( dim( obj) , as.integer(c(3,5))) Gregory OR isTRUE(all( dim( obj) == c(3,5) )) the last one is almost perfect if you leave a way the superfluous isTRUE(..). But, you say that it's part of your function checking it's arguments. In that case, I'd recommend if(length(d - dim(obj)) != 2) stop('d' must be matrix-like) if(!all(d == c(3,5))) stop(the matrix must be 3 x 5) which also provides for nice error messages in case of error. A more concise form with less nice error messages is stopifnot(length(d - dim(obj)) == 2, d == c(3,50)) ## you can leave away all(.) for things in stopifnot(.) Gregory Neither of which feel quite right. Is there a 'correct' way to do this? Gregory Many thanks, You're welcome, Martin Maechler, ETH Zurich Gregory Greg Jefferis. Gregory PS Thinking about it, the second form is (doubly) wrong because: obj=array(1,dim=c(3,5,3,5)) isTRUE(all( dim( obj) == c(3,5) )) Gregory [1] TRUE Gregory OR obj=numeric(10) isTRUE(all( dim( obj) == c(3,5) )) Gregory [1] TRUE Gregory (neither of which are equalities that I am happy with!) -- Gregory Jefferis, PhD and: Research Fellow Department of Zoology St John's College University of Cambridge Cambridge Downing Street CB2 1TP Cambridge, CB2 3EJ United Kingdom Tel: +44 (0)1223 336683 +44 (0)1223 339899 Fax: +44 (0)1223 336676 +44 (0)1223 337720 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
Re: [R] Problem with making Matrix
You are mixing makes. GNU make (presumably gmake) passes on its -w argument to sub-makes, and my guess is that make is a BSD make that does not accept it. The simplest way out is to have the 'make' first in your path as GNU make whilst doing this. BTW, this really is not the appropriate place: the posting guide suggests the maintainers and then R-devel. On Wed, 11 Jan 2006, Andrew Robinson wrote: Hi R-help citizens, I'm having trouble making version 0.99-6 of Matrix on FreeBSD 6.0. The error message is: * Installing *source* package 'Matrix' ... ** libs gcc -I/usr/local/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES -fPIC -g -O2 -c Csparse.c -o Csparse.o ... numerous lines deleted ... gcc -I/usr/local/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES -fPIC -g -O2 -c triplet_to_col.c -o triplet_to_col.o f77 -fPIC -g -O2 -c zpotf2.f -o zpotf2.o f77 -fPIC -g -O2 -c zpotrf.f -o zpotrf.o touch CHOLMOD.stamp UMFPACK.stamp COLAMD.stamp CCOLAMD.stamp AMD.stamp Metis.stamp LDL.stamp gmake[1]: Entering directory `/tmp/R.INSTALL.WMODs1/Matrix/src/CHOLMOD' ( cd Lib ; make ) make: don't know how to make w. Stop gmake[1]: *** [library] Error 2 I am running: version _ platform i386-unknown-freebsd6.0 arch i386 os freebsd6.0 system i386, freebsd6.0 status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R sessionInfo() R version 2.2.1, 2005-12-20, i386-unknown-freebsd6.0 attached base packages: [1] methods stats graphics grDevices utils datasets [7] base NB I was able to install Matrix 0.98-7 using the FreeBSD make without any problem. If I try to make version 0.99-6 using the FreeBSD make then it fails with Missing dependency operator errors. Does anyone have any suggestions? Thanks much, Andrew -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matching country name tables from different sources
dear all, yes but the problem with soundex for example is that it does not work when an error occur in the first place (Canada vs Kanada) as it keeps the fist character. It seems that you have to look after an approximate string matching algorithm (for example, a very good one if from Porter-Jaro and Winkler at the US Census bureau or have o look to the book of Navarro about classification of algorithm). HTH and an happy new year, erik. -Message d'origine- De: Gabor Grothendieck A: Werner Wernersen Cc: r-help@stat.math.ethz.ch Date: 10/01/2006 21:16 Objet: Re: [R] matching country name tables from different sources One other thing to try could be soundex. ITs normally used for last names but it might work here too. Google to find the soundex encoding rules. Reviewing the country names might suggest minor modifications to the soundex algorithm to improve it for your case. On 1/10/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: You can improve it somewhat by first accepting all the largest matches and removing the rows and columns for those and repeatedly doing that with what is left. On 1/10/06, Werner Wernersen [EMAIL PROTECTED] wrote: Thanks for the nice code, Gabor! Unfortunately, it seems not to work for my purpose, confuses lots of countries when I compare two lists of over 150 countries each. Do you have any other suggestions? Gabor Grothendieck [EMAIL PROTECTED] schrieb: If they were the same you could use merge. To figure out the correspondence automatically or semiautomatically, try this: x - c(Canada, US, Mexico) y - c(Kanada, United States, Mehico) result - outer(x, y, function(x,y) mapply(lcs2, x, y)) result[] - sapply(result, nchar) # try both which.max and which.min and if you are lucky # one of them will give unique values and that is the one to use # In this case which.max does. apply(result, 1, which.max) # 1 2 3 # calculate longest common subsequence between 2 strings lcs2 - function(s1,s2) { longest - function(x,y) if (nchar(x) nchar(y)) x else y # Make sure args are strings a - as.character(s1); an - nchar(s1)+1 b - as.character(s2); bn - nchar(s2)+1 # If one arg is an empty string, returns the length of the other if (nchar(a)==0) return(nchar(b)) if (nchar(b)==0) return(nchar(a)) # Initialize matrix for calculations m - matrix(, nrow=an, ncol=bn) for (i in 2:an) for (j in 2:bn) m[i,j] - if (substr(a,i-1,i-1)==substr(b,j-1,j-1)) paste(m[i-1,j-1], substr(a,i-1,i-1), sep = ) else longest(m[i-1,j], m[i,j-1]) # Returns the distance m[an,bn] } On 1/10/06, Werner Wernersen wrote: Hi, Before I reinvent the wheel I wanted to kindly ask you for your opinion if there is a simple way to do it. I want to merge a larger number of tables from different data sources in R and the matching criterium are country names. The tables are of different size and sometimes the country names do differ slightly. Has anyone done this or any recommendation on what commands I should look at to automize this task as much as possible? Thanks a lot for your effort in advance. All the best, Werner - Telefonieren Sie ohne weitere Kosten mit Ihren Freunden von PC zu PC! [[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 Telefonieren Sie ohne weitere Kosten mit Ihren Freunden von PC zu PC! Jetzt Yahoo! Messenger installieren! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html ** Afin d'eviter toute propagation de virus informatique, et en complement des dispositifs en place, ce message (et ses pieces jointes s'il y en a) a ete automatiquement analyse par un antivirus de messagerie. ** ** Afin d'eviter toute propagation de virus informatique, et en complement des dispositifs en place, ce message (et ses pieces jointes s'il y en a) a ete automatiquement analyse par un antivirus de messagerie. ** [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Obtaining the adjusted r-square given the regression coef ficients
Hello Alexandra, R2 is only defined for regressions with intercept. See a decent econometrics textbook for its derivation. HTH, Bernhard -Ursprüngliche Nachricht- Von: Alexandra R. M. de Almeida [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 11. Januar 2006 03:48 An: r-help@stat.math.ethz.ch Betreff: [R] Obtaining the adjusted r-square given the regression coefficients Dear list I want to obtain the adjusted r-square given a set of coefficients (without the intercept), and I don't know if there is a function that does it. Exist I know that if you make a linear regression, you enter the dataset and have in summary the adjusted r-square. But this is calculated using the coefficients that R obtained,and I want other coefficients that i calculated separately and differently (without the intercept term too). I have made a function based in the equations of the book Linear Regression Analisys (Wiley Series in probability and mathematical statistics), but it doesn't return values between 0 and 1. What is wrong The functions is given by: adjustedR2-function(Y,X,saM) { if(is.matrix(Y)==F) (Y-as.matrix(Y)) if(is.matrix(X)==F) (X-as.matrix(X)) if(is.matrix(saM)==F) (saM-as.matrix(saM)) RX-rent.matrix(X,1)$Rentabilidade.tipo RY-rent.matrix(Y,1)$Rentabilidade.tipo r2m-matrix(0,nrow=ncol(Y),ncol=1) RSS-matrix(0,ncol=ncol(Y),nrow=1) SYY-matrix(0,ncol=ncol(Y),nrow=1) for (i in 1:ncol(RY)) { RSS[,i]-(t(RY[,i])%*%RY[,i])-(saM[i,]%*%(t(RX)%*%RX)%*%t(saM)[,i]) SYY[,i]-sum((RY[,i]-mean(RY[,i]))^2) r2m[i,]-1-(RSS[,i]/SYY[,i])*((nrow(RY))/(nrow(RY)-ncol(saM)-1)) } dimnames(r2m)-list(colnames(Y),c(Adjusted R-square)) return(r2m) } Thanks! Alexandra Alexandra R. Mendes de Almeida - [[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 * Confidentiality Note: The information contained in this mess...{{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
Re: [R] Problem with making Matrix
On Wed, Jan 11, 2006 at 08:05:22AM +, Prof Brian Ripley wrote: You are mixing makes. GNU make (presumably gmake) passes on its -w argument to sub-makes, and my guess is that make is a BSD make that does not accept it. The simplest way out is to have the 'make' first in your path as GNU make whilst doing this. Thanks very much, that was just right. I moved the original make, and placed a symlink to gmake there instead. Matrix then installed just fine. BTW, this really is not the appropriate place: the posting guide suggests the maintainers and then R-devel. Ah, that was a mental slip. My apologies. Andrew On Wed, 11 Jan 2006, Andrew Robinson wrote: Hi R-help citizens, I'm having trouble making version 0.99-6 of Matrix on FreeBSD 6.0. The error message is: * Installing *source* package 'Matrix' ... ** libs gcc -I/usr/local/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES -fPIC -g -O2 -c Csparse.c -o Csparse.o ... numerous lines deleted ... gcc -I/usr/local/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES -fPIC -g -O2 -c triplet_to_col.c -o triplet_to_col.o f77 -fPIC -g -O2 -c zpotf2.f -o zpotf2.o f77 -fPIC -g -O2 -c zpotrf.f -o zpotrf.o touch CHOLMOD.stamp UMFPACK.stamp COLAMD.stamp CCOLAMD.stamp AMD.stamp Metis.stamp LDL.stamp gmake[1]: Entering directory `/tmp/R.INSTALL.WMODs1/Matrix/src/CHOLMOD' ( cd Lib ; make ) make: don't know how to make w. Stop gmake[1]: *** [library] Error 2 I am running: version _ platform i386-unknown-freebsd6.0 arch i386 os freebsd6.0 system i386, freebsd6.0 status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R sessionInfo() R version 2.2.1, 2005-12-20, i386-unknown-freebsd6.0 attached base packages: [1] methods stats graphics grDevices utils datasets [7] base NB I was able to install Matrix 0.98-7 using the FreeBSD make without any problem. If I try to make version 0.99-6 using the FreeBSD make then it fails with Missing dependency operator errors. Does anyone have any suggestions? Thanks much, Andrew -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 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 -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Space between axis label and tick labels
I'm writing an publication in two column format and need to shrink some plots. After increasing the axis labels it does not look nice at all. The y-axis label and tick labels almost touch each other and the x-axis tick labels expand into the plot instead of away from it. Is there a better way than cex to control the: 1) font size of axis and tick labels 2) font thickness 3) placement of both axis and yick labels Cheers, Kare -- ### Kare Edvardsen [EMAIL PROTECTED] Norwegian Institute for Air Research (NILU) Polarmiljosenteret NO-9296 Tromso http://www.nilu.no Swb. +47 77 75 03 75 Dir. +47 77 75 03 90 Fax. +47 77 75 03 76 Mob. +47 90 74 60 69 ### __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Improving R-Intro {was Wikis etc.}
David == David Forrest [EMAIL PROTECTED] on Mon, 9 Jan 2006 11:54:30 -0600 (CST) writes: .. .. David Since R has such an extensive set of extensions, David maybe we need a section in the R-intro documentation David near David http://cran.r-project.org/doc/manuals/R-intro.html#Writing-your-own-functions David titled Finding existing functions. It could David explain the difference between base and recommended, David installed, CRAN, and how someone can find and use David things in these areas using help(), '?', David help.search(), help.start(), RSiteSearch(), and the David mailing lists. That's a good suggestion. The file to improve is the texinfo source file (the *.html is produced from it, as well as the *.pdf version of the manual), is always available from the subversion archive (as all the rest of the R sources, past and present), the intro manual being https://svn.r-project.org/R/trunk/doc/manual/R-intro.texi So, yes, we'd welcome (a patch against / an improved version of) the above file! Martin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matching country name tables from different sources
On Tue, 10 Jan 2006, McGehee, Robert wrote: I would throw a tolower() around s1 and s2 so that 'canada' matches with 'CANADA', and perhaps consider using a Levenshtein distance rather than the longest common subsequence. An algorithm for Levenshtein distance can be found here (courtesy of Stephen Upton) https://stat.ethz.ch/pipermail/r-help/2005-January/062254.html Or even ?agrep - uses Levenshtein edit distance and has an argument for ignoring case. First hit in RSiteSearch(fuzzy match), by the way. Robert -Original Message- From: Werner Wernersen [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 10, 2006 2:00 PM To: Gabor Grothendieck Cc: r-help@stat.math.ethz.ch Subject: Re: [R] matching country name tables from different sources Thanks for the nice code, Gabor! Unfortunately, it seems not to work for my purpose, confuses lots of countries when I compare two lists of over 150 countries each. Do you have any other suggestions? Gabor Grothendieck [EMAIL PROTECTED] schrieb: If they were the same you could use merge. To figure out the correspondence automatically or semiautomatically, try this: x - c(Canada, US, Mexico) y - c(Kanada, United States, Mehico) result - outer(x, y, function(x,y) mapply(lcs2, x, y)) result[] - sapply(result, nchar) # try both which.max and which.min and if you are lucky # one of them will give unique values and that is the one to use # In this case which.max does. apply(result, 1, which.max) # 1 2 3 # calculate longest common subsequence between 2 strings lcs2 - function(s1,s2) { longest - function(x,y) if (nchar(x) nchar(y)) x else y # Make sure args are strings a - as.character(s1); an - nchar(s1)+1 b - as.character(s2); bn - nchar(s2)+1 # If one arg is an empty string, returns the length of the other if (nchar(a)==0) return(nchar(b)) if (nchar(b)==0) return(nchar(a)) # Initialize matrix for calculations m - matrix(, nrow=an, ncol=bn) for (i in 2:an) for (j in 2:bn) m[i,j] - if (substr(a,i-1,i-1)==substr(b,j-1,j-1)) paste(m[i-1,j-1], substr(a,i-1,i-1), sep = ) else longest(m[i-1,j], m[i,j-1]) # Returns the distance m[an,bn] } On 1/10/06, Werner Wernersen wrote: Hi, Before I reinvent the wheel I wanted to kindly ask you for your opinion if there is a simple way to do it. I want to merge a larger number of tables from different data sources in R and the matching criterium are country names. The tables are of different size and sometimes the country names do differ slightly. Has anyone done this or any recommendation on what commands I should look at to automize this task as much as possible? Thanks a lot for your effort in advance. All the best, Werner - Telefonieren Sie ohne weitere Kosten mit Ihren Freunden von PC zu PC! [[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 - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem with making Matrix
Andrew == Andrew Robinson [EMAIL PROTECTED] on Wed, 11 Jan 2006 14:12:11 +1100 writes: Andrew Hi R-help citizens, Andrew I'm having trouble making version 0.99-6 of Matrix on FreeBSD 6.0. Andrew The error message is: Andrew * Installing *source* package 'Matrix' ... Andrew ** libs Andrew gcc -I/usr/local/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES -fPIC -g -O2 -c Csparse.c -o Csparse.o Andrew ... numerous lines deleted ... Andrew gcc -I/usr/local/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES -fPIC -g -O2 -c triplet_to_col.c -o triplet_to_col.o Andrew f77 -fPIC -g -O2 -c zpotf2.f -o zpotf2.o Andrew f77 -fPIC -g -O2 -c zpotrf.f -o zpotrf.o Andrew touch CHOLMOD.stamp UMFPACK.stamp COLAMD.stamp CCOLAMD.stamp AMD.stamp Metis.stamp LDL.stamp Andrew gmake[1]: Entering directory `/tmp/R.INSTALL.WMODs1/Matrix/src/CHOLMOD' Andrew ( cd Lib ; make ) Andrew make: don't know how to make w. Stop Andrew gmake[1]: *** [library] Error 2 Andrew I am running: version Andrew _ Andrew platform i386-unknown-freebsd6.0 Andrew arch i386 Andrew os freebsd6.0 Andrew system i386, freebsd6.0 Andrew status Andrew major2 Andrew minor2.1 Andrew year 2005 Andrew month12 Andrew day 20 Andrew svn rev 36812 Andrew language R sessionInfo() Andrew R version 2.2.1, 2005-12-20, i386-unknown-freebsd6.0 Andrew attached base packages: Andrew [1] methods stats graphics grDevices utils datasets Andrew [7] base Andrew NB I was able to install Matrix 0.98-7 using the FreeBSD make without any Andrew problem. Yes, 0.98-7 did not have the new CHOLMOD soureces yet. Andrew problem. If I try to make version 0.99-6 using the FreeBSD make then Andrew it fails with Missing dependency operator errors. Andrew Does anyone have any suggestions? It could be that in FreeBSD behaves differently from GNU make and there's something GNU specific in one of the various 'Makefile's... Ahh, yes, I think I have good guess: The src/CHOLMOD/Makefile has explicit calls to 'make' as in # Compile the C-callable libraries and the Demo programs. all: ( cd Lib ; make ) but from the error message above I see you are using 'gmake' which I assume is an alias for GNU make. Of course the explicit 'make' in these Makefiles is bad -- We (the Matrix authors) may be excused by the fact that it is not our code and we tried to change as little as possible in order to facilitate updates (when new versions of the upstream CHOLMOD code would come about). Can you try and replace 'make' by '$(MAKE)' in the following three places, and see if it works possibly after writing (in your shell) export MAKE=gmake or setenv MAKE gmake (depending on the kind of shell you have) ? AMD/Makefile: ( cd Source ; $(MAKE) lib ) AMD/Makefile: ( cd Source ; $(MAKE) clean ) CHOLMOD/Makefile: ( cd Lib ; $(MAKE) ) CHOLMOD/Makefile: ( cd Lib ; $(MAKE) ) CHOLMOD/Makefile: ( cd Lib ; $(MAKE) purge ) CHOLMOD/Makefile: ( cd Lib ; $(MAKE) clean ) UMFPACK/Makefile: ( cd Source ; $(MAKE) lib ) UMFPACK/Makefile: ( cd Source ; $(MAKE) clean ) Regards, Martin Maechler, ETH Zurich __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to obtain par(ask=TRUE) with trellis-plots
Dear alltogether, how can a delay like possible with par(ask=TRUE) be attained while using trellis-plots within a loop or something like that? the following draws each plot without waiting for a signal (mouse-klick), so par() does not work for that: library(nlme) for(i in 1:3) { fitlme - lme(Orthodont) par(ask=TRUE) # does not work with trellis print( plot(augPred(fitlme)) ) } thanks, leo -- email: [EMAIL PROTECTED] www: http://www.anicca-vijja.de/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] expected values of order statistics
normOrder() in SuppDists Anna Oganyan wrote: Hello, Could somebody point me, is there any function in R which returns expected values of order statistics for normal distribution? I have been looking and couldn't find it. Thanks! Anna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Bob Wheeler --- http://www.bobwheeler.com/ ECHIP, Inc. --- Randomness comes in bunches. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] gregexpr() - length of the matched text to a vector
Hi, I'm using gregexpr(). As a result something like this: # starting positions of the match: [[1]] [1] 7 18 # length of the matched text: attr(,match.length) [1] 4 4 Now, I'd like to have a matrix, 74 18 4 but I don't know how to handle the attr(,match.length) ...? The format of the output is pretty unclear to me in that respect. Thanks in advance, Petri -- Petri Palmu, M.Soc.Sc Statistician [EMAIL PROTECTED] Geneos Ltd tel:+358 9 4366 2512 gsm: +35840 55 249 55 fax:+ 358 9 4366 2523 P.O. Box 25 (Tukholmankatu 2) FIN-00251, Helsinki, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Homogenic groups generation - Randomisation
Dear R-users, We expect to create N homogenic groups of n features from an experimentation including N*n mesures. The aim of this is to prevent from group effects. How to do that with R functionalities. Does anyone know any methodes enabling this ? Best regards. Alexandre MENICACCI Bioinformatics - FOURNIER PHARMA 50, rue de Dijon - 21121 Daix - FRANCE [EMAIL PROTECTED] tél : 03.80.44.76.17 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Binary logistic modelling: setting conditions (defining thresholds) in the fitted model (lrm)
Dear Rlist, We are working with library(Design) R 2.2.1// When using the following fitted model: knots - 5 lrm.1- lrm(X8~rcs(X1,5),x=T,y=T) X8 (binary 0/1 vector) X1, X2 explantory variables We would like to set the probability of X8=1 to zero when the X2 variable is smaller than a defined threshold, e.g. X250, because the X1 variable is not correct (contains more errors) anymore when X250. How could we define this in the model smoothly without changing the values of the variables? We keep in mind that setting thresholds in not a good solution because then information is lost. Therefore we also tested the following model. However, towards operational methods or techniques setting thresholds is simplifying relationships. Especially in this case were we saw that X1 could contain more errors when X2 50. lrm.1- lrm(X8~rcs(X1,5)+ rcs(X2,5),x=T,y=T) Thanks a lot for feedback discussion, Jan Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] gregexpr() - length of the matched text to a vector
Now I found a solution that seems to work OK for me: attributes(gregexpr(expression, text)[[1]]) Petri At 15:00 11.1.2006 +0100, Petri Palmu wrote: Hi, I'm using gregexpr(). As a result something like this: # starting positions of the match: [[1]] [1] 7 18 # length of the matched text: attr(,match.length) [1] 4 4 Now, I'd like to have a matrix, 74 18 4 but I don't know how to handle the attr(,match.length) ...? The format of the output is pretty unclear to me in that respect. Thanks in advance, Petri -- Petri Palmu, M.Soc.Sc Statistician [EMAIL PROTECTED] Geneos Ltd tel:+358 9 4366 2512 gsm: +35840 55 249 55 fax:+ 358 9 4366 2523 P.O. Box 25 (Tukholmankatu 2) FIN-00251, Helsinki, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Petri Palmu, M.Soc.Sc Statistician [EMAIL PROTECTED] Geneos Ltd tel:+358 9 4366 2512 gsm: +35840 55 249 55 fax:+ 358 9 4366 2523 P.O. Box 25 (Tukholmankatu 2) FIN-00251, Helsinki, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matching country name tables from different sources
I was aware of that which is why I mentioned that it is usually used for matching last names rather than countries and noted possible need to modify the algorithm slightly. soundex is a relatively simple algorithm so its not too hard. For example, one could just code the first letter too. On 1/11/06, SAULEAU Erik-André [EMAIL PROTECTED] wrote: dear all, yes but the problem with soundex for example is that it does not work when an error occur in the first place (Canada vs Kanada) as it keeps the fist character. It seems that you have to look after an approximate string matching algorithm (for example, a very good one if from Porter-Jaro and Winkler at the US Census bureau or have o look to the book of Navarro about classification of algorithm). HTH and an happy new year, erik. -Message d'origine- De: Gabor Grothendieck A: Werner Wernersen Cc: r-help@stat.math.ethz.ch Date: 10/01/2006 21:16 Objet: Re: [R] matching country name tables from different sources One other thing to try could be soundex. ITs normally used for last names but it might work here too. Google to find the soundex encoding rules. Reviewing the country names might suggest minor modifications to the soundex algorithm to improve it for your case. On 1/10/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: You can improve it somewhat by first accepting all the largest matches and removing the rows and columns for those and repeatedly doing that with what is left. On 1/10/06, Werner Wernersen [EMAIL PROTECTED] wrote: Thanks for the nice code, Gabor! Unfortunately, it seems not to work for my purpose, confuses lots of countries when I compare two lists of over 150 countries each. Do you have any other suggestions? Gabor Grothendieck [EMAIL PROTECTED] schrieb: If they were the same you could use merge. To figure out the correspondence automatically or semiautomatically, try this: x - c(Canada, US, Mexico) y - c(Kanada, United States, Mehico) result - outer(x, y, function(x,y) mapply(lcs2, x, y)) result[] - sapply(result, nchar) # try both which.max and which.min and if you are lucky # one of them will give unique values and that is the one to use # In this case which.max does. apply(result, 1, which.max) # 1 2 3 # calculate longest common subsequence between 2 strings lcs2 - function(s1,s2) { longest - function(x,y) if (nchar(x) nchar(y)) x else y # Make sure args are strings a - as.character(s1); an - nchar(s1)+1 b - as.character(s2); bn - nchar(s2)+1 # If one arg is an empty string, returns the length of the other if (nchar(a)==0) return(nchar(b)) if (nchar(b)==0) return(nchar(a)) # Initialize matrix for calculations m - matrix(, nrow=an, ncol=bn) for (i in 2:an) for (j in 2:bn) m[i,j] - if (substr(a,i-1,i-1)==substr(b,j-1,j-1)) paste(m[i-1,j-1], substr(a,i-1,i-1), sep = ) else longest(m[i-1,j], m[i,j-1]) # Returns the distance m[an,bn] } On 1/10/06, Werner Wernersen wrote: Hi, Before I reinvent the wheel I wanted to kindly ask you for your opinion if there is a simple way to do it. I want to merge a larger number of tables from different data sources in R and the matching criterium are country names. The tables are of different size and sometimes the country names do differ slightly. Has anyone done this or any recommendation on what commands I should look at to automize this task as much as possible? Thanks a lot for your effort in advance. All the best, Werner - Telefonieren Sie ohne weitere Kosten mit Ihren Freunden von PC zu PC! [[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 Telefonieren Sie ohne weitere Kosten mit Ihren Freunden von PC zu PC! Jetzt Yahoo! Messenger installieren! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html ** Afin d'eviter toute propagation de virus informatique, et en complement des dispositifs en place, ce message (et ses pieces jointes s'il y en a) a ete automatiquement analyse par un antivirus de messagerie. ** ** Afin d'eviter toute propagation de virus informatique, et en complement des
Re: [R] gregexpr() - length of the matched text to a vector
Petri Palmu petri.palmu at geneos.fi writes: I'm using gregexpr(). As a result something like this: # starting positions of the match: [[1]] [1] 7 18 # length of the matched text: attr(,match.length) [1] 4 4 Now, I'd like to have a matrix, 74 18 4 something like x1 = gregexpr(iss,c(mississippi)) x2 = rbind(x1[[1]],attr(x1[[1]],match.length)) x2 [,1] [,2] [1,]25 [2,]33 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] gregexpr() - length of the matched text to a vector
Hi Petri, On 11 Jan 2006, [EMAIL PROTECTED] wrote: I'm using gregexpr(). As a result something like this: # starting positions of the match: [[1]] [1] 7 18 # length of the matched text: attr(,match.length) [1] 4 4 Now, I'd like to have a matrix, 74 18 4 but I don't know how to handle the attr(,match.length) ...? The format of the output is pretty unclear to me in that respect. Brief description of the format: a list. Each element of the list is a result that corresponds to a string element in the input character vector. Each element consists of an integer vector of starting positions for a match. The integer vector has a match.length atttribute consisting of an integer vector of match lengths. Whew. Would a matrix be better? Probably. To get a list of matrices you can do: txt [1] foobarfoobazfoofoo foobar [4] foofoofoo lapply(gregexpr(foo, txt), function(x) cbind(x, attr(x, match.length))) [[1]] x [1,] 1 3 [2,] 7 3 [3,] 13 3 [4,] 16 3 [[2]] x [1,] 1 3 [[3]] x [1,] -1 -1 [[4]] x [1,] 1 3 [2,] 4 3 [3,] 7 3 HTH, + seth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Binary logistic modelling: setting conditions (defining thresholds) in the fitted model (lrm)
Jan Verbesselt wrote: Dear Rlist, We are working with library(Design) R 2.2.1// When using the following fitted model: knots - 5 lrm.1- lrm(X8~rcs(X1,5),x=T,y=T) X8 (binary 0/1 vector) X1, X2 explantory variables We would like to set the probability of X8=1 to zero when the X2 variable is smaller than a defined threshold, e.g. X250, because the X1 variable is not correct (contains more errors) anymore when X250. Are you sure you want the prob(X8=1) to be zero or to you want to just constrain the regression function to be of a certain form? And keep in mind that if the measurement errors are moderate or better it is usually better to use the variable in its original form because otherwise real predictive information is lost. Frank How could we define this in the model smoothly without changing the values of the variables? We keep in mind that setting thresholds in not a good solution because then information is lost. Therefore we also tested the following model. However, towards operational methods or techniques setting thresholds is simplifying relationships. Especially in this case were we saw that X1 could contain more errors when X2 50. lrm.1- lrm(X8~rcs(X1,5)+ rcs(X2,5),x=T,y=T) Thanks a lot for feedback discussion, Jan -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Obtaining the adjusted r-square given the regression coefficients
Alexandra, some additional remarks taken from my past struggles with R2 :^) Without intercept the definition is indeed problematic, as Bernhard notes. First, to estimate a model omitting the intercept you simply have to specify -1 in the model formula (example on an in-built dataset, for data description see help(mtcars)): data(mtcars) attach(mtcars) mod-lm(mpg~hp+wt+qsec) # with intercept summary(mod) and mod0-lm(mpg~hp+wt+qsec-1) # without summary(mod0) The reported R2s are different not only in value (which is obvious) but also in the definition. In fact, there are 2 definitions of R2. With reference to the usual analysis of variance in OLS regression (see e.g. Ch.3 in Greene 2003, Econometric Analysis, and 3.5.2. in particular), let, in our example, SST-sum(mpg^2) # total sum of squares SSR-sum(fitted(mod)^2) # regression sum of squares SSE-sum(resid(mod)^2) # error sum of squares where (a) SST=SSR+SSE, as you may readily check, then the *uncentered* R2 is defined as uR2-SSR/SST while the *centered* R2 as cSST-sum((mpg-mean(mpg))^2) cSSR-sum((fitted(mod)-mean(mpg))^2) # as 1) mean(y)=mean(y_hat) cSSE-sum(resid(mod)^2) # as 2) mean(e)=0 cR2-cSSR/cSST and (b) cSST=cSSR+cSSE. The problem is that the meaning of R2 derives from decompositions (a) and (b), but while (a) always holds for OLS models, (b) only holds for models with an intercept (as do (1-2) above, on which it is based). Thus *centered R2 is meaningless in models without intercept*. People are used to cR2, though, so R reports cR2 for models with intercept, uR2 for those without (EViews, e.g., reports cR2 for both). Adjusted R2s are the same, adjusted by a factor penalizing for df. See Greene, who gives adjR2 = 1-(n-1)/(n-K)(1-R2) for n obs. and K regressors. Finally, it is of course feasible to calculate the model coefficients on your own, but it would be inefficient (R has an optimized routine for OLS, so you'd better use coef(lm(y~X))). Anyway, if you like, y-mpg # just for notational simplicity.. X-cbind(hp,wt,qsec) # add rep(1,length(hp)) to this data matrix # if you want an intercept b-solve(crossprod(X),crossprod(X,y)) # the coefficients for mod0 y_hat-X%*%b # fitted values for y e-y-y_hat# model residuals from which you can obtain anything you need. Cheers Giovanni Giovanni Millo Ufficio Studi Assicurazioni Generali SpA Via Machiavelli 4, 34131 Trieste (I) tel. +39 040 671184 fax +39 040 671160 * Original message: Date: Wed, 11 Jan 2006 09:16:46 - From: Pfaff, Bernhard Dr. [EMAIL PROTECTED] Subject: Re: [R] Obtaining the adjusted r-square given the regression coefficients To: 'Alexandra R. M. de Almeida' [EMAIL PROTECTED], r-help@stat.math.ethz.ch Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=iso-8859-1 Hello Alexandra, R2 is only defined for regressions with intercept. See a decent econometrics textbook for its derivation. HTH, Bernhard -Urspr?ngliche Nachricht- Von: Alexandra R. M. de Almeida [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 11. Januar 2006 03:48 An: r-help@stat.math.ethz.ch Betreff: [R] Obtaining the adjusted r-square given the regression coefficients Dear list I want to obtain the adjusted r-square given a set of coefficients (without the intercept), and I don't know if there is a function that does it. Exist I know that if you make a linear regression, you enter the dataset and have in summary the adjusted r-square. But this is calculated using the coefficients that R obtained,and I want other coefficients that i calculated separately and differently (without the intercept term too). I have made a function based in the equations of the book Linear Regression Analisys (Wiley Series in probability and mathematical statistics), but it doesn't return values between 0 and 1. What is wrong The functions is given by: adjustedR2-function(Y,X,saM) { if(is.matrix(Y)==F) (Y-as.matrix(Y)) if(is.matrix(X)==F) (X-as.matrix(X)) if(is.matrix(saM)==F) (saM-as.matrix(saM)) RX-rent.matrix(X,1)$Rentabilidade.tipo RY-rent.matrix(Y,1)$Rentabilidade.tipo r2m-matrix(0,nrow=ncol(Y),ncol=1) RSS-matrix(0,ncol=ncol(Y),nrow=1) SYY-matrix(0,ncol=ncol(Y),nrow=1) for (i in 1:ncol(RY)) { RSS[,i]-(t(RY[,i])%*%RY[,i])-(saM[i,]%*%(t(RX)%*%RX)%*%t(saM)[,i]) SYY[,i]-sum((RY[,i]-mean(RY[,i]))^2) r2m[i,]-1-(RSS[,i]/SYY[,i])*((nrow(RY))/(nrow(RY)-ncol(saM)-1)) } dimnames(r2m)-list(colnames(Y),c(Adjusted R-square)) return(r2m) } Thanks! Alexandra Alexandra R. Mendes de Almeida - Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list
Re: [R] SPSS and R ? do they like each other?
... and is there also such a nice tool (like spss.get) for exporting data frames to SPSS? write.table does not keep the data frame labels - neither did the other exporting tools that I found. Thanks! Michael [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matrix logic
Uwe, FYI: I tried: data3 - ifelse(is.na(data1), data2, data1) It seems to me that data3 is an array of length 100. I do NOT end up with a dataset of 5 columns and 20 rows. Uwe Ligges [EMAIL PROTECTED] wrote: Tom wrote: On Tue, 10 Jan 2006 20:25:23 -0500, r user wrote: I have 2 dataframes, each with 5 columns and 20 rows. They are called data1 and data2.I wish to create a third dataframe called data3, also with 5 columns and 20 rows. I want data3 to contains the values in data1 when the value in data1 is not NA. Otherwise it should contain the values in data2. I have tried afew methids, but they do not seem to work as intended.: data3-ifelse(is.na(data1)=F,data1,data2) and data3[,]-ifelse(is.na(data1[,])=F,data1[,],data2[,]) Please suggest the âbestâ way. Better way is to have the Syntax correct: data3 - ifelse(is.na(data1), data2, data1) Please check the archives for almost millions of posts asking more or less this question...! Not sure about the bast but... a-c(1,2,3,NA,5) b-c(4,4,4,4,4) c-a c[which(is.na(a))]-b[which(is.na(a))] Why do you want to know which()? na - is.na(a) c[na] - b[na] Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html - Photo Books. You design it and well bind it! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] information
I just got 59 hits from ' RSiteSearch(space-time)'. Have you tried this? If you would like more help from this listserve, please read the posting guide! www.R-project.org/posting-guide.html then submit another question. La experiencia sugiere que las prejuntas sigiendo esta guia tipicamente receiben contestaciones mas rapido y mas utiles. spencer graves angel toledo wrote: Hi. My name is Angel, I am Mexican, and I write by the following thing: I am in search of commands or options in R that can be used in regional economics. Specially I am interested in commands who can be interacted with geographic information systems, to get a regionalization, using a lot of many indicators. -- Atentamente Ángel Toledo Tolentino [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matrix logic
t c wrote: Uwe, FYI: I tried: data3 - ifelse(is.na(data1), data2, data1) It seems to me that data3 is an array of length 100. I do NOT end up with a dataset of 5 columns and 20 rows. I have not read carefully enough, for a data.frame you can generalize the approach as follows: data.frame(mapply(function(x,y,z) ifelse(is.na(y), z, y), names(D), D, D2, SIMPLIFY=FALSE)) Uwe Ligges Uwe Ligges [EMAIL PROTECTED] wrote: Tom wrote: On Tue, 10 Jan 2006 20:25:23 -0500, r user wrote: I have 2 dataframes, each with 5 columns and 20 rows. They are called data1 and data2.I wish to create a third dataframe called data3, also with 5 columns and 20 rows. I want data3 to contains the values in data1 when the value in data1 is not NA. Otherwise it should contain the values in data2. I have tried afew methids, but they do not seem to work as intended.: data3-ifelse(is.na(data1)=F,data1,data2) and data3[,]-ifelse(is.na(data1[,])=F,data1[,],data2[,]) Please suggest the “bestâ€� way. Better way is to have the Syntax correct: data3 - ifelse(is.na(data1), data2, data1) Please check the archives for almost millions of posts asking more or less this question...! Not sure about the bast but... a-c(1,2,3,NA,5) b-c(4,4,4,4,4) c-a c[which(is.na(a))]-b[which(is.na(a))] Why do you want to know which()? na - is.na(a) c[na] - b[na] Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html - Yahoo! Photos – Showcase holiday pictures in hardcover Photo Books. You design it and we’ll bind 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
Re: [R] how to obtain par(ask=TRUE) with trellis-plots
On 1/11/06, Leo Gürtler [EMAIL PROTECTED] wrote: Dear alltogether, how can a delay like possible with par(ask=TRUE) be attained while using trellis-plots within a loop or something like that? the following draws each plot without waiting for a signal (mouse-klick), so par() does not work for that: library(nlme) for(i in 1:3) { fitlme - lme(Orthodont) par(ask=TRUE) # does not work with trellis print( plot(augPred(fitlme)) ) } See ?grid.prompt in the grid package. To use it you can either attach grid, or do grid::grid.prompt(TRUE) Deepayan -- http://www.stat.wisc.edu/~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
[R] Datetimes differences
I want to obtain datetime differences in mins in an other column, in front of my datetimes. I have tried this : T1 - c(12/31/03 23:49,1/1/04 1:14,1/1/04 0:02) T2 - c(1/1/04 0:58,1/1/04 1:16,) toto - data.frame(T1,T2) toto y - strptime(T1,%m/%d/%y %H:%M) x - strptime(T2,%m/%d/%y %H:%M) difftime(x,y) but, i don't know how can i do in order to obtain something like this : ans - c(69,2,NA) res - data.frame(T1,T2,ans) res what is to be done ? Thanks. Florent Bonneu Laboratoire de Statistique et Probabilités bureau 148 bât. 1R2 Université Toulouse 3 118 route de Narbonne - 31062 Toulouse cedex 9 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matrix logic
The following seems close to the form you were trying. It works for matrices, not dataframes. You can use as.matrix and as.data.frame to convert back and forth: # test data data1 - data2 - matrix(1:6,3) data1[2,2] - NA data1[] - ifelse(is.na(data1), data2, data1) On 1/11/06, t c [EMAIL PROTECTED] wrote: Uwe, FYI: I tried: data3 - ifelse(is.na(data1), data2, data1) It seems to me that data3 is an array of length 100. I do NOT end up with a dataset of 5 columns and 20 rows. Uwe Ligges [EMAIL PROTECTED] wrote: Tom wrote: On Tue, 10 Jan 2006 20:25:23 -0500, r user wrote: I have 2 dataframes, each with 5 columns and 20 rows. They are called data1 and data2.I wish to create a third dataframe called data3, also with 5 columns and 20 rows. I want data3 to contains the values in data1 when the value in data1 is not NA. Otherwise it should contain the values in data2. I have tried afew methids, but they do not seem to work as intended.: data3-ifelse(is.na(data1)=F,data1,data2) and data3[,]-ifelse(is.na(data1[,])=F,data1[,],data2[,]) Please suggest the “best†way. Better way is to have the Syntax correct: data3 - ifelse(is.na(data1), data2, data1) Please check the archives for almost millions of posts asking more or less this question...! Not sure about the bast but... a-c(1,2,3,NA,5) b-c(4,4,4,4,4) c-a c[which(is.na(a))]-b[which(is.na(a))] Why do you want to know which()? na - is.na(a) c[na] - b[na] Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html - Photo Books. You design it and we'll bind it! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Datetimes differences
Try difftime(x,y,unit=min) or as.numeric(difftime(x,y,unit=min)) depending on what you want. On 1/11/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I want to obtain datetime differences in mins in an other column, in front of my datetimes. I have tried this : T1 - c(12/31/03 23:49,1/1/04 1:14,1/1/04 0:02) T2 - c(1/1/04 0:58,1/1/04 1:16,) toto - data.frame(T1,T2) toto y - strptime(T1,%m/%d/%y %H:%M) x - strptime(T2,%m/%d/%y %H:%M) difftime(x,y) but, i don't know how can i do in order to obtain something like this : ans - c(69,2,NA) res - data.frame(T1,T2,ans) res what is to be done ? Thanks. Florent Bonneu Laboratoire de Statistique et Probabilités bureau 148 bât. 1R2 Université Toulouse 3 118 route de Narbonne - 31062 Toulouse cedex 9 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Datetimes differences
Is this what you want? toto$ans - difftime(x,y) toto T1 T2 ans 1 12/31/03 23:49 1/1/04 0:58 69 21/1/04 1:14 1/1/04 1:16 2 31/1/04 0:02 NA On 1/11/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I want to obtain datetime differences in mins in an other column, in front of my datetimes. I have tried this : T1 - c(12/31/03 23:49,1/1/04 1:14,1/1/04 0:02) T2 - c(1/1/04 0:58,1/1/04 1:16,) toto - data.frame(T1,T2) toto y - strptime(T1,%m/%d/%y %H:%M) x - strptime(T2,%m/%d/%y %H:%M) difftime(x,y) but, i don't know how can i do in order to obtain something like this : ans - c(69,2,NA) res - data.frame(T1,T2,ans) res what is to be done ? Thanks. Florent Bonneu Laboratoire de Statistique et Probabilités bureau 148 bât. 1R2 Université Toulouse 3 118 route de Narbonne - 31062 Toulouse cedex 9 [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 -- Jim Holtman Cincinnati, OH +1 513 247 0281 What the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Obtaining the adjusted r-square given the regression coefficients
A much shorter (but complete) description of this is on the summary.lm help page. It includes the definitions R (and most statistics references) uses. On Wed, 11 Jan 2006, Millo Giovanni wrote: Alexandra, some additional remarks taken from my past struggles with R2 :^) Without intercept the definition is indeed problematic, as Bernhard notes. First, to estimate a model omitting the intercept you simply have to specify -1 in the model formula (example on an in-built dataset, for data description see help(mtcars)): data(mtcars) attach(mtcars) mod-lm(mpg~hp+wt+qsec) # with intercept summary(mod) and mod0-lm(mpg~hp+wt+qsec-1) # without summary(mod0) The reported R2s are different not only in value (which is obvious) but also in the definition. In fact, there are 2 definitions of R2. With reference to the usual analysis of variance in OLS regression (see e.g. Ch.3 in Greene 2003, Econometric Analysis, and 3.5.2. in particular), let, in our example, SST-sum(mpg^2) # total sum of squares SSR-sum(fitted(mod)^2) # regression sum of squares SSE-sum(resid(mod)^2) # error sum of squares where (a) SST=SSR+SSE, as you may readily check, then the *uncentered* R2 is defined as uR2-SSR/SST while the *centered* R2 as cSST-sum((mpg-mean(mpg))^2) cSSR-sum((fitted(mod)-mean(mpg))^2) # as 1) mean(y)=mean(y_hat) cSSE-sum(resid(mod)^2) # as 2) mean(e)=0 cR2-cSSR/cSST and (b) cSST=cSSR+cSSE. The problem is that the meaning of R2 derives from decompositions (a) and (b), but while (a) always holds for OLS models, (b) only holds for models with an intercept (as do (1-2) above, on which it is based). Thus *centered R2 is meaningless in models without intercept*. People are used to cR2, though, so R reports cR2 for models with intercept, uR2 for those without (EViews, e.g., reports cR2 for both). Adjusted R2s are the same, adjusted by a factor penalizing for df. See Greene, who gives adjR2 = 1-(n-1)/(n-K)(1-R2) for n obs. and K regressors. Finally, it is of course feasible to calculate the model coefficients on your own, but it would be inefficient (R has an optimized routine for OLS, so you'd better use coef(lm(y~X))). Anyway, if you like, y-mpg # just for notational simplicity.. X-cbind(hp,wt,qsec) # add rep(1,length(hp)) to this data matrix # if you want an intercept b-solve(crossprod(X),crossprod(X,y)) # the coefficients for mod0 y_hat-X%*%b # fitted values for y e-y-y_hat# model residuals from which you can obtain anything you need. Cheers Giovanni Giovanni Millo Ufficio Studi Assicurazioni Generali SpA Via Machiavelli 4, 34131 Trieste (I) tel. +39 040 671184 fax +39 040 671160 * Original message: Date: Wed, 11 Jan 2006 09:16:46 - From: Pfaff, Bernhard Dr. [EMAIL PROTECTED] Subject: Re: [R] Obtaining the adjusted r-square given the regression coefficients To: 'Alexandra R. M. de Almeida' [EMAIL PROTECTED], r-help@stat.math.ethz.ch Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=iso-8859-1 Hello Alexandra, R2 is only defined for regressions with intercept. See a decent econometrics textbook for its derivation. HTH, Bernhard -Urspr?ngliche Nachricht- Von: Alexandra R. M. de Almeida [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 11. Januar 2006 03:48 An: r-help@stat.math.ethz.ch Betreff: [R] Obtaining the adjusted r-square given the regression coefficients Dear list I want to obtain the adjusted r-square given a set of coefficients (without the intercept), and I don't know if there is a function that does it. Exist I know that if you make a linear regression, you enter the dataset and have in summary the adjusted r-square. But this is calculated using the coefficients that R obtained,and I want other coefficients that i calculated separately and differently (without the intercept term too). I have made a function based in the equations of the book Linear Regression Analisys (Wiley Series in probability and mathematical statistics), but it doesn't return values between 0 and 1. What is wrong The functions is given by: adjustedR2-function(Y,X,saM) { if(is.matrix(Y)==F) (Y-as.matrix(Y)) if(is.matrix(X)==F) (X-as.matrix(X)) if(is.matrix(saM)==F) (saM-as.matrix(saM)) RX-rent.matrix(X,1)$Rentabilidade.tipo RY-rent.matrix(Y,1)$Rentabilidade.tipo r2m-matrix(0,nrow=ncol(Y),ncol=1) RSS-matrix(0,ncol=ncol(Y),nrow=1) SYY-matrix(0,ncol=ncol(Y),nrow=1) for (i in 1:ncol(RY)) { RSS[,i]-(t(RY[,i])%*%RY[,i])-(saM[i,]%*%(t(RX)%*%RX)%*%t(saM)[,i]) SYY[,i]-sum((RY[,i]-mean(RY[,i]))^2) r2m[i,]-1-(RSS[,i]/SYY[,i])*((nrow(RY))/(nrow(RY)-ncol(saM)-1)) } dimnames(r2m)-list(colnames(Y),c(Adjusted R-square)) return(r2m) } Thanks! Alexandra Alexandra R. Mendes de Almeida - Ai sensi del D.Lgs. 196/2003 si precisa
Re: [R] Datetimes differences
On Wed, 11 Jan 2006 [EMAIL PROTECTED] wrote: I want to obtain datetime differences in mins in an other column, in front of my datetimes. I have tried this : T1 - c(12/31/03 23:49,1/1/04 1:14,1/1/04 0:02) T2 - c(1/1/04 0:58,1/1/04 1:16,) toto - data.frame(T1,T2) toto y - strptime(T1,%m/%d/%y %H:%M) x - strptime(T2,%m/%d/%y %H:%M) difftime(x,y) but, i don't know how can i do in order to obtain something like this : ans - c(69,2,NA) res - data.frame(T1,T2,ans) res data.frame(T1, T2, mins=as.numeric(difftime(x,y, units=mins))) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] complex matrix manipulation question
Mark: I did not see a reply to your question. Did you get one? If not,here's a solution using a while() loop which should be fast. One could also use recursion here in a natural way. This solution assumes that there are no NA's anywhere -- it's a bit trickier if there are NA's in the x column. Also, I have omitted matrix notation and just assumed x and y are vectors. I didn't test this exhaustively, so there might be a few fussy details that still need debugging. The major problem would be that I did not interpret your question correctly, but I hope I got it right. xcsum-cumsum(x) i - 1; k - 0; n -length(x); z - rep(NA,n) while(i = n) { xcsum - xcsum - k inew - which(xcsum W)[1] if(is.na(inew)) break else{ z[inew]-sum(y[i:inew]) i-inew+1 k-xcsum[inew] } } -- Bert -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mark Leeds Sent: Tuesday, January 10, 2006 5:55 PM To: R-Stat Help Subject: [R] complex matrix manipulation question I've done stuff like this before but it's been a while and I'm stuck. Suppose I have a matrix with one column x and another column y and both are numeric and let the row index of the matrix be i Starting at index i ( i would equal on the first iteration ) when the cumulative sum of x_i+1 - x_i is greater than W = some constant, I want to mark that spot in the row, call it i^* and sum all the values in y between i and i^* and put that value a third column z. Otherwise, the values in the indices of z between i and i^*-1 should be NA. Then, start at i^*+1 and do the same thing again. and keep doing thisn until I get all the way through the rows of the matrix. I think this is tricky but I used to do it and I forgot how to. If it has to be done using loops, that's okay but from previous experience, I don't think looping is necessary. Thanks. Mark ** This email and any files transmitted with it are confidentia...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] SPSS and R ? do they like each other?
Thanks again for your answer! I tried it out. write.foreign produces SPSS syntax, but unfortunally this syntax tells SPSS to take the names (and not the labels) in order to produce SPSS variable labels. The former labels get lost. I tried a data frame produced by read.spss and one by spss.get. Here is the read.spss one (the labels meant to be exported are called Text 1, ...): jjread- read.spss(test2.sav, use.value.labels=TRUE, to.data.frame=TRUE) str(jjread) `data.frame': 30 obs. of 3 variables: $ VAR1: num 101 102 103 104 105 106 107 108 109 110 ... $ VAR2: num 6 6 5 6 6 6 6 6 6 6 ... $ VAR3: num 0 0 6 7 0 7 0 0 0 8 ... - attr(*, variable.labels)= Named chr Text 1 Text2 text 3 ..- attr(*, names)= chr VAR1 VAR2 VAR3 datafile-tempfile() codefile-tempfile() write.foreign(jjread,datafile,codefile,package=SPSS) file.show(datafile) file.show(codefile) The syntax file I get is: DATA LIST FILE= C:\DOKUME~1\reinecke\LOKALE~1\Temp\Rtmp15028\file27910 free / VAR1 VAR2 VAR3 . VARIABLE LABELS VAR1 VAR1 VAR2 VAR2 VAR3 VAR3 . EXECUTE. I am working on R 2.2.0. But I think a newer version won ´t fix it either, will it? Greetings, Michael -Ursprüngliche Nachricht- Von: Chuck Cleland [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 11. Januar 2006 17:16 An: Michael Reinecke Cc: R-help@stat.math.ethz.ch Betreff: Re: [R] SPSS and R ? do they like each other? Michael Reinecke wrote: ... and is there also such a nice tool (like spss.get) for exporting data frames to SPSS? write.table does not keep the data frame labels - neither did the other exporting tools that I found. ... library(foreign) ?write.foreign write.foreign(df, datafile, codefile, package = SPSS) The codefile generated is SPSS syntax which will read the datafile and create SPSS variable and value labels. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (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
[R] Looking for functions that do the nearest neighbor method and the variable kernel method
Dear List, Please confirm the following: It may be my eyes playing trick on me, but I can't seem to find functions that do the nearest neighbor method and the variable kernel method for kernel smoothing and density estimation corresponding to the book: Silverman, B.W., (1986) Density Estimation for Statistics and Data Analysis. With appreciation, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Permutation columns or boostrapping
Hi, I want to permutate the following matrix and replace permutated columns. Is it possible to control the number of columns permutated. Let's say I only want to permute two columns. Can i do that with the sample method or should i any bootstrapping method ?? I'm not sure this is the best statisticaly way of doing it...?? So the idea behind is to ramdonly generate 1000 permutated matrices from the original data matrix and estimated the significance of each of the values. Any help would be extremely apreciated.. Here is the code i have so far... that works x - matrix(1:10,nr=5,nc=6) x [,1] [,2] [,3] [,4] [,5] [,6] [1,]161616 [2,]272727 [3,]383838 [4,]494949 [5,]5 105 105 10 y-x[,sample(1:6,replace=TRUE)] y [,1] [,2] [,3] [,4] [,5] [,6] [1,]166166 [2,]277277 [3,]388388 [4,]499499 [5,]5 10 105 10 10 best, david __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] SPSS and R ? do they like each other?
On Wed, 11 Jan 2006, Michael Reinecke wrote: Thanks again for your answer! I tried it out. write.foreign produces SPSS syntax, but unfortunally this syntax tells SPSS to take the names (and not the labels) in order to produce SPSS variable labels. The former labels get lost. Well, yes. That's because write.foreign is basically intended for exporting R data frame, which don't have variable labels. It should be a fairly simple change. Look at foreign:::writeForeignSPSS which is the function that does the work. -thomas I tried a data frame produced by read.spss and one by spss.get. Here is the read.spss one (the labels meant to be exported are called Text 1, ...): jjread- read.spss(test2.sav, use.value.labels=TRUE, to.data.frame=TRUE) str(jjread) `data.frame': 30 obs. of 3 variables: $ VAR1: num 101 102 103 104 105 106 107 108 109 110 ... $ VAR2: num 6 6 5 6 6 6 6 6 6 6 ... $ VAR3: num 0 0 6 7 0 7 0 0 0 8 ... - attr(*, variable.labels)= Named chr Text 1 Text2 text 3 ..- attr(*, names)= chr VAR1 VAR2 VAR3 datafile-tempfile() codefile-tempfile() write.foreign(jjread,datafile,codefile,package=SPSS) file.show(datafile) file.show(codefile) The syntax file I get is: DATA LIST FILE= C:\DOKUME~1\reinecke\LOKALE~1\Temp\Rtmp15028\file27910 free / VAR1 VAR2 VAR3 . VARIABLE LABELS VAR1 VAR1 VAR2 VAR2 VAR3 VAR3 . EXECUTE. I am working on R 2.2.0. But I think a newer version won ´t fix it either, will it? Greetings, Michael -Ursprüngliche Nachricht- Von: Chuck Cleland [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 11. Januar 2006 17:16 An: Michael Reinecke Cc: R-help@stat.math.ethz.ch Betreff: Re: [R] SPSS and R ? do they like each other? Michael Reinecke wrote: ... and is there also such a nice tool (like spss.get) for exporting data frames to SPSS? write.table does not keep the data frame labels - neither did the other exporting tools that I found. ... library(foreign) ?write.foreign write.foreign(df, datafile, codefile, package = SPSS) The codefile generated is SPSS syntax which will read the datafile and create SPSS variable and value labels. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (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 Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Regular expressions
Matching regular expressions Dear useRs! I have the following problem. I would like to find objects in my environment that have two strings in it. For example, I might want to find objects that have in their names MY and TARGET. I do not care about the ordering of these two substrings in the name, neither what is in front, behind or between them, the only thing important is that both words are present. I apologize if this is covered in help pages (then I did not understand it by reading them several times) or it was answered previously (then I did not find it). Since ls with argument pattern essentially uses grep (if I am not mistaken), I have an example for grep text-c(somethigMYsomthing elseTARGET another thing,MY somthing TARGET another thing,somethig somthing elseTARGETMY another thing,somethigMTARGETY another thing) grep(pattern=MYTARGET, x=text) #I would like to get 1 2 3 and not 4 or actually their names using text[grep(pattern=MYTARGET, x=text)] #of course, the pattern in this case is wrong I know I can do text[grep(pattern=MY, x=text)][grep(pattern=TARGET, x=text[grep(pattern=MY,x=text)])] However I hope there exists a more elegant way. Thanks in advance for any suggestions! Best, Ales Ziberna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Regular expressions
Ales Ziberna [EMAIL PROTECTED] writes: Matching regular expressions Dear useRs! I have the following problem. I would like to find objects in my environment that have two strings in it. For example, I might want to find objects that have in their names MY and TARGET. I do not care about the ordering of these two substrings in the name, neither what is in front, behind or between them, the only thing important is that both words are present. I apologize if this is covered in help pages (then I did not understand it by reading them several times) or it was answered previously (then I did not find it). Since ls with argument pattern essentially uses grep (if I am not mistaken), I have an example for grep text-c(somethigMYsomthing elseTARGET another thing,MY somthing TARGET another thing,somethig somthing elseTARGETMY another thing,somethigMTARGETY another thing) grep(pattern=MYTARGET, x=text) #I would like to get 1 2 3 and not 4 or actually their names using text[grep(pattern=MYTARGET, x=text)] #of course, the pattern in this case is wrong I know I can do text[grep(pattern=MY, x=text)][grep(pattern=TARGET, x=text[grep(pattern=MY,x=text)])] However I hope there exists a more elegant way. Perhaps this? text[intersect(grep(MY,text), grep(TARGET,text))] -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lmer(): nested and non-nested factors in logistic regression
The version of lmer based on the supernodal Cholesky factorization, which we will release real soon, does not crash on this example. It does give very large estimates of the variances in that model fit, at least for the simulation that I ran. It is best if you use set.seed(123454321) (or whatever seed appeals to you) before you simulate data if you are going to post the results. That way we can be sure we are running on the same data you did. On 1/10/06, Andrew Gelman [EMAIL PROTECTED] wrote: Thanks to some help by Doug Bates (and the updated version of the Matrix package), I've refined my question about fitting nested and non-nested factors in lmer(). I can get it to work in linear regression but it crashes in logistic regression. Here's my example: # set up the predictors n.age - 4 n.edu - 4 n.rep - 100 n.state - 50 n - n.age*n.edu*n.rep age.id - rep (1:n.age, each=n.edu*n.rep) edu.id - rep (1:n.edu, n.age, each=n.rep) age.edu.id - n.edu*(age.id - 1) + edu.id state.id - sample (1:n.state, n, replace=TRUE) # simulate the varying parameters a.age - rnorm (n.age, 1, 2) a.edu - rnorm (n.edu, 3, 4) a.age.edu - rnorm (n.age*n.edu, 0, 5) a.state - rnorm (n.state, 0, 6) # simulate the data and print to check that i did it right y.hat - a.age[age.id] + a.edu[edu.id] + a.age.edu[age.edu.id] + a.state[state.id] y - rnorm (n, y.hat, 1) print (cbind (age.id, edu.id, age.edu.id, state.id, y.hat, y)) # this model (and simpler versions) work fine: fit.1 - lmer (y ~ 1 + (1 | age.id) + (1 | edu.id) + (1 | age.edu.id) + (1 | state.id)) # now go to logistic regression ypos - ifelse (y mean(y), 1, 0) # these work fine: fit.2 - lmer (ypos ~ 1 + (1 | age.id) + (1 | edu.id) + (1 | age.edu.id), family=binomial(link=logit)) fit.3 - lmer (ypos ~ 1 + (1 | age.id) + (1 | edu.id) + (1 | state.id), family=binomial(link=logit)) # this one causes R to crash!!! fit.4 - lmer (ypos ~ 1 + (1 | age.id) + (1 | edu.id) + (1 | age.edu.id) + (1 | state.id), family=binomial(link=logit)) -- All help appreciated. This is for our book on regression and multilevel models, and it would be great if people could get started fitting these models in R before having to do the more elaborate modeling in Bugs. Andrew -- Andrew Gelman Professor, Department of Statistics Professor, Department of Political Science [EMAIL PROTECTED] www.stat.columbia.edu/~gelman Tues, Wed, Thurs: Social Work Bldg (Amsterdam Ave at 122 St), Room 1016 212-851-2142 Mon, Fri: International Affairs Bldg (Amsterdam Ave at 118 St), Room 711 212-854-7075 Mailing address: 1255 Amsterdam Ave, Room 1016 Columbia University New York, NY 10027-5904 212-851-2142 (fax) 212-851-2164 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Regular expressions
Ales Ziberna [EMAIL PROTECTED] writes: Dear useRs! I have the following problem. I would like to find objects in my environment that have two strings in it. For example, I might want to find objects that have in their names MY and TARGET. I do not care about the ordering of these two substrings in the name, neither what is in front, behind or between them, the only thing important is that both words are present. I apologize if this is covered in help pages (then I did not understand it by reading them several times) or it was answered previously (then I did not find it). Since ls with argument pattern essentially uses grep (if I am not mistaken), I have an example for grep text-c(somethigMYsomthing elseTARGET another thing,MY somthing TARGET another thing,somethig somthing elseTARGETMY another thing,somethigMTARGETY another thing) grep(pattern=MYTARGET, x=text) #I would like to get 1 2 3 and not 4 or actually their names using text[grep(pattern=MYTARGET, x=text)] #of course, the pattern in this case is wrong I know I can do text[grep(pattern=MY, x=text)][grep(pattern=TARGET, x=text[grep(pattern=MY,x=text)])] However I hope there exists a more elegant way. Thanks in advance for any suggestions! Best, Ales Ziberna How about: text[grep((MY|TARGET), text)] That works on my Redhat box, R version 2.2.0. --Todd -- Why does clip mean both cut apart and fasten together? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Improving R-Intro {was Wikis etc.}
On an improved R wiki, R-intro: I think the issue of user-friendliness of documentation has been raised. When I first started using R, I found the S-PLUS online documentation very useful. It is very user-friendly and a great introduction, organized by application. See: S-PLUS 6 Guide to Statistics, Volume I S-PLUS 6 Guide to Statistics, Volume II at http://www.insightful.com/support/doc_splus_win.asp How about a wiki based on this as a model, with some preliminaries and then user additions. Of course, the bottom line is, we need something targeted at end-users, not developers. Brett Martin Maechler wrote: That's a good suggestion. The file to improve is the texinfo source file (the *.html is produced from it, as well as the *.pdf version of the manual), is always available from the subversion archive (as all the rest of the R sources, past and present), the intro manual being https://svn.r-project.org/R/trunk/doc/manual/R-intro.texi So, yes, we'd welcome (a patch against / an improved version of) the above file! Martin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Dates
Dear R Users, I am trying to use its, and for that, I need to use as.POSIXct . My dates are of the format:10 January 2006. How do I convert this into the format acceptable to its ? Thanks, Tolga == Please access the attached hyperlink for an important electr...{{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
Re: [R] Dates
See ?strptime Also the help desk article in RNews 4/1 contains info on dates. On 1/11/06, Uzuner, Tolga [EMAIL PROTECTED] wrote: Dear R Users, I am trying to use its, and for that, I need to use as.POSIXct . My dates are of the format:10 January 2006. How do I convert this into the format acceptable to its ? Thanks, Tolga == Please access the attached hyperlink for an important electr...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Space between axis label and tick labels
On Wed, 11-Jan-2006 at 10:52AM +0100, Kare Edvardsen wrote: | I'm writing an publication in two column format and need to shrink some | plots. After increasing the axis labels it does not look nice at all. | The y-axis label and tick labels almost touch each other and the x-axis | tick labels expand into the plot instead of away from it. Is there a | better way than cex to control the: | | 1) font size of axis and tick labels | | 2) font thickness | | 3) placement of both axis and yick labels Try ?par and check out what it has to say about cex.axis and cex.lab. Without any example code, I'm not clear on what you've tried, but you might need to check out the axis function as well. HTH -- Patrick Connolly HortResearch Mt Albert Auckland New Zealand Ph: +64-9 815 4200 x 7188 ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~ I have the world`s largest collection of seashells. I keep it on all the beaches of the world ... Perhaps you`ve seen it. ---Steven Wright ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Regular expressions
Thank you! This is definitely an improvement! Best, Ales Ziberna -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Dalgaard Sent: Wednesday, January 11, 2006 7:24 PM To: Ales Ziberna Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Regular expressions Ales Ziberna [EMAIL PROTECTED] writes: Matching regular expressions Dear useRs! I have the following problem. I would like to find objects in my environment that have two strings in it. For example, I might want to find objects that have in their names MY and TARGET. I do not care about the ordering of these two substrings in the name, neither what is in front, behind or between them, the only thing important is that both words are present. I apologize if this is covered in help pages (then I did not understand it by reading them several times) or it was answered previously (then I did not find it). Since ls with argument pattern essentially uses grep (if I am not mistaken), I have an example for grep text-c(somethigMYsomthing elseTARGET another thing,MY somthing TARGET another thing,somethig somthing elseTARGETMY another thing,somethigMTARGETY another thing) grep(pattern=MYTARGET, x=text) #I would like to get 1 2 3 and not 4 or actually their names using text[grep(pattern=MYTARGET, x=text)] #of course, the pattern in this case is wrong I know I can do text[grep(pattern=MY, x=text)][grep(pattern=TARGET, x=text[grep(pattern=MY,x=text)])] However I hope there exists a more elegant way. Perhaps this? text[intersect(grep(MY,text), grep(TARGET,text))] -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Regular expressions
I guess I have not been clear enough. I want both words in the results. So if we have: text-c(somethigMYsomthing elseTARGET another thing,MY somthing TARGET another thing,somethig somthing elseTARGETMY another thing,somethigMTARGETY another thing, somthingMY somthing else) The last element should not be returned. The best suggestion was given by Gabor Grothendieck: grep(MY.*TARGET|TARGET.*MY, text) While the one by Peter Dalgaard also does the trick: text[intersect(grep(MY,text), grep(TARGET,text))] I was just supriessed that or (|) works and and () does not. Thanks to all! Best, Ales Ziberna -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Taylor, Z Todd Sent: Wednesday, January 11, 2006 7:50 PM To: r-help@stat.math.ethz.ch Subject: Re: [R] Regular expressions Ales Ziberna [EMAIL PROTECTED] writes: Dear useRs! I have the following problem. I would like to find objects in my environment that have two strings in it. For example, I might want to find objects that have in their names MY and TARGET. I do not care about the ordering of these two substrings in the name, neither what is in front, behind or between them, the only thing important is that both words are present. I apologize if this is covered in help pages (then I did not understand it by reading them several times) or it was answered previously (then I did not find it). Since ls with argument pattern essentially uses grep (if I am not mistaken), I have an example for grep text-c(somethigMYsomthing elseTARGET another thing,MY somthing TARGET another thing,somethig somthing elseTARGETMY another thing,somethigMTARGETY another thing) grep(pattern=MYTARGET, x=text) #I would like to get 1 2 3 and not 4 or actually their names using text[grep(pattern=MYTARGET, x=text)] #of course, the pattern in this case is wrong I know I can do text[grep(pattern=MY, x=text)][grep(pattern=TARGET, x=text[grep(pattern=MY,x=text)])] However I hope there exists a more elegant way. Thanks in advance for any suggestions! Best, Ales Ziberna How about: text[grep((MY|TARGET), text)] That works on my Redhat box, R version 2.2.0. --Todd -- Why does clip mean both cut apart and fasten together? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] F-test degree of freedoms in lme4 ?
I have a problem moving from multistratum aov analysis to lmer. My dataset has observations of ampl at 4 levels of gapf and 2 levels of bl on 6 subjects levels VP, with 2 replicates wg each, and is balanced. Here is the summary of this set with aov: summary(aov(ampl~gapf*bl+Error(VP/(bl*gapf)),hframe2)) Error: VP Df Sum Sq Mean Sq F value Pr(F) Residuals 5531 106 Error: VP:bl Df Sum Sq Mean Sq F value Pr(F) bl 1 1700170037.8 0.0017 ** Residuals 5225 45 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Error: VP:gapf Df Sum Sq Mean Sq F value Pr(F) gapf 3933 31124.2 5.3e-06 *** Residuals 15193 13 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Error: VP:bl:gapf Df Sum Sq Mean Sq F value Pr(F) gapf:bl3 93.931.33.68 0.036 * Residuals 15 127.6 8.5 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Error: Within Df Sum Sq Mean Sq F value Pr(F) Residuals 48318 7 This is mostly identical the analysis by BMDP 4V, except for the Greenhouse-Geisser epsilons, which are not estimated this way. I have to analyse a similar dataset, which is not balanced. So I need to change the method. Following Pinheiro/Bates p.90f, I tried hf2.lme - lme(ampl~gapf*bl,hframe2,random=list(VP=pdDiag(~gapf*bl),bl=pdDiag(~gapf))) and some variations of this to get the same F tests generated. At least, I got the F-test on error stratum VP:bl this way, but not the other two: anova(hf2.lme) numDF denDF F-value p-value (Intercept) 178 764.86 .0001 gapf378 17.68 .0001 bl 1 5 37.81 0.0017 gapf:bl 3782.99 0.0362 Then I tried to move to lmer. I tried to find something equivalent to the above lme call, with no success at all. In case, that the problem is in the data, here is the set: VP ampl wg bl gapf 1 WJ 22 w s 144 2 CR 23 w s 144 3 MZ 25 w s 144 4 MP 34 w s 144 5 HJ 36 w s 144 6 SJ 26 w s 144 7 WJ 34 w s 80 8 CR 31 w s 80 9 MZ 33 w s 80 10 MP 36 w s 80 11 HJ 37 w s 80 12 SJ 32 w s 80 13 WJ 34 w s 48 14 CR 37 w s 48 15 MZ 38 w s 48 16 MP 38 w s 48 17 HJ 40 w s 48 18 SJ 32 w s 48 19 WJ 36 w s 16 20 CR 40 w s 16 21 MZ 39 w s 16 22 MP 40 w s 16 23 HJ 40 w s 16 24 SJ 38 w s 16 25 WJ 16 g s 144 26 CR 28 g s 144 27 MZ 18 g s 144 28 MP 33 g s 144 29 HJ 37 g s 144 30 SJ 28 g s 144 31 WJ 28 g s 80 32 CR 33 g s 80 33 MZ 24 g s 80 34 MP 34 g s 80 35 HJ 36 g s 80 36 SJ 30 g s 80 37 WJ 32 g s 48 38 CR 38 g s 48 39 MZ 34 g s 48 40 MP 37 g s 48 41 HJ 39 g s 48 42 SJ 30 g s 48 43 WJ 36 g s 16 44 CR 34 g s 16 45 MZ 36 g s 16 46 MP 40 g s 16 47 HJ 40 g s 16 48 SJ 36 g s 16 49 WJ 22 w b 144 50 CR 24 w b 144 51 MZ 20 w b 144 52 MP 26 w b 144 53 HJ 22 w b 144 54 SJ 16 w b 144 55 WJ 26 w b 80 56 CR 24 w b 80 57 MZ 26 w b 80 58 MP 27 w b 80 59 HJ 26 w b 80 60 SJ 18 w b 80 61 WJ 28 w b 48 62 CR 23 w b 48 63 MZ 28 w b 48 64 MP 29 w b 48 65 HJ 27 w b 48 66 SJ 24 w b 48 67 WJ 32 w b 16 68 CR 26 w b 16 69 MZ 30 w b 16 70 MP 28 w b 16 71 HJ 30 w b 16 72 SJ 22 w b 16 73 WJ 22 g b 144 74 CR 18 g b 144 75 MZ 18 g b 144 76 MP 26 g b 144 77 HJ 22 g b 144 78 SJ 18 g b 144 79 WJ 24 g b 80 80 CR 26 g b 80 81 MZ 30 g b 80 82 MP 26 g b 80 83 HJ 26 g b 80 84 SJ 24 g b 80 85 WJ 28 g b 48 86 CR 28 g b 48 87 MZ 27 g b 48 88 MP 30 g b 48 89 HJ 26 g b 48 90 SJ 16 g b 48 91 WJ 28 g b 16 92 CR 19 g b 16 93 MZ 24 g b 16 94 MP 32 g b 16 95 HJ 30 g b 16 96 SJ 22 g b 16 -- Dipl.-Math. Wilhelm Bernhard Kloke Institut fuer Arbeitsphysiologie an der Universitaet Dortmund Ardeystrasse 67, D-44139 Dortmund, Tel. 0231-1084-257 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] 4 smoothed lines on xyplot
On 1/11/06, Dean Sonneborn [EMAIL PROTECTED] wrote: I am using the R code listed below to create 4 smoothed lines on a xyplot. I'm having trouble fine tuning it. First I think I may need a black and white plot so how do I get it to plot the lines with different characters, preferable the same characters used in the key (plus, X circle and triangle). I might also be interest in a version that draws four solid lines of different colors but when I try to use a white background the lines change to dots and dashs. When I don't use a white background it seems to use the solid colors lines. plotchar - c(3, 4 ,1 ,2 ) colr- c(green, blue , red, black) library(lattice) trellis.par.set(col.whitebg() ) xyplot(AWGT ~ lipid_adj_lpcb2_cent, groups=grpx, data=pcb_graph3, auto.key=TRUE, col=colr, pch=plotchar, type=c(1, smooth), span=.8, key=list(x=.14, y=.84, points=list(col=colr, pch=plotchar), lines=list(col=colr, pch=plotchar), text=list(levels(pcb_graph3$grpx) , col=colr, pch=plotchar))) Why are you using both auto.key and key? Anyway, the easiest way is to change the settings and use auto.key, e.g. xyplot(AWGT ~ lipid_adj_lpcb2_cent, groups=grpx, data=pcb_graph3, auto.key = list(lines = TRUE, points = TRUE), par.settings = list(superpose.symbol = list(col = colr, pch = plotchar), superpose.line = list(col = colr, lty = 1)), type=c(p, smooth), span=.8) (I'm not sure what type you meant to use, your email has 1, which doesn't do anything.) Deepayan -- http://www.stat.wisc.edu/~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
[R] updating formula inside function
Dear R-Helpers Given a function like foo - function(data,var1,var2,var3) { f - formula(paste(var1,'~',paste(var2,var3,sep='+'),sep='')) linmod - lm(f) return(linmod) } By typing foo(mydata,'a','b','c') I get the result of the linear model a~b+c. How can I rewrite the function so that the formula can be updated inside the function, i.e. foo - function(data,var1,var2,var3,var4) { f - formula(paste(var1,'~',paste(var2,var3,sep='+'),sep='')) linmod - lm(f) return(linmod) f2 - update.formula(f,.~.-var3+var4) } Like that it won't work because var3 and var4 are characters, but also with substitute() and eval() I did not manage to get the favoured result. Can somebody help me out? Thank you in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] updating formula inside function
This was just discussed last week: https://www.stat.math.ethz.ch/pipermail/r-help/2006-January/083812.html On 1/11/06, Christian Bieli [EMAIL PROTECTED] wrote: Dear R-Helpers Given a function like foo - function(data,var1,var2,var3) { f - formula(paste(var1,'~',paste(var2,var3,sep='+'),sep='')) linmod - lm(f) return(linmod) } By typing foo(mydata,'a','b','c') I get the result of the linear model a~b+c. How can I rewrite the function so that the formula can be updated inside the function, i.e. foo - function(data,var1,var2,var3,var4) { f - formula(paste(var1,'~',paste(var2,var3,sep='+'),sep='')) linmod - lm(f) return(linmod) f2 - update.formula(f,.~.-var3+var4) } Like that it won't work because var3 and var4 are characters, but also with substitute() and eval() I did not manage to get the favoured result. Can somebody help me out? Thank you in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] a series of 1's and -1's
Does anyone know of a simple test in any R package that given a series of negative ones and positive ones ( no other values are possible in the series ) returns a test of whether the series is random or not. ( a test at each point would be good but I can use the apply function to implement that ) ? thanks. ** This email and any files transmitted with it are confidentia...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] March 29-31, Data Mining Conference, Southern California, Early-bird Deadline Savings of $50
SALFORD SYSTEMS DATA MINING CONFERENCE 2006 San Diego, California, March 29-31, 2006 Focusing on the Contributions of Data Mining to Solving Real-World Challenges Business, Biomedical and Environmental Real-World Case Study Presentations TOPICS INCLUDE: Credit Risk Modeling; Targeted Marketing and Campaign Optimization; New Methods for Personalization; Analytical CRM; Fraud Detection; Military Applications; Crime Analysis; Drug Discovery; Data Analysis Related to Insurance, Epidemiology, Clinical Medicine, Proteomics and Genomics, Mass Spectrometry and Demographic Data; Tools for Tall and Wide Data State-of-the-Art Research from Leading Academic Institutions **A Commemoration and Celebration of the Lifetime Achievements of Data Mining Visionary and World-Renowned Statistician Leo Breiman PRE-CONFERENCE TRAINING Sharpen your expertise! In-depth courses available for attendees who are new to data mining. REGISTER NOW! EARLY-BIRD DEADLINE SAVINGS OF $50 http://www.salforddatamining.com/docs/regform06.pdf CONFERENCE PROGRAM: http://www.salforddatamining.com/program-sd.htm GREAT NETWORKING OPPORTUNITY Attendees at Prior Conferences Included: The International Monetary Fund, Barnes and Noble, Pfizer, Union Bank, Wells Fargo, Ciphergen, Stanford Linear Accelerator, Johns Hopkins Medical School, UC Berkeley, Cold Spring Harbor Laboratory, Novartis, Columbia University School of Public Health, Harvard Medical School, HSBC, International Steel Group(Bethlehem Steel), Cap Gemini, ATT Labs-Research, PricewaterhouseCoopers Sincerely, Lisa Solomon __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem with making Matrix
Dear Martin, That works just fine too. Thanks for the suggestion, Andrew Can you try and replace 'make' by '$(MAKE)' in the following three places, and see if it works possibly after writing (in your shell) export MAKE=gmake or setenv MAKE gmake (depending on the kind of shell you have) ? AMD/Makefile: ( cd Source ; $(MAKE) lib ) AMD/Makefile: ( cd Source ; $(MAKE) clean ) CHOLMOD/Makefile: ( cd Lib ; $(MAKE) ) CHOLMOD/Makefile: ( cd Lib ; $(MAKE) ) CHOLMOD/Makefile: ( cd Lib ; $(MAKE) purge ) CHOLMOD/Makefile: ( cd Lib ; $(MAKE) clean ) UMFPACK/Makefile: ( cd Source ; $(MAKE) lib ) UMFPACK/Makefile: ( cd Source ; $(MAKE) clean ) Regards, Martin Maechler, ETH Zurich -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] a series of 1's and -1's
I would compare the Shannon entropy of your test vector with the entropy of your expected probability distribution to see if they are close. That is, if you're binary probability distribution is half 1 and half -1, then if your string is long you would expect about half the numbers in your vector to be 1 and half to be -1, i.e. H(s)=1. Moreover, you should also look at the entropy of every subset of the vector and compare that to your distribution as well. For instance, does the sequence (1, 1) show up just as often as (1, -1), (-1, 1) and (-1, 1)? As this problem is specific to a certain random process, I doubt there is a canned test in R. Also, the sample entropy should converge to the distribution of the underlying process as the sample size increases for all subsets of the sample, probably following a t-distribution (Central Limit Theorem), although I'd need to noodle on this a bit more. You can then construct a test of significance if you know the sample size and how far the sample entropy is from the hypothesized process's distribution. Unfortunately, it's been a while since I've done information encoding, but hopefully this gets you started. You can read up on informational entropy here: http://en.wikipedia.org/wiki/Informational_entropy And if you do find a test in R, I would be interested as well. Best, Robert -Original Message- From: Mark Leeds [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 11, 2006 4:46 PM To: R-Stat Help Subject: [R] a series of 1's and -1's Does anyone know of a simple test in any R package that given a series of negative ones and positive ones ( no other values are possible in the series ) returns a test of whether the series is random or not. ( a test at each point would be good but I can use the apply function to implement that ) ? thanks. ** This email and any files transmitted with it are confidentia...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] SPSS and R ? do they like each other?
Michael Reinecke wrote: Thanks again for your answer! I tried it out. write.foreign produces SPSS syntax, but unfortunally this syntax tells SPSS to take the names (and not the labels) in order to produce SPSS variable labels. The former labels get lost. I tried a data frame produced by read.spss and one by spss.get. Here is the read.spss one (the labels meant to be exported are called Text 1, ...): jjread- read.spss(test2.sav, use.value.labels=TRUE, to.data.frame=TRUE) str(jjread) `data.frame': 30 obs. of 3 variables: $ VAR1: num 101 102 103 104 105 106 107 108 109 110 ... $ VAR2: num 6 6 5 6 6 6 6 6 6 6 ... $ VAR3: num 0 0 6 7 0 7 0 0 0 8 ... - attr(*, variable.labels)= Named chr Text 1 Text2 text 3 ..- attr(*, names)= chr VAR1 VAR2 VAR3 datafile-tempfile() codefile-tempfile() write.foreign(jjread,datafile,codefile,package=SPSS) file.show(datafile) file.show(codefile) The syntax file I get is: DATA LIST FILE= C:\DOKUME~1\reinecke\LOKALE~1\Temp\Rtmp15028\file27910 free / VAR1 VAR2 VAR3 . VARIABLE LABELS VAR1 VAR1 VAR2 VAR2 VAR3 VAR3 . EXECUTE. I am working on R 2.2.0. But I think a newer version won ´t fix it either, will it? Here is a functiong based on modifying foreign:::writeForeignSPSS (by Thomas Lumley) which might work for you: write.SPSS - function (df, datafile, codefile, varnames = NULL) { adQuote - function(x){paste(\, x, \, sep = )} dfn - lapply(df, function(x) if (is.factor(x)) as.numeric(x) else x) write.table(dfn, file = datafile, row = FALSE, col = FALSE) if(is.null(attributes(df)$variable.labels)) varlabels - names(df) else varlabels - attributes(df)$variable.labels if (is.null(varnames)) { varnames - abbreviate(names(df), 8) if (any(sapply(varnames, nchar) 8)) stop(I cannot abbreviate the variable names to eight or fewer letters) if (any(varnames != names(df))) warning(some variable names were abbreviated) } cat(DATA LIST FILE=, dQuote(datafile), free\n, file = codefile) cat(/, varnames, .\n\n, file = codefile, append = TRUE) cat(VARIABLE LABELS\n, file = codefile, append = TRUE) cat(paste(varnames, adQuote(varlabels), \n), .\n, file = codefile, append = TRUE) factors - sapply(df, is.factor) if (any(factors)) { cat(\nVALUE LABELS\n, file = codefile, append = TRUE) for (v in which(factors)) { cat(/\n, file = codefile, append = TRUE) cat(varnames[v], \n, file = codefile, append = TRUE) levs - levels(df[[v]]) cat(paste(1:length(levs), adQuote(levs), \n, sep = ), file = codefile, append = TRUE) } cat(.\n, file = codefile, append = TRUE) } cat(\nEXECUTE.\n, file = codefile, append = TRUE) } -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (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
Re: [R] data order affects glmmPQL
From: Spencer Graves The correlation between the predictions from your two model fits is 0.95. This suggests to me that the differences between the two sets of answers have little practical importance, and anyone who disagrees may be trying to read more from the results than can actually be supported by the data. It should be fairly easy to select the apparent best from among several such answers being the one that had a higher log(likelihood). This pushes me to prefer fit.bar with a log(likelihood) of -32.31 to fit.foo with -33.05. I agree that the differences are somewhat disturbing, but you are dealing with the output from an iterative solution of a notoriously difficult problem, and the standard wisdom is that it is wise to try several sets of starting values. By modifying the order of the observations in the data.frame, you have effectively done that. Spencer, thank you for setting my mind at ease. Still, I suspect there's a bug here, as the convergence procedure halts entirely when I sort the data yet another way. See http://article.gmane.org/gmane.comp.lang.r.general/53559 . Also, I wonder if it's appropriate to simply cherry-pick a model based on logLik, since there's no final test that of goodness of fit that happens on independent data after one has picked a model in this way. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Log-likelihood for Multinominal Probit Regression Model
Thank you very much for pointing me to these very useful references! Best regards. SC At 01:54 PM 1/11/2006, ronggui wrote: the usage of MNP is described in MNP: R Package for Fitting the Multinomial Probit Model http://www.jstatsoft.org/counter.php?id=128url=v14/i03/v14i03.pdfct=1 If the Dependent Variables is Unordered ,why not use Multinomial Logistic Regression.see http://gking.harvard.edu/zelig/docs/_TT_mlogit_TT__Multino.html Hope this helps. 2006/1/11, S.C. Wong [EMAIL PROTECTED]: I use mnp to run a multinominal probit regression model, but the summary doesn't contain the model statistics, such as the log-likelihood and degree of freedom, for the assessment of the goodness-of-fit of the fitted model. Is there any way that I can generate these statistics for the fitted model in R? Many thanks in advance! SC __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- »ÆÈÙ¹ó Deparment of Sociology Fudan University [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] question for mshapiro test
Hi, I have a question about the p-value of mshapiro test. I simulated data from bivariate normal 1000 times and used mshapiro test to see how many times the test would reject the null hypothesis when the p-value is 0.05. The answer should be around 50 since the p-value is 0.05. But I got a much higher value. Here is the R code I used and the result. library(mvnormtest,lib.loc=~/mshapiro) library(MASS) n=50 dim=2 ntrial = 1000 x-matrix(1:(dim*n),ncol=dim) count = 0 for( trial in 1:ntrial) { x-mvrnorm(n,rep(0,dim),diag(1,dim,dim)) data_hn-x p-mshapiro.test(t(data_hn))$p.value if( p= 0.05) count - count+1 } print(count) [1] 117 Can you help me out? Thank you very much. Liang __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] glmmPQL error message (was 'data order affects glmmPQL')
1. The function glmmPQL is in the MASS package, as can be seen by looking at the top line in the help file for glmmPQL. To find the maintainer, type 'help(package=MASS)'. The results say, Maintainer: Brian Ripley [EMAIL PROTECTED]. 2. It is generally NOT appropriate to simply cherry-pick a model based on logLik, as you suggested. However, your example does NOT involve this issue, because you are making multiple attempts to fit the same model to the same data set. With any iterative algorithm, it is considered legitimate to try fitting the same model with the same data with different starting values and select the one with the largest log(likelihood), considering that all others had not adequately converged. In this case, the algorithm runs and produces similar but different answers when the order is changed. Since the model does not seem to consider anything that would theoretically be affected by the sort order, it seems to me that this is crudely equivalent to changing the starting values, as I mentioned before. Therefore, I would consider it quite legitimate to pick the fit with the highest logLik. 3. I agree it is disturbing when glmmPQL generates Error in lme.formula(fixed = zz ~ test + coder, random = ~1 | id, data = list( : false convergence (8). If it were my problem, I might make local compies of glmmPQL and lme.formula and trace through the code line by line using debug until I developed an idea about how I might change the code to get it past this error and on to something close to convergence. Hope this helps. spencer graves Jack Tanner wrote: From: Spencer Graves The correlation between the predictions from your two model fits is 0.95. This suggests to me that the differences between the two sets of answers have little practical importance, and anyone who disagrees may be trying to read more from the results than can actually be supported by the data. It should be fairly easy to select the apparent best from among several such answers being the one that had a higher log(likelihood). This pushes me to prefer fit.bar with a log(likelihood) of -32.31 to fit.foo with -33.05. I agree that the differences are somewhat disturbing, but you are dealing with the output from an iterative solution of a notoriously difficult problem, and the standard wisdom is that it is wise to try several sets of starting values. By modifying the order of the observations in the data.frame, you have effectively done that. Spencer, thank you for setting my mind at ease. Still, I suspect there's a bug here, as the convergence procedure halts entirely when I sort the data yet another way. See http://article.gmane.org/gmane.comp.lang.r.general/53559 . Also, I wonder if it's appropriate to simply cherry-pick a model based on logLik, since there's no final test that of goodness of fit that happens on independent data after one has picked a model in this way. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Loading Excel file into Limma
Dear mailing group, This is my first time here. Glad to have this resource! I am currently trying to load an Excel file into R (limma package loaded) using the source(*name of directory*) command, but it cannot open the file. I renamed the file as .R and .RData, to no avail. The Excel data contains one gene name per row and about 100 data points per gene (columns). I am only used to loading preprepared microarray data with all the t's crossed and i's dotted, with the read.maimages command. Can anyone help me out with this silly-sounding challenge? Sincerely - in the truest sense - Norman Goodacre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Loading Excel file into Limma
well, I don't know anything about the limma package and I might be misunderstanding your apparently simple question What I do for excel files is the following: 1. I save a copy of the file as .csv (comma separated values) in the working directory. This format allows you work perfectly with the file in excel. 2. open in R using: read.csv(filename.csv) Hope it helps At 12:48 12/01/2006, you wrote: Dear mailing group, This is my first time here. Glad to have this resource! I am currently trying to load an Excel file into R (limma package loaded) using the source(*name of directory*) command, but it cannot open the file. I renamed the file as .R and .RData, to no avail. The Excel data contains one gene name per row and about 100 data points per gene (columns). I am only used to loading preprepared microarray data with all the t's crossed and i's dotted, with the read.maimages command. Can anyone help me out with this silly-sounding challenge? Sincerely - in the truest sense - Norman Goodacre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Ahimsa Campos Arceiz The University Museum, The University of Tokyo Hongo 7-3-1, Bunkyo-ku, Tokyo 113-0033 phone +81-(0)3-5841-2824 cell +81-(0)80-5402-7702 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Loading Excel file into Limma
no idea bout limma. but you could load excel data into R by using rodbc. here is a sample code and hope it helpful. library(RODBC); ### # 1. READ DATA FROM EXCEL INTO R # ### xlsConnect-odbcConnectExcel(C:\\temp\\demo.xls); demo-sqlFetch(xlsConnect, Sheet1); odbcClose(xlsConnect); rm(demo); On 12 Jan 2006 03:48:26 +, N. Goodacre [EMAIL PROTECTED] wrote: Dear mailing group, This is my first time here. Glad to have this resource! I am currently trying to load an Excel file into R (limma package loaded) using the source(*name of directory*) command, but it cannot open the file. I renamed the file as .R and .RData, to no avail. The Excel data contains one gene name per row and about 100 data points per gene (columns). I am only used to loading preprepared microarray data with all the t's crossed and i's dotted, with the read.maimages command. Can anyone help me out with this silly-sounding challenge? Sincerely - in the truest sense - Norman Goodacre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- WenSui Liu (http://statcompute.blogspot.com) Senior Decision Support Analyst Health Policy and Clinical Effectiveness Cincinnati Children Hospital Medical Center [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Loading Excel file into Limma
R won't read an Excel sheet directly. You need to export it, saving it as a CSV or tab delimited file. You can then import using read.table. The entire path and file have to be in double-quotes as well. Try ?read.table for more info. JWD On Wednesday 11 January 2006 19:48, N. Goodacre wrote: Dear mailing group, This is my first time here. Glad to have this resource! I am currently trying to load an Excel file into R (limma package loaded) using the source(*name of directory*) command, but it cannot open the file. I renamed the file as .R and .RData, to no avail. The Excel data contains one gene name per row and about 100 data points per gene (columns). I am only used to loading preprepared microarray data with all the t's crossed and i's dotted, with the read.maimages command. Can anyone help me out with this silly-sounding challenge? Sincerely - in the truest sense - Norman Goodacre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Loading Excel file into Limma
another options: use read.xls in gdata pcakges if you have installed perl in you machine . 12 Jan 2006 03:48:26 +, N. Goodacre [EMAIL PROTECTED]: Dear mailing group, This is my first time here. Glad to have this resource! I am currently trying to load an Excel file into R (limma package loaded) using the source(*name of directory*) command, but it cannot open the file. I renamed the file as .R and .RData, to no avail. The Excel data contains one gene name per row and about 100 data points per gene (columns). I am only used to loading preprepared microarray data with all the t's crossed and i's dotted, with the read.maimages command. Can anyone help me out with this silly-sounding challenge? Sincerely - in the truest sense - Norman Goodacre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 黄荣贵 Deparment of Sociology Fudan 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
Re: [R] matrix logic
I don't know how to keep factors' levels with : data.frame(mapply(function(x,y,z) ifelse(is.na(y), z, y), names(D), D, D2, SIMPLIFY=FALSE)) but in that way it's ok : data.frame(mapply(function(z,x,y) { y[is.na(y)] - x[is.na(y)] ; y }, names(D), D, D2, SIMPLIFY=F)) (?) Uwe Ligges a écrit : t c wrote: Uwe, FYI: I tried: data3 - ifelse(is.na(data1), data2, data1) It seems to me that data3 is an array of length 100. I do NOT end up with a dataset of 5 columns and 20 rows. I have not read carefully enough, for a data.frame you can generalize the approach as follows: data.frame(mapply(function(x,y,z) ifelse(is.na(y), z, y), names(D), D, D2, SIMPLIFY=FALSE)) Uwe Ligges Uwe Ligges [EMAIL PROTECTED] wrote: Tom wrote: On Tue, 10 Jan 2006 20:25:23 -0500, r user wrote: I have 2 dataframes, each with 5 columns and 20 rows. They are called data1 and data2.I wish to create a third dataframe called data3, also with 5 columns and 20 rows. I want data3 to contains the values in data1 when the value in data1 is not NA. Otherwise it should contain the values in data2. I have tried afew methids, but they do not seem to work as intended.: data3-ifelse(is.na(data1)=F,data1,data2) and data3[,]-ifelse(is.na(data1[,])=F,data1[,],data2[,]) Please suggest the “bestâ€� way. Better way is to have the Syntax correct: data3 - ifelse(is.na(data1), data2, data1) Please check the archives for almost millions of posts asking more or less this question...! Not sure about the bast but... a-c(1,2,3,NA,5) b-c(4,4,4,4,4) c-a c[which(is.na(a))]-b[which(is.na(a))] Why do you want to know which()? na - is.na(a) c[na] - b[na] Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html - Yahoo! Photos – Showcase holiday pictures in hardcover Photo Books. You design it and we’ll bind 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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Strange behaviour of load
Dear All, simetimes when I load an Rdata I get this message ### Code: load('bladder1.RData') Carico il pacchetto richiesto: rpart ( Bad traslastion: Load required package-...) Carico il pacchetto richiesto: MASS Carico il pacchetto richiesto: mlbench Carico il pacchetto richiesto: survival Carico il pacchetto richiesto: splines Carico il pacchetto richiesto: 'survival' The following object(s) are masked from package:Hmisc : untangle.specials Carico il pacchetto richiesto: class Carico il pacchetto richiesto: nnet # So I have many unrequired packages loaded. Any idea? TIA Giovanni dr. Giovanni Parrinello Section of Medical Statistics Department of Biotecnologies Viale Europa, 11 25100 Brescia Italy Tel: +3930/3717528 Fax: +3930/3717488 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] a series of 1's and -1's
On Wed, 11 Jan 2006, Mark Leeds wrote: Does anyone know of a simple test in any R package that given a series of negative ones and positive ones ( no other values are possible in the series ) returns a test of whether the series is random or not. ( a test at each point would be good but I can use the apply function to implement that ) ? help.search(runs) points to function runs.test() in package tseries, with examples: x - factor(sign(rnorm(100))) # randomness runs.test(x) x - factor(rep(c(-1, 1), 50)) # over-mixing runs.test(x) which looks like your case thanks. ** This email and any files transmitted with it are confidentia...{{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 -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [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