Re: [R] how to fetch rows with certain characteristics
tapply(x, y, min) where x is the vector of numbers and y the vector of class labels. Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and StatisticsTel: +31 (0)43 388-2277 School for Public Health and Primary Care Office Location: Maastricht University, P.O. Box 616 Room B2.01 (second floor) 6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck) From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Waverley @ Palo Alto [waverley.paloa...@gmail.com] Sent: Thursday, October 29, 2009 6:47 AM To: r-help Subject: [R] how to fetch rows with certain characteristics Hi, I have a matrix, first column is of certain values, second column is the class labels or a factor. e.g. 1.2 1 1.3 1 1.3 1 1.5 1 2.1 2 2.0 2 9.9 2 1.4 3 1.8 3 1.9 3 I want to find out what is the min values of column 1 for each corresponding class (column 2). For the above example, I want to return a matrix of 1.2 1 2.0 2 1.3 3 Can someone suggest how to code for that? The second column can be of characters. Thanks much. -- Waverley @ Palo Alto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Basic question ( too broad for help topics).
Hi Jim, out_df - my_df[ my_df$STREP %in% my_num, c(COUNTY, FIPS, STSEN, STREP, PREC)] should do the trick. See ?match for details. On Thu, Oct 29, 2009 at 1:53 AM, Jim Burke j.bu...@earthlink.net wrote: I have searched help topics but don't know exactly what to search for. Need to use my_num to find any matching STREPs in my_df my_num - c(101,102,103,104,105,107,108,112,113,114,115) ## my_df has 8,000 different STREPS in it. ## I have a statement where I can select ONE item from data frame my_df out_df - my_df[ my_df$STREP==101, c(COUNTY, FIPS, STSEN, STREP, PREC)] ## A comparative SQL command ## SELECT ## COUNTY, FIPS, STSEN, STREP, PREC ## FROM my_df ## WHERE my_df.STREP IN(101,102,103,104,105,107,108,112,113,114,115) ## ORDER BY STREP; Thanks for any help, Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Basic question ( too broad for help topics).
Thanks Ista, Your suggestion worked like a charm. Mark, thanks to you too. But don't worry about the data I sent to you. Good night everyone, Jim Ista Zahn wrote: Hi Jim, out_df - my_df[ my_df$STREP %in% my_num, c(COUNTY, FIPS, STSEN, STREP, PREC)] should do the trick. See ?match for details. On Thu, Oct 29, 2009 at 1:53 AM, Jim Burke j.bu...@earthlink.net wrote: I have searched help topics but don't know exactly what to search for. Need to use my_num to find any matching STREPs in my_df my_num - c(101,102,103,104,105,107,108,112,113,114,115) ## my_df has 8,000 different STREPS in it. ## I have a statement where I can select ONE item from data frame my_df out_df - my_df[ my_df$STREP==101, c(COUNTY, FIPS, STSEN, STREP, PREC)] ## A comparative SQL command ## SELECT ## COUNTY, FIPS, STSEN, STREP, PREC ## FROM my_df ## WHERE my_df.STREP IN(101,102,103,104,105,107,108,112,113,114,115) ## ORDER BY STREP; Thanks for any help, Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] modeling and forecasting commodity time series?
Hi Luna, you may want to look at the IIF website, http://www.forecasters.org They have a mailing list for forecasters - you may get more of a response there than on a dedicated R list. HTH, Stephan Luna Moon schrieb: Hi all, Could anybody please shed some lights on me about good books/literature about modeling and forecasting financial time series in the commodity space? Thanks so much! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Non-normal residuals.
On Wed, 28 Oct 2009 14:48:34 -0700 Bert Gunter gunter.ber...@gene.com wrote: If generalities -- with the attendant risk of occasional specific caveats and violations -- can be tolerated, then George Box's (paraphrased) comments of circa 40-50 years ago seem apropos: why do statisticians obsess over normality, to which most analyses -- i.e. inference (especially from balanced designs)-- are robust, when lack of independence of the observations is the violation of assumptions that can reek the greatest havoc on the statistical analysis? While I very much agree with the sentiment, ordinary linear regression is *not* very robust when dealing with very heavy-tailed errors, such as the t-distribution with low degrees of freedom. Of course, one could use 'rlm' instead of 'lm' (and I often prefer to do so), but with proper/better modelling of the error distribution, you will better confidence and prediction intervals. -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Parameter Estimation of Inverse Gamma distribution
Dear R users, i am searching for the solution of this problem in R: how to estimate the shape and scale parameters of Inverse Gamma distribution. Your views and help will be appreciated. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re trieving comments from PostgreSQL tables with RODBC and psqlodbc
I don't know whether this is an RODBC issue, a psqlodbc issue or a PostgreSQL issue; I've searched the documentation and forums for each, with no success. I want to list all the tables in a PostgreSQL schema, and return the table comments as well as the table names. As an example, one table is defined as follows: CREATE TABLE scen990.ezone_locationprice_year1 ( ezone integer NOT NULL, lprice_man_year1 real, lprice_war_year1 real, lprice_ret_year1 real, lprice_gen_year1 real, lprice_med_year1 real, lprice_gov_year1 real, CONSTRAINT ezone_locationprice_year1_pkey PRIMARY KEY (ezone) ) WITHOUT OIDS; ALTER TABLE scen990.ezone_locationprice_year1 OWNER TO mscope; COMMENT ON TABLE scen990.ezone_locationprice_year1 IS 'calculated'; The RODBC function sqlTables() returns all the tables, but the records look like this: TABLE_QUALIFIER TABLE_OWNER TABLE_NAME TABLE_TYPE REMARKS mscope scen990 ezone_locationprice_year1 TABLE All the REMARKS values are empty strings. Can I get it to return the COMMENT ON values instead? (the table_owner and tablet_qualifier are switched but that doesn't worry me) I'm using R 2.8.1, RODBC 1.2-4, psqlodbc 8.0.2, and PostgreSQL 8.1.5 . Regards, Jim Cser -- View this message in context: http://www.nabble.com/Retrieving-comments-from-PostgreSQL-tables-with-RODBC-and-psqlodbc-tp26104999p26104999.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] roc plot with zero length labels error
I am trying to create the roc plot bootstrap method from library(verification), and when I set the plot =both or emp then I get the following error. The roc.plot works fine when the plot is set to binorm. This is my first time using this function in R and am not sure what this error means or how to resolve the issue. It seems to work ok with the example dataset. Is there an option or data formatting I need to due to resolve this error? roc.plot((scicomp5.model1[164]==High Price), pred, CI = T, n.boot = 100, plot = 'both',binormal = TRUE, + main = paste('AREA UNDER CURVE (AUC) =', round(auc$A, 2))) Error in text.default(DAT[id, 3, i], DAT[id, 2, i], plot.thres[id2], pos = 4, : zero length 'labels' Chris Anderson http://www.seocodebreaker.com/?thankyou-page=429 Instant Debt Consolidation Quote Free debt consolidation quote online! No obligation. No credit check. http://thirdpartyoffers.netzero.net/TGL2241/c?cp=cyoog8NQa4mNZIgs6R2NrwAAJ1HbVVWM9bC-t-Va2hgXndJzAAQFAEWLnT8AAAMlABI2kQA= [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help on paramter optimization
Hi, I am new to R and I need to solve the following problem: I have an ODE model with variables x(t) and y(t) that can be solved using the deSolve package. That model uses several parameters. Now I have a set of observations for y(t), denoted as Y(t). I need to optimize the value of these parameters such that error between the model output y(t) and the observation Y(t) is minimized. In another word, y(t) is fitted to Y(t) as much as possible. What R package is available to optimize these parameter? Is there any sample R codes available? Thank you very much for your help! Jiefeng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] GLMMPQL and negbinomial: trouble with the X-axis in PREDICT
Ahh, yes. The level made all the difference. I originally thought the level only applied to binomial response variables, so I disregarded it. And I'll just add that plot(e) below still produced an indexed x axis, so I just combined the vectors and then was able to plot the scaled variable properly. MyData-data.frame(BERRIES = seq(from =20, to=3600, by=100)) e-predict(m1,MyData,type=response, level=0) q2-cbind(MyData,e) plot(q2$BERRIES,q2$e) Thanks for the fast responses! ~erin Erin Latham, MGIS Candidate Geography Dept, University of Calgary, AB, Canada __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re ading and Creating Shape Files
Hello R Community, I have imported a dataset which contain X Y coordinates and would like to recreate a shape file after some data analysis. What i have done is to import some taxlot data and join them based on some criteria. I want to check to see how well the joining went by reviewing the results in GIS. A couple things. I cant seem to import a shape file correctly using the maptools package and the readShapeSpatial. I have tried Building=file(data/input/BuildingShape/Building.shp) Bldg-readShapeSpatial(fn=data/input/BuildingShape/Building,proj4string=NAD83) #-- Bldg-readShapeSpatial(data/input/BuildingShape/Building,proj4string=NAD83) #--- Building=file(data/input/BuildingShape/Building.shp) Bldg-readShapeSpatial(Building,proj4string=NAD83) I know i am mis interpreting the documentation but it doesnt seem like it is very complicated so i am of course confused. Also, i am wondering if i can create a shape file by simply using XY coordinates from a data frame. So for: Ycoord=c( 865296.4, 865151.5, 865457.0 ,865363.4 ,865311.0, 865260.9 ,865210.7 ,865173.3, 865123.6 ,865038.2 ,864841.1 ,864745.4 ,864429.1 ,864795.6 ,864334.9 ,864882.0) Xcoord=c( 4227640 ,4227816 ,4228929 ,4228508 ,4229569 ,4229498 ,4226747, 4226781, 4229597, 4229204, 4228910, 4228959 ,4229465 ,4229794 ,4229596 ,4229082) Lot-c(1900 , 2000, 2100 , 100 ,200 , 300, 400 , 500 , 600 , 701 , 900 , 1000 , 1100, 300 ,100, 200) XYcoord-spCbind(Ycoord,Xcoord) #doesnt work so XYcoord=c(Ycoord,Xcoord) TaxLots-cbind(Ycoord,Xcoord,Lot) writeSpatialShape(XYcoord, TaxLots.., file=data/input/test/Taxlots,strictFilename=FALSE) So help reading in shape files and then creating them using XY coordinates if possible Any help would be appreciated. Thank you. -- View this message in context: http://www.nabble.com/Reading-and-Creating-Shape-Files-tp26098828p26098828.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] GGPLOT2 Different Layers Different X Values
Hello Hadley, I'm not sure how easily I'd be able to come up with a good example. My data contain thousands of points, and I can't really divulge this data outside my company. But I can tell you that I found a solution (though somewhat hackish). I just created another matrix with each date having a single value. I then added that as a separate histogram scaled to something ridiculously small (like 0.0001). It acts as a sort of place holder for all the other layers. It seems to do that job. Thanks, Jon -Original Message- From: Hadley Wickham [mailto:h.wick...@gmail.com] Sent: Wednesday, October 28, 2009 6:59 AM To: Bleyhl, Jonathan Cc: r-help@r-project.org Subject: Re: [R] GGPLOT2 Different Layers Different X Values Hi John, Could you please provide a small reproducible example? Thanks, Hadley Sent from my iPhone On 26/10/2009, at 6:50 PM, Jonathan Bleyhl jonathan_ble...@affymetrix.com wrote: I'm trying to plot values based on a date and then overlay a histogram also by date. The problem is that both data sets don't have exactly the same dates. So when I add the histogram, any dates that aren't already there from from the scatter plot just get tacked on at the end and are out of order. I tried using scale_x_discrete, but to no avail. Thanks, Jon -- View this message in context: http://www.nabble.com/GGPLOT2-Different-Layers-Different-X-Values-tp26069893p26069893.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This transmission is intended for the sole use of the individual and entity to whom it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. You are hereby notified that any use, dissemination, distribution or duplication of this transmission by someone other than the intended addressee or its designated agent is strictly prohibited. If you have received this transmission in error, please notify the sender immediately by reply to this transmission and delete it from your computer. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] multiple pages with ggplot2 facet_wrap?
I currently use lattice functions to produce multiple pages of plots using the layout argument to specify the number of rows and columns of panels, e.g., xyplot(price ~ carat | clarity, diamonds, layout = c(2, 2)) This results in 2 pages of 4 panels each. diamonds is a data.frame distributed with ggplot2. I would like to do the same with ggplot2 but have been unsuccessful. The following sequence of statements seemed like a logical way to do it: p - ggplot(diamonds, aes(carat, price)) p + geom_point() + facet_wrap(~clarity, ncol = 2, nrow = 2) But they result in the error statement: Error in nrow * ncol : non- numeric argument to binary operator. Is facet_wrap or facet_grid capable of producing multiple pages of plots and, if so, how? Thanks, Bill William R Gillespie, VP Strategic Modeling Simulation Metrum Research Group LLC 2 Tunxis Road, Suite 112, Tariffville, CT 06081 Direct FAX:919-371-2786, Main:860-735-7043 bi...@metrumrg.com www.metrumrg.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] write to RTF format - possible?
Hi everybody, To write a .txt file I use write.table() Is there a way to write to a .rtf file as well? TIA Mark ––– Mark Heckmann Dipl. Wirt.-Ing. cand. Psych. Vorstraße 93 B01 28359 Bremen Blog: www.markheckmann.de R-Blog: http://ryouready.wordpress.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Basic simple question
I have a statement like below. my_num - c(101,102,103,104,105,107,108,112,113,114,115) my_df has 8,000 different STREPS in it. I have a statement where I can select ONE item from data frame my_df txhd_df - prec_dist_df[ my_df$STREP==101, c(COUNTY, FIPS, STSEN, STREP, PREC)] I would like to make R compare and deliver only the STREPS that are in my_num. A comparative SQL command WHERE STREP IN(101,102,103,104,105,107,108,112,113,114,115) Thanks for any help, Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Labelling individual points on 3D PCA scatterplot
Thank you Duncan! That is very helpful, after posting this i did figure out how to convert the 2d coordinates into 3d. I was initially hesitant about using rgl because i thought it looked messy. With the modifications you suggested for the plot, it actually looks very clear now in rgl! And it rotates :-D Thanks again! Tom Rzeszutek MSc. Candidate McMaster University Duncan Murdoch-2 wrote: On 10/28/2009 11:21 AM, trz wrote: Hi There, I'm attempting to plot 10 values on a three-dimensional PCA with text labels next to each point. While i have no trouble doing this on 2D plots using the 'text' or 'textxy' function, I cannot find a function to do this on a 3D plot. I am using princomp for my PCA: PCA-princomp(eucdata, cor=TRUE) PCA$scores [,1:3]# the three principal components i want to plot Then i am using 'scatterplot3d' to plot my first 3 principal components: scatterplot3d(PCA$scores [,1:3],xlab=Component 1 (26.9%),main=My 3D PCA,ylab=Component 2 + (17.9%), zlab=Component 3 (12.4%),type=h,box=FALSE,pch=21,bg=color) And i get this: http://www.nabble.com/file/p26096592/myPCA.jpeg 'text' and 'textxy' only accept 2D coordinates so they do not label my points in a way that makes sense. I'm open to other 3D plotting functions in R, i just think this one is easy to visually understand. In addition, If there is any way to move the grid up to z=0 please let me know. To be clear i am trying to make my PCA look more like this one i found in a journal article (Trejaut et al., 2005): http://www.nabble.com/file/p26096592/journal.pbio.0030247.g003.png scatterplot3d will return a function that can transform 3D coordinates to 2D so you can plot labels in the right place; see its man page. Alternatively, you could use the rgl package. Using the example(princomp) results, the call is similar to what you had, with some extra work for embellishment: plot3d(pc.cr$scores [,1:3],xlab=Component 1,main=My 3D PCA,ylab=Component 2, zlab=Component 3, type=h, box=F, axes=F) spheres3d(pc.cr$scores[,1:3], radius=0.1, col=pink) grid3d(side=z, at=list(z=0)) text3d(pc.cr$scores[,1:3], text=rownames(pc.cr$scores), adj=1.3) This looks too crowded, but maybe you have fewer points to plot. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Labelling-individual-points-on-3D-PCA-scatterplot-tp26096592p26101737.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] output of for
Hello! I've got troubles on following thing: As output I need a string like: INPUT_FILENAMES = H:\\AKK_temp\\Modis\\MOD13Q1\\austria\\MOD09Q1.A2008073.h18v04.005.2008083134952.hdf|H:\\AKK_temp\\Modis\\MOD13Q1\\austria\\MOD09Q1.A2008073.h19v04.005.2008082182221.hdf The filenames (dates) are with pathname (wrkdr) and separated with |. The number of input filenames changes (minimum 1, maximum n) wrkdr - H:\\akk_temp\\Modis\\MOD09 dates is a data.frame where each row is a date and each column is a Modis-image (the name of it) I did this as following: paste('INPUT_FILENAMES = ', for(g in 1:(ntiles-1)) {paste(wrkdr,'\\',dates[i,g+1],'|',sep='')} , for(g in ntiles){ paste(wrkdr,'\\',dates[i,g+1],sep='') } ,sep='') and this did work (in an other wrkdr and other dates) but after changing, for gave no more output. And I don't know why!!! Why i use for twice? Because after the last file there is no |... Thanks for help Matteo [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] superscript in ylab
Try ylab=expression(Temperature*degree*C)) type demo(mathplot) at R prompt for more customizations. Walmes Zeviani Lavras - MG, Brasil. Lathouri, Maria wrote: Dear all I am doing some plots in R. I want to have as label in y-axis Temperature (oC). I have used ylab=expression(paste({Temperature} ^o*C)) but what I get is TemperatureoC. How can I have a space between Temperature and the units and also the units to be in brackets? Many thanks Maria [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/superscript-in-ylab-tp26099304p26099677.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sample weight for box plot?
Hi, I would like to make a box and whisker plot but use a sample weight for each observation. I've searched around a bit and have not found a method of doing this. Anyone have any advice? Thanks much, Sean Parks -- View this message in context: http://www.nabble.com/sample-weight-for-box-plot--tp26104205p26104205.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] operation with if/else on a dataframe
Hi to all, I have this dataframe (I show the first six rows) head(table) A RFold.Change P.Value Count1 Count2 1 ENSRNOE002_at 0 1.13 0.601 1 2 ENSRNOE009_at 0-1.04 0.733 3 3 ENSRNOE020_at 0-1.08 0.680 0 4 ENSRNOE021_at 0-1.31 0.201 2 5 ENSRNOE023_at 0-1.06 0.643 3 6 ENSRNOE024_at 0-1.14 0.403 3 I would like to generate a function that determine for each row a new value (resulting in a new vector of values to add to the dataframe). The function should give for every row the same value showed in column R. However,I need of this because not all the R-values reported in this table are correctly determined following the criteria mentioned below. These new values calculated by the function must be: 1)UP if all the following conditions are verified in a certain row: Fold.Change is = +1.5, P.Value is 0.05 Count1 = 2 2)DOWN if all the following conditions are verified in a certain row: Fold.Change is = -1.5, P.Value is 0.05 Count2 = 2 3) 0 if both of previous conditions are not verified So I have set these fllowing parameters (new objects) because I'll have to repeat this procedure to different dataframes in which the order of columns of interest might change (So I can change these parameters depending on the order of the columns in any different table) Fold.change - 3 #(because in this table, Fold.Change value is the third column and so on...) P.Value - 4 Count1 - 5 Count2 - 6 The function is: func_UP_0_DOWN - function(x) { if (x[Fold.Change] = 1.5 x[P.Value] = 0.05 x[Count1] = 2) { return (UP)} else { if (x[Fold.Change] = -1.5 x[P.Value] = 0.05 x[Count2] = 2) { return (DOWN)} else { return(0)} } } and then I have decided to apply the function for every row: values.vector - apply(table,1,func_UP_0_DOWN) But when I check the resulting vector of calculated values: table(values.vector) values.vector 0 192279 I have all zero but this is wrong since I expect some UP and DOWN However, if I apply this function on a single row in which I just know that there is a UP-value... (for example row 66): table[66,] RFold.Change P.Value Count1 Count2 66 ENSRNOE162_atUP 1.84 0.013 3 the function seems to work correctly: func_UP_0_DOWN(table[66,]) [1] UP This is my problem, I cannot use the function to recalculate values in R-column for all rows in my dataframe. I don't understand where is the problem, can someone help me? Thanks a lot!! Francesco -- View this message in context: http://www.nabble.com/operation-with-if-else-on-a-dataframe-tp26109081p26109081.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] please help
Is there any function for finding number of groups using upper tail rule or moving average approach suggested by Mojena? I would also like to find functions for other stopping rules in Hierarchical clustering method. If anyone knows please kindly let me know. Kind regards, Ms.Karunambigai M PhD Scholar Dept. of Biostatistics NIMHANS Bangalore India Now, send attachments up to 25MB with Yahoo! India Mail. Learn how. http://in.overview.mail.yahoo.com/photos [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bezier interpolation
Dear List, I am trying to interpolate animal tracking data using Bezier curves. I need a function similar to spline() or approx() but that has a method Bezier. I have tried xspline() but it does not allow you to set the number of points to interpolate between a given interval (n points between min(x) and max(x)). Mark Hindell asked the same question in 2006 (http://tolstoy.newcastle.edu.au/R/e2/help/06/12/7034.html). I contacted him and he never found a workable function. Has one been developed since then? Thanks, Tim Tim Clark Department of Zoology University of Hawaii __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re trieving comments from PostgreSQL tables with RODBC and psqlodbc
You seriously need to update your way-obsolete software (see the posting guide), but you are seeing what your ODBC driver is returning, not an R issue. R-sig-db is a better list for help on database connectivity. On Wed, 28 Oct 2009, Jim Cser wrote: I don't know whether this is an RODBC issue, a psqlodbc issue or a PostgreSQL issue; I've searched the documentation and forums for each, with no success. I want to list all the tables in a PostgreSQL schema, and return the table comments as well as the table names. As an example, one table is defined as follows: CREATE TABLE scen990.ezone_locationprice_year1 ( ezone integer NOT NULL, lprice_man_year1 real, lprice_war_year1 real, lprice_ret_year1 real, lprice_gen_year1 real, lprice_med_year1 real, lprice_gov_year1 real, CONSTRAINT ezone_locationprice_year1_pkey PRIMARY KEY (ezone) ) WITHOUT OIDS; ALTER TABLE scen990.ezone_locationprice_year1 OWNER TO mscope; COMMENT ON TABLE scen990.ezone_locationprice_year1 IS 'calculated'; The RODBC function sqlTables() returns all the tables, but the records look like this: TABLE_QUALIFIER TABLE_OWNER TABLE_NAME TABLE_TYPE REMARKS mscope scen990 ezone_locationprice_year1 TABLE All the REMARKS values are empty strings. Can I get it to return the COMMENT ON values instead? (the table_owner and tablet_qualifier are switched but that doesn't worry me) I'm using R 2.8.1, RODBC 1.2-4, psqlodbc 8.0.2, and PostgreSQL 8.1.5 . Regards, Jim Cser -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] operation with if/else on a dataframe
On Thu, 2009-10-29 at 01:47 -0700, Fran100681 wrote: Hi to all, I have this dataframe (I show the first six rows) head(table) A RFold.Change P.Value Count1 Count2 1 ENSRNOE002_at 0 1.13 0.601 1 2 ENSRNOE009_at 0-1.04 0.733 3 3 ENSRNOE020_at 0-1.08 0.680 0 4 ENSRNOE021_at 0-1.31 0.201 2 5 ENSRNOE023_at 0-1.06 0.643 3 6 ENSRNOE024_at 0-1.14 0.403 3 I would like to generate a function that determine for each row a new value (resulting in a new vector of values to add to the dataframe). The function should give for every row the same value showed in column R. However,I need of this because not all the R-values reported in this table are correctly determined following the criteria mentioned below. These new values calculated by the function must be: 1)UP if all the following conditions are verified in a certain row: Fold.Change is = +1.5, P.Value is 0.05 Count1 = 2 2)DOWN if all the following conditions are verified in a certain row: Fold.Change is = -1.5, P.Value is 0.05 Count2 = 2 3) 0 if both of previous conditions are not verified So I have set these fllowing parameters (new objects) because I'll have to repeat this procedure to different dataframes in which the order of columns of interest might change (So I can change these parameters depending on the order of the columns in any different table) Fold.change - 3 #(because in this table, Fold.Change value is the third column and so on...) P.Value - 4 Count1 - 5 Count2 - 6 [ Quote text] This is my problem, I cannot use the function to recalculate values in R-column for all rows in my dataframe. I don't understand where is the problem, can someone help me? Thanks a lot!! Francesco Francesco, I think you solve this problem with a simple way. Remember in R the most function and operations are vectorized so look this example: set.seed(123) x-rpois(20,5) y-rpois(20,15) z-rpois(20,10) dta-data.frame(x,y,z) dta dta$NEW-ifelse(x5 y15 z10,UP, ifelse(x5 y15 z10,DOWN, 0)) dta First, I use ifelse command to simplify your nested conditional situation. Second, I know that R test this nested condition in order so the first position will result test x[1],y[1] and z[1], the second postion will result test x[2],y[2] and z[2] ... The new vector result is the same order the original data.frame so I use dta$NEW to create a new column in data.frame -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] correlated binary data and overall probability
Dear All, I try to simulate correlated binary data for a clinical research project. Unfortunately, I do not come to grips with bindata(). Consider corr-data.frame(ID=as.factor(rep(c(1:10), each=5)), task=as.factor(rep(c(1:5),10))) [this format might be more appropriate:] corr2-data.frame(ID=as.factor(rep(c(1:10),5)), tablet=as.factor(rep(c(1:5),each=10))) Now, I want to add one column 'outcome' for the binary response: * within each 'task', the probabilty of success (1) is fixed, (say rbinom(x,1,0.7)) * within each 'ID', the outcomes are correlated (say 0.8) How can I generate this column 'outcome' with the given proporties? Many thanks for hints or even code! Regards, Christian -- http://portal.gmx.net/de/go/dsl02 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot, data frame and html
Gregoire, it worked very well, thanks -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Gregoire Pau gregoire@embl.de To: r-help@r-project.org Cc: Silvano silv...@uel.br Sent: Wednesday, October 28, 2009 10:08 AM Subject: Re: [R] boxplot, data frame and html Hello Silvano, 'hwrite' appends HTML elements in a web page. The web page has to be opened before adding elements in it. The following code should work: require(hwriter) p = openPage('T1000.html') hwrite(t1000[,c(1,5,6)], p, bgcolor='#ffdc98', row.bgcolor='#ffdc98', br=TRUE) hwriteImage('caixa.jpg', p, br=TRUE) hwrite('', p, br=TRUE) closePage(p) Greg --- Gregoire Pau EMBL Research Officer http://www.ebi.ac.uk/~gpau/ Silvano wrote: Hi, I'm trying put in same page: - a data frame with 3 columns and 45 lines; - a box plot; the code is: require(hwriter) hwrite(t1000[,c(1,5,6)], 'T1000.html', bgcolor='#ffdc98', row.bgcolor='#ffdc98', br=TRUE) p = openPage('T1000.html') hwriteImage('caixa.jpg', p, br=TRUE) hwrite('',p, br=TRUE) closePage(p) but isn't working. What's wrong? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] write to RTF format - possible?
Hello On 10/28/09, Mark Heckmann mark.heckm...@gmx.de wrote: To write a .txt file I use write.table() Is there a way to write to a .rtf file as well? With odfWeave [1] you can create OOo documents, from which the conversion to .rtf would be trivial. If you wan to export a table, then you could also export it in an HTML file (say, via xtable() ) and then Open with Gnumeric. I think MS Office would also do this, but OOo doesn't seem to. Liviu [1] http://cran.r-project.org/web/packages/odfWeave/index.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] changing default character size depending on settings for mfcol: How to scale font consistently?
Dear R-users, I would like to create pdf files with varying paper sizes. The paper size is determine by the number of plots that I squeeze on a page using par(mfcol). I also add text to each of these plots. I observed that depending on the number of plots per page, the default character size is changing, leading to differing font sizes in my plot annotations. I would like to use cex to scale the font size so that I obtain identical font sizes in my pdf, independent of the size of my page in the pdf. My question is, how do I find out the current default for character size so that I can calculate an appropriate scaling factor? Or are there any better alternatives? Below, I added an example code to produce three pdf files. Note that the red letters in the plot have different sizes, depending on the number of plots per page. Thank you very much in advance! Kim platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 10.0 year 2009 month 10 day26 svn rev50208 language R version.string R version 2.10.0 (2009-10-26) Example code test.data - matrix(rnorm(300, 100, 25), nrow=3, ncol = 100, byrow = TRUE) x - seq(1,100) how.many.to.plot - c(1,2,3) for(i in 1:length(how.many.to.plot)) { test.data.red - matrix(test.data[1:how.many.to.plot[i],], nrow =how.many.to.plot[i], ncol = 100) pdf.name - paste(test, how.many.to.plot[i], .pdf, sep=,collapse=) pdf(file= pdf.name, width = 7, height=(7/5)*nrow(test.data.red)) par(mar=c(0, 0, 0, 0.0), cex = 1, oma = c(0,0,0,0), mfcol= c(nrow(test.data.red),1)) for(j in 1:(nrow(test.data.red))) { plot( x, test.data.red[j,], ylim = c(0, max(test.data.red[j,])), type = l, xaxt = n, yaxt = n, ) text( x = 30, y = 75, labels = LETTERS[j], cex = 1.6, col =red ) } dev.off() } -- Kim Milferstedt, PhD Postdoctoral Researcher INRA Laboratoire de Biotechnologie de l'Environnement Avenue des Etangs F-11100 Narbonne France phone: (+33) 04 68 42 51 87 fax: (+33) 04 68 42 51 60 email: milfe...@supagro.inra.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] HOW to determine the number of components of the mixture model stratfied by age
On Oct 28, 2009, at 10:41 PM, lybaomc wrote: DOES NOBODY KNOW? HELP! You submitted a question that appeared somewhat vague and had no reproducible example. Sometimes people will step forward and create a particular example to demonstrate coding options but there is no expectation that someone _should_ do so. Generally the cycle time to an answer is less than 24 hours so during the last week you should have been asking yourself what _you_ might have in the construction of your question that made it answer-unworthy. Read the Posting Guide. The answer to how to write a good question for r-help should be there. -- David. lybaomc wrote: Hi,all with my data,there are more than 1000 quantitative results of antibody concentrations, there may be 2 components(positive and negative), or 3 components (may be strong positive, positive, and negative), or 4-6 components. Could you tell me how to determine the number of components of the mixture model? the anova.mix in mixdist of the R software seems not work. my data is a little complicated(TABLE ), there are more than 1000 quantitative results of antibody concentrations stratified by age.The overall density of results at age j, Fj, is a mixture of the component densities, so if there are 5 age groups, then there will be 5 mixture models. Do i have to analyse each stratum respectively? TABLE age Bin length freq 1 1 19.75 4 1 2 21.7510 11241.7536 2 1 19.75 4 2 2 21.7510 21241.7536 --- appreciated lybao -- View this message in context: http://www.nabble.com/HOW-to-determine-the-number-of-components-of-the-mixture-model-stratfied-by-age-tp25971060p26105416.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is there a faster way to do it?
You might also want to consider using na.string=9 in the scan(). jim holtman wrote: Here is a faster way of doing the replacement: (provide reproducible data next time) x - matrix(sample(6:9, 64, TRUE), 8) x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,]87767879 [2,]77867677 [3,]77769667 [4,]99768766 [5,]69988989 [6,]97697867 [7,]79897978 [8,]99699886 x.f - 1:8 # replacement values based on column x.ind - which(x == 9, arr.ind=TRUE) x.ind row col [1,] 4 1 [2,] 6 1 [3,] 8 1 [4,] 4 2 [5,] 5 2 [6,] 7 2 [7,] 8 2 [8,] 5 3 [9,] 6 4 [10,] 7 4 [11,] 8 4 [12,] 3 5 [13,] 8 5 [14,] 5 6 [15,] 7 6 [16,] 1 8 [17,] 5 8 x[x.ind] - x.f[x.ind[,'col']] x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,]87767878 [2,]77867677 [3,]77765667 [4,]12768766 [5,]62388688 [6,]17647867 [7,]72847678 [8,]12645886 On Wed, Oct 28, 2009 at 12:55 PM, Marcio Resende mresende...@yahoo.com.br wrote: #Mdarts is a matrix 2343x788 #frequencia is a vector 2343x1 # 9 in Mdarts[fri,frj] stands for my missing values which i want to replace by the value in the vector frequencia Mdarts-t(matrix(scan(C:/GWS/CNB/dartg.txt),ncol=nindT,nrow=nm, byrow=T)) frequencia - matrix(scan(C:/GWS/CNB/freq.txt),ncol=1) for (fri in 1:nindT){ for (frj in 1:nm){ Mdarts[fri,frj] - if (Mdarts[fri,frj] == 9) frequencia[frj] else Mdarts[fri,frj] Mdarts[fri,frj] - Mdarts[fri,frj]/1-(frequencia[frj]^2) } } Is there a faster way to it? Maybe using any apply function? Thanks in advance -- View this message in context: http://www.nabble.com/Is-there-a-faster-way-to-do-it--tp26098223p26098223.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Removing generating data by category
Here is another way based on pasting ids as hinted below: a - data.frame(id=c(c(A1,A2,A3,A4,A5), c(A3,A2,A3,A4,A5)), loc=c(B1,B2,B3,B4,B5), clm=c(rep((General),6),rep(Life,4))) a$uid - paste(a$id, ., a$loc, sep=) out - tapply( a$clm, a$uid, paste ) # can also add collapse=, $A1.B1 [1] General $A2.B2 [1] General Life $A3.B1 [1] General $A3.B3 [1] General Life $A4.B4 [1] General Life $A5.B5 [1] General Life Then here are those with single policies. out[ which( sapply(out, length) == 1 ) ] $A1.B1 [1] General $A3.B1 [1] General David Winsemius wrote: On Oct 28, 2009, at 9:30 PM, Steven Kang wrote: Dear R users, Basically, from the following arbitrary data set: a - data .frame (id = c (c (A1 ,A2 ,A3 ,A4 ,A5 ),c (A3 ,A2 ,A3 ,A4,A5)),loc=c(B1,B2,B3,B4,B5),clm=c(rep((General), 6),rep(Life,4))) a id loc clm 1 A1 B1 General 2 A2 B2 General 3 A3 B3 General 4 A4 B4 General 5 A5 B5 General 6 A3 B1 General 7 A2 B2Life 8 A3 B3Life 9 A4 B4Life 10 A5 B5Life I desire removing records (highlighted records above) with identical values in each fields (id loc) but with different value of clm (i.e according to category) Take a look at this merge operation on separate rows of a. merge( a[a$clm==Life, ], a[a$clm==General, ] , by=c(id, loc), all=T) id loc clm.x clm.y 1 A1 B1 NA General 2 A2 B2 Life General 3 A3 B1 NA General 4 A3 B3 Life General 5 A4 B4 Life General 6 A5 B5 Life General Assignment of that object and selection with is.na should complete the process. a2m - merge( a[a$clm==Life, ], a[a$clm==General, ] , by=c(id, loc), all=T) a2m[ is.na(a2m$clm.x) | is.na(a2m$clm.y), ] id loc clm.x clm.y 1 A1 B1 NA General 3 A3 B1 NA General Alternate methods might include paste-ing id to loc and removing duplicates. i.e categ - table(a$id,a$clm) categ General Life A1 10 A2 11 A3 21 A4 11 A5 11 The desired output is id loc clm 1 A1 B1 General 6 A3 B1 General Because the data set I am working on is quite big (~ 800,000 x 20) with majority of the fields values being long strings, looping turned out to be very inefficient in comapring individual rows.. Are there any alternative efficient methods in implementing this problem? Steven __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sample weight for box plot?
On Oct 28, 2009, at 8:00 PM, Sean Parks wrote: Hi, I would like to make a box and whisker plot but use a sample weight for each observation. I've searched around a bit and have not found a method of doing this. Anyone have any advice? There are a variety of ways to get weighted quantiles. Two that have come up in recent r-help postings are the facilities in the quantreg package and wtd.quantile in Hmisc. Once you have calculated the five numbers that define a box-whisker plot they can be passed to bxp. ?bxp -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Basic simple question
try: txhd_df - prec_dist_df[ my_df$STREP %in% my_num, c(COUNTY, FIPS, STSEN, STREP, PREC)] On Thu, Oct 29, 2009 at 1:04 AM, Jim Burke j.bu...@earthlink.net wrote: I have a statement like below. my_num - c(101,102,103,104,105,107,108,112,113,114,115) my_df has 8,000 different STREPS in it. I have a statement where I can select ONE item from data frame my_df txhd_df - prec_dist_df[ my_df$STREP==101, c(COUNTY, FIPS, STSEN, STREP, PREC)] I would like to make R compare and deliver only the STREPS that are in my_num. A comparative SQL command WHERE STREP IN(101,102,103,104,105,107,108,112,113,114,115) Thanks for any help, Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lmer and negative binomial family
Dear listers, One of my former students is trying to fit a model of the negative binomial family with lmer. In the past (two years ago), the following call was working well: m1a-lmer(mapos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.451),REML=TRUE,data=manu) But now (R version 2.9.2 and lme4 version 0.999375-32), that gives (even with the library MASS loaded): m1a-lmer(mapos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.451),REML=TRUE,data=manu) Error in famType(glmFit$family) : unknown GLM family: 'Negative Binomial' Any idea about what happens ? Patrick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lmer and negative binomial family
Dear listers, One of my former students is trying to fit a model of the negative binomial family with lmer. In the past (two years ago), the following call was working well: m1a-lmer(mapos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.451),REML=TRUE,data=manu) But now (R version 2.9.2 and lme4 version 0.999375-32), that gives (even with the library MASS loaded): m1a-lmer(mapos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.451),REML=TRUE,data=manu) Error in famType(glmFit$family) : unknown GLM family: 'Negative Binomial' Any idea about what happens ? Patrick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lmer and negative binomial family
Patrick Giraudoux a écrit : Dear listers, One of my former students is trying to fit a model of the negative binomial family with lmer. In the past (two years ago), the following call was working well: m1a-lmer(mapos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.451),REML=TRUE,data=manu) But now (R version 2.9.2 and lme4 version 0.999375-32), that gives (even with the library MASS loaded): m1a-lmer(mapos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.451),REML=TRUE,data=manu) Error in famType(glmFit$family) : unknown GLM family: 'Negative Binomial' Any idea about what happens ? Patrick Oups. Sorry to reply to myself, but the answer was here: http://www.nabble.com/What-happen-for-Negative-binomial-link-in-Lmer-fonction--td26013041.html [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lmer and negative binomial family
Patrick, I am not sure about this but (1) I think you need to load the lme4 package, not MASS (2) I don't think neg.bin is allowable. I suggest you load lme4 and then type ?family John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Patrick Giraudoux patrick.giraud...@univ-fcomte.fr 10/29/2009 8:43 AM Dear listers, One of my former students is trying to fit a model of the negative binomial family with lmer. In the past (two years ago), the following call was working well: m1a-lmer(mapos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.451),REML=TRUE,data=manu) But now (R version 2.9.2 and lme4 version 0.999375-32), that gives (even with the library MASS loaded): m1a-lmer(mapos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.451),REML=TRUE,data=manu) Error in famType(glmFit$family) : unknown GLM family: 'Negative Binomial' Any idea about what happens ? Patrick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] x11(title=' ')
From: r-help-boun...@r-project.org on behalf of Jim Lemon Sent: Thu 29-Oct-09 0:20 Cc: R Help Subject: Re: [R] x11(title=' ') On 10/28/2009 09:51 PM, Prof Brian Ripley wrote: ... Are you perchance x11() on Windows, when you should be using windows()? The posting guide asked you to tell us your OS, amongst other things I say, my dear professor, if this MS chap who has used a Microsoft email client and a Microsoft email service turns out to be using Linux, he's covered his tracks pretty well. Well, he wouldn't be the only one who can use Linux for serious R work, but is forced by institutional policy to use MS for email. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Invert the sign of a number
Hello, just a simple question How can I do to invert the sign of a number? (for example: -4 to 4, 2 to -2 and so on..) I was looking for a specific function in R but I didn't found it... thank you Francesco -- View this message in context: http://www.nabble.com/Invert-the-sign-of-a-number-tp26110267p26110267.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] similarity measure for binary data
I am doing hierarchical clustering with cluster package. I couldnot find similarity measures like matching coefficient, Jaccard coefficient and sokal and sneath. Could anyone please tell package with similarity measures for binary data? kind regards, Ms.Karunambigai M PhD Scholar Dept. of Biostatistics NIMHANS Bangalore India From cricket scores to your friends. Try the Yahoo! India Homepage! http://in.yahoo.com/trynew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] singular variance-covariance warning in lmer
Dear R Users, I was hoping for some help with a recurrent error message in lmer. I am trying to model the effect of temperature on metabolic rate in animals (response = int.length) at different temperatures (mean.sst), with repeated measurements on the same individuals (random effect = female). Ideally I would make a random slope and intercept model where the rate can change differently with temperature for different individuals: model-lmer(int.length~mean.sst+(mean.sst|female)) However, I get the following warning message: Warning message: Estimated variance-covariance for factor 'female' is singular in: `LMEoptimize-`(`*tmp*`, value = list(maxIter = 200L, tolerance = 1.49011611938477e-08, summary(model) Linear mixed-effects model fit by REML Formula: int.length ~ mean.sst + (mean.sst | female) AIC BIC logLik MLdeviance REMLdeviance 155.4 164.5 -72.7 142.8145.4 Random effects: Groups NameVariance Std.Dev. Corr female (Intercept) 6.8459e-10 2.6165e-05 mean.sst6.8169e-10 2.6109e-05 -0.065 Residual 1.3634e+00 1.1676e+00 number of obs: 46, groups: female, 18 Fixed effects: Estimate Std. Error t value (Intercept) 48.8249 6.5895 7.409 mean.sst -1.3609 0.2518 -5.406 Correlation of Fixed Effects: (Intr) mean.sst -1.000 If I try and run just a random intercepts model I get similar problems: model2-lmer(int.length~mean.sst+(1|female)) Warning message: Estimated variance for factor 'female' is effectively zero in: `LMEoptimize-`(`*tmp*`, value = list(maxIter = 200L, tolerance = 1.49011611938477e-08, I have tried disabling PQL iterations using control = list(usePQL = FALSE, msVerbose=TRUE), following Douglas Bates' recommendation on the mailing list archives but I still get a similar message. Does this mean that the variance among subjects is too close to zero for estimation of the random effects? I compared the random effects model to a linear model with just lm(int.length ~ mean.sst) using a likelihood ratio test and got p = 1.0 (which is always suspicious). It would actually make sense for there to be negligible variation among subjects in their response to temperature, however I am concerned that I am making a fundamental error somewhere along the line. I would greatly appreciate any suggestions you may have. Best regards Sam Weber University of Exeter, UK. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Invert the sign of a number
x - -x On Thu, Oct 29, 2009 at 6:06 AM, Fran100681 franar...@hotmail.it wrote: Hello, just a simple question How can I do to invert the sign of a number? (for example: -4 to 4, 2 to -2 and so on..) I was looking for a specific function in R but I didn't found it... thank you Francesco -- View this message in context: http://www.nabble.com/Invert-the-sign-of-a-number-tp26110267p26110267.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Invert the sign of a number
On 29/10/2009 6:06 AM, Fran100681 wrote: Hello, just a simple question How can I do to invert the sign of a number? (for example: -4 to 4, 2 to -2 and so on..) I was looking for a specific function in R but I didn't found it... thank you You want the unary - operator. For example, -x has opposite signs to x. Even --4 will work to give 4, but it will scare C programmers, so it's probably best to use parentheses: -(-4) Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] operation with if/else on a dataframe
Ok, thank you a lot!! Bernardo Rangel tura wrote: On Thu, 2009-10-29 at 01:47 -0700, Fran100681 wrote: Hi to all, I have this dataframe (I show the first six rows) head(table) A RFold.Change P.Value Count1 Count2 1 ENSRNOE002_at 0 1.13 0.601 1 2 ENSRNOE009_at 0-1.04 0.733 3 3 ENSRNOE020_at 0-1.08 0.680 0 4 ENSRNOE021_at 0-1.31 0.201 2 5 ENSRNOE023_at 0-1.06 0.643 3 6 ENSRNOE024_at 0-1.14 0.403 3 I would like to generate a function that determine for each row a new value (resulting in a new vector of values to add to the dataframe). The function should give for every row the same value showed in column R. However,I need of this because not all the R-values reported in this table are correctly determined following the criteria mentioned below. These new values calculated by the function must be: 1)UP if all the following conditions are verified in a certain row: Fold.Change is = +1.5, P.Value is 0.05 Count1 = 2 2)DOWN if all the following conditions are verified in a certain row: Fold.Change is = -1.5, P.Value is 0.05 Count2 = 2 3) 0 if both of previous conditions are not verified So I have set these fllowing parameters (new objects) because I'll have to repeat this procedure to different dataframes in which the order of columns of interest might change (So I can change these parameters depending on the order of the columns in any different table) Fold.change - 3 #(because in this table, Fold.Change value is the third column and so on...) P.Value - 4 Count1 - 5 Count2 - 6 [ Quote text] This is my problem, I cannot use the function to recalculate values in R-column for all rows in my dataframe. I don't understand where is the problem, can someone help me? Thanks a lot!! Francesco Francesco, I think you solve this problem with a simple way. Remember in R the most function and operations are vectorized so look this example: set.seed(123) x-rpois(20,5) y-rpois(20,15) z-rpois(20,10) dta-data.frame(x,y,z) dta dta$NEW-ifelse(x5 y15 z10,UP, ifelse(x5 y15 z10,DOWN, 0)) dta First, I use ifelse command to simplify your nested conditional situation. Second, I know that R test this nested condition in order so the first position will result test x[1],y[1] and z[1], the second postion will result test x[2],y[2] and z[2] ... The new vector result is the same order the original data.frame so I use dta$NEW to create a new column in data.frame -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/operation-with-if-else-on-a-dataframe-tp26109081p26110139.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R crashes
My R crashes frequently when run with huge data. -- View this message in context: http://www.nabble.com/R-crashes-tp26110355p26110355.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Invert the sign of a number
Fran100681 franar...@hotmail.it wrote just a simple question How can I do to invert the sign of a number? (for example: -4 to 4, 2 to -2 and so on..) I was looking for a specific function in R but I didn't found it... thank you Is there something wrong with *-1 ? Peter Peter L. Flom, PhD Statistical Consultant Website: www DOT peterflomconsulting DOT com Writing; http://www.associatedcontent.com/user/582880/peter_flom.html Twitter: @peterflom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] The system cannot find the file specified
What is the problem here? I did an install package from the Rgui menu. Windows Vista SNIP trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.9/mvtnorm_0.9-8.zip' Content type 'application/zip' length 236089 bytes (230 Kb) opened URL downloaded 230 Kb trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.9/QRMlib_1.4.4.zip' Content type 'application/zip' length 2369023 bytes (2.3 Mb) opened URL downloaded 2.3 Mb package 'robustbase' successfully unpacked and MD5 sums checked package 'fUtilities' successfully unpacked and MD5 sums checked package 'fEcofin' successfully unpacked and MD5 sums checked package 'fCalendar' successfully unpacked and MD5 sums checked package 'fSeries' successfully unpacked and MD5 sums checked package 'mvtnorm' successfully unpacked and MD5 sums checked package 'QRMlib' successfully unpacked and MD5 sums checked Error in normalizePath(path) : path[1]=C:\Program Files\R\R-2.9.2\library/QRMlib: The system cannot find the file specified SNIP __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R crashes
And PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. --- On Thu, 10/29/09, premmad mtechp...@gmail.com wrote: From: premmad mtechp...@gmail.com Subject: [R] R crashes To: r-help@r-project.org Received: Thursday, October 29, 2009, 6:13 AM My R crashes frequently when run with huge data. -- View this message in context: http://www.nabble.com/R-crashes-tp26110355p26110355.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] column names of a correlation matrix
Thanks! guys for the help. cheers! Lee On Wed, Oct 28, 2009 at 7:03 PM, Tony Plate tpl...@acm.org wrote: Here's a simple example that might help you get what you want: set.seed(1) x - matrix(rnorm(30), ncol=3, dimnames=list(NULL, letters[1:3])) (xc - cor(x)) a b c a 1.000 -0.3767034 -0.7158385 b -0.3767034 1.000 0.6040273 c -0.7158385 0.6040273 1.000 (cd - data.frame(elt=outer(colnames(xc), colnames(xc), paste, sep=:)[upper.tri(xc)], row=row(xc)[upper.tri(xc)], col=col(xc)[upper.tri(xc)], cor=xc[upper.tri(xc)])) elt row colcor 1 a:b 1 2 -0.3767034 2 a:c 1 3 -0.7158385 3 b:c 2 3 0.6040273 cd[order(-cd$cor),] elt row colcor 3 b:c 2 3 0.6040273 1 a:b 1 2 -0.3767034 2 a:c 1 3 -0.7158385 If you need something more efficient, try using which(..., arr.ind) to pick out matrix style indices, e.g.: (ii - which(xc -0.4 upper.tri(xc), arr.ind=T)) row col a 1 2 b 2 3 cbind(ii, cor=xc[ii]) row colcor a 1 2 -0.3767034 b 2 3 0.6040273 -- Tony Plate Lee William wrote: Hi! All, I am working on a correlation matrix of 4217x4217 named 'cor_expN'. I wish to obtain pairs with highest correlation values. So, I did this b=matrix(data=NA,nrow=4217,ncol=1) rownames(b)=rownames(cor_expN) for(i in 1:4217){b[i,]=max(cor_expN[i,])} head(b) [,1] aaeA_b3241_14 0.7181912 aaeB_b3240_15 0.7513084 aaeR_b3243_15 0.7681684 aaeX_b3242_12 0.5230587 aas_b2836_14 0.6615927 aat_b0885_140.6344144 Now I want the corresponding columns for the above values. For that I tried this c=matrix(data=NA,nrow=4217,ncol=1) for(i in 1:4217){b[i,]=colnames(max(cor_expN[i,]))} And got the following error: Error in b[i, ] = colnames(max(cor_expN[i, ])) : number of items to replace is not a multiple of replacement length Any thoughts? Lee [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.10 under Windows XP: glitches and successes
Hi Duncan, Duncan Murdoch wrote: On 28/10/2009 5:54 PM, Ross Boylan wrote: I just installed 2.10 on XP; ESS is my primary interface. I seem to be able to access all the help files; under 2.8.1 I was having seemingly random problems accessing some help topics (including one day I could and a few days later I couldn't, and vice-versa). That's good. I noticed a few glitches. First, the installer asks if you want text, CHM, or HTML help, but offers only text or HTML. I understand CHM has been removed; I guess this is just an old message. Yes, already fixed in the patched version. Second, install.packages(intervals) produced the usual line about selecting a mirror, but no selection list popped up. It just sat there until I interrupted the session and reentered the command with a pre-specified repos. I selected custom install but took the defaults; I noticed there was some optional tk/tcl stuff (which I did not select); I'm guessing it's required for these selections. Perhaps it should be installed by default? That's something I haven't seen before. I do get the mirror dialog, and it doesn't use tcl/tk, so I'd appreciate hearing if you can spot any pattern here (including the pattern I never get it). (The install option is about installing the tcl/tk help files: mainly useful if you're developing with tcl/tk, not necessary for most users. The Tcl/tk code itself is always installed.) It could be that R is being blocked by your anti-virus software; what it's trying to do is to read a list of mirrors from This is a longstanding problem for R under ess/emacs on Windows (and maybe Xemacs as well, but I don't know for sure). This problem manifests itself in install.packages(), but the real problem comes from the line if (.Platform$OS.type == windows | .Platform$GUI == AQUA) return(.Internal(select.list(list, preselect, multiple, title))) in select.list(). If you run R under ess/emacs and do something as simple as select.list(letters) it will freeze and you have to use C-g, C-c C-c to 'unfreeze'. Paradoxically, after doing so, select.list() will then function correctly. You can get around this problem by first loading the tcltk package, if that is of any help. This problem only occurs under emacs/ess; if you run R from a DOS prompt or via the GUI then select.list() works correctly the first time. Best, Jim http://cran.r-project.org/CRAN_mirrors.csv using the code in getCRANmirrors(). If that download fails or is delayed forever, you won't get the selection list. Third, every time one asks for help on a new topic there is a considerable delay (seemed like forever, probably c 15 seconds) before the help comes up. My first thought was that the on-demand help was being assembled, but I didn't see much CPU use. It might be latency in talking to MSIE, and this latency might even be from my (Sophos) antivirus software, which kept warning me about a program suspiciously launching MSIE. If you ask for help you already requested there is no delay (good) and it does not focus on the tab with the relevant help (which strikes me as the ideal behavior, though it may be hard to do). When you ask for help the first time, it starts the internal server, but that should be fast. Then it passes the URL to Windows to open, and Windows needs to open the browser to show it, which tends to be slow. When you ask subsequently, it will send the request to Windows again, but if the browser is open, that should be quick. I'd guess this is your antivirus checking out the URL; when I do it (with no antivirus checking on such things) it's pretty slow on the first occurence (because it needs to start Firefox), then pretty fast after that. Fourth, I read the previous comments about how more beta testers would be useful :) Yep. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- James W. MacDonald, M.S. Biostatistician Douglas Lab University of Michigan Department of Human Genetics 5912 Buhl 1241 E. Catherine St. Ann Arbor MI 48109-5618 734-615-7826 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Prediction Error Calculation
Any help would be appreciated. quaildoc wrote: Hello List, I am fitting a logistic regression model for some presence/absence type data. I have numerous covariates I am fitting to explain variation, and I am using AIC to rank models. However, I would like to report how well my best model (s) do at prediction. I have looked over the archives and the web and have come up with something that gives me what I think is the mean prediction error, BUT I am not sure of that. I am sort of unfamiliar with these types of statistics. Here is my code: metrics.global-glm(Type~MPI+IJI+ED+PRD+class2+class3+class5, family=binomial, data=metrics)## ##Type is my binary response 0 or 1 muhat-metrics.global$fitted.values ##assigns the fitted values a name muhat global.diag-glm.diag(metrics.global) ##creates a the diagnostic values cv.err-mean((metrics.global$y-muhat)^2/(1-global.diag$h)^2) ###calculates cv.err cv.err My main problem is I am unsure how to interpret what cv.err means for my model. I know that h is a leverage statistic for each observation. I would appreciate some interpretation clarification. Thank you. -- View this message in context: http://www.nabble.com/Prediction-Error-Calculation-tp26031236p26113145.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The system cannot find the file specified
Is 2.10 out? I'll give it a try. Thanks, Mark On Thu, Oct 29, 2009 at 6:45 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 29/10/2009 9:43 AM, Mark Knecht wrote: On Thu, Oct 29, 2009 at 6:39 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 29/10/2009 9:11 AM, Mark Knecht wrote: What is the problem here? I did an install package from the Rgui menu. Windows Vista normalizePath uses the Windows functions GetFullPathName and GetLongPathName to clean up paths, and one of them returned the error you saw. Does that path exist on your system? Duncan Murdoch SNIP Error in normalizePath(path) : path[1]=C:\Program Files\R\R-2.9.2\library/QRMlib: The system cannot find the file specified SNIP C:\Program Files\R\R-2.9.2\library does exist C:\Program Files\R\R-2.9.2\library/QRMlib does not. As it was the QRMlib package being installed it doesn't surprise me that it's not there, but please note the '/' instead of '\' like the rest of the path. I've seen this a number of times recently. This is the first I've posted here. Do you have write permission in C:\Program Files\R\R-2.9.2\library? It could be that the installer just tried to create the QRMlib subdir, and failed, and that's why it doesn't exist. What happens in 2.10.0? Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The system cannot find the file specified
On 29/10/2009 9:11 AM, Mark Knecht wrote: What is the problem here? I did an install package from the Rgui menu. Windows Vista normalizePath uses the Windows functions GetFullPathName and GetLongPathName to clean up paths, and one of them returned the error you saw. Does that path exist on your system? Duncan Murdoch SNIP trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.9/mvtnorm_0.9-8.zip' Content type 'application/zip' length 236089 bytes (230 Kb) opened URL downloaded 230 Kb trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.9/QRMlib_1.4.4.zip' Content type 'application/zip' length 2369023 bytes (2.3 Mb) opened URL downloaded 2.3 Mb package 'robustbase' successfully unpacked and MD5 sums checked package 'fUtilities' successfully unpacked and MD5 sums checked package 'fEcofin' successfully unpacked and MD5 sums checked package 'fCalendar' successfully unpacked and MD5 sums checked package 'fSeries' successfully unpacked and MD5 sums checked package 'mvtnorm' successfully unpacked and MD5 sums checked package 'QRMlib' successfully unpacked and MD5 sums checked Error in normalizePath(path) : path[1]=C:\Program Files\R\R-2.9.2\library/QRMlib: The system cannot find the file specified SNIP __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.10 under Windows XP: glitches and successes
On 29/10/2009 9:26 AM, James W. MacDonald wrote: Hi Duncan, Duncan Murdoch wrote: On 28/10/2009 5:54 PM, Ross Boylan wrote: I just installed 2.10 on XP; ESS is my primary interface. I seem to be able to access all the help files; under 2.8.1 I was having seemingly random problems accessing some help topics (including one day I could and a few days later I couldn't, and vice-versa). That's good. I noticed a few glitches. First, the installer asks if you want text, CHM, or HTML help, but offers only text or HTML. I understand CHM has been removed; I guess this is just an old message. Yes, already fixed in the patched version. Second, install.packages(intervals) produced the usual line about selecting a mirror, but no selection list popped up. It just sat there until I interrupted the session and reentered the command with a pre-specified repos. I selected custom install but took the defaults; I noticed there was some optional tk/tcl stuff (which I did not select); I'm guessing it's required for these selections. Perhaps it should be installed by default? That's something I haven't seen before. I do get the mirror dialog, and it doesn't use tcl/tk, so I'd appreciate hearing if you can spot any pattern here (including the pattern I never get it). (The install option is about installing the tcl/tk help files: mainly useful if you're developing with tcl/tk, not necessary for most users. The Tcl/tk code itself is always installed.) It could be that R is being blocked by your anti-virus software; what it's trying to do is to read a list of mirrors from This is a longstanding problem for R under ess/emacs on Windows (and maybe Xemacs as well, but I don't know for sure). Okay, I'll leave it to those guys to debug. If R is doing something it shouldn't, let me know what, and I'll try to fix it. (I'd guess the problem is that Emacs makes assumptions about the OS that just aren't true in Windows, but it might be a bug we could work around.) Duncan Murdoch This problem manifests itself in install.packages(), but the real problem comes from the line if (.Platform$OS.type == windows | .Platform$GUI == AQUA) return(.Internal(select.list(list, preselect, multiple, title))) in select.list(). If you run R under ess/emacs and do something as simple as select.list(letters) it will freeze and you have to use C-g, C-c C-c to 'unfreeze'. Paradoxically, after doing so, select.list() will then function correctly. You can get around this problem by first loading the tcltk package, if that is of any help. This problem only occurs under emacs/ess; if you run R from a DOS prompt or via the GUI then select.list() works correctly the first time. Best, Jim http://cran.r-project.org/CRAN_mirrors.csv using the code in getCRANmirrors(). If that download fails or is delayed forever, you won't get the selection list. Third, every time one asks for help on a new topic there is a considerable delay (seemed like forever, probably c 15 seconds) before the help comes up. My first thought was that the on-demand help was being assembled, but I didn't see much CPU use. It might be latency in talking to MSIE, and this latency might even be from my (Sophos) antivirus software, which kept warning me about a program suspiciously launching MSIE. If you ask for help you already requested there is no delay (good) and it does not focus on the tab with the relevant help (which strikes me as the ideal behavior, though it may be hard to do). When you ask for help the first time, it starts the internal server, but that should be fast. Then it passes the URL to Windows to open, and Windows needs to open the browser to show it, which tends to be slow. When you ask subsequently, it will send the request to Windows again, but if the browser is open, that should be quick. I'd guess this is your antivirus checking out the URL; when I do it (with no antivirus checking on such things) it's pretty slow on the first occurence (because it needs to start Firefox), then pretty fast after that. Fourth, I read the previous comments about how more beta testers would be useful :) Yep. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal,
Re: [R] The system cannot find the file specified
On Thu, Oct 29, 2009 at 6:39 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 29/10/2009 9:11 AM, Mark Knecht wrote: What is the problem here? I did an install package from the Rgui menu. Windows Vista normalizePath uses the Windows functions GetFullPathName and GetLongPathName to clean up paths, and one of them returned the error you saw. Does that path exist on your system? Duncan Murdoch SNIP Error in normalizePath(path) : path[1]=C:\Program Files\R\R-2.9.2\library/QRMlib: The system cannot find the file specified SNIP C:\Program Files\R\R-2.9.2\library does exist C:\Program Files\R\R-2.9.2\library/QRMlib does not. As it was the QRMlib package being installed it doesn't surprise me that it's not there, but please note the '/' instead of '\' like the rest of the path. I've seen this a number of times recently. This is the first I've posted here. Thanks, Mark __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] fast cumulative matrix multiplication
Hi all, I am looking for a function like cumprod() that works for matrix multiplication. In other words, I have matrices [M1, M2, ..., Mn], and I want to calculate [M1, M1%*%M2, M1%*%M2%*%M3, ..., M1%*%...%*%Mn] as quickly as possible. Right now I'm using a for() loop but it seems like there should be a faster way. Any help is appreciated! Thanks, Todd Schneider todd.w.schnei...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The system cannot find the file specified
On 29/10/2009 9:43 AM, Mark Knecht wrote: On Thu, Oct 29, 2009 at 6:39 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 29/10/2009 9:11 AM, Mark Knecht wrote: What is the problem here? I did an install package from the Rgui menu. Windows Vista normalizePath uses the Windows functions GetFullPathName and GetLongPathName to clean up paths, and one of them returned the error you saw. Does that path exist on your system? Duncan Murdoch SNIP Error in normalizePath(path) : path[1]=C:\Program Files\R\R-2.9.2\library/QRMlib: The system cannot find the file specified SNIP C:\Program Files\R\R-2.9.2\library does exist C:\Program Files\R\R-2.9.2\library/QRMlib does not. As it was the QRMlib package being installed it doesn't surprise me that it's not there, but please note the '/' instead of '\' like the rest of the path. I've seen this a number of times recently. This is the first I've posted here. Do you have write permission in C:\Program Files\R\R-2.9.2\library? It could be that the installer just tried to create the QRMlib subdir, and failed, and that's why it doesn't exist. What happens in 2.10.0? Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error installing RSPerl.
Dear list, I have updated to version R-2.10.0. When I try to load the RSPerl library I get the following error: library(RSPerl) Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/usr/local/lib/R/library/RSPerl/libs/RSPerl.so': /usr/local/lib/R/library/RSPerl/libs/RSPerl.so: undefined symbol: boot_DB_File__Glob Error: package/namespace load failed for 'RSPerl' I do not know how to fix this. Can anyone please help? I'm runninn R on Ubuntu 9.04 Many thanks, Grainne. sessionInfo() R version 2.10.0 (2009-10-26) i686-pc-linux-gnu locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Year and Month extraction from Date object.
On Tue, 2009-10-27 at 14:49 -0700, rkevinbur...@charter.net wrote: Hello, I have seen much discussion on Date. But I can't seem to do this simple operation. I can convert a string to a date: d - as.Date(DATE, format=%m/%d/%Y) But what I want to do is extract the year and month so I can construct an element in a ts object. Ideally I would like to see d$year but that doesn't seem to be available. Once I have a Date object how can I get an integer year? as.numeric(format(d, format = %Y)) as.numeric(format(d, format = %m)) and so on. Look at the formats in ?strftime for further details. HTH G Thank you. Kevin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] x11(title=' ')
Dear all sorry that i am late to reply for the question about my OS, I am using MS Windows XP 2003 OS thanking you Warm RegardMSNepal Date: Wed, 28 Oct 2009 22:20:50 +1100 From: j...@bitwrit.com.au CC: r-help@r-project.org Subject: Re: [R] x11(title=' ') On 10/28/2009 09:51 PM, Prof Brian Ripley wrote: ... Are you perchance x11() on Windows, when you should be using windows()? The posting guide asked you to tell us your OS, amongst other things I say, my dear professor, if this MS chap who has used a Microsoft email client and a Microsoft email service turns out to be using Linux, he's covered his tracks pretty well. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen2:102009 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Trouble retrieving data (.xls) from folder on my computer.
Using gdata on windows and im having trouble to retrieve an excel file from a folder on my computer. This is my dummy: R download.file(http://people.su.se/~lundh/data/cpi_kpix.rda;, + cpi_kpix.rda) R URL - http://people.su.se/; R PATH - ~lundh/data/ R FILE - cpi_kpix.rda R download.file(paste(URL,PATH,FILE,sep=), + cpi_kpix.rda) R library(gdata) R FILE - Stock_Returns_1931_2002.xls R stock.xls - read.xls(paste(URL, PATH, FILE, sep = ), + header = TRUE)[, 3:4] Downloading... Done. Converting xls file to csv file... Done. Reading csv file... Done. Im not suppose to download the file though its already on my computer. How do i type in the path så R finds my .xls?? kind regards Tobias -- View this message in context: http://www.nabble.com/Trouble-retrieving-data-%28.xls%29-from-folder-on-my-computer.-tp26113172p26113172.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What happen for Negative binomial link in Lmer fonction?
Thank you for your answers, I have an exemple of that i was using: m1a-lmer(atpos~ninter+saison+milieu*zone+(1|code),family=neg.bin(0.429),method=Laplace,data=manu) summary(m1a) Generalized linear mixed model fit using Laplace Formula: atpos ~ ninter + saison + milieu * zone + (1 | code) Data: manu Family: Negative Binomial(log link) AIC BIC logLik deviance 125.1 147.6 -54.57109.1 I think It was the version lme4 0.9975-10. Unfortunately, I have this version no more available on my computer.. I wonder if this old results are still valid.. Ben Bolker wrote: ROBARDET Emmanuelle wrote: Dear R users, I'm performing some GLMMs analysis with a negative binomial link. I already performed such analysis some months ago with the lmer() function but when I tried it today I encountered this problem: Erreur dans famType(glmFit$family) : unknown GLM family: 'Negative Binomial' Does anyone know if the negative binomial family has been removed from this function? I really appreciate any response. Emmanuelle I would be extremely surprised if this worked in the past; to the best of my knowledge the negative binomial family has never been implemented in lmer. One could in principle do a glmmPQL fit with the negative binomial family (with a fixed value of the overdispersion parameter). glmmADMB is another option. Can you say which version etc. you were using??? Follow-ups should probably be sent to r-sig-mixed-mod...@r-project.org -- View this message in context: http://www.nabble.com/What-happen-for-Negative-binomial-link-in-Lmer-fonction--tp26013041p26113408.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re ading and Creating Shape Files
PDXRugger wrote: Hello R Community, I have imported a dataset which contain X Y coordinates and would like to recreate a shape file after some data analysis. What i have done is to import some taxlot data and join them based on some criteria. I want to check to see how well the joining went by reviewing the results in GIS. A couple things. I cant seem to import a shape file correctly using the maptools package and the readShapeSpatial. I have tried Building=file(data/input/BuildingShape/Building.shp) Bldg-readShapeSpatial(fn=data/input/BuildingShape/Building,proj4string=NAD83) #-- Bldg-readShapeSpatial(data/input/BuildingShape/Building,proj4string=NAD83) #--- Building=file(data/input/BuildingShape/Building.shp) Bldg-readShapeSpatial(Building,proj4string=NAD83) I know i am mis interpreting the documentation but it doesnt seem like it is very complicated so i am of course confused. I haven't used the maptools package for this kind of operation, so I offer any specific advice. However, the value of proj4string seems to be a little odd-- unless NAD83 is a variable that contains a string. It should probably be a quoted list of PROJ4 declarations such as: proj4string = '+proj=longlat +datum=NAD83' If maptools is leveraging the sp package, then you probably need to enclose the string in the CRS() function: proj4string = CRS('+proj=longlat +datum=NAD83') Note that the above example assumes coordinates are in lat/lon using the NAD83 datum. If your data is in a different projection, such as UTM, you will need to change the PROJ4 string accordingly. PDXRugger wrote: Also, i am wondering if i can create a shape file by simply using XY coordinates from a data frame. So for: Ycoord=c( 865296.4, 865151.5, 865457.0 ,865363.4 ,865311.0, 865260.9 ,865210.7 ,865173.3, 865123.6 ,865038.2 ,864841.1 ,864745.4 ,864429.1 ,864795.6 ,864334.9 ,864882.0) Xcoord=c( 4227640 ,4227816 ,4228929 ,4228508 ,4229569 ,4229498 ,4226747, 4226781, 4229597, 4229204, 4228910, 4228959 ,4229465 ,4229794 ,4229596 ,4229082) Lot-c(1900 , 2000, 2100 , 100 ,200 , 300, 400 , 500 , 600 , 701 , 900 , 1000 , 1100, 300 ,100, 200) XYcoord-spCbind(Ycoord,Xcoord) #doesnt work so XYcoord=c(Ycoord,Xcoord) TaxLots-cbind(Ycoord,Xcoord,Lot) writeSpatialShape(XYcoord, TaxLots.., file=data/input/test/Taxlots,strictFilename=FALSE) So help reading in shape files and then creating them using XY coordinates if possible Any help would be appreciated. Thank you. Maybe maptools provides a nice way to do this-- again I haven't used it much. My shapefile workflow usually centers on the sp and rgdal packages. First, sp is used to create a spatial object that holds the coordinates and data. Assuming you have point data: require(rgdal) lots - SpatialPointsDataFrame( coords = cbind(Xcoord,Ycoord), data = data.frame( Lot = Lot )) *Note that SpatialPointsDataFrame also takes a proj4string argument of the form: proj4string = CRS( 'proj declarations' ) I have omitted it since I don't know what projection your data is in. You can then create a shapefile using the writeOGR() routine in rgdal: writeOGR( lots, dsn = 'tstShapefile', layer = 'tstShapefile', driver='ESRI Shapefile') The readOGR() function can also be used to read a shapefile-- note that you give it the name of the directory containing the shapefile components and not the name of an individual component such as 'shapefile.shp'. Hope this helps! -Charlie - Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University -- View this message in context: http://www.nabble.com/Reading-and-Creating-Shape-Files-tp26098828p26114143.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.10 under Windows XP: glitches and successes
On a related note, on windows xp + ESS + R 2.9.2, I have long waits when I run: browseURL( unitTestOutFile, browser=C:/Program Files/Mozilla Firefox/firefox.exe) Firefox is always already open, and sometimes the old test results are already open too. Sometimes it takes minutes to open up, sometimes using submit+step in emacs seems to be correlated with this getting this to go a bit faster (but I can't tell what causes the huge variation in time opening the webpage)... I'm upgrading to 2.10.x next time I can schedule it on my work machine. Blair On Thu, Oct 29, 2009 at 9:42 AM, Duncan Murdoch murd...@stats.uwo.cawrote: On 29/10/2009 9:26 AM, James W. MacDonald wrote: Hi Duncan, Duncan Murdoch wrote: On 28/10/2009 5:54 PM, Ross Boylan wrote: I just installed 2.10 on XP; ESS is my primary interface. I seem to be able to access all the help files; under 2.8.1 I was having seemingly random problems accessing some help topics (including one day I could and a few days later I couldn't, and vice-versa). That's good. I noticed a few glitches. First, the installer asks if you want text, CHM, or HTML help, but offers only text or HTML. I understand CHM has been removed; I guess this is just an old message. Yes, already fixed in the patched version. Second, install.packages(intervals) produced the usual line about selecting a mirror, but no selection list popped up. It just sat there until I interrupted the session and reentered the command with a pre-specified repos. I selected custom install but took the defaults; I noticed there was some optional tk/tcl stuff (which I did not select); I'm guessing it's required for these selections. Perhaps it should be installed by default? That's something I haven't seen before. I do get the mirror dialog, and it doesn't use tcl/tk, so I'd appreciate hearing if you can spot any pattern here (including the pattern I never get it). (The install option is about installing the tcl/tk help files: mainly useful if you're developing with tcl/tk, not necessary for most users. The Tcl/tk code itself is always installed.) It could be that R is being blocked by your anti-virus software; what it's trying to do is to read a list of mirrors from This is a longstanding problem for R under ess/emacs on Windows (and maybe Xemacs as well, but I don't know for sure). Okay, I'll leave it to those guys to debug. If R is doing something it shouldn't, let me know what, and I'll try to fix it. (I'd guess the problem is that Emacs makes assumptions about the OS that just aren't true in Windows, but it might be a bug we could work around.) Duncan Murdoch This problem manifests itself in install.packages(), but the real problem comes from the line if (.Platform$OS.type == windows | .Platform$GUI == AQUA) return(.Internal(select.list(list, preselect, multiple, title))) in select.list(). If you run R under ess/emacs and do something as simple as select.list(letters) it will freeze and you have to use C-g, C-c C-c to 'unfreeze'. Paradoxically, after doing so, select.list() will then function correctly. You can get around this problem by first loading the tcltk package, if that is of any help. This problem only occurs under emacs/ess; if you run R from a DOS prompt or via the GUI then select.list() works correctly the first time. Best, Jim http://cran.r-project.org/CRAN_mirrors.csv using the code in getCRANmirrors(). If that download fails or is delayed forever, you won't get the selection list. Third, every time one asks for help on a new topic there is a considerable delay (seemed like forever, probably c 15 seconds) before the help comes up. My first thought was that the on-demand help was being assembled, but I didn't see much CPU use. It might be latency in talking to MSIE, and this latency might even be from my (Sophos) antivirus software, which kept warning me about a program suspiciously launching MSIE. If you ask for help you already requested there is no delay (good) and it does not focus on the tab with the relevant help (which strikes me as the ideal behavior, though it may be hard to do). When you ask for help the first time, it starts the internal server, but that should be fast. Then it passes the URL to Windows to open, and Windows needs to open the browser to show it, which tends to be slow. When you ask subsequently, it will send the request to Windows again, but if the browser is open, that should be quick. I'd guess this is your antivirus checking out the URL; when I do it (with no antivirus checking on such things) it's pretty slow on the first occurence (because it needs to start Firefox), then pretty fast after that. Fourth, I read the previous comments about how more beta testers would be useful :) Yep. Duncan Murdoch __ R-help@r-project.org mailing list
Re: [R] The system cannot find the file specified
Thanks Duncan. 2.10 seems to install things correctly. Cheers, Mark On Thu, Oct 29, 2009 at 6:52 AM, Mark Knecht markkne...@gmail.com wrote: Is 2.10 out? I'll give it a try. Thanks, Mark On Thu, Oct 29, 2009 at 6:45 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 29/10/2009 9:43 AM, Mark Knecht wrote: On Thu, Oct 29, 2009 at 6:39 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 29/10/2009 9:11 AM, Mark Knecht wrote: What is the problem here? I did an install package from the Rgui menu. Windows Vista normalizePath uses the Windows functions GetFullPathName and GetLongPathName to clean up paths, and one of them returned the error you saw. Does that path exist on your system? Duncan Murdoch SNIP Error in normalizePath(path) : path[1]=C:\Program Files\R\R-2.9.2\library/QRMlib: The system cannot find the file specified SNIP C:\Program Files\R\R-2.9.2\library does exist C:\Program Files\R\R-2.9.2\library/QRMlib does not. As it was the QRMlib package being installed it doesn't surprise me that it's not there, but please note the '/' instead of '\' like the rest of the path. I've seen this a number of times recently. This is the first I've posted here. Do you have write permission in C:\Program Files\R\R-2.9.2\library? It could be that the installer just tried to create the QRMlib subdir, and failed, and that's why it doesn't exist. What happens in 2.10.0? Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Trouble retrieving data (.xls) from folder on my computer.
On Oct 29, 2009, at 9:36 AM, tobiasfa wrote: Using gdata on windows and im having trouble to retrieve an excel file from a folder on my computer. This is my dummy: R download.file(http://people.su.se/~lundh/data/cpi_kpix.rda;, + cpi_kpix.rda) R URL - http://people.su.se/; R PATH - ~lundh/data/ R FILE - cpi_kpix.rda R download.file(paste(URL,PATH,FILE,sep=), + cpi_kpix.rda) R library(gdata) R FILE - Stock_Returns_1931_2002.xls R Downloading... Done. Converting xls file to csv file... Done. Reading csv file... Done. Im not suppose to download the file though its already on my computer. How do i type in the path så R finds my .xls?? It's probably not where you think it is. Try using: stock.xls - read.xls(file.choose(), header = TRUE)[, 3:4] ... and navigating your directory tree. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] singular variance-covariance warning in lmer
Hi Sam, Just a stab in the dark here, but is your grouping variable really female? What does str(data.frame(mean.sst, female) look like? How many levels does female have? -Ista On Thu, Oct 29, 2009 at 7:10 AM, Weber, Sam sam.we...@exeter.ac.uk wrote: Dear R Users, I was hoping for some help with a recurrent error message in lmer. I am trying to model the effect of temperature on metabolic rate in animals (response = int.length) at different temperatures (mean.sst), with repeated measurements on the same individuals (random effect = female). Ideally I would make a random slope and intercept model where the rate can change differently with temperature for different individuals: model-lmer(int.length~mean.sst+(mean.sst|female)) However, I get the following warning message: Warning message: Estimated variance-covariance for factor 'female' is singular in: `LMEoptimize-`(`*tmp*`, value = list(maxIter = 200L, tolerance = 1.49011611938477e-08, summary(model) Linear mixed-effects model fit by REML Formula: int.length ~ mean.sst + (mean.sst | female) AIC BIC logLik MLdeviance REMLdeviance 155.4 164.5 -72.7 142.8 145.4 Random effects: Groups Name Variance Std.Dev. Corr female (Intercept) 6.8459e-10 2.6165e-05 mean.sst 6.8169e-10 2.6109e-05 -0.065 Residual 1.3634e+00 1.1676e+00 number of obs: 46, groups: female, 18 Fixed effects: Estimate Std. Error t value (Intercept) 48.8249 6.5895 7.409 mean.sst -1.3609 0.2518 -5.406 Correlation of Fixed Effects: (Intr) mean.sst -1.000 If I try and run just a random intercepts model I get similar problems: model2-lmer(int.length~mean.sst+(1|female)) Warning message: Estimated variance for factor 'female' is effectively zero in: `LMEoptimize-`(`*tmp*`, value = list(maxIter = 200L, tolerance = 1.49011611938477e-08, I have tried disabling PQL iterations using control = list(usePQL = FALSE, msVerbose=TRUE), following Douglas Bates' recommendation on the mailing list archives but I still get a similar message. Does this mean that the variance among subjects is too close to zero for estimation of the random effects? I compared the random effects model to a linear model with just lm(int.length ~ mean.sst) using a likelihood ratio test and got p = 1.0 (which is always suspicious). It would actually make sense for there to be negligible variation among subjects in their response to temperature, however I am concerned that I am making a fundamental error somewhere along the line. I would greatly appreciate any suggestions you may have. Best regards Sam Weber University of Exeter, UK. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Trouble retrieving data (.xls) from folder on my computer.
If its already on your computer try one of these: xls - read.xls(myfile.xls) # if its in current directory xls - read.xls(/path/to/myfile.xls) # to specify path xls - read.xls(file.choose()) # use explorer style interface to choose On Thu, Oct 29, 2009 at 9:36 AM, tobiasfa tobias.farnly...@gmail.com wrote: Using gdata on windows and im having trouble to retrieve an excel file from a folder on my computer. This is my dummy: R download.file(http://people.su.se/~lundh/data/cpi_kpix.rda;, + cpi_kpix.rda) R URL - http://people.su.se/; R PATH - ~lundh/data/ R FILE - cpi_kpix.rda R download.file(paste(URL,PATH,FILE,sep=), + cpi_kpix.rda) R library(gdata) R FILE - Stock_Returns_1931_2002.xls R stock.xls - read.xls(paste(URL, PATH, FILE, sep = ), + header = TRUE)[, 3:4] Downloading... Done. Converting xls file to csv file... Done. Reading csv file... Done. Im not suppose to download the file though its already on my computer. How do i type in the path så R finds my .xls?? kind regards Tobias -- View this message in context: http://www.nabble.com/Trouble-retrieving-data-%28.xls%29-from-folder-on-my-computer.-tp26113172p26113172.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.10 under Windows XP: glitches and successes
On 29/10/2009 10:23 AM, Blair Christian wrote: On a related note, on windows xp + ESS + R 2.9.2, I have long waits when I run: browseURL( unitTestOutFile, browser=C:/Program Files/Mozilla Firefox/firefox.exe) Firefox is always already open, and sometimes the old test results are already open too. Sometimes it takes minutes to open up, sometimes using submit+step in emacs seems to be correlated with this getting this to go a bit faster (but I can't tell what causes the huge variation in time opening the webpage)... I'm upgrading to 2.10.x next time I can schedule it on my work machine. You should probably report ESS problems to their mailing list. I don't use it or support it, and I don't know if they'll read this message since it doesn't mention ESS in the subject line. Duncan Murdoch Blair On Thu, Oct 29, 2009 at 9:42 AM, Duncan Murdoch murd...@stats.uwo.cawrote: On 29/10/2009 9:26 AM, James W. MacDonald wrote: Hi Duncan, Duncan Murdoch wrote: On 28/10/2009 5:54 PM, Ross Boylan wrote: I just installed 2.10 on XP; ESS is my primary interface. I seem to be able to access all the help files; under 2.8.1 I was having seemingly random problems accessing some help topics (including one day I could and a few days later I couldn't, and vice-versa). That's good. I noticed a few glitches. First, the installer asks if you want text, CHM, or HTML help, but offers only text or HTML. I understand CHM has been removed; I guess this is just an old message. Yes, already fixed in the patched version. Second, install.packages(intervals) produced the usual line about selecting a mirror, but no selection list popped up. It just sat there until I interrupted the session and reentered the command with a pre-specified repos. I selected custom install but took the defaults; I noticed there was some optional tk/tcl stuff (which I did not select); I'm guessing it's required for these selections. Perhaps it should be installed by default? That's something I haven't seen before. I do get the mirror dialog, and it doesn't use tcl/tk, so I'd appreciate hearing if you can spot any pattern here (including the pattern I never get it). (The install option is about installing the tcl/tk help files: mainly useful if you're developing with tcl/tk, not necessary for most users. The Tcl/tk code itself is always installed.) It could be that R is being blocked by your anti-virus software; what it's trying to do is to read a list of mirrors from This is a longstanding problem for R under ess/emacs on Windows (and maybe Xemacs as well, but I don't know for sure). Okay, I'll leave it to those guys to debug. If R is doing something it shouldn't, let me know what, and I'll try to fix it. (I'd guess the problem is that Emacs makes assumptions about the OS that just aren't true in Windows, but it might be a bug we could work around.) Duncan Murdoch This problem manifests itself in install.packages(), but the real problem comes from the line if (.Platform$OS.type == windows | .Platform$GUI == AQUA) return(.Internal(select.list(list, preselect, multiple, title))) in select.list(). If you run R under ess/emacs and do something as simple as select.list(letters) it will freeze and you have to use C-g, C-c C-c to 'unfreeze'. Paradoxically, after doing so, select.list() will then function correctly. You can get around this problem by first loading the tcltk package, if that is of any help. This problem only occurs under emacs/ess; if you run R from a DOS prompt or via the GUI then select.list() works correctly the first time. Best, Jim http://cran.r-project.org/CRAN_mirrors.csv using the code in getCRANmirrors(). If that download fails or is delayed forever, you won't get the selection list. Third, every time one asks for help on a new topic there is a considerable delay (seemed like forever, probably c 15 seconds) before the help comes up. My first thought was that the on-demand help was being assembled, but I didn't see much CPU use. It might be latency in talking to MSIE, and this latency might even be from my (Sophos) antivirus software, which kept warning me about a program suspiciously launching MSIE. If you ask for help you already requested there is no delay (good) and it does not focus on the tab with the relevant help (which strikes me as the ideal behavior, though it may be hard to do). When you ask for help the first time, it starts the internal server, but that should be fast. Then it passes the URL to Windows to open, and Windows needs to open the browser to show it, which tends to be slow. When you ask subsequently, it will send the request to Windows again, but if the browser is open, that should be quick. I'd guess this is your antivirus checking out the URL; when I do it (with no antivirus checking on such things) it's pretty slow on the first occurence (because it needs to start Firefox), then pretty fast after that. Fourth, I read the
Re: [R] Error installing RSPerl.
Hi Grainne There is one likely cause. But before getting into the explanation, can you send me the output from when you installed the package, e.g. the output from R CMD INSTALL RSPerl and any configuration arguments you specified. You can send this to me off-list and we can summarize at the end. Thanks, D. Grainne Kerr wrote: Dear list, I have updated to version R-2.10.0. When I try to load the RSPerl library I get the following error: library(RSPerl) Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/usr/local/lib/R/library/RSPerl/libs/RSPerl.so': /usr/local/lib/R/library/RSPerl/libs/RSPerl.so: undefined symbol: boot_DB_File__Glob Error: package/namespace load failed for 'RSPerl' I do not know how to fix this. Can anyone please help? I'm runninn R on Ubuntu 9.04 Many thanks, Grainne. sessionInfo() R version 2.10.0 (2009-10-26) i686-pc-linux-gnu locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] The 'subset matching' challenge
Dear all, The following problem just has been submitted to me by an accountant. In his new job, he has to close some old accounts. He has yearly amounts, and a list of products that have been bought over the years, at certain prices for which he has an exhaustive record. The problem is: He does not know what product was bought this or that year (don't ask). He does not want to find back the real story, but just write realistic accounts, for which the sum of a subset of product prices will give the exact yearly amount. Here is a real example from his data: # A list of 64 product prices products = c(30500,30500,30500,30500,42000,42000,42000,42000,42000,42000,42000,42000,42000,42000,71040,90900,76950,35100,71190, 53730,456000,70740,70740,533600,83800,59500,27465,28000,28000,28000,28000,28000,26140,49600,77000,123289,27000,27000,27000, 27000,27000,27000,8,33000,33000,55000,77382,48048,51186,4,35000,21716,63051,15025,15025,15025,15025,80,111, 59700,25908,829350,1198000,1031655) # Global amount amount = 4748652 Now he wants to find all subsets of the 'product' vector which sums to 'amount'. I wrote the following code, which is clearly not optimal: # Create a matrix of subsets of size r among the integer set 1:n subsets - function(n, r, v = 1:n) { if(r = 0) vector(mode(v), 0) else if(r = n) v[1:n] else rbind(cbind(v[1], Recall(n-1, r-1, v[-1])),Recall(n-1, r, v[-1])) } # Main function find.amount = function(amount,products) { if(sum(products)amount) { cat(There is no solution.\n) return() } l = length(products) cat(\nThere are,l,product prices\n\n) names(products) = paste(Product,1:l,sep=) products = sort(products) for(i in 2:l) { # If the sum of the i smallest prices is greater than amount, then stop if(sum(products[1:i])amount) break # Look for matching subsets only in the case when the sum of i largest prices is greater than amount if(sum(rev(products)[1:i])=amount) { # Generates all subsets of i indicies in 1:l subs = subsets(l,i) nl = nrow(subs) nc = ncol(subs) # Compute sums of corresponding price subsets sums = rowSums(matrix(products[subs],nl,nc)) # Which ones match the global amount ? w = which(sums == amount) how.many = length(w) if(how.many0) { cat(\n-- There are,how.many,solutions with,nc,products :\n) for(j in 1:how.many) { print(products[subs[w[j],]]) } } else cat(\n-- There is no solution with,nc,products.\n) } else cat(\n-- There is no solution with,i,products.\n) } } Then I can use these functions on a smaller example: find.amount(4,c(1,1,1,1,2,2)) and a number of matching subsets are provided. The problem is: This approach creates a whole matrix of subsets of r integers among 1:n, which rapidly gives huge matrices, and this is clearly not optimal for the real data provided above. Would anyone have a suggestion as to an alternative and more efficient strategy? Good luck, Yvonnick Noel University of Brittany, Rennes 2 France __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Invert the sign of a number
On Thu, 29 Oct 2009 09:05:22 -0400 Duncan Murdoch murd...@stats.uwo.ca wrote: You want the unary - operator. For example, -x It even has a nice help page: ?- -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The 'subset matching' challenge
yvonnick noel wrote: Dear all, The following problem just has been submitted to me by an accountant. In his new job, he has to close some old accounts. He has yearly amounts, and a list of products that have been bought over the years, at certain prices for which he has an exhaustive record. The problem is: He does not know what product was bought this or that year (don't ask). He does not want to find back the real story, but just write realistic accounts, for which the sum of a subset of product prices will give the exact yearly amount. Here is a real example from his data: # A list of 64 product prices products = c(30500,30500,30500,30500,42000,42000,42000,42000,42000,42000,42000,42000,42000,42000,71040,90900,76950,35100,71190, 53730,456000,70740,70740,533600,83800,59500,27465,28000,28000,28000,28000,28000,26140,49600,77000,123289,27000,27000,27000, 27000,27000,27000,8,33000,33000,55000,77382,48048,51186,4,35000,21716,63051,15025,15025,15025,15025,80,111, 59700,25908,829350,1198000,1031655) # Global amount amount = 4748652 Now he wants to find all subsets of the 'product' vector which sums to 'amount'. I wrote the following code, which is clearly not optimal: # Create a matrix of subsets of size r among the integer set 1:n subsets - function(n, r, v = 1:n) { if(r = 0) vector(mode(v), 0) else if(r = n) v[1:n] else rbind(cbind(v[1], Recall(n-1, r-1, v[-1])),Recall(n-1, r, v[-1])) } # Main function find.amount = function(amount,products) { if(sum(products)amount) { cat(There is no solution.\n) return() } l = length(products) cat(\nThere are,l,product prices\n\n) names(products) = paste(Product,1:l,sep=) products = sort(products) for(i in 2:l) { # If the sum of the i smallest prices is greater than amount, then stop if(sum(products[1:i])amount) break # Look for matching subsets only in the case when the sum of i largest prices is greater than amount if(sum(rev(products)[1:i])=amount) { # Generates all subsets of i indicies in 1:l subs = subsets(l,i) nl = nrow(subs) nc = ncol(subs) # Compute sums of corresponding price subsets sums = rowSums(matrix(products[subs],nl,nc)) # Which ones match the global amount ? w = which(sums == amount) how.many = length(w) if(how.many0) { cat(\n-- There are,how.many,solutions with,nc,products :\n) for(j in 1:how.many) { print(products[subs[w[j],]]) } } else cat(\n-- There is no solution with,nc,products.\n) } else cat(\n-- There is no solution with,i,products.\n) } } Then I can use these functions on a smaller example: find.amount(4,c(1,1,1,1,2,2)) and a number of matching subsets are provided. The problem is: This approach creates a whole matrix of subsets of r integers among 1:n, which rapidly gives huge matrices, and this is clearly not optimal for the real data provided above. Would anyone have a suggestion as to an alternative and more efficient strategy? Good luck, Yvonnick Noel University of Brittany, Rennes 2 France I believe this is the knapsack problem. RSiteSearch(knapsack) might help a little bit. http://xkcd.com/287/ -- View this message in context: http://www.nabble.com/The-%27subset-matching%27-challenge-tp26114520p26114758.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] change in default behavior of ?functionname in R 2.10?
Hi everyone, I just installed R 2.10 using the Windows binary. At some point in the past using the Windows binary installation, the default behavior of ?functionname changed from plain text to a nice html interface. Now with R 2.10, the default behavior has changed back to the plain text help. I assume this has some thing to do with these changes listed for R 2.10, but I don't quite understand what it's saying or how to change my system back to the html-style help: Package help is now converted from Rd by the R-based converters that were first introduced in 2.9.0. This means - Packages that were installed by R-devel after 2009-08-09 should not be used with earlier versions of R, and most aspects of package help (including the runnable examples) will be missing if they are so used. - Text, HTML and latex help and examples for packages installed under the new system are converted on-demand from stored parsed Rd files. (Conversions stored in packages installed under R 2.10.0 are used if no parsed Rd files are found. It is recommended that such packages be re-installed.) o HTML help is now generated dynamically using an HTTP server running in the R process and listening on the loopback interface. - Those worried about security implications of such a server can disable it by setting the environment variable R_DISABLE_HTTPD to a non-empty value. This disables help.start() and HTML help (so text help is shown instead). - The Java/Javascript search engine has been replaced by an HTML interface to help.search(). help.start() no longer has an argument 'searchEngine' as it is no longer needed. - The HTML help can now locate cross-references of the form \link[pkg]{foo} and \link[pkg:foo]{bar} where 'foo' is an alias in the package, rather than the documented (basename of a) filename (since the documentation has been much ignored). I'd appreciate any help, as the html-style help is so much more convenient! Thanks, Jenny sessionInfo() R version 2.10.0 (2009-10-26) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] grid stats graphics grDevices datasets utils methods [8] base other attached packages: [1] ath1121501cdf_2.5.0 limma_3.2.1 affyQCReport_1.24.0 [4] lattice_0.17-26 xtable_1.5-5 simpleaffy_2.22.0 [7] genefilter_1.28.0made4_1.20.0 scatterplot3d_0.3-29 [10] gplots_2.7.3 caTools_1.10 bitops_1.0-4.1 [13] gdata_2.6.1 gtools_2.6.1 RColorBrewer_1.0-2 [16] ade4_1.4-11 affyPLM_1.22.0 preprocessCore_1.8.0 [19] gcrma_2.18.0 affycoretools_1.18.0 KEGG.db_2.3.5 [22] GO.db_2.3.5 RSQLite_0.7-3DBI_0.2-4 [25] AnnotationDbi_1.8.0 affy_1.24.0 Biobase_2.6.0 [28] RWinEdt_1.8-1 loaded via a namespace (and not attached): [1] affyio_1.14.0 annaffy_1.18.0annotate_1.24.0 biomaRt_2.2.0 [5] Biostrings_2.14.0 Category_2.12.0 GOstats_2.12.0graph_1.24.0 [9] GSEABase_1.8.0IRanges_1.4.0 RBGL_1.20.0 RCurl_1.2-1 [13] splines_2.10.0survival_2.35-7 tools_2.10.0 XML_2.6-0 Jenny Drnevich, Ph.D. Functional Genomics Bioinformatics Specialist W.M. Keck Center for Comparative and Functional Genomics Roy J. Carver Biotechnology Center University of Illinois, Urbana-Champaign 330 ERML 1201 W. Gregory Dr. Urbana, IL 61801 USA ph: 217-244-7355 fax: 217-265-5066 e-mail: drnev...@illinois.edu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Keeping NAs in model.matrix for glm.fit
Hi, For efficiency purposes I'm using glm.fit instead of glm, and I'm pre-constructing a model design matrix using model.matrix(). I'm finding that the 'NAs' in the x are being removed by model.matrix by default, and would like to know how could I keep them (or remove the corresponding NAs in the Y) so that the length for both response and predictor would be the same. Thanks for your reply. myformula = ~ offset(Bgrid[i,1] * x) MM - model.matrix(myformula) alpha[i] - coef(glm.fit(MM, Y, family=binomial())) Ted - Ted Chiang Bioinformatics Analyst Centre for Computational Biology Hospital for Sick Children, Toronto 416.813.7028 tchi...@sickkids.ca __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lmer and negative binomial family
John Sorkin wrote: Patrick, I am not sure about this but (1) I think you need to load the lme4 package, not MASS (2) I don't think neg.bin is allowable. I suggest you load lme4 and then type ?family John This conversation would probably go better on r-sig-mixed-mod...@r-project.org ... In the meanwhile -- for a long time (I thought always, but I guess that's not true) the allowable families have been hard-coded within lme4, for purposes of efficiency. The bottom line is that you can only use the following families: famNms - c(binomial, gaussian, Gamma, inverse.gaussian, poisson, quasibinomial, quasipoisson, quasi) 'quasipoisson' might be good, if you're willing to settle for a quasi- answer, although you should be careful with random effects variances -- in earlier versions there are some problems with the scaling there If you really need NB I would suggest glmmADMB ... -- View this message in context: http://www.nabble.com/lmer-and-negative-binomial-family-tp26112313p26115443.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] output of for
Look at the collapse argument to the paste function. You should be able to do what you want much simpler without any explicit for loops. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Matteo Mattiuzzi Sent: Wednesday, October 28, 2009 11:28 AM To: R-help@r-project.org Subject: [R] output of for Hello! I've got troubles on following thing: As output I need a string like: INPUT_FILENAMES = H:\\AKK_temp\\Modis\\MOD13Q1\\austria\\MOD09Q1.A2008073.h18v04.005.2008 083134952.hdf|H:\\AKK_temp\\Modis\\MOD13Q1\\austria\\MOD09Q1.A2008073.h 19v04.005.2008082182221.hdf The filenames (dates) are with pathname (wrkdr) and separated with |. The number of input filenames changes (minimum 1, maximum n) wrkdr - H:\\akk_temp\\Modis\\MOD09 dates is a data.frame where each row is a date and each column is a Modis-image (the name of it) I did this as following: paste('INPUT_FILENAMES = ', for(g in 1:(ntiles-1)) {paste(wrkdr,'\\',dates[i,g+1],'|',sep='')} , for(g in ntiles){ paste(wrkdr,'\\',dates[i,g+1],sep='') } ,sep='') and this did work (in an other wrkdr and other dates) but after changing, for gave no more output. And I don't know why!!! Why i use for twice? Because after the last file there is no |... Thanks for help Matteo [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The 'subset matching' challenge
If you look for subset sum problem, you will find relevant information. A starter: http://en.wikipedia.org/wiki/Subset_sum_problem Detlef On Thu, 29 Oct 2009 15:47:22 +0100 Yvonnick Noël yvonnick.n...@uhb.fr wrote: Dear all, The following problem just has been submitted to me by an accountant. In his new job, he has to close some old accounts. He has yearly amounts, and a list of products that have been bought over the years, at certain prices for which he has an exhaustive record. The problem is: He does not know what product was bought this or that year (don't ask). He does not want to find back the real story, but just write realistic accounts, for which the sum of a subset of product prices will give the exact yearly amount. Here is a real example from his data: # A list of 64 product prices products = c(30500,30500,30500,30500,42000,42000,42000,42000,42000,42000,42000,42000,42000,42000,71040,90900,76950,35100,71190, 53730,456000,70740,70740,533600,83800,59500,27465,28000,28000,28000,28000,28000,26140,49600,77000,123289,27000,27000,27000, 27000,27000,27000,8,33000,33000,55000,77382,48048,51186,4,35000,21716,63051,15025,15025,15025,15025,80,111, 59700,25908,829350,1198000,1031655) # Global amount amount = 4748652 Now he wants to find all subsets of the 'product' vector which sums to 'amount'. I wrote the following code, which is clearly not optimal: # Create a matrix of subsets of size r among the integer set 1:n subsets - function(n, r, v = 1:n) { if(r = 0) vector(mode(v), 0) else if(r = n) v[1:n] else rbind(cbind(v[1], Recall(n-1, r-1, v[-1])),Recall(n-1, r, v[-1])) } # Main function find.amount = function(amount,products) { if(sum(products)amount) { cat(There is no solution.\n) return() } l = length(products) cat(\nThere are,l,product prices\n\n) names(products) = paste(Product,1:l,sep=) products = sort(products) for(i in 2:l) { # If the sum of the i smallest prices is greater than amount, then stop if(sum(products[1:i])amount) break # Look for matching subsets only in the case when the sum of i largest prices is greater than amount if(sum(rev(products)[1:i])=amount) { # Generates all subsets of i indicies in 1:l subs = subsets(l,i) nl = nrow(subs) nc = ncol(subs) # Compute sums of corresponding price subsets sums = rowSums(matrix(products[subs],nl,nc)) # Which ones match the global amount ? w = which(sums == amount) how.many = length(w) if(how.many0) { cat(\n-- There are,how.many,solutions with,nc,products :\n) for(j in 1:how.many) { print(products[subs[w[j],]]) } } else cat(\n-- There is no solution with,nc,products.\n) } else cat(\n-- There is no solution with,i,products.\n) } } Then I can use these functions on a smaller example: find.amount(4,c(1,1,1,1,2,2)) and a number of matching subsets are provided. The problem is: This approach creates a whole matrix of subsets of r integers among 1:n, which rapidly gives huge matrices, and this is clearly not optimal for the real data provided above. Would anyone have a suggestion as to an alternative and more efficient strategy? Good luck, Yvonnick Noel University of Brittany, Rennes 2 France __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] New variables remember how they were created?
On Wed, Oct 28, 2009 at 12:40 PM, Adaikalavan Ramasamy a.ramas...@imperial.ac.uk wrote: Your example is too complicated for me. But few points: 1) What do you mean by instrument? Do you mean variable? By instruments, I mean instrumental variables. Very common in econometrics: http://en.wikipedia.org/wiki/Instrumental_variable Doing two-stage least squares in this example requires using instrumental variables. 2) diff(demand) is identical to demand[-1] - demand[-204] Just trying to be explicit with the use of the lag and then including it as an instrument. 3) system() is a built-in R function, so avoid using it as variable name Ok thanks. 4) The variable yd is in the eqInvest formula and subsequently to the system formula. The variable y.1 is in the instruments formula. Both formulas are passed onto systemfit() call. Thus I see no surprises here. Try simplifying and rephrasing please if you want further help. Ok, here it goes. This is an introductory example, so I'm not sure how much more I can simplify it, and the details of the estimator aren't that important. Everything here works, and I understand what's going on, but I just wonder how R knows that yd was creating using y.1. In the second stage of the fit, the endogenous regressors on the RHS are replaced by the fitted values from the first stage found from regressing these endogenous regressors on all of the instrumental variables (these are exogenous and commonly called instruments) in the system. So I have yd which is partially an endogenous variable and partially an exogenous variable y - y.1. In the second stage of the estimation it seems that this yd is replaced by (z - y.1), where z is the instrumental variable (the result of fitting y against all of the instruments). So how does R know that yd should be replace by (z - y.1) unless yd carries some information that it was originally created as (y - y.1). Maybe this question is best asked on the devel list? Cheers, Skipper Regards, Adai Skipper Seabold wrote: Hello all, I hope this question is appropriate for this ML. Basically, I am wondering if when you create a new variable, if the variable holds some information about how it was created. Let me explain, I have the following code to replicate an example in a textbook (Greene's Econometric Analysis), using the systemfit package. dta - read.table('http://pages.stern.nyu.edu/~wgreene/Text/Edition6/TableF5-1.txt', header = TRUE) attach(dta) library(systemfit) demand - realcons + realinvs + realgovt c.1 - realcons[-204] y.1 - demand[-204] yd - demand[-1] - y.1 eqConsump - realcons[-1] ~ demand[-1] + c.1 eqInvest - realinvs[-1] ~ tbilrate[-1] + yd system - list( Consumption = eqConsump, Investment = eqInvest) instruments - ~ realgovt[-1] + tbilrate[-1] + c.1 + y.1 # 2SLS greene2sls - systemfit( system, 2SLS, inst = instruments, methodResidCov = noDfCor ) When I do the 2SLS fit, it seems that even though I declared y.1 as an instrument that the estimator knows that yd was created using y1, so it (correctly) transforms yd to use the instrument in the final estimation. So I'm wondering if yd somehow carries knowledge of how it was created. Thanks, Skipper __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] singular variance-covariance warning in lmer
Hi Ista, The command looks like: $ female : Factor w/ 18 levels 2,4,5,8,..: 1 1 1 1 2 2 2 3 4 4 ... Female is a factor with 18 levels, so I assume this is how the analysis is being grouped. Best Sam From: Ista Zahn [istaz...@gmail.com] Sent: 29 October 2009 14:35 To: Weber, Sam Cc: r-help@R-project.org Subject: Re: [R] singular variance-covariance warning in lmer Hi Sam, Just a stab in the dark here, but is your grouping variable really female? What does str(data.frame(mean.sst, female) look like? How many levels does female have? -Ista On Thu, Oct 29, 2009 at 7:10 AM, Weber, Sam sam.we...@exeter.ac.uk wrote: Dear R Users, I was hoping for some help with a recurrent error message in lmer. I am trying to model the effect of temperature on metabolic rate in animals (response = int.length) at different temperatures (mean.sst), with repeated measurements on the same individuals (random effect = female). Ideally I would make a random slope and intercept model where the rate can change differently with temperature for different individuals: model-lmer(int.length~mean.sst+(mean.sst|female)) However, I get the following warning message: Warning message: Estimated variance-covariance for factor 'female' is singular in: `LMEoptimize-`(`*tmp*`, value = list(maxIter = 200L, tolerance = 1.49011611938477e-08, summary(model) Linear mixed-effects model fit by REML Formula: int.length ~ mean.sst + (mean.sst | female) AIC BIC logLik MLdeviance REMLdeviance 155.4 164.5 -72.7 142.8145.4 Random effects: Groups NameVariance Std.Dev. Corr female (Intercept) 6.8459e-10 2.6165e-05 mean.sst6.8169e-10 2.6109e-05 -0.065 Residual 1.3634e+00 1.1676e+00 number of obs: 46, groups: female, 18 Fixed effects: Estimate Std. Error t value (Intercept) 48.8249 6.5895 7.409 mean.sst -1.3609 0.2518 -5.406 Correlation of Fixed Effects: (Intr) mean.sst -1.000 If I try and run just a random intercepts model I get similar problems: model2-lmer(int.length~mean.sst+(1|female)) Warning message: Estimated variance for factor 'female' is effectively zero in: `LMEoptimize-`(`*tmp*`, value = list(maxIter = 200L, tolerance = 1.49011611938477e-08, I have tried disabling PQL iterations using control = list(usePQL = FALSE, msVerbose=TRUE), following Douglas Bates' recommendation on the mailing list archives but I still get a similar message. Does this mean that the variance among subjects is too close to zero for estimation of the random effects? I compared the random effects model to a linear model with just lm(int.length ~ mean.sst) using a likelihood ratio test and got p = 1.0 (which is always suspicious). It would actually make sense for there to be negligible variation among subjects in their response to temperature, however I am concerned that I am making a fundamental error somewhere along the line. I would greatly appreciate any suggestions you may have. Best regards Sam Weber University of Exeter, UK. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Trouble retrieving data (.xls) from folder on my computer.
This is what R says: xls - read.xls(file.choose()) Converting xls file to csv file... Error in system(cmd, intern = !verbose) : perl not found Error in file.exists(tfn) : invalid 'file' argument xls - read.xls(file.choose(), perl=C:/perl/bin/perl.exe) Converting xls file to csv file... Error in system(cmd, intern = !verbose) : perl not found Error in file.exists(tfn) : invalid 'file' argument (I have installed Perl!) Gabor Grothendieck wrote: If its already on your computer try one of these: xls - read.xls(myfile.xls) # if its in current directory xls - read.xls(/path/to/myfile.xls) # to specify path xls - read.xls(file.choose()) # use explorer style interface to choose On Thu, Oct 29, 2009 at 9:36 AM, tobiasfa tobias.farnly...@gmail.com wrote: Using gdata on windows and im having trouble to retrieve an excel file from a folder on my computer. This is my dummy: R download.file(http://people.su.se/~lundh/data/cpi_kpix.rda;, + cpi_kpix.rda) R URL - http://people.su.se/; R PATH - ~lundh/data/ R FILE - cpi_kpix.rda R download.file(paste(URL,PATH,FILE,sep=), + cpi_kpix.rda) R library(gdata) R FILE - Stock_Returns_1931_2002.xls R stock.xls - read.xls(paste(URL, PATH, FILE, sep = ), + header = TRUE)[, 3:4] Downloading... Done. Converting xls file to csv file... Done. Reading csv file... Done. Im not suppose to download the file though its already on my computer. How do i type in the path så R finds my .xls?? kind regards Tobias -- View this message in context: http://www.nabble.com/Trouble-retrieving-data-%28.xls%29-from-folder-on-my-computer.-tp26113172p26113172.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Trouble-retrieving-data-%28.xls%29-from-folder-on-my-computer.-tp26113172p26115725.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Weird error: Error in xj[i] : invalid subscript type 'list'
I got the error. I haven't been able to get a stand along case so that I can show it here. But could somebody give some clue on what could cause this error? Since I never defined xj[i], I don't understand where this error come from. Error in xj[i] : invalid subscript type 'list' __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Rounding and printing
Hello, I am trying to print a table with numbers all rounded to the same number of digits (one after the decimal), but R seems to want to not print .0 for integers. I can go in and fix it one number at a time, but I'd like to understand the principle. Here's an example of the code. The problem is the 13th element, 21 or 21.0: nvb_deaths - round(ss[,10]/100,digits=1) nvb_deaths [1] 56.5 1.6 0.2 3.9 0.1 2.2 0.2 2.6 1.5 4.1 1.1 6.1 21.0 nvb_dths - paste(nvb_deaths, (,round(100*nvb_deaths/nvb_deaths[1],digits=1),%),sep=) nvb_dths [1] 56.5 (100%) 1.6 (2.8%) 0.2 (0.4%) 3.9 (6.9%) 0.1 (0.2%) 2.2 (3.9%) [7] 0.2 (0.4%) 2.6 (4.6%) 1.5 (2.7%) 4.1 (7.3%) 1.1 (1.9%) 6.1 (10.8%) [13] 21 (37.2%) print(nvb_deaths,digits=1) [1] 56.5 1.6 0.2 3.9 0.1 2.2 0.2 2.6 1.5 4.1 1.1 6.1 21.0 paste(print(nvb_deaths,digits=1), (,round(100*nvb_deaths/nvb_deaths[1],digits=1),%),sep=) [1] 56.5 1.6 0.2 3.9 0.1 2.2 0.2 2.6 1.5 4.1 1.1 6.1 21.0 [1] 56.5 (100%) 1.6 (2.8%) 0.2 (0.4%) 3.9 (6.9%) 0.1 (0.2%) 2.2 (3.9%) [7] 0.2 (0.4%) 2.6 (4.6%) 1.5 (2.7%) 4.1 (7.3%) 1.1 (1.9%) 6.1 (10.8%) [13] 21 (37.2%) I'm running R v2.8.1 on Windows. Any help is much appreciated. Cheers, Alan Cohen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to fetch rows with certain characteristics
Thanks. That works. However, in my own case, there are more columns of other kinds of data. So to me, it is more important to get the row index of those that has the min values of particular column in particular class (which is another column). Can you help more as how to get those row index? One issue is that for some class they may share the same min value so that using %in% does not work. My goal is to reduce the original matrix size and get the result back in the original matrix format. Thanks. On Wed, Oct 28, 2009 at 11:55 PM, Ista Zahn istaz...@gmail.com wrote: There are various ways, including x - read.table(textConnection(1.2 1 + 1.3 1 + 1.3 1 + 1.5 1 + 2.1 2 + 2.0 2 + 9.9 2 + 1.4 3 + 1.8 3 + 1.9 3) ) x - as.matrix(x) x.min - cbind(tapply(x[,1], x[,2], min), unique(x[,V2])) Most of that is just formatting it in the way you requested. All you need to compute the values is tapply(x[,1], x[,2], min) -Ista On Thu, Oct 29, 2009 at 1:47 AM, Waverley @ Palo Alto waverley.paloa...@gmail.com wrote: Hi, I have a matrix, first column is of certain values, second column is the class labels or a factor. e.g. 1.2 1 1.3 1 1.3 1 1.5 1 2.1 2 2.0 2 9.9 2 1.4 3 1.8 3 1.9 3 I want to find out what is the min values of column 1 for each corresponding class (column 2). For the above example, I want to return a matrix of 1.2 1 2.0 2 1.3 3 Can someone suggest how to code for that? The second column can be of characters. Thanks much. -- Waverley @ Palo Alto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org -- Waverley @ Palo Alto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Trouble retrieving data (.xls) from folder on my computer.
Either make sure that perl is on your PATH or if the path/filename you specified is correct then try with backslashes just in case: C:\\perl\\bin\\perl.exe Also check the upper/lower case of each component of your path just in case. On Thu, Oct 29, 2009 at 11:52 AM, tobiasfa tobias.farnly...@gmail.com wrote: This is what R says: xls - read.xls(file.choose()) Converting xls file to csv file... Error in system(cmd, intern = !verbose) : perl not found Error in file.exists(tfn) : invalid 'file' argument xls - read.xls(file.choose(), perl=C:/perl/bin/perl.exe) Converting xls file to csv file... Error in system(cmd, intern = !verbose) : perl not found Error in file.exists(tfn) : invalid 'file' argument (I have installed Perl!) Gabor Grothendieck wrote: If its already on your computer try one of these: xls - read.xls(myfile.xls) # if its in current directory xls - read.xls(/path/to/myfile.xls) # to specify path xls - read.xls(file.choose()) # use explorer style interface to choose On Thu, Oct 29, 2009 at 9:36 AM, tobiasfa tobias.farnly...@gmail.com wrote: Using gdata on windows and im having trouble to retrieve an excel file from a folder on my computer. This is my dummy: R download.file(http://people.su.se/~lundh/data/cpi_kpix.rda;, + cpi_kpix.rda) R URL - http://people.su.se/; R PATH - ~lundh/data/ R FILE - cpi_kpix.rda R download.file(paste(URL,PATH,FILE,sep=), + cpi_kpix.rda) R library(gdata) R FILE - Stock_Returns_1931_2002.xls R stock.xls - read.xls(paste(URL, PATH, FILE, sep = ), + header = TRUE)[, 3:4] Downloading... Done. Converting xls file to csv file... Done. Reading csv file... Done. Im not suppose to download the file though its already on my computer. How do i type in the path så R finds my .xls?? kind regards Tobias -- View this message in context: http://www.nabble.com/Trouble-retrieving-data-%28.xls%29-from-folder-on-my-computer.-tp26113172p26113172.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Trouble-retrieving-data-%28.xls%29-from-folder-on-my-computer.-tp26113172p26115725.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The system cannot find the file specified
I think your are using R 2.10.0. I get similar messages when I have too many resources in use. Like FireFox eating memory and CPU. When you get this message go look in your R installation library subdirectory. You will see a weird number as a folder name. Under that folder is the package you were trying to install. Simply copy that package name folder to the correct folder location for the other packages in library. Then clean up by removing that weird folder name. Hope this helps, Jim Mark Knecht wrote: What is the problem here? I did an install package from the Rgui menu. Windows Vista SNIP trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.9/mvtnorm_0.9-8.zip' Content type 'application/zip' length 236089 bytes (230 Kb) opened URL downloaded 230 Kb trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.9/QRMlib_1.4.4.zip' Content type 'application/zip' length 2369023 bytes (2.3 Mb) opened URL downloaded 2.3 Mb package 'robustbase' successfully unpacked and MD5 sums checked package 'fUtilities' successfully unpacked and MD5 sums checked package 'fEcofin' successfully unpacked and MD5 sums checked package 'fCalendar' successfully unpacked and MD5 sums checked package 'fSeries' successfully unpacked and MD5 sums checked package 'mvtnorm' successfully unpacked and MD5 sums checked package 'QRMlib' successfully unpacked and MD5 sums checked Error in normalizePath(path) : path[1]=C:\Program Files\R\R-2.9.2\library/QRMlib: The system cannot find the file specified SNIP __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Weird error: Error in xj[i] : invalid subscript type 'list'
On Thu, 29 Oct 2009 11:28:44 -0500 Peng Yu pengyu...@gmail.com wrote: I got the error. I haven't been able to get a stand along case so that I can show it here. But could somebody give some clue on what could cause this error? Since I never defined xj[i], I don't understand where this error come from. Error in xj[i] : invalid subscript type 'list' You use a function which extracts subsets of an object, but the indices happens to be a list. Example: x=1:5 z=as.list(1:2) x[z] -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Weird error: Error in xj[i] : invalid subscript type 'list'
On Oct 29, 2009, at 12:28 PM, Peng Yu wrote: I got the error. I haven't been able to get a stand along case so that I can show it here. But could somebody give some clue on what could cause this error? Since I never defined xj[i], I don't understand where this error come from. Error in xj[i] : invalid subscript type 'list' This reminds me of the stories told by guys coming into emergency rooms who have been involved in fights: I was just sitting on the corner, minding my own business, when I was attacked by this error. xj - 1:4 xj[list(1,2)] Error in xj[list(1, 2)] : invalid subscript type 'list' -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rounding and printing
On Thu, 29 Oct 2009 12:29:42 -0400 Alan Cohen coh...@smh.toronto.on.ca wrote: I am trying to print a table with numbers all rounded to the same number of digits (one after the decimal), but R seems to want to not print .0 for integers. 'round' only rounds numbers; it doesn't format them. Use 'formatC' instead. Example: x=c(1.234, 20.31, 25, 0.7) formatC(x, digits=1, format=f) [1] 1.2 20.3 25.0 0.7 'prettyNum' may also be useful. -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Question about is.na for missing data
Greetings, I am trying to a simple mean imputation using the following command (yes, I know it is not an ideal way to impute missing data) asd[is.na(asd)] - mean(asd,na.rm=TRUE) This has worked quite well in the past. Now, however, I am getting the following error messsage. Error in `[-.data.frame`(`*tmp*`, is.na(asd), value = c(2433.64150943396, : rhs is the wrong length for indexing by a logical matrix An inspection of the data set reveals no value of the sort give above. Any thoughts? Thanks in advance, David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The system cannot find the file specified
Do you have write permission in C:\Program Files\R\R-2.9.2\library? It could be that the installer just tried to create the QRMlib subdir, and failed, and that's why it doesn't exist. One possible reason for failure is that your virus checker prevented the R installer from creating a new directory. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rounding and printing
On Oct 29, 2009, at 12:29 PM, Alan Cohen wrote: Hello, I am trying to print a table with numbers all rounded to the same number of digits (one after the decimal), but R seems to want to not print .0 for integers. I can go in and fix it one number at a time, but I'd like to understand the principle. Here's an example of the code. The problem is the 13th element, 21 or 21.0: nvb_deaths - round(ss[,10]/100,digits=1) nvb_deaths [1] 56.5 1.6 0.2 3.9 0.1 2.2 0.2 2.6 1.5 4.1 1.1 6.1 21.0 ?sprintf # fmt = %1.1f nvb_dths - paste(sprintf(%1.1f, nvb_deaths), (,round(100*nvb_deaths/ nvb_deaths[1],digits=1),%),sep=) nvb_dths [1] 56.5 (100%) 1.6 (2.8%) 0.2 (0.4%) 3.9 (6.9%) 0.1 (0.2%) 2.2 (3.9%) 0.2 (0.4%) [8] 2.6 (4.6%) 1.5 (2.7%) 4.1 (7.3%) 1.1 (1.9%) 6.1 (10.8%) 21.0 (37.2%) nvb_dths - paste(nvb_deaths, (,round(100*nvb_deaths/ nvb_deaths[1],digits=1),%),sep=) nvb_dths [1] 56.5 (100%) 1.6 (2.8%) 0.2 (0.4%) 3.9 (6.9%) 0.1 (0.2%) 2.2 (3.9%) [7] 0.2 (0.4%) 2.6 (4.6%) 1.5 (2.7%) 4.1 (7.3%) 1.1 (1.9%) 6.1 (10.8%) [13] 21 (37.2%) print(nvb_deaths,digits=1) [1] 56.5 1.6 0.2 3.9 0.1 2.2 0.2 2.6 1.5 4.1 1.1 6.1 21.0 paste(print(nvb_deaths,digits=1), (,round(100*nvb_deaths/ nvb_deaths[1],digits=1),%),sep=) [1] 56.5 1.6 0.2 3.9 0.1 2.2 0.2 2.6 1.5 4.1 1.1 6.1 21.0 [1] 56.5 (100%) 1.6 (2.8%) 0.2 (0.4%) 3.9 (6.9%) 0.1 (0.2%) 2.2 (3.9%) [7] 0.2 (0.4%) 2.6 (4.6%) 1.5 (2.7%) 4.1 (7.3%) 1.1 (1.9%) 6.1 (10.8%) [13] 21 (37.2%) I'm running R v2.8.1 on Windows. Any help is much appreciated. Cheers, Alan Cohen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] a minor bug in venn from gplots?
Hi list, I found this one when I was trying to output the Venn diagram to a .pdf file. When there are 4 sets of groups to draw, the .pdf file automatically has 3 pages and the figure only appears on the 3rd page in the .pdf file with the first 2 pages being blank. Try the following: (I'm using R-2.9.0 on WinXP, gplots 2.7.1). gplots 2.7.3 has the same problem. ###== pdf(test.pdf) A- 1:20 B- 1:20 C- 2:20 D- 3:21 input-list(A,B,C,D) venn(input) dev.off() ###== By looking at the code of drawVennDiagram, I think the problem comes from the fact there are one grid.newpage() call and two plot function calls when numCircles==4 (see below). I wonder the grid.newpage() and the second plot call are necessary? Thanks a lot. ...Tao ##= else if (4 = numCircles numCircles = 5 !simplify) { grid.newpage() === relocate_elp - function(e, alpha, x, y) { phi = (alpha/180) * pi xr = e[, 1] * cos(phi) + e[, 2] * sin(phi) yr = -e[, 1] * sin(phi) + e[, 2] * cos(phi) xr = x + xr yr = y + yr return(cbind(xr, yr)) } lab - function(identifier, data, showLabel = showSetLogicLabel) { r - data[identifier, 1] if (showLabel) { return(paste(identifier, r, sep = \n)) } else { return(r) } } plot(c(0, 400), c(0, 400), type = n, axes = F, ylab = , xlab = ) if (4 == numCircles) { elps = cbind(162 * cos(seq(0, 2 * pi, len = 1000)), 108 * sin(seq(0, 2 * pi, len = 1000))) plot(c(0, 400), c(0, 400), type = n, axes = F, === ylab = , xlab = ) polygon(relocate_elp(elps, 45, 130, 170)) polygon(relocate_elp(elps, 45, 200, 200)) ... ###=== _ [[elided Hotmail spam]] D24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_myidea:102009 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The system cannot find the file specified
On 10/29/2009 12:58 PM, hadley wickham wrote: Do you have write permission in C:\Program Files\R\R-2.9.2\library? It could be that the installer just tried to create the QRMlib subdir, and failed, and that's why it doesn't exist. One possible reason for failure is that your virus checker prevented the R installer from creating a new directory. Yes, virus checkers cause a lot of trouble for R. Some of them open files for exclusive access while checking, and when R tries to read or write the same file while the virus checker has it locked, it fails. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question about is.na for missing data
On Thu, 29 Oct 2009 11:45:19 -0500 David Kaplan dkap...@education.wisc.edu wrote: asd[is.na(asd)] - mean(asd,na.rm=TRUE) This has worked quite well in the past. Now, however, I am getting the following error messsage. Error in `[-.data.frame`(`*tmp*`, is.na(asd), value = c(2433.64150943396, : rhs is the wrong length for indexing by a logical matrix An inspection of the data set reveals no value of the sort give above. Any thoughts? I would venture to guess that your 'asd' object is not of the type you think it is. What is the value of str(asd) -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Weird error: Error in xj[i] : invalid subscript type 'list'
On 10/29/2009 12:28 PM, Peng Yu wrote: I got the error. I haven't been able to get a stand along case so that I can show it here. But could somebody give some clue on what could cause this error? Since I never defined xj[i], I don't understand where this error come from. Error in xj[i] : invalid subscript type 'list' Next time you see it, run traceback() afterwards to see which function triggered it. That might help you to track it down and fix it. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The system cannot find the file specified
On Thu, 29 Oct 2009, hadley wickham wrote: (quoting Duncan Murdoch without attribution, tut tut) Do you have write permission in C:\Program Files\R\R-2.9.2\library? It could be that the installer just tried to create the QRMlib subdir, and failed, and that's why it doesn't exist. One possible reason for failure is that your virus checker prevented the R installer from creating a new directory. Another (more likely, and mentioned in the rw-FAQ) is that a file indexing service prevented the file being renamed. As I understand this thread, the OP was able to install several packages but the last one failed. That's more consistent with file indexing (a concurrent process that will interfere apparently randomly) than with permission issues. Anti-virus software normally intervenes before the file gets written, not on renaming. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to turn individual consecutive information into survival objects?
Dear R List, I have a dataset with the following structure: personal_id, p_0, p_1, p_2, , p_36, p_37 1, NA, 1, 4, , 1, NA 2, NA, NA, NA, , 4, NA . . . 6020, NA, 3, 3, , NA, NA 6021, NA, 2, 2, , 4, NA I used some made-up data. It is just meant to show the structure of the dataset. The variables of interest are p_0, ... p_37. They represent types of activity of the 6021 persons interviewed in 38 consecutive period. The values for p_0 and p_37 are coded as follows: 1 = self-employed 2 = employed 3 = in training 4 = unemployed NA = no information available p_0 is the period before p_1. This period was just before the survey, so that none of the individuals were interviewed in this period. p_37 is the period after p_36. This period was just after the survey, so that none of the individuals were interviewed in this period. I would like to transform this dataset into information on the lenght of the first spell of unemployment. (If there are multiple spells I would just like to use the first one.) My question is how can I convert the records in this dataset into survivul objects - Surv() - so that they can be used with a function like coxph(). Could anyone give me a pointer to a function that performs this specific conversion? Thanks in advance! Guido Get your new Email address! Grab the Email name you#39;ve always wanted before someone else does! http://mail.promotions.yahoo.com/newdomains/aa/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question about is.na for missing data
On Thu, 29 Oct 2009 18:12:34 +0100 Karl Ove Hufthammer k...@huftis.org wrote: rhs is the wrong length for indexing by a logical matrix An inspection of the data set reveals no value of the sort give above. Any thoughts? I would venture to guess that your 'asd' object is not of the type you think it is. More specifically, I think it is a data frame with more than one column. Then 'mean' will calculate the average value for each column, instead of a single value. -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to turn individual consecutive information into survival objects?
On Thu, 29 Oct 2009 10:21:23 -0700 (PDT) Guido van Steen gvst...@yahoo.com wrote: I would like to transform this dataset into information on the lenght of the first spell of unemployment. (If there are multiple spells I would just like to use the first one.) If 'dat' is your data frame (or matrix): l.sum=apply(dat,1,rle) f.length=function(x) x$lengths[match(4,x$values)] sapply(l.sum,f.length) The results is a vector of the lengths of the first run of '4' for each row (i.e., the first element corresponds to the first row, the second element to the second row, and so on). I very often find uses for the 'rle' function. It fast, it's fun, and it's great that it's part of base R. :-) -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.