[R] Rule Based Text Classification
Hi, Is there any package in R which can help me do rule based text mining. -Nalin American Express made the following annotations on Mon Jun 18 2012 00:27:17 ** This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you. American Express a ajouté le commentaire suivant le Mon Jun 18 2012 00:27:17 Ce courrier et toute pièce jointe qu'il contient sont réservés au seul destinataire indiqué et peuvent renfermer des renseignements confidentiels et privilégiés. Si vous n'êtes pas le destinataire prévu, toute divulgation, duplication, utilisation ou distribution du courrier ou de toute pièce jointe est interdite. Si vous avez reçu cette communication par erreur, veuillez nous en aviser par courrier et détruire immédiatement le courrier et les pièces jointes. Merci. ** --- [[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] Need help in using OPTIM / OPTIMIZATION function
Hi R-Experts, I want to know for one parameter case, which function is better or correct, optim or optimization? I want to optimize the function to get mle using optimization function for single parameter case. Is there any other method to check the optimization really gives the global mle not the local mle. Looking forward for your reply. Thanks in advance. Regards, hena [[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] Interactive Graphics
Hi, I'd like to make an interactive graph like this: http://blog.ggplot2.org/post/25201174009/name-popularity I believe he was done with the ggplot2 and saved in svg format. if someone has experience with this subject (graph interactive web) could give me a help? Thanks -- Éder David Borges da Silva eder...@gmail.com eder...@hotmail.com Skype: ederdbs 041 96717488 Tudo é Relativo...(Albert Einstein) [[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] Package of EM and MI for IRT in R
Dear all members, I am Phd. candidate student at Chulalongkorn U., Thailand. I am interested in expectation maximization algorithm (EM) and multiple imputation (MI) for imputation missing values(missing at random(MAR) and missing not at random (MNAR)) in IRT (3-PL). So, I want to know about package in R or function of EM and MI for simulate this problem I am looking forward your answer. sincerely yours, Kamontip Srihaset [[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] checking the validity of the expressions
hi I have a data and have to convert it into the given expression like data=1000:2000 and expression is exp() The code should be checking the validity of the expressions and give out the result that it is valid expression or invalid expression. can any one help - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/checking-the-validity-of-the-expressions-tp4633671.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] Update dataframe to Access without delete values
Hi! I created a table named TEST2 in my base Access named CINDY. My columns are : A (numeric), B (character), C (numeric) There are values in this table. In R, I created a data.frame fr: fr - data.frame(A = c(1,2,3),B = c(c,d,u), C=c(4,5,6)) I would like export this data.frame in my table TEST2 without delete the values which are inside. I tried : sqlUpdate(CINDY, fr, 'TEST2',index=colnames(fr)) But it doesn't work... Can you help me please? Thanks -- View this message in context: http://r.789695.n4.nabble.com/Update-dataframe-to-Access-without-delete-values-tp4633673.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] Error while installing R on RHEL 6
Hi, I am trying to install R from source and using configure command but gettting one error message. *configure: error: --with-readline=yes (default) and headers/libs are not available* I am installing on server which is not connected by net so can install by source only. Can u pls suggest me how to rectify such pblm. Regards -- View this message in context: http://r.789695.n4.nabble.com/Error-while-installing-R-on-RHEL-6-tp4633675.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] noob requesting help
David Winsemius wrote That's going to remove a lot of rows. Since you are not telling us what columns correspond to those concepts, I'm going to use the terms you are. Something along the lines of: require(lattice) histogram( ~ hours | bird, data=dat2, nint =24 , xlim=c(0,24)) histogram( ~ hours ,data=dat2, nint =24 , xlim=c(0,24)) The result on that example was just a list with one element, a dataframe. str(departures) List of 1 $ 121.3:'data.frame': 1 obs. of 4 variables: ..$ device_info_serial: int 121 ..$ hour : int 10 ..$ time : POSIXct[1:1], format: 2009-05-21 04:59:24 ..$ tripID: int 3 So to get what you might have expected dep - departures[[1]] dep device_info_serial hourtime tripID 1121 10 2009-05-21 04:59:24 3 But since you didn't actually describe what you did want (or if you did you left upthread), its only a guess. I'll try to explain my goals more clearly. The columns are: dat2$device_info_serial: The 'number' of the bird, ranging from 121 to 542. There are 34 different birds, each with their own number. dat2$tripID: The number of the trip. Every bird has a trip 1, 2, 3, etc. (some birds have as much as 265 trips, many have less). Every trip has many measurements, as trips take hours and measurements were taken every 15 minutes. dat2$time: The time at which a measurement was taken. dat2$hour: The 'hour' part of dat2$time; the hour in which a measurement was taken From my dataset, I need to gather only the first measurement of every trip of every bird. This way, I can make (circular) graphs of the departure-times for each trip of each bird. I think that I am very close after using: departures - lapply(split(dat2, list(dat2$device_info_serial, dat2$tripID)), function(x) x[x$time == min(x$time),]) But it is in the wrong format. I need it to be in a format so that I can use commands such as departures$hour and departures$device_info_serial. I need this so that I can circulise (circularise?) dat2$hour and so that I can make graphs for each bird seperately. Making the graphs etc. shouldn't be a problem if I have a dataset that I can use like this: d121 - departures[which(departures$device_info_serial == 121),] d130 - departures[which(departures$device_info_serial == 130),] d132 - departures[which(departures$device_info_serial == 132),] d133 - departures[which(departures$device_info_serial == 133),] and cdAll - circular(departures$hour, units='hours', template='clock24') cd121 - circular(d121$hour, units='hours', template='clock24') cd130 - circular(d130$hour, units='hours', template='clock24') cd132 - circular(d132$hour, units='hours', template='clock24') So, if I'm not mistaken, I only need your help with transforming the 'departures' that I have now into something with $hour and $device_info_serial. I hope this is possible. I hope my ignorance isn't frustrating you too much. I'm trying my best to understand and learn how to work with R in the short timespan that I have. Peter -- View this message in context: http://r.789695.n4.nabble.com/noob-requesting-help-tp4632803p4633678.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] Error while installing R on RHEL 6
Hi, I am trying to install R from source and using configure command but gettting one error message. *configure: error: --with-readline=yes (default) and headers/libs are not available* I am installing on server which is not connected by net so can install by source only. Can u pls suggest me how to rectify such pblm. Regards -- View this message in context: http://r.789695.n4.nabble.com/Error-while-installing-R-on-RHEL-6-tp4633676.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] out put of loop in list
Hello I have a loop to draw few samples and I want to but this samples in one list, how I can make this? when I use it , the list show just the last sample. I want to know the correct way to put all samples in one list. Regards Sulafah [[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] Loop Help
I think that for now I'll keep it as is and try to clean the data in excel. Could someone please tell me how can I export the result to csv, since write.csv exports only the last j? Thank you so much in advance! -- View this message in context: http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633677.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] triangular matrix
Hello, I got this matrix of gentic distances between my samples. it is 85x85 but only lower half (without diagonal) contains my distances. How can I make a mean and standard deviation on these distances, please ? Thank you! Lucia -- View this message in context: http://r.789695.n4.nabble.com/triangular-matrix-tp4633679.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] Error while installing R on RHEL 6
Hello, The error message gives you the solution. Regards Le 18/06/2012 18:26, Manish Gupta a écrit : Hi, I am trying to install R from source and using configure command but gettting one error message. *configure: error: --with-readline=yes (default) and headers/libs are not available* I am installing on server which is not connected by net so can install by source only. Can u pls suggest me how to rectify such pblm. Regards -- View this message in context: http://r.789695.n4.nabble.com/Error-while-installing-R-on-RHEL-6-tp4633675.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] Error while installing R on RHEL 6
Do you mean, --with-readline=no or after installing the readline headers? Regards Le 18/06/2012 20:17, manish gupta a écrit : I used it but still same error. Regards On Mon, Jun 18, 2012 at 7:14 PM, Pascal Oettlikri...@ymail.com wrote: Hello, The error message gives you the solution. Regards Le 18/06/2012 18:26, Manish Gupta a écrit : Hi, I am trying to install R from source and using configure command but gettting one error message. *configure: error: --with-readline=yes (default) and headers/libs are not available* I am installing on server which is not connected by net so can install by source only. Can u pls suggest me how to rectify such pblm. Regards -- View this message in context: http://r.789695.n4.nabble.com/** Error-while-installing-R-on-**RHEL-6-tp4633675.htmlhttp://r.789695.n4.nabble.com/Error-while-installing-R-on-RHEL-6-tp4633675.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-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ 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] Adding title to colorkey
On Sat, Jun 16, 2012 at 2:10 PM, Stephen Eglen s.j.eg...@damtp.cam.ac.uk wrote: A recent paper on visualisation (in Neuron, a leading neuroscience journal) surveyed how well previous articles in this journal labelled their graphs (e.g. axis labelling and describing their error bars). Of particular interest is that (only) 40% of plots labelled what their colorkey was showing (variable and units). The paper is at http://dx.doi.org/10.1016/j.neuron.2012.05.001 R is not yet that prominent (compared to matlab) in Neuroscience, so I doubt many of the graphs were generated by levelplot() and friends. However, how can the colorkey be labelled? I notice that this topic has been raised before, e.g. http://tolstoy.newcastle.edu.au/R/e16/help/11/11/2281.html For now, I've done: library(lattice) library(grid) levelplot(matrix(1:9,3,3), par.settings = list(layout.widths = list(axis.key.padding = 4))) grid.text('title here', y=unit(0.5, npc), rot=90, x=unit(0.88, npc)) i.e. adding some space between levelplot and colorkey. The x,y positions of the grid.text call need fine-tuning once the plot is close to finalised. Does anyone have a better solution for vertical colorkeys? e.g. can the plot objected be interrogated to work out what the central x,y value is? This is slightly simpler: levelplot(matrix(1:9,3,3), ylab.right = title here, par.settings = list(layout.widths = list(axis.key.padding = 0, ylab.right = 2))) There really should be a function allowing easy construction of complex legends combining simpler ones. There is currently only mergedTrellisLegendGrob in latticeExtra (not very robust) which can be used as follows: library(latticeExtra) p - levelplot(matrix(1:9,3,3)) p$legend$right - list(fun = mergedTrellisLegendGrob(p$legend$right, list(fun = textGrob, args = list(title here, rot = -90)), vertical = FALSE)) p -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] autocorrelation of a series
Hello all, I have a general question about time series and I wonder if someone could help me. I have time series data of this form: x=c(rnorm(500,0,1),rnorm(500,5,1),rnorm(500,10,1),rnorm(500,3,1),rnorm(500,8,1),rnorm(500,4,1),rnorm(500,1,1),rnorm(500,7,1)) time=1:4000 plot(time,x) Each rnorm generates a different cluster. I would like to do a statistical test of mean difference between the first, the second and the seventh cluster: HO: mean(rnorm(500,0,1)) = mean(rnorm(500,5,1)) = mean(rnorm(500,1,1)) My questions are: (a) Can I simply do this by an ANOVA model on these values or by change-point analysis (using multiple.mean.norm of the package changepoint)? (b) If I want to check for the autocorrelation of my series (by acf), which data should I use: the residuals of the ANOVA model or the actual data? The actual data will give me high autocorrelation due to the trend, is that correct? Thank you for your help, Mike __ 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-pkgs] igraph 0.6 released
Dear All, we have released version 0.6 of the igraph package today. This is a major new version, with a lot of new features, and (sadly) it is not completely compatible with code that was written for the previous igraph versions. (See Major new features below for details.) I have included below a list of (bigger) changes. Please see the details in the release notes and the NEWS section at the igraph homepage: http://igraph.sf.net Best Regards, Gabor = Major new features = - Vertices and edges are numbered from 1 instead of 0. Note that this makes most of the old R igraph code incompatible with igraph 0.6. If you want to use your old code, please use the igraph0 package. See more at http://igraph.sf.net/relnotes-0.6.html. - The '[' and '[[' operators can now be used on igraph graphs, for '[' the graph behaves as an adjacency matrix, for '[[' is is treated as an adjacency list. It is also much simpler to manipulate the graph structure, i.e. add/remove edges and vertices, with some new operators. See more at ?graph.structure. - In all functions that take a vector or list of vertices or edges, vertex/edge names can be given instead of the numeric ids. - New package 'igraphdata', contains a number of data sets that can be used directly in igraph. - Igraph now supports loading graphs from the Nexus online data repository, see nexus.get(), nexus.info(), nexus.list() and nexus.search(). - All the community structure finding algorithm return a 'communities' object now, which has a bunch of useful operations, see ?communities for details. - Vertex and edge attributes are handled much better now. They are kept whenever possible, and can be combined via a flexible API. See ?attribute.combination. - R now prints igraph graphs to the screen in a more structured and informative way. The output of summary() was also updated accordingly. = R: Other new features = - It is possible to mark vertex groups on plots, via shading. Communities and cohesive blocks are plotted using this by default. - Some igraph demos are now available, see a list via 'demo(package=igraph)'. - igraph now tries to select the optimal layout algorithm, when plotting a graph. - Added a simple console, using Tcl/Tk. It contains a text area for status messages and also a status bar. See igraph.console(). - Reimplemented igraph options support, see igraph.options() and getIgraphOpt(). - Igraph functions can now print status messages. === R: New or updated functions === Community detection --- - The multi-level modularity optimization community structure detection algorithm by Blondel et al. was added, see multilevel.community(). - Distance between two community structures: compare.communities(). - Community structure via exact modularity optimization, optimal.community(). - Hierarchical random graphs and community finding, porting the code from Aaron Clauset. See hrg.game(), hrg.fit(), etc. - Added the InfoMAP community finding method, thanks to Emmanuel Navarro for the code. See infomap.community(). Shortest paths -- - Eccentricity (eccentricity()), and radius (radius()) calculations. - Shortest path calculations with get.shortest.paths() can now return the edges along the shortest paths. - get.all.shortest.paths() now supports edge weights. Centrality -- - Centralization scores for degree, closeness, betweenness and eigenvector centrality. See centralization.scores(). - Personalized Page-Rank scores, see page.rank(). - Subgraph centrality, subgraph.centrality(). - Authority (authority.score()) and hub (hub.score()) scores support edge weights now. - Support edge weights in betweenness and closeness calculations. - bonpow(), Bonacich's power centrality and alpha.centrality(), Alpha centrality calculations now use sparse matrices by default. - Eigenvector centrality calculation, evcent() now works for directed graphs. - Betweenness calculation can now use arbitrarily large integers, this is required for some lattice-like graphs to avoid overflow. Input/output and file formats - - Support the DL file format in graph.read(). See http://www.analytictech.com/networks/dataentry.htm. - Support writing the LEDA file format in write.graph(). Plotting and layouts - Star layout: layout.star(). - Layout based on multidimensional scaling, layout.mds(). - New layouts layout.grid() and layout.grid.3d(). - Sugiyama layout algorithm for layered directed acyclic graphs, layout.sugiyama(). Graph generators - New graph generators: static.fitness.game(), static.power.law.game(). - barabasi.game() was rewritten and it supports three algorithms now, the default algorithm does not generate multiple or loop edges. The graph generation process can now start from a
Re: [R] Error while installing R on RHEL 6
On 18/06/2012 10:26, Manish Gupta wrote: Hi, I am trying to install R from source and using configure command but gettting one error message. *configure: error: --with-readline=yes (default) and headers/libs are not available* I am installing on server which is not connected by net so can install by source only. Can u pls suggest me how to rectify such pblm. PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Please do as you were asked. The solution is in the R manuals this asked you to read, specifically http://cran.r-project.org/doc/manuals/R-admin.html#Essential-programs-and-libraries -- 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] triangular matrix
Hi Lucia, On Mon, Jun 18, 2012 at 6:11 PM, lucinka lucia.bohus...@gmail.com wrote: Hello, I got this matrix of gentic distances between my samples. it is 85x85 but only lower half (without diagonal) contains my distances. How can I make a mean and standard deviation on these distances, please ? You can try something like dist.vec - dist.matrix[lower.tri(dist.matrix)] mean(dist.vec) sd(dist.vec) Regards, - Jon __ 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] noob requesting help
Hello, Have you tried what I wrote in my last post? Revised: # Make a copy first, and operate on the copy. dep - departures names(dep) - NULL dep - data.frame(dep) Rui Barradas Em 18-06-2012 11:09, capital_P escreveu: David Winsemius wrote That's going to remove a lot of rows. Since you are not telling us what columns correspond to those concepts, I'm going to use the terms you are. Something along the lines of: require(lattice) histogram( ~ hours | bird, data=dat2, nint =24 , xlim=c(0,24)) histogram( ~ hours ,data=dat2, nint =24 , xlim=c(0,24)) The result on that example was just a list with one element, a dataframe. str(departures) List of 1 $ 121.3:'data.frame':1 obs. of 4 variables: ..$ device_info_serial: int 121 ..$ hour : int 10 ..$ time : POSIXct[1:1], format: 2009-05-21 04:59:24 ..$ tripID: int 3 So to get what you might have expected dep - departures[[1]] dep device_info_serial hourtime tripID 1121 10 2009-05-21 04:59:24 3 But since you didn't actually describe what you did want (or if you did you left upthread), its only a guess. I'll try to explain my goals more clearly. The columns are: dat2$device_info_serial: The 'number' of the bird, ranging from 121 to 542. There are 34 different birds, each with their own number. dat2$tripID: The number of the trip. Every bird has a trip 1, 2, 3, etc. (some birds have as much as 265 trips, many have less). Every trip has many measurements, as trips take hours and measurements were taken every 15 minutes. dat2$time: The time at which a measurement was taken. dat2$hour: The 'hour' part of dat2$time; the hour in which a measurement was taken From my dataset, I need to gather only the first measurement of every trip of every bird. This way, I can make (circular) graphs of the departure-times for each trip of each bird. I think that I am very close after using: departures - lapply(split(dat2, list(dat2$device_info_serial, dat2$tripID)), function(x) x[x$time == min(x$time),]) But it is in the wrong format. I need it to be in a format so that I can use commands such as departures$hour and departures$device_info_serial. I need this so that I can circulise (circularise?) dat2$hour and so that I can make graphs for each bird seperately. Making the graphs etc. shouldn't be a problem if I have a dataset that I can use like this: d121 - departures[which(departures$device_info_serial == 121),] d130 - departures[which(departures$device_info_serial == 130),] d132 - departures[which(departures$device_info_serial == 132),] d133 - departures[which(departures$device_info_serial == 133),] and cdAll - circular(departures$hour, units='hours', template='clock24') cd121 - circular(d121$hour, units='hours', template='clock24') cd130 - circular(d130$hour, units='hours', template='clock24') cd132 - circular(d132$hour, units='hours', template='clock24') So, if I'm not mistaken, I only need your help with transforming the 'departures' that I have now into something with $hour and $device_info_serial. I hope this is possible. I hope my ignorance isn't frustrating you too much. I'm trying my best to understand and learn how to work with R in the short timespan that I have. Peter -- View this message in context: http://r.789695.n4.nabble.com/noob-requesting-help-tp4632803p4633678.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] noob requesting help
Rui Barradas wrote Try names(departures) - NULL dep - data.frame(departures[ !sapply(departures, is.null) ]) You now have data.frame 'dep'. dep - data.frame(departures[ !sapply(departures, is.null) ]) Error in data.frame(`121.1` = list(device_info_serial = integer(0), hour = integer(0), : arguments imply differing number of rows: 0, 1, 2 dep - departures names(dep) - NULL dep - data.frame(dep) Error in data.frame(list(device_info_serial = integer(0), hour = integer(0), : arguments imply differing number of rows: 0, 1, 2 -- View this message in context: http://r.789695.n4.nabble.com/noob-requesting-help-tp4632803p4633691.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] some help to improve hist to plot relative frequencies
On Fri, Jun 15, 2012 at 9:22 PM, gianni lavaredo gianni.lavar...@gmail.com wrote: Dear Researches, sorry for disturb. I wish to improve my figure in R plotting the relative frequencies of my data set. library(lattice) a - c(0,0,0,1,1,2,4,5,6,7,7,7,7,7,8,8,8,8,9,9,9,9,10,10,11) histogram(a, xlab=myData) what i wish to do is: 1) invert the order of X and Y (eg: Precent of Total on X-axis and MyData on X-axis) 2) plot not the bar of histogram but a line (i tried with lines(density(a)) but the result is not what i wish) Take your pick: ta - table(a) dotplot(ta, type = h, lwd = 2, origin = 0) dotplot(100 * prop.table(ta), type = h, lwd = 2, origin = 0, xlab = Percent of total) xyplot(as.numeric(names(ta)) ~ 100 * prop.table(ta), type = h, lwd = 2, origin = 0, horizontal = TRUE, xlab = Percent of total, ylab = myData, xlim = c(-1, NA)) -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to specify newdata in a Cox-Modell with a time dependent interaction term?
I've been out for a week, with one more to go. I'll look at this in earnest when I return. Terry T On 06/17/2012 04:07 AM, Jürgen Biedermann wrote: Dear John, Thank you very much for your help! It was very important for getting along further. I found out some additional things which I want to give back to you as feedback (maybe other persons will have the same problems). It's also possible to leave away the individual=T argument. Instead you can use: newdata.1- data.frame(unique(Rossi.2[c(start,stop)]),fin=0,age=30,prio=5,Id=1,arrest.time=0) fit - survfit(mod.allison.5, newdata.1, id=Id) *but not* fit - survfit(mod.allison.5, newdata.1, id=Id) so you have to leave away the in specifying the id variable -- maybe the help file could be more precise here. Additionally I found out some more things while dealing with my original data. It's very important to specify the Surv object and the formula directly in the coxph function, *so don't do this:* SurvO - Surv(Rossi.2$start, Rossi.2$stop, Rossi.2$arrest.time) form - as.formula(SurvO ~ fin + age + age:stop + prio) mod.allison.5- coxph(form, data=Rossi.2) mod.allison.5 newdata.1- data.frame(unique(Rossi.2[c(start,stop)]),fin=0,age=30,prio=5,arrest.time=0) fit - survfit(mod.allison.5, newdata.1, individual=T) Fehler in model.frame.default(data = newdata.1, formula = SurvO ~ fin + : Variablenlängen sind unterschiedlich (gefunden für 'fin') -- Error, length of variables are different I think the error message is not optimal here, anyway. The problem obviously consists in the survfit-function not recognizing the names of the variables anymore. It seems completely logic, but anyway, it took me many hours. Thanks again, Jürgen - Korrespondenz -- Betreff: Re: How to specify newdata in a Cox-Modell with a time dependent interaction term? Von: John Fox j...@mcmaster.ca An: J?rgen Biedermann juergen.biederm...@googlemail.com Datum: 16.06.2012 17:22 Dear Jurgen, fit- survfit(mod.allison.5, newdata.1, individual=TRUE) fit Call: survfit(formula = mod.allison.5, newdata = newdata.1, individual = TRUE) records n.max n.start events median 0.95LCL 0.95UCL 19809 432 432 114 NA NA NA plot(fit) # shows one survival curve See ?survfit.coxph. Best, John On Sat, 16 Jun 2012 16:23:41 +0200 Jürgen Biedermannjuergen.biederm...@googlemail.com wrote: Dear John, Thank you very much for the quick answer. I will use the mentioned citation of your book in the future. However: The Id argument is necessary for the function to know that the different rows belong to one individual. Or how the Help-File says: id: optional variable name of subject identifiers. If this is present, then each group of rows with the same subject id represents the covariate path through time of a single subject, and the result will contain one curve per subject. If the coxph fit had strata then that must also be specified in newdata. If missing, then each individual row of newdata is presumed to represent a distinct subject and there will be nrow(newdata) times the number of strata curves in the result (one for each strata/subject combination). I tried your proposal anyway, but, as expected, fifty different survival curves appeared. So, there is still no solution. Best regards Jürgen -- --- Jürgen Biedermann Bergmannstraße 3 10961 Berlin-Kreuzberg Mobil: +49 176 247 54 354 Home: +49 30 940 53 044 e-mail:juergen.biederm...@gmail.com - Korrespondenz -- Betreff: Re: How to specify newdata in a Cox-Modell with a time dependent interaction term? Von: John Foxj...@mcmaster.ca An: J?rgen Biedermannjuergen.biederm...@googlemail.com Datum: 16.06.2012 15:55 Dear Jürgen, All the values of your Id variable are equal to 1; how can that make sense? Removing the argument Id=id may get you what you want. By the way, the document to which you refer was an appendix to a 2002 book that has been superseded by Fox and Weisberg, An R Companion to Applied Regression, Second Edition (Sage, 2011). Appendices for that book are available athttp://socserv.socsci.mcmaster.ca/jfox/Books/Companion/appendix.html. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Sat, 16 Jun 2012 15:04:48 +0200 Jürgen Biedermannjuergen.biederm...@googlemail.com wrote: Dear Mr. Therneau, Mr. Fox, or to whoever, who has some time... I don't find a solution to use the survfit function (package: survival) for a defined pattern of covariates with a Cox-Model including a time dependent interaction term. Somehow the definition of my newdata argument seems to be erroneous. I
Re: [R] Loop Help
What do you mean by only the last j? write.csv writes to a file you specify and I assume that you are changing the file name if you are making successive writes. You need to provide more detail. On Mon, Jun 18, 2012 at 5:47 AM, @ngel aggelopou...@gmail.com wrote: I think that for now I'll keep it as is and try to clean the data in excel. Could someone please tell me how can I export the result to csv, since write.csv exports only the last j? Thank you so much in advance! -- View this message in context: http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633677.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 Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loop Help
Hello Jim thank you so much for your response. When I use write.csv, on the csv file is saved only the last loop So when I write results.matrix - apply(degree_w(net.static[[i]]), 2, mean) write.csv(results.matrix, file = results.csv) instead of getting a 550 line document with all loop results, I only get the last one! Could you please help me? Thank you so much in advance -- View this message in context: http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633699.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] Loop Help
Then don't do that. write.csv is designed to write a complete matrix or data frame in one call. Combine your list of matrices into one (e.g. using sapply) and write that in one call afterward rather than piecewise as you do the calculations. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. @ngel aggelopou...@gmail.com wrote: Hello Jim thank you so much for your response. When I use write.csv, on the csv file is saved only the last loop So when I write results.matrix - apply(degree_w(net.static[[i]]), 2, mean) write.csv(results.matrix, file = results.csv) instead of getting a 550 line document with all loop results, I only get the last one! Could you please help me? Thank you so much in advance -- View this message in context: http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633699.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] Efficient distance calculation on big matrix
Stefan, that looks wonderful! I am most certainly going to try to download and use your 'wordspace', even though I am unsure on how to even download it at this point. Many thanks! But yes, I need the Canberra distance unfortunately. But decreasing the time by more than 60% will save me days! If I can get there. 2012/6/17 Stefan Evert stefa...@collocations.de: I'm working on analyzing a large data set, lets asume that dim(Data)=c(1000,8700). I want to calculate the canberra distance between the columns of this matrix, and using a toy example ('test' is a matrix filled with random numbers 0-1): system.time(d-as.matrix(dist(t(test), method = canberra, diag = FALSE, upper = FALSE, p = 2))) user system elapsed 1417.713 3.219 1421.144 The system.time results also confuse me a bit, since 99% of the time is not system time but user time. What does that mean? User time is the time that R spends working on your problem; system time refers to tasks done by the operating system, e.g. disk access, managing locks and, most importantly, swapping when you run out of RAM. With multi-threading, system time can be much larger than the time that has actually elapsed. Is there any way to calculate the distance which would take less time? Well, one thing you can do is to get a faster computer. :-) The command above takes only 670 seconds on my MacBook Pro (without multi-threading). Calculating a distance matrix is an expensive computation. In your example, R has to carry out (8700 * 8700 * 1000) / 2 = 37.8 billion floating point divisions. With approx. 27 clock cycles per division (according to tables I've found on the Web), this takes at least 340 seconds even on a 3GHz CPU (and ignoring memory access, addition/subtraction, loops, etc.). You can shave off some of the time if you implement the distance calculation in C, inline the code to avoid callback functions in loops, operate on columns of the matrix directly (which should be more cache-friendly than rows) and don't check for NA's, NaN's and other degenerate cases. I've done just that in my experimental R package wordspace, which isn't on CRAN yet: library(wordspace) A - matrix(runif(8.7e6), 1000, 8700) system.time(d1 - as.matrix(dist(t(A), method=canberra))) user system elapsed 669.207 2.724 669.305 system.time(d2 - dist.matrix(A, method=canberra, byrow=FALSE)) user system elapsed 250.534 0.784 250.301 all(d1 == d2) [1] TRUE If you aren't tied to Canberra distance, you can use a less expensive metric such as the Manhattan distance for an additional, more substantial speed boost: system.time(d3 - dist.matrix(A, method=manhattan, byrow=FALSE)) user system elapsed 42.488 0.999 43.569 This is still single-threaded, so you can run multiple of these calculations in parallel depending on how many cores your server has. Hope this helps, Stefan PS: In case you'd like to give it a try yourself and aren't daunted by a complete lack of documentation: svn checkout svn://scm.r-forge.r-project.org/svnroot/wordspace/pkg [ ev...@linglit.tu-darmstadt.de | http://purl.org/stefan.evert ] __ 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] Using Sub
Hi Duncan, That's right but I want to be able to use this to replace back slashes with front slashes when I copy and paste file paths. How can I make this work so I don't get this error? Thanks. Dan -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Friday, June 15, 2012 12:04 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub On 12-06-14 6:23 PM, Lopez, Dan wrote: Hi, I have been trying to get the sub function to work but can't for the life of me figure it out. I tried looking at ?sub but I think there is something that I am just not understanding. Example failed attempts sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: '\C' is an unrecognized escape in character string starting G:\C This isn't anything to do with sub(), it's the third string that's the problem. When you say G:\Comp... it thinks you've escaped the C, but there's no such escape. Duncan Murdoch sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=TRUE) Error: '\C' is an unrecognized escape in character string starting G:\C sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=FALSE) Error: '\C' is an unrecognized escape in character string starting G:\C) sub(/,\,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: unexpected symbol in sub(/,\,G Thanks. Dan __ 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] out put of loop in list
I would be good if you showed us what you are doing now. There are ways of drawing samples and storing in a list, but we have to see what you are trying to accomplish. You could use 'lapply' or do it in a loop, but the solution would depend on how you are doing things now and what is the problem you are trying to solve. On Mon, Jun 18, 2012 at 5:38 AM, solafah bh solafa...@yahoo.com wrote: Hello I have a loop to draw few samples and I want to but this samples in one list, how I can make this? when I use it , the list show just the last sample. I want to know the correct way to put all samples in one list. Regards Sulafah [[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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aligning axis labels in a colorkey from levelplot
On Sat, Jun 16, 2012 at 1:41 PM, Stephen Eglen s.j.eg...@damtp.cam.ac.uk wrote: R does a great job with the fine details regarding plots. e.g in the following: library(lattice) y - -4:4/10 xyplot(y~1, las=1) the y axis is labelled with numbers -0.4, -0.2, 0.0, 0.2, 0.4 with the numbers aligned on the decimal point. How do I get the same behaviour in the colorkey of a levelplot? e.g. levelplot(matrix(y,3,3)) the numbers in the colorkey seem left-aligned, and because of the minus sign, the numbers now do not align on the decimal point. Likewise when the number of digits changes: levelplot(matrix(4:12,3,3)) Justification is hard-coded, and that's not easy to change. This is not only for the colorkey; e.g., xyplot(y~1, scales = list(alternating = 3)) will also give you left-aligned axes on the right. My only suggestion (other than custom labels as suggested by ilai) is levelplot(matrix(4:12,3,3), colorkey = list(space = left)) -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error while installing R on RHEL 6
I used it but still same error. Regards On Mon, Jun 18, 2012 at 7:14 PM, Pascal Oettli kri...@ymail.com wrote: Hello, The error message gives you the solution. Regards Le 18/06/2012 18:26, Manish Gupta a écrit : Hi, I am trying to install R from source and using configure command but gettting one error message. *configure: error: --with-readline=yes (default) and headers/libs are not available* I am installing on server which is not connected by net so can install by source only. Can u pls suggest me how to rectify such pblm. Regards -- View this message in context: http://r.789695.n4.nabble.com/** Error-while-installing-R-on-**RHEL-6-tp4633675.htmlhttp://r.789695.n4.nabble.com/Error-while-installing-R-on-RHEL-6-tp4633675.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-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Manish Gupta (M.Sc Bioinformatics) Bioinformatics Software Developer (Scientist) MSC Status company KL-59200 Malaysia [[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] out put of loop in list
Hello, Please read the posting guide: to draw samples from what? A vector? Matrix? Etc... Anyway, here it goes. In all cases the result is a list with 4 elements. # Draw 4 samples of integers from 1 to 10 x - rep(10, 4) # without replacement set.seed(1) lapply(x, sample, size=6) # with replacement set.seed(12) lapply(x, sample, size=6, replace=TRUE) # # Draw 4 samples from a vector # Make up a vector set.seed(123) (y - sample(LETTERS, 10)) lapply(1:4, function(i) sample(y, size=6, replace=TRUE)) Hope this helps, Rui Barradas Em 18-06-2012 10:38, solafah bh escreveu: Hello I have a loop to draw few samples and I want to but this samples in one list, how I can make this? when I use it , the list show just the last sample. I want to know the correct way to put all samples in one list. Regards Sulafah [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] making svm work harder
Hi all, I am working on an optimization of the svm classification function based on the package e1071. So far we have not been able to find any dataset that really slows down the application. However, from R users surveys seem that svm would be a good function to speed up. Is there any one working with this package and has experienced long time simulations? Do you know a dataset that could help us to properly profile the svm? Could you give me an example of how to read it and apply it to svm? Please, any help would be much appreciated!!! Best, L -- View this message in context: http://r.789695.n4.nabble.com/making-svm-work-harder-tp4633694.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] checking the validity of the expressions
What does any of this mean? Can you give a concrete example of the transformation you hope to accomplish? Michael On Mon, Jun 18, 2012 at 3:10 AM, arunkumar akpbond...@gmail.com wrote: hi I have a data and have to convert it into the given expression like data=1000:2000 and expression is exp() The code should be checking the validity of the expressions and give out the result that it is valid expression or invalid expression. can any one help - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/checking-the-validity-of-the-expressions-tp4633671.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.
[R] Installation problems in Pander from Github
Hello all, I was trying to create nice tables in HTML on windows and then got to know about Pander. I have installed Pandoc, devtools, Rtools (which has same path as of R ) . I have also gone through the depends of Pander and fixed it all. Still i am not able to install and getting a conflicting error of *cannot cd to directory 'C:/Program' *where i have installed my R , Rtools and Pandoc. Please guide me through this installation. -- Avinash Barnwal Statistics and informatics Department of Mathematics IIT Kharagpur [[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] Package of EM and MI for IRT in R
Possibly Amelia: http://cran.r-project.org/web/packages/Amelia/index.html Best, Michael On Mon, Jun 18, 2012 at 3:19 AM, Kamontip Srihaset kamonti...@student.chula.ac.th wrote: Dear all members, I am Phd. candidate student at Chulalongkorn U., Thailand. I am interested in expectation maximization algorithm (EM) and multiple imputation (MI) for imputation missing values(missing at random(MAR) and missing not at random (MNAR)) in IRT (3-PL). So, I want to know about package in R or function of EM and MI for simulate this problem I am looking forward your answer. sincerely yours, Kamontip Srihaset [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Need to append vector to all levels of nested list WITHOUT a loop
Hi everyone, I have a list betaMoments with 2 levels, e.g. beta1 = list( +m = 4, +v = 5 +) beta2 = list( +m = 6, +v = 7 +) betaMoments = list() betaMoments[[1]] = beta1 betaMoments[[2]] = beta2 and I have a matrix Names which has the same number of lines as the list has first level elements (here 2; beta1 and beta2). Now I need to make every line of Names (e.g. Names[1,] = c(2,3,4)) to become an element of the corresponding list element. For example, calling betaMoments[[1]] shall return betaMoments[[1]] $m [1] 4 $v [1] 5 $line [1] c(2,3,4) ... thats Names[1,] I can not do it with a loop since I need to execute this list construction way too often. So I need a speedy solution. Would be great if someone could help me, this really keeps me away from resolving the true issues. Regards, Johannes Dr. Johannes Reichl Project Manager Energy Institute at the Johannes Kepler University Linz Altenberger Straße 69 A-4040 Linz Tel.: +43-732-2468-5652 Fax: +43-732-2468-5651 Email: rei...@energieinstitut-linz.at Web: www.energieinstitut-linz.at www.energyefficiency.at __ 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 w/ Start up Script
I noticed about a couple weeks ago that my R start up script starting showing the below errors, following the line Type 'q()' to quit R Not sure what I did different and so far it hasn't caused major problems but kind of fear that it will. Can you please help? I also posted my Rprofile below. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ?R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default The following object(s) are masked from 'package:methods': getClass, getClasses, getMethods The following object(s) are masked from 'package:base': attach, detach, gc, load, save R.utils v1.12.1 (2012-03-20) successfully loaded. See ?R.utils for help. Attaching package: 'R.utils' The following object(s) are masked from 'package:utils': timestamp The following object(s) are masked from 'package:base': cat, commandArgs, getOption, inherits, isOpen, lapply, parse, warnings And here is my Rprofile.site file specs: # Things you might want to change # options(papersize=a4) # options(editor=notepad) # options(pager=internal) # set the default help type # options(help_type=text) options(help_type=html) # set a site library # .Library.site - file.path(chartr(\\, /, R.home()), site-library) # set a CRAN mirror local({r - getOption(repos) r[CRAN] - http://cran.cnr.Berkeley.edu; options(repos=r)}) # Give a fortune cookie, but only to interactive sessions # (This would need the fortunes package to be installed.) # if (interactive()) #fortunes::fortune() Daniel Lopez Workforce Analytics Metrics Team [[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] How do anova() and Anova(type=III) handle incomplete designs?
Thanks for your response, John. That was helpful. I was using Type III from Anova() as a comparison to some results I had obtained JMP, which I've lost access to and have moved on to R, and I was confused by the error. Given that I do have a continuous covariate, the analyses are not likely comparable, considering your response. I am still confused about interpretation of interactions within an anova() with an incomplete design, as mine is. Is the interaction term still informative? - Justin Montemarano Graduate Student Kent State University - Biological Sciences http://www.montegraphia.com On Sat, Jun 16, 2012 at 9:20 PM, John Fox j...@mcmaster.ca wrote: Dear Justin, anova() and Anova() are entirely different functions; the former is part of the standard R distribution and the second part of the car package. By default, Anova() produces an error for type-III tests conducted on rank-deficient models because the hypotheses tested aren't generally sensible. From ?Anova: singular.ok defaults to TRUE for type-II tests, and FALSE for type-III tests (where the tests for models with aliased coefficients will not be straightforwardly interpretable); if FALSE, a model with aliased coefficients produces an error. and The designations type-II and type-III are borrowed from SAS, but the definitions used here do not correspond precisely to those employed by SAS. Type-II tests are calculated according to the principle of marginality, testing each term after all others, except ignoring the term's higher-order relatives; so-called type-III tests violate marginality, testing each term in the model after all of the others. This definition of Type-II tests corresponds to the tests produced by SAS for analysis-of-variance models, where all of the predictors are factors, but not more generally (i.e., when there are quantitative predictors). Be very careful in formulating the model for type-III tests, or the hypotheses tested will not make sense. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Fri, 15 Jun 2012 15:01:27 -0400 Justin Montemarano jmont...@kent.edu wrote: Hello all: I am confused about the output from a lm() model with an incomplete design/missing level. I have two categorical predictors and a continuous covariate (day) that I am using to model larval mass (l.mass): leaf.species has three levels - map, syc, and oak cond.time has two levels - 30 and 150. There are no response values for Map-150, so that entire, two-way, level is missing. When running anova() on the model with Type I SS, the full factorial design does not return errors; however, using package:car Anova() and Type III SS, I receive an singularity error unless I used the argument 'singular.ok = T' (it is defaulted to F). So, why don't I receive an error with anova() when I do with Anova(type = III)? How do anova() and Anova() handle incomplete designs, and how can interactions of variables with missing levels be interpreted? I realize these are fairly broad questions, but any insight would be helpful. Thanks, all. Below is code to illustrate my question(s): lmMass - lm(log(l.mass) ~ day*leaf.species + cond.time, data = growth.data) #lm() without cond.time interactions lmMassInt - lm(log(l.mass) ~ day*leaf.species*cond.time, data = growth.data) #lm() with cond.time interactions anova(lmMass); anova(lmMassInt) #ANOVA summary of both models with Type I SS Analysis of Variance Table Response: log(l.mass) Df Sum Sq Mean Sq F valuePr(F) day1 51.373 51.373 75.7451 2.073e-15 leaf.species 2 0.340 0.170 0.25060.7786 cond.time 1 0.161 0.161 0.23690.6271 day:leaf.species 2 1.296 0.648 0.95510.3867 Residuals179 121.404 0.678 Analysis of Variance Table Response: log(l.mass) Df Sum Sq Mean Sq F value Pr(F) day 1 51.373 51.373 76.5651 1.693e-15 leaf.species 2 0.340 0.170 0.2533 0.77654 cond.time1 0.161 0.161 0.2394 0.62523 day:leaf.species 2 1.296 0.648 0.9655 0.38281 day:cond.time1 0.080 0.080 0.1198 0.72965 leaf.species:cond.time 1 1.318 1.318 1.9642 0.16282 day:leaf.species:cond.time 1 1.915 1.915 2.8539 0.09293 Residuals 176 118.091 0.671 Anova(lmMass, type = 'III'); Anova(lmMassInt, type = 'III') #ANOVA summary of both models with Type III SS Anova Table (Type III tests) Response: log(l.mass)
[R] Obtaining r-squared values from phylogenetic autoregression in ape
Hello, I am trying to carry out a phylogenetic autoregression to test whether my data show a phylogenetic signal, but I keep calculating bizzare R-squared values. My script is: library(ape) x - R:1,GK:1)d:1,(MW:1,G:1)n:1)a:1,SPW:1)a:1,WB:1)b:1,(((SPBF:1,PBF:1)n:1,(HBF:1,SWF:1)c:1)i:1,(PE:1,((P:1,C:1)w:1,(MF:1,HF:1)l:1)b:1)c:1)x:1)a:1,((CHB:1,AD:1)a:1,BA:1,SSB:1)i:1,(HB:1,SB:1)b:1)x:1,SC:1)x:1,((BRH:1,PH:1)e:1,(WLH:1,GH:1)b:1)d:1)x:1,DBF:1)a:1)a:1,((WW:1,(OT:1,SW:1)v:1)b:1,B:1)z:1)a:1,((DS:1,GS:1)j:1,(SSS:1,LS:1,(ES:1,SS:1)a:1)b:1)e:1)a; treeX - read.tree(text=x) treeX - compute.brlen(treeX, method = Grafen) data - c(4.854185, 6.008532, 6.221286, 4.369945, 10.044475, 5.801292, 5.128374, 5.540995, 4.566704, 10.188250, 7.121077, 4.469329, 4.815972, 7.798617, 5.892205, 4.853027, 5.080509, 7.982360, 7.518022, 5.675702, 11.989929, 6.760587, 7.433313, 7.906303, 7.235088, 7.131338, 5.582816, 6.769775, 11.886225, 5.589256, 5.626147, 4.714369, 6.040151, 9.098583, 5.194043, 8.830687, 6.231105) species - c( AD, B,BA, BRH , C,CHB, DBF, DS, ES, G,GH, GK, GS, HB, HBF, HF, LS, MF, MW, OT, P,PBF, PE, PH, R, SB,SC, SPBF, SPW, SS, SSB, SSS, SW, SWF, WB, WLH, WW) names(data) - species cor.mat - vcv.phylo(treeX, cor=TRUE) regr - compar.cheverud(data, cor.mat) regr$rhohat [1] 5.541462 1 - var(regr$residuals)/var(data) [,1] [1,] -1.333095 I don't understand why the autoregression coefficient falls outside the interval -1 to 1, or why the calculation for obtaining an R-squared produces a value that doesn't make sense. Have I made a mistake in the application of this method, or have I misunderstood when it is appropriate to use phylogenetic autoregression? Thanks for your help. Louise [[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] Loop Help
On Jun 18, 2012, at 5:47 AM, @ngel wrote: I think that for now I'll keep it There is no it in this message. Users of Nabble often fail to read the POsitng Guide where it is requested that you include context. as is and try to clean the data in excel. Could someone please tell me how can I export the result to csv, since write.csv exports only the last j? You are probably not changing the name of the output file as you, in some entirely unspecified manner, loop over arguments to write.csv. Thank you so much in advance! -- View this message in context: http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633677.html Sent from the R help mailing list archive at Nabble.com. The archive of Rhelp is not at Nabble. And Rhelp is a mailing list, not a website. -- David Winsemius, MD 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] noob requesting help
Hello, Ok, sorry about the misleading tip. This should do it. do.call(rbind, dep) Rui Barradas Em 18-06-2012 13:32, capital_P escreveu: Rui Barradas wrote Try names(departures) - NULL dep - data.frame(departures[ !sapply(departures, is.null) ]) You now have data.frame 'dep'. dep - data.frame(departures[ !sapply(departures, is.null) ]) Error in data.frame(`121.1` = list(device_info_serial = integer(0), hour = integer(0), : arguments imply differing number of rows: 0, 1, 2 dep - departures names(dep) - NULL dep - data.frame(dep) Error in data.frame(list(device_info_serial = integer(0), hour = integer(0), : arguments imply differing number of rows: 0, 1, 2 -- View this message in context: http://r.789695.n4.nabble.com/noob-requesting-help-tp4632803p4633691.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] Using Sub
Hi A.K., That works but when I copy and paste from Window explorer it will have a single backslashes and not double. It works with double as what you have in your example below but not with single as what I would end up passing. Do you have any other suggestions or methods to accomplish this? Thanks. Dan -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Monday, June 18, 2012 8:59 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub Hi, I guess you need something like this: str1-G:\\Compensation Audits_Reports\\Step Audit\\Steps off Step.accdb gsub('','/',str1) [1] G:/Compensation Audits_Reports/Step Audit/Steps off Step.accdb A.K. - Original Message - From: Lopez, Dan lopez...@llnl.gov To: Duncan Murdoch murdoch.dun...@gmail.com Cc: R help r-help@r-project.org Sent: Monday, June 18, 2012 10:37 AM Subject: Re: [R] Using Sub Hi Duncan, That's right but I want to be able to use this to replace back slashes with front slashes when I copy and paste file paths. How can I make this work so I don't get this error? Thanks. Dan -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Friday, June 15, 2012 12:04 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub On 12-06-14 6:23 PM, Lopez, Dan wrote: Hi, I have been trying to get the sub function to work but can't for the life of me figure it out. I tried looking at ?sub but I think there is something that I am just not understanding. Example failed attempts sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: '\C' is an unrecognized escape in character string starting G:\C This isn't anything to do with sub(), it's the third string that's the problem. When you say G:\Comp... it thinks you've escaped the C, but there's no such escape. Duncan Murdoch sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=TRUE) Error: '\C' is an unrecognized escape in character string starting G:\C sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=FALSE) Error: '\C' is an unrecognized escape in character string starting G:\C) sub(/,\,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: unexpected symbol in sub(/,\,G Thanks. Dan __ 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, self-contained, reproducible code.
Re: [R] Efficient distance calculation on big matrix
It so happens I have been looking at very similar changes, as well as adding multi-threading support for dist(); these should make it into R-devel later this summer. Best, luke On Sun, 17 Jun 2012, Stefan Evert wrote: I'm working on analyzing a large data set, lets asume that dim(Data)=c(1000,8700). I want to calculate the canberra distance between the columns of this matrix, and using a toy example ('test' is a matrix filled with random numbers 0-1): system.time(d-as.matrix(dist(t(test), method = canberra, diag = FALSE, upper = FALSE, p = 2))) user system elapsed 1417.7133.219 1421.144 The system.time results also confuse me a bit, since 99% of the time is not system time but user time. What does that mean? User time is the time that R spends working on your problem; system time refers to tasks done by the operating system, e.g. disk access, managing locks and, most importantly, swapping when you run out of RAM. With multi-threading, system time can be much larger than the time that has actually elapsed. Is there any way to calculate the distance which would take less time? Well, one thing you can do is to get a faster computer. :-) The command above takes only 670 seconds on my MacBook Pro (without multi-threading). Calculating a distance matrix is an expensive computation. In your example, R has to carry out (8700 * 8700 * 1000) / 2 = 37.8 billion floating point divisions. With approx. 27 clock cycles per division (according to tables I've found on the Web), this takes at least 340 seconds even on a 3GHz CPU (and ignoring memory access, addition/subtraction, loops, etc.). You can shave off some of the time if you implement the distance calculation in C, inline the code to avoid callback functions in loops, operate on columns of the matrix directly (which should be more cache-friendly than rows) and don't check for NA's, NaN's and other degenerate cases. I've done just that in my experimental R package wordspace, which isn't on CRAN yet: library(wordspace) A - matrix(runif(8.7e6), 1000, 8700) system.time(d1 - as.matrix(dist(t(A), method=canberra))) user system elapsed 669.207 2.724 669.305 system.time(d2 - dist.matrix(A, method=canberra, byrow=FALSE)) user system elapsed 250.534 0.784 250.301 all(d1 == d2) [1] TRUE If you aren't tied to Canberra distance, you can use a less expensive metric such as the Manhattan distance for an additional, more substantial speed boost: system.time(d3 - dist.matrix(A, method=manhattan, byrow=FALSE)) user system elapsed 42.488 0.999 43.569 This is still single-threaded, so you can run multiple of these calculations in parallel depending on how many cores your server has. Hope this helps, Stefan PS: In case you'd like to give it a try yourself and aren't daunted by a complete lack of documentation: svn checkout svn://scm.r-forge.r-project.org/svnroot/wordspace/pkg [ ev...@linglit.tu-darmstadt.de | http://purl.org/stefan.evert ] __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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] SAP ABAP Consultant available
Please DO NOT put ads for your services on this site. This is a violation of the R forum terms. I will be forwarding this issue to the appropriate moderator to take further action. On Tue, Jun 12, 2012 at 1:37 PM, Kanna ka...@silverxis.com wrote: [1]Click here to unsubscribe if you no longer wish to receive our emails Hello, We have an excellent consultant, Pritesh Agrawal - SAP ABAP . Below is his/her quick profile for your review. Pritesh Agrawal - SAP ABAP - Rate: Open Total Exp: 9+ Available: immediate Relocation: OPEN Over 9.5 years of work experience in SAP R/3 technical, functional and project management for clients in UK, Europe, Asia, and North America. Specializes in, SAP ABAP, ABAP OOPS, Interfaces using ALE/EDI/IDOC and SAP Business Workflow. Worked extensively in functional areas FI/CO, SD, MM, PP, QM, SC, DC, CRM, APO IS-Utilities, IS-Retail. Implementation experience on all types of ABAP development which included designing and developing objects related to Interfaces, Conversions, Enhancements, SAP scripts, Smartforms, Reports, Data Dictionary, RFCs, ALE/EDI, Workflows, BADIs, Enhancement spots, BAPIs, Dialog Programming Program Optimization. Extensively used LSMW for Master Data uploads. Expertise in applying OSS Notes and performing runtime analysis and optimization of programs. Working experience in environments R/3 4.0, 4.6, 4.7, ECC 5.0, ECC 6.0, ERP 6.0 EHP5. Upgrade and Support Pack application activities using SPAU and SPDD Rate: Open Total Exp: 9 + Available: immediate Relocation: OPEN To obtain a complete resume of this consultant and many others we have available, please feel free to contact me. Thanks Regards, Kanna SilverXis We Deliver: Talent, Solution, Satisfaction 1162 W Pioneer Pkwy, Arlington, TX 76013. T: 817-861-*533 F: 847-758-2770 [2]ka...@silverxis.com [3]www.silverxis.com _ This email is generated using [4]CONREP software. [5][8011234857.jpg] G5540 References 1. http://adso.conrep.com/conrep/actions/mail/unsubscribe.php?param=QVBSSUQ9MTEwMTA5NTAyMzU0JkFQTUlEPTQyNCZDTVBDRD01NTQwJkZST009a2FubmFAc2lsdmVyeGlzLmNvbSZUTz1yLWhlbHBAci1wcm9qZWN0Lm9yZyZKT0JJRD0xMTAxMDAyMTkwOTcmU1VCSj1TQVAgQUJBUCBDb25zdWx0YW50IGF2YWlsYWJsZSZ1c3JpZD0xMTAxMDAzMDUyMTYmSkJDSUQ9NjEwMDAzNzk5OTU2 2. mailto:ka...@silverxis.com 3. http://www.silverxis.com/ 4. http://www.conrep.com/?emlsrc=110109823481-110100305216emailed=r-help@r-project.orgT=MM 5. http://www.conrep.com/?emlsrc=110109823481-110100305216emailed=r-help@r-project.orgT=MM __ 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] Cholesky decomposition error
see inline! On Mon, Jun 18, 2012 at 12:38 AM, nata...@orchidpharma.com wrote: Thanks Kjetil for your detailed code for log-Cholesky but my situation is like optimization of the variables inside the matrix. But you must of course call my function makemat inside the call to optim() or whatever function you use for optimization! Here is an extended example, assuming the functions I have defined earlier: library(MASS) # for mvrnorm library(mvtnorm) # for dmvnorm Let us simulate a multinorma sample with expectation zero (to simplify the example) and covariance matrix Sigma: Sigma [,1] [,2] [,3] [1,]311 [2,]131 [3,]113 testdat - mvrnorm(n=100, rep(0, 3), Sigma) We can calculate the usual maxlik estimator of Sigma: (t(testdat) %*% testdat) /100 [,1] [,2] [,3] [1,] 3.2424618 0.9670133 1.673897 [2,] 0.9670133 2.9447654 1.289127 [3,] 1.6738970 1.2891268 3.084106 objective - function(Sigma) { sum(apply(testdat, 1, FUN=function(x) dmvnorm(x, rep(0, 3), Sigma, log=TRUE))) } objective(Sigma) start $diag [1] 0.5493061 0.4904146 0.4581454 $upper [1] 0.5773503 0.5773503 0.4082483 startSigma - c(start$diag, start$upper) startSigma [1] 0.5493061 0.4904146 0.4581454 0.5773503 0.5773503 0.4082483 objective(Sigma) [1] -571.5945 objective(Sigma/3) [1] -699.0552 objective(3*Sigma) [1] -638.9688 Finally: optim(startSigma, fn=function(parvec) { R - makemat(parvec[1:3], parvec[4:6]) S - t(R) %*% R print(S) # remove this when works! obj - -objective(S) obj }, control=list(REPORT=1)) # with method=BFGS dopes not work well, because takes too long # steps! default Nelder-Mead is slow, but works. Giving the following output: much removed ... $par [1] 0.5811796 0.4969062 0.3485920 0.5469560 0.9248746 0.4896758 $value [1] 567.648 $counts function gradient 501 NA $convergence [1] 1 $message NULL res - .Last.value res$par [1] 0.5811796 0.4969062 0.3485920 0.5469560 0.9248746 0.4896758 makemat(res$par[1:3], res$par[4:6]) [,1] [,2] [,3] [1,] 1.788146 0.546956 0.9248746 [2,] 0.00 1.643628 0.4896758 [3,] 0.00 0.00 1.4170710 R -makemat(res$par[1:3], res$par[4:6]) t(R) %*% R [,1] [,2] [,3] [1,] 3.1974676 0.9780374 1.653811 [2,] 0.9780374 3.0006752 1.310711 [3,] 1.6538112 1.3107108 3.103266 Sigma [,1] [,2] [,3] [1,]311 [2,]131 [3,]113 ¿Easy? Let me change your own example matrix to explain the problem. A martrix is [,1] [,2] [,3] [1,] 3*Vs+Vn 1*Vs 1*Vs [2,] 1*Vs 3*Vs+Vn 1*Vs [3,] 1*Vs 1*Vs 3*Vs+Vn So make your own makemat function specific to this problem! which you then use inside the call to optim. kjetil So I have to optimize two variables Vs and Vn using the maximum likelihood function, which need the determinant and inverse of the matrix A to compute the value. Isn't it logically correct that I have to seed some initial values for the Vs and Vn and use it for predicting the value of the matrix and check for its positive definite condition, If you construct the matrix by above method, it will automatically be posdef, so no need to check! (except as check on programming ... ) if the condition fulfill, then I have to compute the determinant value and inverse of the matrix in order to use them in the maximum likelihood function and the optimization iteration to be carried out further until parameters converges. I sincerely believe that you have points to implements log-Cholesky in my situation, but I am simply not able to see where is the Choleksy decomposition to be implemented in this my workflow. Regards, B.Nataraj -Original Message- From: Kjetil Halvorsen [mailto:kjetilbrinchmannhalvor...@gmail.com] Sent: Sunday, June 17, 2012 4:10 AM To: Nataraj B (ORLL-Biotech) Cc: r-help@r-project.org Subject: Re: [R] Cholesky decomposition error see below. On Fri, Jun 15, 2012 at 11:53 PM, nata...@orchidpharma.com wrote: Dear Mr.Kjetil, Thanks for your comment. You have already pointed me the article in reply to one of my earlier post to this list and I am following the paper. Now I am checking for condition for positive definiteness for original matrix using a simple script (got from earlier posting in the list) and if the condition passed then the optimization function perform decomposition of the matrix using chol() function. I believe all 5 parameterization techniques listed in the paper weigh each other based on its performance and not on accuracy, please correct me if I am wrong. Since I am novice, I just want to start with the easiest method Cholesky for my purpose. Are you recommending log-Cholesky function , if so could you please tell me the name of the function which does log-Cholesky
Re: [R] Loop Help
@angel, You can try append option in write.table for e.g. for(i in 1:20) write.table(i,out.txt,append=T,sep=\t,row.names=F,col.names=F) This will help you save your all results by writing each results on subsequent rows. Hope this helps Ozgur Hello Jim thank you so much for your response. When I use write.csv, on the csv file is saved only the last loop So when I write results.matrix - apply(degree_w(net.static[[i]]), 2, mean) write.csv(results.matrix, file = results.csv) instead of getting a 550 line document with all loop results, I only get the last one! Could you please help me? Thank you so much in advance -- View this message in context: http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633722.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] Package of EM and MI for IRT in R
SEARCH! Go to rseek.org Type missing data imputation . You will bring up several alternatives. -- Bert On Mon, Jun 18, 2012 at 8:04 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Possibly Amelia: http://cran.r-project.org/web/packages/Amelia/index.html Best, Michael On Mon, Jun 18, 2012 at 3:19 AM, Kamontip Srihaset kamonti...@student.chula.ac.th wrote: Dear all members, I am Phd. candidate student at Chulalongkorn U., Thailand. I am interested in expectation maximization algorithm (EM) and multiple imputation (MI) for imputation missing values(missing at random(MAR) and missing not at random (MNAR)) in IRT (3-PL). So, I want to know about package in R or function of EM and MI for simulate this problem I am looking forward your answer. sincerely yours, Kamontip Srihaset [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] Using Sub
Please study how escapes work. The representation you see in the source code is not the same as what is actually stored in memory. As to your problems with the clipboard, I recommend writing scripts that do not interact with the clipboard directly. Violating this rule puts an error-prone human in the loop for repeating the script, and will eventually lead to irreproducible results. That said, using the clipboard to create the script itself is fine. I usually just edit Windows paths in scripts to have forward slashes or double backslashes, and I use relative paths liberally. You can also play with file.choose() or readLines(clipboard) to get source-compatible paths. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Lopez, Dan lopez...@llnl.gov wrote: Hi A.K., That works but when I copy and paste from Window explorer it will have a single backslashes and not double. It works with double as what you have in your example below but not with single as what I would end up passing. Do you have any other suggestions or methods to accomplish this? Thanks. Dan -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Monday, June 18, 2012 8:59 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub Hi, I guess you need something like this: str1-G:\\Compensation Audits_Reports\\Step Audit\\Steps off Step.accdb gsub('','/',str1) [1] G:/Compensation Audits_Reports/Step Audit/Steps off Step.accdb A.K. - Original Message - From: Lopez, Dan lopez...@llnl.gov To: Duncan Murdoch murdoch.dun...@gmail.com Cc: R help r-help@r-project.org Sent: Monday, June 18, 2012 10:37 AM Subject: Re: [R] Using Sub Hi Duncan, That's right but I want to be able to use this to replace back slashes with front slashes when I copy and paste file paths. How can I make this work so I don't get this error? Thanks. Dan -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Friday, June 15, 2012 12:04 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub On 12-06-14 6:23 PM, Lopez, Dan wrote: Hi, I have been trying to get the sub function to work but can't for the life of me figure it out. I tried looking at ?sub but I think there is something that I am just not understanding. Example failed attempts sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: '\C' is an unrecognized escape in character string starting G:\C This isn't anything to do with sub(), it's the third string that's the problem. When you say G:\Comp... it thinks you've escaped the C, but there's no such escape. Duncan Murdoch sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=TRUE) Error: '\C' is an unrecognized escape in character string starting G:\C sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=FALSE) Error: '\C' is an unrecognized escape in character string starting G:\C) sub(/,\,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: unexpected symbol in sub(/,\,G Thanks. Dan __ 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, 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] Using Sub
The parser (the part of R that interprets text as R code) interprets things like \t as the tab character and there is no way to avoid that. However, when the functions readLines(), scan(), and readline() handle input they do not assign any special meanings to backslashes. Hence, if you want to be able to copy and paste entries from other Windows applications to R you can do it by using scan(), etc. E.g., readline(prompt=File path? ) File path? C:\Documents and Settings\Bill Dunlap\My Documents\the data.csv [1] C:\\Documents and Settings\\Bill Dunlap\\My Documents\\the data.csv gsub(, /, .Last.value) [1] C:/Documents and Settings/Bill Dunlap/My Documents/the data.csv It is not terribly convenient, but it is possible. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Newmiller Sent: Monday, June 18, 2012 10:29 AM To: Daniel Lopez; arun Cc: R help Subject: Re: [R] Using Sub Please study how escapes work. The representation you see in the source code is not the same as what is actually stored in memory. As to your problems with the clipboard, I recommend writing scripts that do not interact with the clipboard directly. Violating this rule puts an error-prone human in the loop for repeating the script, and will eventually lead to irreproducible results. That said, using the clipboard to create the script itself is fine. I usually just edit Windows paths in scripts to have forward slashes or double backslashes, and I use relative paths liberally. You can also play with file.choose() or readLines(clipboard) to get source- compatible paths. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Lopez, Dan lopez...@llnl.gov wrote: Hi A.K., That works but when I copy and paste from Window explorer it will have a single backslashes and not double. It works with double as what you have in your example below but not with single as what I would end up passing. Do you have any other suggestions or methods to accomplish this? Thanks. Dan -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Monday, June 18, 2012 8:59 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub Hi, I guess you need something like this: str1-G:\\Compensation Audits_Reports\\Step Audit\\Steps off Step.accdb gsub('','/',str1) [1] G:/Compensation Audits_Reports/Step Audit/Steps off Step.accdb A.K. - Original Message - From: Lopez, Dan lopez...@llnl.gov To: Duncan Murdoch murdoch.dun...@gmail.com Cc: R help r-help@r-project.org Sent: Monday, June 18, 2012 10:37 AM Subject: Re: [R] Using Sub Hi Duncan, That's right but I want to be able to use this to replace back slashes with front slashes when I copy and paste file paths. How can I make this work so I don't get this error? Thanks. Dan -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Friday, June 15, 2012 12:04 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub On 12-06-14 6:23 PM, Lopez, Dan wrote: Hi, I have been trying to get the sub function to work but can't for the life of me figure it out. I tried looking at ?sub but I think there is something that I am just not understanding. Example failed attempts sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: '\C' is an unrecognized escape in character string starting G:\C This isn't anything to do with sub(), it's the third string that's the problem. When you say G:\Comp... it thinks you've escaped the C, but there's no such escape. Duncan Murdoch sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=TRUE) Error: '\C' is an unrecognized escape in character string starting G:\C sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=FALSE) Error: '\C' is an unrecognized escape in character string starting G:\C) sub(/,\,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: unexpected symbol in sub(/,\,G Thanks. Dan __ 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,
Re: [R] Process XML files
Please ignore my previous request for clarification. I was able to resolve my problem using getNodeSet. Thanks, Santosh On Thu, Jun 14, 2012 at 10:54 AM, Santosh santosh2...@gmail.com wrote: Dear Rxperts, I am back to favoRite! I would need your favoR, please! Is there a way to use read format arguments for POSIXct or strptime from the xml file without specifying format=... in these functions? The format of data-time values are present in the xml file as shown below. Please see below am example section of XML code: ?xml version=1.0??mso-application progid=Excel.Sheet?Workbook xmlns=urn:schemas-microsoft-com:office:spreadsheet xmlns:o=urn:schemas-microsoft-com:office:office xmlns:x=urn:schemas-microsoft-com:office:excel xmlns:ss=urn:schemas-microsoft-com:office:spreadsheet xmlns:html= http://www.w3.org/TR/REC-html40;StylesStyle ss:ID=s11NumberFormat ss:Format=/mm/dd\ hh:mm;@//StyleStyle ss:ID=s21Font ss:Color=White ss:Bold=1/Interior ss:Color=Black ss:Pattern=Solid//StyleStyle ss:ID=s31BordersBorder ss:Position=Bottom ss:LineStyle=Double ss:Weight=3//Borders/StyleStyle ss:ID=s41Font ss:Size=20//StyleStyle ss:ID=s12NumberFormat ss:Format=hh:mm:ss.000//Style/StylesWorksheet ss:Name=StartTable ss:DefaultColumnWidth=80RowCellData ss:Type=StringID/Data/CellCellData ss:Type=String1/Data/Cell/RowRowCellData ss:Type=StringStart/Data/CellCell ss:StyleID=s11*Data ss:Type=DateTime2012-06-14T09:16:16.512/Data*/Cell/Row/Table /Worksheet/Workbook On Fri, Jun 8, 2012 at 8:08 AM, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 06.06.2012 22:44, Santosh wrote: Hello experts, Sorry for posting the SPlus related question here.. I have not found any solution yet after some attempts and hence, sending it to a wider spectrum of users! I was successful in processing files uing R's XML librariy. Not that we know, we just know about an R *package* called XML. Thank you, Rxperts! I know there are libraries like XML and SPXML available in S-Plus. Could anyone please share examples of reading an xml file and save the contents in a data frame? Are there Splus equivalents of getNodeSet, xmlSApply and xmlValue? Most of us do not have S-PLUS available to check (actually, we do have a 13 year old copy S-PLUS 4.5 at our department). You do, obviously, hence why not check it yourself? And if you can't, why not ask the vendor of your statistics software? Best, Uwe Ligges Thanks so much! Santosh [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] Using Sub
Jeff - Thanks. I think I'll just stick to using file.choose(). Dan -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Monday, June 18, 2012 10:29 AM To: Lopez, Dan; arun Cc: R help Subject: Re: [R] Using Sub Please study how escapes work. The representation you see in the source code is not the same as what is actually stored in memory. As to your problems with the clipboard, I recommend writing scripts that do not interact with the clipboard directly. Violating this rule puts an error-prone human in the loop for repeating the script, and will eventually lead to irreproducible results. That said, using the clipboard to create the script itself is fine. I usually just edit Windows paths in scripts to have forward slashes or double backslashes, and I use relative paths liberally. You can also play with file.choose() or readLines(clipboard) to get source-compatible paths. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Lopez, Dan lopez...@llnl.gov wrote: Hi A.K., That works but when I copy and paste from Window explorer it will have a single backslashes and not double. It works with double as what you have in your example below but not with single as what I would end up passing. Do you have any other suggestions or methods to accomplish this? Thanks. Dan -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Monday, June 18, 2012 8:59 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub Hi, I guess you need something like this: str1-G:\\Compensation Audits_Reports\\Step Audit\\Steps off Step.accdb gsub('','/',str1) [1] G:/Compensation Audits_Reports/Step Audit/Steps off Step.accdb A.K. - Original Message - From: Lopez, Dan lopez...@llnl.gov To: Duncan Murdoch murdoch.dun...@gmail.com Cc: R help r-help@r-project.org Sent: Monday, June 18, 2012 10:37 AM Subject: Re: [R] Using Sub Hi Duncan, That's right but I want to be able to use this to replace back slashes with front slashes when I copy and paste file paths. How can I make this work so I don't get this error? Thanks. Dan -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Friday, June 15, 2012 12:04 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub On 12-06-14 6:23 PM, Lopez, Dan wrote: Hi, I have been trying to get the sub function to work but can't for the life of me figure it out. I tried looking at ?sub but I think there is something that I am just not understanding. Example failed attempts sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: '\C' is an unrecognized escape in character string starting G:\C This isn't anything to do with sub(), it's the third string that's the problem. When you say G:\Comp... it thinks you've escaped the C, but there's no such escape. Duncan Murdoch sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=TRUE) Error: '\C' is an unrecognized escape in character string starting G:\C sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=FALSE) Error: '\C' is an unrecognized escape in character string starting G:\C) sub(/,\,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: unexpected symbol in sub(/,\,G Thanks. Dan __ 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, 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] multiplicative error model
What do you mean by using the package? Aren't the examples in the package manual at http://cran.r-project.org/web/packages/dynamo/dynamo.pdf enough for you? Ozgur -- View this message in context: http://r.789695.n4.nabble.com/multiplicative-error-model-tp4633730p4633732.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do anova() and Anova(type=III) handle incomplete designs?
Dear Justin, On Mon, 18 Jun 2012 11:24:33 -0400 Justin Montemarano jmont...@kent.edu wrote: Thanks for your response, John. That was helpful. I was using Type III from Anova() as a comparison to some results I had obtained JMP, which I've lost access to and have moved on to R, and I was confused by the error. Given that I do have a continuous covariate, the analyses are not likely comparable, considering your response. If you look more carefully, you'll see that the reference here was to type-II tests. I believe that the definition used by Anova() is more sensible. I am still confused about interpretation of interactions within an anova() with an incomplete design, as mine is. Is the interaction term still informative? I don't think that these matters are easily discussed on an email list. Briefly, I'd argue that the type-II tests (as defined by Anova) still have a straightforward interpretation since the test for a (say, two-way) interaction represent a contrast to a model that's additive with respect to the predictors involved in the interaction. Best, John - Justin Montemarano Graduate Student Kent State University - Biological Sciences http://www.montegraphia.com On Sat, Jun 16, 2012 at 9:20 PM, John Fox j...@mcmaster.ca wrote: Dear Justin, anova() and Anova() are entirely different functions; the former is part of the standard R distribution and the second part of the car package. By default, Anova() produces an error for type-III tests conducted on rank-deficient models because the hypotheses tested aren't generally sensible. From ?Anova: singular.ok defaults to TRUE for type-II tests, and FALSE for type-III tests (where the tests for models with aliased coefficients will not be straightforwardly interpretable); if FALSE, a model with aliased coefficients produces an error. and The designations type-II and type-III are borrowed from SAS, but the definitions used here do not correspond precisely to those employed by SAS. Type-II tests are calculated according to the principle of marginality, testing each term after all others, except ignoring the term's higher-order relatives; so-called type-III tests violate marginality, testing each term in the model after all of the others. This definition of Type-II tests corresponds to the tests produced by SAS for analysis-of-variance models, where all of the predictors are factors, but not more generally (i.e., when there are quantitative predictors). Be very careful in formulating the model for type-III tests, or the hypotheses tested will not make sense. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Fri, 15 Jun 2012 15:01:27 -0400 Justin Montemarano jmont...@kent.edu wrote: Hello all: I am confused about the output from a lm() model with an incomplete design/missing level. I have two categorical predictors and a continuous covariate (day) that I am using to model larval mass (l.mass): leaf.species has three levels - map, syc, and oak cond.time has two levels - 30 and 150. There are no response values for Map-150, so that entire, two-way, level is missing. When running anova() on the model with Type I SS, the full factorial design does not return errors; however, using package:car Anova() and Type III SS, I receive an singularity error unless I used the argument 'singular.ok = T' (it is defaulted to F). So, why don't I receive an error with anova() when I do with Anova(type = III)? How do anova() and Anova() handle incomplete designs, and how can interactions of variables with missing levels be interpreted? I realize these are fairly broad questions, but any insight would be helpful. Thanks, all. Below is code to illustrate my question(s): lmMass - lm(log(l.mass) ~ day*leaf.species + cond.time, data = growth.data) #lm() without cond.time interactions lmMassInt - lm(log(l.mass) ~ day*leaf.species*cond.time, data = growth.data) #lm() with cond.time interactions anova(lmMass); anova(lmMassInt) #ANOVA summary of both models with Type I SS Analysis of Variance Table Response: log(l.mass) Df Sum Sq Mean Sq F valuePr(F) day1 51.373 51.373 75.7451 2.073e-15 leaf.species 2 0.340 0.170 0.25060.7786 cond.time 1 0.161 0.161 0.23690.6271 day:leaf.species 2 1.296 0.648 0.95510.3867 Residuals179 121.404 0.678 Analysis of Variance Table Response: log(l.mass) Df Sum Sq Mean Sq F value Pr(F) day
Re: [R] Error w/ Start up Script
On Jun 18, 2012, at 11:25 AM, Lopez, Dan wrote: I noticed about a couple weeks ago that my R start up script starting showing the below errors, following the line Type 'q()' to quit R I didn't see any errors reported. I didn't see any warnings, either. -- David. Not sure what I did different and so far it hasn't caused major problems but kind of fear that it will. Can you please help? I also posted my Rprofile below. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ? R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default The following object(s) are masked from 'package:methods': getClass, getClasses, getMethods The following object(s) are masked from 'package:base': attach, detach, gc, load, save R.utils v1.12.1 (2012-03-20) successfully loaded. See ?R.utils for help. Attaching package: 'R.utils' The following object(s) are masked from 'package:utils': timestamp The following object(s) are masked from 'package:base': cat, commandArgs, getOption, inherits, isOpen, lapply, parse, warnings And here is my Rprofile.site file specs: # Things you might want to change # options(papersize=a4) # options(editor=notepad) # options(pager=internal) # set the default help type # options(help_type=text) options(help_type=html) # set a site library # .Library.site - file.path(chartr(\\, /, R.home()), site- library) # set a CRAN mirror local({r - getOption(repos) r[CRAN] - http://cran.cnr.Berkeley.edu; options(repos=r)}) # Give a fortune cookie, but only to interactive sessions # (This would need the fortunes package to be installed.) # if (interactive()) #fortunes::fortune() Daniel Lopez Workforce Analytics Metrics Team [[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. David Winsemius, MD 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] Error w/ Start up Script
David, Sorry I should have been more specific. They are not as much errors as they are extra script that is running at startup after Type q() to quit R. It wasn't there before. And am thinking eventually it could become a problem. Thanks. Dan Here it is again...what it looks like when I first startup R (partial copy and paste): ... .. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ?R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default .. ... -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Monday, June 18, 2012 12:12 PM To: Lopez, Dan Cc: R help (r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script On Jun 18, 2012, at 11:25 AM, Lopez, Dan wrote: I noticed about a couple weeks ago that my R start up script starting showing the below errors, following the line Type 'q()' to quit R I didn't see any errors reported. I didn't see any warnings, either. -- David. Not sure what I did different and so far it hasn't caused major problems but kind of fear that it will. Can you please help? I also posted my Rprofile below. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ? R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default The following object(s) are masked from 'package:methods': getClass, getClasses, getMethods The following object(s) are masked from 'package:base': attach, detach, gc, load, save R.utils v1.12.1 (2012-03-20) successfully loaded. See ?R.utils for help. Attaching package: 'R.utils' The following object(s) are masked from 'package:utils': timestamp The following object(s) are masked from 'package:base': cat, commandArgs, getOption, inherits, isOpen, lapply, parse, warnings And here is my Rprofile.site file specs: # Things you might want to change # options(papersize=a4) # options(editor=notepad) # options(pager=internal) # set the default help type # options(help_type=text) options(help_type=html) # set a site library # .Library.site - file.path(chartr(\\, /, R.home()), site- library) # set a CRAN mirror local({r - getOption(repos) r[CRAN] - http://cran.cnr.Berkeley.edu; options(repos=r)}) # Give a fortune cookie, but only to interactive sessions # (This would need the fortunes package to be installed.) # if (interactive()) #fortunes::fortune() Daniel Lopez Workforce Analytics Metrics Team [[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. David Winsemius, MD 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] Interactive Graphics
As I recall, there is a package that can be used to create interactive svg files. I don't remember its name, but I seem to recall it was fairly easy to find on the CRAN packages page. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/17/12 7:01 PM, Eder David Borges eder...@gmail.com wrote: Hi, I'd like to make an interactive graph like this: http://blog.ggplot2.org/post/25201174009/name-popularity I believe he was done with the ggplot2 and saved in svg format. if someone has experience with this subject (graph interactive web) could give me a help? Thanks -- Éder David Borges da Silva eder...@gmail.com eder...@hotmail.com Skype: ederdbs 041 96717488 Tudo é Relativo...(Albert Einstein) [[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] Error w/ Start up Script
?suppressPackageStartupMessages Put this into your appropriate startup file. ?Startup ## for details on starting R and what files are executed at startup. -- Bert On Mon, Jun 18, 2012 at 12:46 PM, Lopez, Dan lopez...@llnl.gov wrote: David, Sorry I should have been more specific. They are not as much errors as they are extra script that is running at startup after Type q() to quit R. It wasn't there before. And am thinking eventually it could become a problem. Thanks. Dan Here it is again...what it looks like when I first startup R (partial copy and paste): ... .. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ?R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default .. ... -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Monday, June 18, 2012 12:12 PM To: Lopez, Dan Cc: R help (r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script On Jun 18, 2012, at 11:25 AM, Lopez, Dan wrote: I noticed about a couple weeks ago that my R start up script starting showing the below errors, following the line Type 'q()' to quit R I didn't see any errors reported. I didn't see any warnings, either. -- David. Not sure what I did different and so far it hasn't caused major problems but kind of fear that it will. Can you please help? I also posted my Rprofile below. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ? R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default The following object(s) are masked from 'package:methods': getClass, getClasses, getMethods The following object(s) are masked from 'package:base': attach, detach, gc, load, save R.utils v1.12.1 (2012-03-20) successfully loaded. See ?R.utils for help. Attaching package: 'R.utils' The following object(s) are masked from 'package:utils': timestamp The following object(s) are masked from 'package:base': cat, commandArgs, getOption, inherits, isOpen, lapply, parse, warnings And here is my Rprofile.site file specs: # Things you might want to change # options(papersize=a4) # options(editor=notepad) # options(pager=internal) # set the default help type # options(help_type=text) options(help_type=html) # set a site library # .Library.site - file.path(chartr(\\, /, R.home()), site- library) # set a CRAN mirror local({r - getOption(repos) r[CRAN] - http://cran.cnr.Berkeley.edu; options(repos=r)}) # Give a fortune cookie, but only to interactive sessions # (This would need the fortunes package to be installed.) # if (interactive()) #fortunes::fortune() Daniel Lopez Workforce Analytics Metrics Team [[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. David Winsemius, MD 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] Error w/ Start up Script
Hi Bert, I tried entering: ?suppressPackageStartupMessages and then suppressPackageStartupMessages into my Rprofile.site file and the messages still came up. I did however go to the Misc menu and select List search path and got the below results. Not exactly sure what it means but I do notice that several of the packages that popup at startup as being masked appear in this list. Maybe this is the problem? If so how do you take out what you don't need at startup? search() [1] .GlobalEnv package:stats package:graphics package:grDevices package:datasets [6] package:rattle package:R.utils package:utils package:R.oopackage:R.methodsS3 [11] package:methods Autoloads package:base 0 Thanks. Dan From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Monday, June 18, 2012 1:10 PM To: Lopez, Dan Cc: David Winsemius; R help (r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script ?suppressPackageStartupMessages Put this into your appropriate startup file. ?Startup ## for details on starting R and what files are executed at startup. -- Bert On Mon, Jun 18, 2012 at 12:46 PM, Lopez, Dan lopez...@llnl.govmailto:lopez...@llnl.gov wrote: David, Sorry I should have been more specific. They are not as much errors as they are extra script that is running at startup after Type q() to quit R. It wasn't there before. And am thinking eventually it could become a problem. Thanks. Dan Here it is again...what it looks like when I first startup R (partial copy and paste): ... .. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ?R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default .. ... -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.netmailto:dwinsem...@comcast.net] Sent: Monday, June 18, 2012 12:12 PM To: Lopez, Dan Cc: R help (r-help@r-project.orgmailto:r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script On Jun 18, 2012, at 11:25 AM, Lopez, Dan wrote: I noticed about a couple weeks ago that my R start up script starting showing the below errors, following the line Type 'q()' to quit R I didn't see any errors reported. I didn't see any warnings, either. -- David. Not sure what I did different and so far it hasn't caused major problems but kind of fear that it will. Can you please help? I also posted my Rprofile below. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ? R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default The following object(s) are masked from 'package:methods': getClass, getClasses, getMethods The following object(s) are masked from 'package:base': attach, detach, gc, load, save R.utils v1.12.1 (2012-03-20) successfully loaded. See ?R.utils for help. Attaching package: 'R.utils' The following object(s) are masked from 'package:utils': timestamp The following object(s) are masked from 'package:base': cat, commandArgs, getOption, inherits, isOpen, lapply, parse, warnings And here is my Rprofile.site file specs: # Things you might want to change # options(papersize=a4) # options(editor=notepad) # options(pager=internal) # set the default help type # options(help_type=text) options(help_type=html) # set a site library # .Library.site - file.path(chartr(\\, /, R.home()), site- library) # set a CRAN mirror local({r - getOption(repos) r[CRAN] - http://cran.cnr.Berkeley.edu; options(repos=r)}) # Give a fortune cookie, but only to interactive sessions # (This would need the fortunes package to be installed.) # if (interactive()) #fortunes::fortune() Daniel Lopez Workforce Analytics Metrics Team [[alternative HTML version deleted]] __ R-help@r-project.orgmailto: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 West Hartford, CT __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
[R] How to average time series data within certain time periods
Hi, I am new to R and wondering how I can subset and average time series data based on given irregular time periods: Say I have a time series of a measured variable x (hourly data) in values.csv with columns date and x which I would like to average within certain irregular time periods (events), given in events.csv with columns EventID, start, and stop (where start and stop indicate the start and stop dates of the corresponding event). What I usually do is to load the two csvs into a database and then perform an SQL statement like this: SELECT a.EventID, avg(b.x) from events as a, values as b WHERE b.date between a.start and a.stop GROUP BY a.EventID This gives a table with the EventIDs and the corresponding mean values of x as an output. As my data are not that large I would like to avoid the database and do the averaging in R but I cannot find the way of doing this in R. I would appreciate any advice to set me on track. Thanks, Dominik __ 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] Loop Help
Thank you Jeff, that sounds like the solution to my problem but how would I do that code-wise? could you please help? -- View this message in context: http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633701.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] multiplicative error model
HI, i'm trying to estimate a multiplicative error model in R, i've seen the dynamo package but it seems that i'm not able to use it. does someone know how can i do it? thanks -- View this message in context: http://r.789695.n4.nabble.com/multiplicative-error-model-tp4633730.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] Changing strip text
I'm trying to create a 5-panel xyplot with each strip labelled by treatment. The code is as follows: xyplot(log(pfuml)~Transfer|Treat,groups=Pop,ylab=Log10 Pfu/ml,as.table=T, type=a, auto.key= list(space=right,points=F,lines=T)) I've tried: strip=strip.custom(factor.levels=c(0,2,4,8,16) But it's not working, I still only get Treat printed on each strip. Any ideas? Thank you, Julie [[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] noob requesting help
Rui Barradas wrote sorry about the misleading tip. This should do it. do.call(rbind, dep) No problem at all. That did the trick. Thank you both so much for your help. I am forever in your debt. -- View this message in context: http://r.789695.n4.nabble.com/noob-requesting-help-tp4632803p4633742.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] Inconsistency using seq
Hi all, Is there any problem of precision when using seq?. For example: x- seq(0,4,0.1) x[4]=0.3 BUT: x[4]-0.3=5.551115e-17 It means when I use this condition within an if clause, it does not find values with 0.3 for x[4] as it is not precisely 0.3. Is there any bug in seq() ? -- View this message in context: http://r.789695.n4.nabble.com/Inconsistency-using-seq-tp4633739.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] Trying to speed up an if/else statement in simulations
Dear R-help, I am trying to write a function to simulate datasets of size n which contain two time-to-event outcome variables with associated 'Event'/'Censored' indicator variables (flag1 and flag2 respectively). One of these indicator variables needs to be dependent on the other, so I am creating the first and trying to use this to create the second using an if/else statement. My data structure needs to follow this algorithm (for each row of the data): If flag1=1 then flag2 should be 1 with probability 0.95 and zero otherwise Else if flag1=0 then flag2 should be 1 with probability 0.5 and zero otherwise I can set up this example quite simply using if else statements, but this is incredibly inefficient when running thousands of datasets: data-as.data.frame(rbinom(10,1,0.5)) colnames(data)-'flag1' for (i in 1:n) { if (data$flag1[i]==1) {data$flag2[i]-rbinom(1,1,0.95)} else {data$flag2[i]-rbinom(1,1,0.5)} } I think to speed up the simulations I would be better changing to vectorisation and using something like: ifelse(data$flag1==1,rbinom(1,1,0.95),rbinom(1,1,0.5)) but the rbinom statements here generate one value and repeat this draw for every element of flag2 that matches the 'if' statement on flag1. Is there a way to assign flag2 to a new bernoulli draw for each subject in the data frame with flag1=1? I hope my question is clear, and thank you in advance for your help. Thanks, Natalie PhD student, Reading University P.S. I am using R 2.12.1 on Windows 7. -- View this message in context: http://r.789695.n4.nabble.com/Trying-to-speed-up-an-if-else-statement-in-simulations-tp4633725.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] Error w/ Start up Script
I gave you the references you need. It's up to you to read and understand how to use them. You apparently need to work harder to do so. BTW ?anything is an alternative way to type help(anything) at the command line for R's help pages. -- Bert On Mon, Jun 18, 2012 at 1:34 PM, Lopez, Dan lopez...@llnl.gov wrote: Hi Bert, ** ** I tried entering: ?suppressPackageStartupMessages and then suppressPackageStartupMessages into my Rprofile.site file and the messages still came up. ** ** I did however go to the Misc menu and select List search path and got the below results. Not exactly sure what it means but I do notice that several of the packages that popup at startup as being masked appear in this list. Maybe this is the problem? If so how do you take out what you dont need at startup? ** ** search() [1] .GlobalEnv package:stats package:graphics package:grDevices package:datasets [6] package:rattle package:R.utils package:utils package:R.oopackage:R.methodsS3 [11] package:methods Autoloads package:base 0 ** ** Thanks. Dan ** ** *From:* Bert Gunter [mailto:gunter.ber...@gene.com] *Sent:* Monday, June 18, 2012 1:10 PM *To:* Lopez, Dan *Cc:* David Winsemius; R help (r-help@r-project.org) *Subject:* Re: [R] Error w/ Start up Script ** ** ?suppressPackageStartupMessages Put this into your appropriate startup file. ?Startup ## for details on starting R and what files are executed at startup. -- Bert On Mon, Jun 18, 2012 at 12:46 PM, Lopez, Dan lopez...@llnl.gov wrote:*** * David, Sorry I should have been more specific. They are not as much errors as they are extra script that is running at startup after Type q() to quit R. It wasn't there before. And am thinking eventually it could become a problem. Thanks. Dan Here it is again...what it looks like when I first startup R (partial copy and paste): ... .. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ?R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default .. ... -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Monday, June 18, 2012 12:12 PM To: Lopez, Dan Cc: R help (r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script On Jun 18, 2012, at 11:25 AM, Lopez, Dan wrote: I noticed about a couple weeks ago that my R start up script starting showing the below errors, following the line Type 'q()' to quit R I didn't see any errors reported. I didn't see any warnings, either. -- David. Not sure what I did different and so far it hasn't caused major problems but kind of fear that it will. Can you please help? I also posted my Rprofile below. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ? R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default The following object(s) are masked from 'package:methods': getClass, getClasses, getMethods The following object(s) are masked from 'package:base': attach, detach, gc, load, save R.utils v1.12.1 (2012-03-20) successfully loaded. See ?R.utils for help. Attaching package: 'R.utils' The following object(s) are masked from 'package:utils': timestamp The following object(s) are masked from 'package:base': cat, commandArgs, getOption, inherits, isOpen, lapply, parse, warnings And here is my Rprofile.site file specs: # Things you might want to change # options(papersize=a4) # options(editor=notepad) # options(pager=internal) # set the default help type # options(help_type=text) options(help_type=html) # set a site library # .Library.site - file.path(chartr(\\, /, R.home()), site- library) # set a CRAN mirror local({r - getOption(repos) r[CRAN] - http://cran.cnr.Berkeley.edu; options(repos=r)}) # Give a fortune cookie, but only to interactive sessions # (This would need the fortunes package to be installed.) # if (interactive()) #fortunes::fortune() Daniel Lopez Workforce Analytics Metrics Team [[alternative HTML version deleted]] __
Re: [R] Inconsistency using seq
Le lundi 18 juin 2012 à 12:58 -0700, hamoreno a écrit : Hi all, Is there any problem of precision when using seq?. For example: x- seq(0,4,0.1) x[4]=0.3 BUT: x[4]-0.3=5.551115e-17 It means when I use this condition within an if clause, it does not find values with 0.3 for x[4] as it is not precisely 0.3. Is there any bug in seq() ? No. Have a look at the FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f Cheers __ 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] Inconsistency using seq
Please read R FAQ 7.31. The problem is with your computer (and everyone else's), and has nothing to do with seq(). On Mon, Jun 18, 2012 at 3:58 PM, hamoreno hamor...@asu.edu wrote: Hi all, Is there any problem of precision when using seq?. For example: x- seq(0,4,0.1) x[4]=0.3 BUT: x[4]-0.3=5.551115e-17 It means when I use this condition within an if clause, it does not find values with 0.3 for x[4] as it is not precisely 0.3. Is there any bug in seq() ? -- Sarah Goslee http://www.functionaldiversity.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] Inconsistency using seq
No, this is rather the nature of floating point calculations. You may perhaps be looking for ?all.equal or R FAQ 7.31 (I think that's the one) which is google-able. It's a complicated subject, but those should get you started. Best, Michael On Jun 18, 2012, at 2:58 PM, hamoreno hamor...@asu.edu wrote: Hi all, Is there any problem of precision when using seq?. For example: x- seq(0,4,0.1) x[4]=0.3 BUT: x[4]-0.3=5.551115e-17 It means when I use this condition within an if clause, it does not find values with 0.3 for x[4] as it is not precisely 0.3. Is there any bug in seq() ? -- View this message in context: http://r.789695.n4.nabble.com/Inconsistency-using-seq-tp4633739.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] Error w/ Start up Script
Ouch Bert. Not patience for the newbies, I see. I know what ?anything means which is why I didn't ask about ?Startup. But being that I just recently discovered what Rprofile.site is I thought it might do something different within the start-up file and tried it both ways. Besides I think what I really need is to just figure out as I said: I did however go to the Misc menu and select List search path and got the below results. Not exactly sure what it means but I do notice that several of the packages that popup at startup as being masked appear in this list. Maybe this is the problem? If so how do you take out what you don't need at startup? search() [1] .GlobalEnv package:stats package:graphics package:grDevices package:datasets [6] package:rattle package:R.utils package:utils package:R.oopackage:R.methodsS3 [11] package:methods Autoloads package:base Dan From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Monday, June 18, 2012 1:50 PM To: Lopez, Dan Cc: David Winsemius; R help (r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script I gave you the references you need. It's up to you to read and understand how to use them. You apparently need to work harder to do so. BTW ?anything is an alternative way to type help(anything) at the command line for R's help pages. -- Bert On Mon, Jun 18, 2012 at 1:34 PM, Lopez, Dan lopez...@llnl.govmailto:lopez...@llnl.gov wrote: Hi Bert, I tried entering: ?suppressPackageStartupMessages and then suppressPackageStartupMessages into my Rprofile.site file and the messages still came up. I did however go to the Misc menu and select List search path and got the below results. Not exactly sure what it means but I do notice that several of the packages that popup at startup as being masked appear in this list. Maybe this is the problem? If so how do you take out what you don't need at startup? search() [1] .GlobalEnv package:stats package:graphics package:grDevices package:datasets [6] package:rattle package:R.utils package:utils package:R.oopackage:R.methodsS3 [11] package:methods Autoloads package:base 0 Thanks. Dan From: Bert Gunter [mailto:gunter.ber...@gene.commailto:gunter.ber...@gene.com] Sent: Monday, June 18, 2012 1:10 PM To: Lopez, Dan Cc: David Winsemius; R help (r-help@r-project.orgmailto:r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script ?suppressPackageStartupMessages Put this into your appropriate startup file. ?Startup ## for details on starting R and what files are executed at startup. -- Bert On Mon, Jun 18, 2012 at 12:46 PM, Lopez, Dan lopez...@llnl.govmailto:lopez...@llnl.gov wrote: David, Sorry I should have been more specific. They are not as much errors as they are extra script that is running at startup after Type q() to quit R. It wasn't there before. And am thinking eventually it could become a problem. Thanks. Dan Here it is again...what it looks like when I first startup R (partial copy and paste): ... .. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ?R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default .. ... -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.netmailto:dwinsem...@comcast.net] Sent: Monday, June 18, 2012 12:12 PM To: Lopez, Dan Cc: R help (r-help@r-project.orgmailto:r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script On Jun 18, 2012, at 11:25 AM, Lopez, Dan wrote: I noticed about a couple weeks ago that my R start up script starting showing the below errors, following the line Type 'q()' to quit R I didn't see any errors reported. I didn't see any warnings, either. -- David. Not sure what I did different and so far it hasn't caused major problems but kind of fear that it will. Can you please help? I also posted my Rprofile below. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ? R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default The following object(s) are masked from 'package:methods': getClass, getClasses, getMethods The following object(s) are masked from 'package:base': attach, detach, gc, load, save R.utils v1.12.1 (2012-03-20) successfully loaded.
Re: [R] Inconsistency using seq
Thanks everyone... Seems that I will have to use round before seq to make sure everything has the correct precision. -- View this message in context: http://r.789695.n4.nabble.com/Inconsistency-using-seq-tp4633739p4633750.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] How can I declutter/make a biplot less messy in R
I am doing a principle component analysis on a dataset with a lot of different variables and have constructed a biplot of the data. Unfortunately, as can be seen on the attached image, the biplot is very messy, cluttered, and hard to read. I have performed a few modifications including outlier removal from a few of the variables, which has made the plot better, however it still is too cluttered to read the variable names. Is there any further improvment that can be made to the attached plot and if so what steps should I take? Thanks, Derek http://r.789695.n4.nabble.com/file/n4633703/biplot.jpg -- View this message in context: http://r.789695.n4.nabble.com/How-can-I-declutter-make-a-biplot-less-messy-in-R-tp4633703.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] Using Sub
Hi, I guess you need something like this: str1-G:\\Compensation Audits_Reports\\Step Audit\\Steps off Step.accdb gsub('','/',str1) [1] G:/Compensation Audits_Reports/Step Audit/Steps off Step.accdb A.K. - Original Message - From: Lopez, Dan lopez...@llnl.gov To: Duncan Murdoch murdoch.dun...@gmail.com Cc: R help r-help@r-project.org Sent: Monday, June 18, 2012 10:37 AM Subject: Re: [R] Using Sub Hi Duncan, That's right but I want to be able to use this to replace back slashes with front slashes when I copy and paste file paths. How can I make this work so I don't get this error? Thanks. Dan -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Friday, June 15, 2012 12:04 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub On 12-06-14 6:23 PM, Lopez, Dan wrote: Hi, I have been trying to get the sub function to work but can't for the life of me figure it out. I tried looking at ?sub but I think there is something that I am just not understanding. Example failed attempts sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: '\C' is an unrecognized escape in character string starting G:\C This isn't anything to do with sub(), it's the third string that's the problem. When you say G:\Comp... it thinks you've escaped the C, but there's no such escape. Duncan Murdoch sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=TRUE) Error: '\C' is an unrecognized escape in character string starting G:\C sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=FALSE) Error: '\C' is an unrecognized escape in character string starting G:\C) sub(/,\,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: unexpected symbol in sub(/,\,G Thanks. Dan __ 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, self-contained, reproducible code.
[R] Installing xlsx package on Mac OS X
Hi all, I'm using a Mac port of R on Mac 10.6. I need to install xlsx package but it does not install. Do any of you know a way to install it? Thanks very much. Sincerely, Victoria Xiao [[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] Using Sub
Hi Dan, I am using linux. So, not sure whether this will work or you tried it before. After you paste the path at (1:), then press enter two times. One more point. In your path, there were spaces within slashes. So, if you do the scan, it will return as 5 items, which you have to join again. I removed the spaces and tried this. But you can try. str=scan(what=character,allowEscapes=F) 1: G:\CompensationAudits_Reports\StepAudit\StepsoffStep.accdb 2: Read 1 item str [1] G:\\CompensationAudits_Reports\\StepAudit\\StepsoffStep.accdb gsub('', '/',str) [1] G:/CompensationAudits_Reports/StepAudit/StepsoffStep.accdb A.K. - Original Message - From: Lopez, Dan lopez...@llnl.gov To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Monday, June 18, 2012 12:03 PM Subject: RE: [R] Using Sub Hi A.K., That works but when I copy and paste from Window explorer it will have a single backslashes and not double. It works with double as what you have in your example below but not with single as what I would end up passing. Do you have any other suggestions or methods to accomplish this? Thanks. Dan -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Monday, June 18, 2012 8:59 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub Hi, I guess you need something like this: str1-G:\\Compensation Audits_Reports\\Step Audit\\Steps off Step.accdb gsub('','/',str1) [1] G:/Compensation Audits_Reports/Step Audit/Steps off Step.accdb A.K. - Original Message - From: Lopez, Dan lopez...@llnl.gov To: Duncan Murdoch murdoch.dun...@gmail.com Cc: R help r-help@r-project.org Sent: Monday, June 18, 2012 10:37 AM Subject: Re: [R] Using Sub Hi Duncan, That's right but I want to be able to use this to replace back slashes with front slashes when I copy and paste file paths. How can I make this work so I don't get this error? Thanks. Dan -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Friday, June 15, 2012 12:04 AM To: Lopez, Dan Cc: R help Subject: Re: [R] Using Sub On 12-06-14 6:23 PM, Lopez, Dan wrote: Hi, I have been trying to get the sub function to work but can't for the life of me figure it out. I tried looking at ?sub but I think there is something that I am just not understanding. Example failed attempts sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: '\C' is an unrecognized escape in character string starting G:\C This isn't anything to do with sub(), it's the third string that's the problem. When you say G:\Comp... it thinks you've escaped the C, but there's no such escape. Duncan Murdoch sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=TRUE) Error: '\C' is an unrecognized escape in character string starting G:\C sub(\\,/,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb,fixed=FALSE) Error: '\C' is an unrecognized escape in character string starting G:\C) sub(/,\,G:\Compensation Audits_Reports\Step Audit\Steps off Step.accdb) Error: unexpected symbol in sub(/,\,G Thanks. Dan __ 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, self-contained, reproducible code.
Re: [R] Trying to speed up an if/else statement in simulations
inline below Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of nqf Sent: Monday, June 18, 2012 10:30 AM To: r-help@r-project.org Subject: [R] Trying to speed up an if/else statement in simulations Dear R-help, I am trying to write a function to simulate datasets of size n which contain two time-to-event outcome variables with associated 'Event'/'Censored' indicator variables (flag1 and flag2 respectively). One of these indicator variables needs to be dependent on the other, so I am creating the first and trying to use this to create the second using an if/else statement. My data structure needs to follow this algorithm (for each row of the data): If flag1=1 then flag2 should be 1 with probability 0.95 and zero otherwise Else if flag1=0 then flag2 should be 1 with probability 0.5 and zero otherwise I can set up this example quite simply using if else statements, but this is incredibly inefficient when running thousands of datasets: data-as.data.frame(rbinom(10,1,0.5)) colnames(data)-'flag1' for (i in 1:n) { if (data$flag1[i]==1) {data$flag2[i]-rbinom(1,1,0.95)} else {data$flag2[i]-rbinom(1,1,0.5)} } Do you mean n - 10 data - data.frame(flag1 = rbinom(n, 1, 0.5)) for(i in seq_len(n)) { if (data$flag1[i]==1) {data$flag2[i]-rbinom(1,1,0.95)} else {data$flag2[i]-rbinom(1,1,0.5)} } ? I think to speed up the simulations I would be better changing to vectorisation and using something like: ifelse(data$flag1==1,rbinom(1,1,0.95),rbinom(1,1,0.5)) but the rbinom statements here generate one value and repeat this draw for every element of flag2 that matches the 'if' statement on flag1. Assuming that n is nrow(data), use data$flag2 - ifelse(data$flag1==1, rbinom(n, 1, 0.95), rbinom(n, 1, 0.5)) so you get n independent draws from each distribution instead of 1. I prefer to factor out the common arguments as in data$flag2 - rbinom(n, 1, ifelse(data$flag1==1, 0.95, 0.5)) Is there a way to assign flag2 to a new bernoulli draw for each subject in the data frame with flag1=1? I hope my question is clear, and thank you in advance for your help. Thanks, Natalie PhD student, Reading University P.S. I am using R 2.12.1 on Windows 7. -- View this message in context: http://r.789695.n4.nabble.com/Trying-to-speed-up-an-if- else-statement-in-simulations-tp4633725.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.
[R] Biplot - how can I make it more readable?
Hello, I am doing a principle component analysis on a dataset with a lot of different variables and have constructed a biplot of the data. Unfortunately, as can be seen on the attached image, the biplot is very messy, cluttered, and hard to read. I have performed a few modifications including outlier removal from a few of the variables, which has made the plot better, however it still is too cluttered to read the variable names. Is there any further improvment that can be made to the attached plot and if so what steps should I take? Thanks, Derek __ 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] S4 into a data frame
Greetings, I'm still very new to R; however I have been tasked with converting an S4 object into a data.frame. We are just trying to learn the basics of S4. Could anyone offer a 'simple' example of coercing an S4 object (such as might be stored in a package attribute) into a data.frame? Ultimately, we would like to do something along the lines of mydata - as.data.frame(original S4 object) Thanks in advance! -- View this message in context: http://r.789695.n4.nabble.com/S4-into-a-data-frame-tp4633746.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] (1-1e-100)==1 true?
Hi, This problems has bothered me for the lase couple of hours. 1e-100==0 [1] FALSE (1-1e-100)==1 [1] TRUE How can I tell R that 1-1e-100 does not equal to 1, actually, I found out that (1-1e-16)==1 [1] FALSE (1-1e-17)==1 [1] TRUE The reason I care about this is that I was try to use qnorm() in my code, for example, qnorm(1e-100) [1] -21.27345 and if I want to find qnorm(x) where x is very close to 1, say x=1-1e-100, then you would think using qnorm(1-x, lower.tail=F) would give me something other than INF, but that does not work since R would recognize x==1 in this case and therefore, 1-x==0, so qnorm(1-x, lower.tail=F) will give me INF which is what I try to avoid in my code. How could get around this, any suggestions? Thanks, Haifeng Wu Graduate Student University of South Carolina -- View this message in context: http://r.789695.n4.nabble.com/1-1e-100-1-true-tp4633754.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How can I declutter/make a biplot less messy in R
Don't do the biplot. Darn hard to make sense of anyway. Plot the scores and the loadings separately. You can see how to do that in this thread: http://r.789695.n4.nabble.com/How-to-plot-PCA-output-td4614732.html Good Luck. Bryan *** Bryan Hanson Professor of Chemistry Biochemistry DePauw University On Jun 18, 2012, at 10:37 AM, dss wrote: I am doing a principle component analysis on a dataset with a lot of different variables and have constructed a biplot of the data. Unfortunately, as can be seen on the attached image, the biplot is very messy, cluttered, and hard to read. I have performed a few modifications including outlier removal from a few of the variables, which has made the plot better, however it still is too cluttered to read the variable names. Is there any further improvment that can be made to the attached plot and if so what steps should I take? Thanks, Derek http://r.789695.n4.nabble.com/file/n4633703/biplot.jpg -- View this message in context: http://r.789695.n4.nabble.com/How-can-I-declutter-make-a-biplot-less-messy-in-R-tp4633703.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.
[R] Listing all binary trees of an ordinal set
Hi all, I'm new to R, have been reading books and trying to get started coding too. The first thing of substance I've been trying to do is to create a function to return a list of all binary trees of a list of ordinals. So, for example, an input of list(3,1,2,4) would return: list(list(1, list(2, list(3, 4))), list(1, list(list(2, 3), 4)), list(list(1, 2), list(3, 4)), list(list(1, list(2, 3)), 4), list(list(list(1, 2), 3), 4)) I've been trying recursions but nothing I've written has been both complete and correct in the final formatting, and I'm sort of clueless when it comes to recursive wrappers. For example, one function I wrote, g=function(x) { len.x = length(x); if (len.x 2) { y=list() for (i in 1:(len.x-1)) y[[i]] = list(g(x[1:i]),g(x[-i:-1])) return(y) } else return(x) } trim = function(x) { for (i in 1:length(x)) { if ((length(x[[i]]) == 1) is.list(x[[i]])) x[[i]] = x[[i]][[1]] } return(x) } findBinTreesOrd=function(x) { x.lst = sort(unlist(x)) all.bin.trees = g(x.lst) trim(all.bin.trees) } returns the trees in a compact, recursively nested form that I haven't found a way to expand to the format that I desire. Any help in either writing a wrapper for that or a different approach to achieve what I'm trying to get would be greatly appreciated--again, I'm quite new to R and am still shaky with the powers and constraints that come with it. LM -- View this message in context: http://r.789695.n4.nabble.com/Listing-all-binary-trees-of-an-ordinal-set-tp4633753.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How can I declutter/make a biplot less messy in R
Hi Derek, It's good form to provide an example with code so that we can see what functions you're using and what you've tried. I'm going to assume that you're using princomp(). Here's one way to reduce the clutter: pc.cr - princomp(USArrests, cor = TRUE) biplot(pc.cr, xlabs=rep(x, nrow(USArrests))) You can also change the colors and the scalings: see ?biplot.princomp and ?biplot.default for details. Outlier removal may not be a good idea. You also didn't tell us what your intent was: a publication-quality plot? Something simply for you to look at yourself? Without knowing that, it's hard to improve it. Sarah On Mon, Jun 18, 2012 at 10:37 AM, dss derek.scha...@srnl.doe.gov wrote: I am doing a principle component analysis on a dataset with a lot of different variables and have constructed a biplot of the data. Unfortunately, as can be seen on the attached image, the biplot is very messy, cluttered, and hard to read. I have performed a few modifications including outlier removal from a few of the variables, which has made the plot better, however it still is too cluttered to read the variable names. Is there any further improvment that can be made to the attached plot and if so what steps should I take? Thanks, Derek -- Sarah Goslee http://www.functionaldiversity.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] Inconsistency using seq
Nope. round() is not failsafe either. Basically, there is theoretically no way to guarantee immunity to floating point error in conditional comparisons. You need to either switch to integers -- which **are** exactly represented -- or figure out another way. Of course, practically speaking, sufficient rounding will work. It's just that it **can** always break. ... and you know Murphy's first law. -- Bert On Mon, Jun 18, 2012 at 1:54 PM, hamoreno hamor...@asu.edu wrote: Thanks everyone... Seems that I will have to use round before seq to make sure everything has the correct precision. -- View this message in context: http://r.789695.n4.nabble.com/Inconsistency-using-seq-tp4633739p4633750.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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] Trying to speed up an if/else statement in simulations
Tena koe Natalie Does this do what you want? set.seed(123) natalie - matrix(NA, nrow=10^5, ncol=2, dimnames=list(NULL, paste0('flag', 1:2))) natalie[,'flag1'] - rbinom(nrow(natalie), 1, 0.5) natalie[natalie[,'flag1']==1, 'flag2'] - rbinom(sum(natalie[,'flag1']), 1, 0.95) natalie[natalie[,'flag1']==0, 'flag2'] - rbinom(nrow(natalie)-sum(natalie[,'flag1']), 1, 0.5) tapply(natalie[,'flag2'], natalie[,'flag1'], table) HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of nqf Sent: Tuesday, 19 June 2012 5:30 a.m. To: r-help@r-project.org Subject: [R] Trying to speed up an if/else statement in simulations Dear R-help, I am trying to write a function to simulate datasets of size n which contain two time-to-event outcome variables with associated 'Event'/'Censored' indicator variables (flag1 and flag2 respectively). One of these indicator variables needs to be dependent on the other, so I am creating the first and trying to use this to create the second using an if/else statement. My data structure needs to follow this algorithm (for each row of the data): If flag1=1 then flag2 should be 1 with probability 0.95 and zero otherwise Else if flag1=0 then flag2 should be 1 with probability 0.5 and zero otherwise I can set up this example quite simply using if else statements, but this is incredibly inefficient when running thousands of datasets: data-as.data.frame(rbinom(10,1,0.5)) colnames(data)-'flag1' for (i in 1:n) { if (data$flag1[i]==1) {data$flag2[i]-rbinom(1,1,0.95)} else {data$flag2[i]-rbinom(1,1,0.5)} } I think to speed up the simulations I would be better changing to vectorisation and using something like: ifelse(data$flag1==1,rbinom(1,1,0.95),rbinom(1,1,0.5)) but the rbinom statements here generate one value and repeat this draw for every element of flag2 that matches the 'if' statement on flag1. Is there a way to assign flag2 to a new bernoulli draw for each subject in the data frame with flag1=1? I hope my question is clear, and thank you in advance for your help. Thanks, Natalie PhD student, Reading University P.S. I am using R 2.12.1 on Windows 7. -- View this message in context: http://r.789695.n4.nabble.com/Trying-to-speed-up-an-if-else-statement-in-simulations-tp4633725.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. The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited. __ 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] Inconsistency using seq
actually, you should build your sequences with integers and scale those to get floating point sequences. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. hamoreno hamor...@asu.edu wrote: Thanks everyone... Seems that I will have to use round before seq to make sure everything has the correct precision. -- View this message in context: http://r.789695.n4.nabble.com/Inconsistency-using-seq-tp4633739p4633750.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] Trying to speed up an if/else statement in simulations
I might try something like: data[data$flag1 == 1, flag2] - runif(sum(data$flag1 == 1)) 0.95 and similarly for the other case. Hope this helps, Michael On Mon, Jun 18, 2012 at 12:29 PM, nqf n.j.frank...@pgr.reading.ac.uk wrote: Dear R-help, I am trying to write a function to simulate datasets of size n which contain two time-to-event outcome variables with associated 'Event'/'Censored' indicator variables (flag1 and flag2 respectively). One of these indicator variables needs to be dependent on the other, so I am creating the first and trying to use this to create the second using an if/else statement. My data structure needs to follow this algorithm (for each row of the data): If flag1=1 then flag2 should be 1 with probability 0.95 and zero otherwise Else if flag1=0 then flag2 should be 1 with probability 0.5 and zero otherwise I can set up this example quite simply using if else statements, but this is incredibly inefficient when running thousands of datasets: data-as.data.frame(rbinom(10,1,0.5)) colnames(data)-'flag1' for (i in 1:n) { if (data$flag1[i]==1) {data$flag2[i]-rbinom(1,1,0.95)} else {data$flag2[i]-rbinom(1,1,0.5)} } I think to speed up the simulations I would be better changing to vectorisation and using something like: ifelse(data$flag1==1,rbinom(1,1,0.95),rbinom(1,1,0.5)) but the rbinom statements here generate one value and repeat this draw for every element of flag2 that matches the 'if' statement on flag1. Is there a way to assign flag2 to a new bernoulli draw for each subject in the data frame with flag1=1? I hope my question is clear, and thank you in advance for your help. Thanks, Natalie PhD student, Reading University P.S. I am using R 2.12.1 on Windows 7. -- View this message in context: http://r.789695.n4.nabble.com/Trying-to-speed-up-an-if-else-statement-in-simulations-tp4633725.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] Trying to speed up an if/else statement in simulations
On Jun 18, 2012, at 1:29 PM, nqf wrote: Dear R-help, I am trying to write a function to simulate datasets of size n which contain two time-to-event outcome variables with associated 'Event'/'Censored' indicator variables (flag1 and flag2 respectively). One of these indicator variables needs to be dependent on the other, so I am creating the first and trying to use this to create the second using an if/else statement. My data structure needs to follow this algorithm (for each row of the data): If flag1=1 then flag2 should be 1 with probability 0.95 and zero otherwise Else if flag1=0 then flag2 should be 1 with probability 0.5 and zero otherwise I can set up this example quite simply using if else statements, but this is incredibly inefficient when running thousands of datasets: data-as.data.frame(rbinom(10,1,0.5)) colnames(data)-'flag1' for (i in 1:n) { if (data$flag1[i]==1) {data$flag2[i]-rbinom(1,1,0.95)} else {data$flag2[i]-rbinom(1,1,0.5)} } I think to speed up the simulations I would be better changing to vectorisation and using something like: ifelse(data$flag1==1,rbinom(1,1,0.95),rbinom(1,1,0.5)) but the rbinom statements here generate one value and repeat this draw for every element of flag2 that matches the 'if' statement on flag1. Is there a way to assign flag2 to a new bernoulli draw for each subject in the data frame with flag1=1? If the parameters for the the Bernoulli draws stay the same, as they appear to do then all you need to do is read the help page for `rbinom` and use the appropriate call to create vectors that are as long as data$flag. -- David Winsemius, MD 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] Error w/ Start up Script
You are perhaps not using suppressPackageStartupMessages() correctly if you're getting those warnings: my .Rprofile has these lines: suppressPackageStartupMessages(library(quantmod)) suppressPackageStartupMessages(library(ggplot2)) suppressPackageStartupMessages(library(lattice)) but produces no warnings (the first does when loading in a clean session without suppressing) Best, Michael On Mon, Jun 18, 2012 at 4:08 PM, Lopez, Dan lopez...@llnl.gov wrote: Ouch Bert. Not patience for the newbies, I see. I know what ?anything means which is why I didn't ask about ?Startup. But being that I just recently discovered what Rprofile.site is I thought it might do something different within the start-up file and tried it both ways. Besides I think what I really need is to just figure out as I said: I did however go to the Misc menu and select List search path and got the below results. Not exactly sure what it means but I do notice that several of the packages that popup at startup as being masked appear in this list. Maybe this is the problem? If so how do you take out what you don't need at startup? search() [1] .GlobalEnv package:stats package:graphics package:grDevices package:datasets [6] package:rattle package:R.utils package:utils package:R.oo package:R.methodsS3 [11] package:methods Autoloads package:base Dan From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Monday, June 18, 2012 1:50 PM To: Lopez, Dan Cc: David Winsemius; R help (r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script I gave you the references you need. It's up to you to read and understand how to use them. You apparently need to work harder to do so. BTW ?anything is an alternative way to type help(anything) at the command line for R's help pages. -- Bert On Mon, Jun 18, 2012 at 1:34 PM, Lopez, Dan lopez...@llnl.govmailto:lopez...@llnl.gov wrote: Hi Bert, I tried entering: ?suppressPackageStartupMessages and then suppressPackageStartupMessages into my Rprofile.site file and the messages still came up. I did however go to the Misc menu and select List search path and got the below results. Not exactly sure what it means but I do notice that several of the packages that popup at startup as being masked appear in this list. Maybe this is the problem? If so how do you take out what you don't need at startup? search() [1] .GlobalEnv package:stats package:graphics package:grDevices package:datasets [6] package:rattle package:R.utils package:utils package:R.oo package:R.methodsS3 [11] package:methods Autoloads package:base 0 Thanks. Dan From: Bert Gunter [mailto:gunter.ber...@gene.commailto:gunter.ber...@gene.com] Sent: Monday, June 18, 2012 1:10 PM To: Lopez, Dan Cc: David Winsemius; R help (r-help@r-project.orgmailto:r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script ?suppressPackageStartupMessages Put this into your appropriate startup file. ?Startup ## for details on starting R and what files are executed at startup. -- Bert On Mon, Jun 18, 2012 at 12:46 PM, Lopez, Dan lopez...@llnl.govmailto:lopez...@llnl.gov wrote: David, Sorry I should have been more specific. They are not as much errors as they are extra script that is running at startup after Type q() to quit R. It wasn't there before. And am thinking eventually it could become a problem. Thanks. Dan Here it is again...what it looks like when I first startup R (partial copy and paste): ... .. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ?R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default .. ... -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.netmailto:dwinsem...@comcast.net] Sent: Monday, June 18, 2012 12:12 PM To: Lopez, Dan Cc: R help (r-help@r-project.orgmailto:r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script On Jun 18, 2012, at 11:25 AM, Lopez, Dan wrote: I noticed about a couple weeks ago that my R start up script starting showing the below errors, following the line Type 'q()' to quit R I didn't see any errors reported. I didn't see any warnings, either. -- David. Not sure what I did different and so far it hasn't caused major problems but kind of fear that it will. Can you please help? I also posted my Rprofile below.
[R] Changing many csv files using apply?
Dear all, I have many csv files whose contents I want to change a bit en masse. So far, I've written code that can change them in a for loop, like so: # Subset of files in the folder I want to change subset = somestring # Retrieve list of files to change filelist=list.files() filelist = filelist[grep(subset, filelist)] for(i in 1:length(filelist)){ setwd(readdir) temp = read.csv(filelist[i],as.is = T, strip.white = T) whatever I want to do to temp setwd(writedir) write.table(temp, file = filelist[i], sep = ,, col.names=NA) } It's a little slow though, so I would like to get rid of the for loop but preserve its function. Would it be possible to use sapply() or something similar? Any insight would be appreciated! Best regards, Emily __ 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] Changing strip text
On 2012-06-18 10:02, Julie Truman wrote: I'm trying to create a 5-panel xyplot with each strip labelled by treatment. The code is as follows: xyplot(log(pfuml)~Transfer|Treat,groups=Pop,ylab=Log10 Pfu/ml,as.table=T, type=a, auto.key= list(space=right,points=F,lines=T)) I've tried: strip=strip.custom(factor.levels=c(0,2,4,8,16) But it's not working, I still only get Treat printed on each strip. Any ideas? Convert your Treat variable to a factor with appropriate levels before plotting or (less desirable) use as.factor(Treat) in place of Treat. A couple of bits of advice for future posts: 1. We don't have your data, so either provide relevant information about it ( str() is useful) or, if possible, illustrate your problem with a built-in dataset. Or make up some data to illustrate the problem. 2. Excise extraneous information from your code; here we don't need your ylab, as.table, groups, type, auto.key. Peter Ehlers Thank you, Julie [[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] Error w/ Start up Script
Hi Michael, I wasn't getting how to actually use it from ?suppressPackageStartupMessages example online. Thank you very much. Dan -Original Message- From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Sent: Monday, June 18, 2012 2:53 PM To: Lopez, Dan Cc: R help (r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script You are perhaps not using suppressPackageStartupMessages() correctly if you're getting those warnings: my .Rprofile has these lines: suppressPackageStartupMessages(library(quantmod)) suppressPackageStartupMessages(library(ggplot2)) suppressPackageStartupMessages(library(lattice)) but produces no warnings (the first does when loading in a clean session without suppressing) Best, Michael On Mon, Jun 18, 2012 at 4:08 PM, Lopez, Dan lopez...@llnl.gov wrote: Ouch Bert. Not patience for the newbies, I see. I know what ?anything means which is why I didn't ask about ?Startup. But being that I just recently discovered what Rprofile.site is I thought it might do something different within the start-up file and tried it both ways. Besides I think what I really need is to just figure out as I said: I did however go to the Misc menu and select List search path and got the below results. Not exactly sure what it means but I do notice that several of the packages that popup at startup as being masked appear in this list. Maybe this is the problem? If so how do you take out what you don't need at startup? search() [1] .GlobalEnv package:stats package:graphics package:grDevices package:datasets [6] package:rattle package:R.utils package:utils package:R.oo package:R.methodsS3 [11] package:methods Autoloads package:base Dan From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Monday, June 18, 2012 1:50 PM To: Lopez, Dan Cc: David Winsemius; R help (r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script I gave you the references you need. It's up to you to read and understand how to use them. You apparently need to work harder to do so. BTW ?anything is an alternative way to type help(anything) at the command line for R's help pages. -- Bert On Mon, Jun 18, 2012 at 1:34 PM, Lopez, Dan lopez...@llnl.govmailto:lopez...@llnl.gov wrote: Hi Bert, I tried entering: ?suppressPackageStartupMessages and then suppressPackageStartupMessages into my Rprofile.site file and the messages still came up. I did however go to the Misc menu and select List search path and got the below results. Not exactly sure what it means but I do notice that several of the packages that popup at startup as being masked appear in this list. Maybe this is the problem? If so how do you take out what you don't need at startup? search() [1] .GlobalEnv package:stats package:graphics package:grDevices package:datasets [6] package:rattle package:R.utils package:utils package:R.oo package:R.methodsS3 [11] package:methods Autoloads package:base 0 Thanks. Dan From: Bert Gunter [mailto:gunter.ber...@gene.commailto:gunter.ber...@gene.com] Sent: Monday, June 18, 2012 1:10 PM To: Lopez, Dan Cc: David Winsemius; R help (r-help@r-project.orgmailto:r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script ?suppressPackageStartupMessages Put this into your appropriate startup file. ?Startup ## for details on starting R and what files are executed at startup. -- Bert On Mon, Jun 18, 2012 at 12:46 PM, Lopez, Dan lopez...@llnl.govmailto:lopez...@llnl.gov wrote: David, Sorry I should have been more specific. They are not as much errors as they are extra script that is running at startup after Type q() to quit R. It wasn't there before. And am thinking eventually it could become a problem. Thanks. Dan Here it is again...what it looks like when I first startup R (partial copy and paste): ... .. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Attempting to load the environment 'package:R.utils' R.methodsS3 v1.2.2 (2010-11-17) successfully loaded. See ?R.methodsS3 for help. R.oo v1.9.3 (2012-03-18) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object(s) are masked from 'package:R.methodsS3': throw.default .. ... -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.netmailto:dwinsem...@comcast.net] Sent: Monday, June 18, 2012 12:12 PM To: Lopez, Dan Cc: R help (r-help@r-project.orgmailto:r-help@r-project.org) Subject: Re: [R] Error w/ Start up Script On Jun 18, 2012, at 11:25 AM, Lopez, Dan wrote: I noticed about a couple
Re: [R] (1-1e-100)==1 true?
This is standard behaviour for a floating-point computational system like R. You might like to take a look at this blog post for a backgrounder on floating-point arithmetic in R. http://blog.revolutionanalytics.com/2009/03/when-is-a-zero-not-a-zero.html # David Smith On Mon, Jun 18, 2012 at 2:26 PM, whf1984911 whf1984...@yahoo.com.cn wrote: Hi, This problems has bothered me for the lase couple of hours. 1e-100==0 [1] FALSE (1-1e-100)==1 [1] TRUE How can I tell R that 1-1e-100 does not equal to 1, actually, I found out that (1-1e-16)==1 [1] FALSE (1-1e-17)==1 [1] TRUE The reason I care about this is that I was try to use qnorm() in my code, for example, qnorm(1e-100) [1] -21.27345 and if I want to find qnorm(x) where x is very close to 1, say x=1-1e-100, then you would think using qnorm(1-x, lower.tail=F) would give me something other than INF, but that does not work since R would recognize x==1 in this case and therefore, 1-x==0, so qnorm(1-x, lower.tail=F) will give me INF which is what I try to avoid in my code. How could get around this, any suggestions? Thanks, Haifeng Wu Graduate Student University of South Carolina -- David M Smith da...@revolutionanalytics.com VP of Marketing, Revolution Analytics http://blog.revolutionanalytics.com Tel: +1 (650) 646-9523 (Palo Alto, CA, USA) Twitter: @revodavid __ 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] Changing many csv files using apply?
sapply() won't be notably faster. What you might try (no guarantee) is wrapping things up as if you were going to use sapply() but instead use mclapply() from the parallel package -- that will parallelize the results and should be faster by roughly as many cores as you use. The no guarantee disclaimer comes from me not being able to guarantee that I/O is nicely parallelized having never tried it myself (it probably is though, those R folks are pretty good at what they do) Michael On Mon, Jun 18, 2012 at 4:38 PM, Chang, Emily@OEHHA emily.ch...@oehha.ca.gov wrote: Dear all, I have many csv files whose contents I want to change a bit en masse. So far, I've written code that can change them in a for loop, like so: # Subset of files in the folder I want to change subset = somestring # Retrieve list of files to change filelist=list.files() filelist = filelist[grep(subset, filelist)] for(i in 1:length(filelist)){ setwd(readdir) temp = read.csv(filelist[i],as.is = T, strip.white = T) whatever I want to do to temp setwd(writedir) write.table(temp, file = filelist[i], sep = ,, col.names=NA) } It's a little slow though, so I would like to get rid of the for loop but preserve its function. Would it be possible to use sapply() or something similar? Any insight would be appreciated! Best regards, Emily __ 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] S4 into a data frame
On 06/18/2012 01:49 PM, spf385 wrote: Greetings, I'm still very new to R; however I have been tasked with converting an S4 object into a data.frame. We are just trying to learn the basics of S4. Could anyone offer a 'simple' example of coercing an S4 object (such as might be stored in a package attribute) into a data.frame? Ultimately, we would like to do something along the lines of mydata- as.data.frame(original S4 object) see ?setAs for more extensive discussion. Not sure what 'stored in a package attribute might mean'. Here's a class setClass(A, representation(x=numeric, y=numeric)) and how to coerce from A to a data.frame setAs(A, data.frame, function(from) data.frame(x=from@x, y=from@y)) and then in action a = new(A, x=1:5, y=5:1) as(a, data.frame) x y 1 1 5 2 2 4 3 3 3 4 4 2 5 5 1 To use as.data.frame(a), you'd have to implement the 'as.data.frame.A' S3 method, e.g., as.data.frame.A = function(x) as(x, data.frame) Also, probably you'd want a validity method (see ?setValidity) on A, to ensure that x, y were equal length. Martin Thanks in advance! -- View this message in context: http://r.789695.n4.nabble.com/S4-into-a-data-frame-tp4633746.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. -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 __ 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] Listing all binary trees of an ordinal set
On Jun 18, 2012, at 5:25 PM, elmo wrote: Hi all, I'm new to R, have been reading books and trying to get started coding too. The first thing of substance I've been trying to do is to create a function to return a list of all binary trees of a list of ordinals. So, for example, an input of list(3,1,2,4) would return: Please do not cross-post (but DO read the Posting Guide where this was is requested). You have already gotten an answer on StackOverflow. -- David. list(list(1, list(2, list(3, 4))), list(1, list(list(2, 3), 4)), list(list(1, 2), list(3, 4)), list(list(1, list(2, 3)), 4), list(list(list(1, 2), 3), 4)) I've been trying recursions but nothing I've written has been both complete and correct in the final formatting, and I'm sort of clueless when it comes to recursive wrappers. For example, one function I wrote, g=function(x) { len.x = length(x); if (len.x 2) { y=list() for (i in 1:(len.x-1)) y[[i]] = list(g(x[1:i]),g(x[-i:-1])) return(y) } else return(x) } trim = function(x) { for (i in 1:length(x)) { if ((length(x[[i]]) == 1) is.list(x[[i]])) x[[i]] = x[[i]][[1]] } return(x) } findBinTreesOrd=function(x) { x.lst = sort(unlist(x)) all.bin.trees = g(x.lst) trim(all.bin.trees) } returns the trees in a compact, recursively nested form that I haven't found a way to expand to the format that I desire. Any help in either writing a wrapper for that or a different approach to achieve what I'm trying to get would be greatly appreciated--again, I'm quite new to R and am still shaky with the powers and constraints that come with it. LM -- View this message in context: http://r.789695.n4.nabble.com/Listing-all-binary-trees-of-an-ordinal-set-tp4633753.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 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] (1-1e-100)==1 true?
On 18-Jun-2012 21:26:41 whf1984911 wrote: Hi, This problems has bothered me for the lase couple of hours. 1e-100==0 [1] FALSE (1-1e-100)==1 [1] TRUE How can I tell R that 1-1e-100 does not equal to 1, actually, I found out that (1-1e-16)==1 [1] FALSE (1-1e-17)==1 [1] TRUE The reason I care about this is that I was try to use qnorm() in my code, for example, qnorm(1e-100) [1] -21.27345 and if I want to find qnorm(x) where x is very close to 1, say x=1-1e-100, then you would think using qnorm(1-x, lower.tail=F) would give me something other than INF, but that does not work since R would recognize x==1 in this case and therefore, 1-x==0, so qnorm(1-x, lower.tail=F) will give me INF which is what I try to avoid in my code. How could get around this, any suggestions? Thanks, Haifeng Wu Graduate Student University of South Carolina You are working close to, and also beyond, the boundary of what R can internally represent, so anomalies like this will frequently turn up. For the sort of extreme values which you are using, it is better to make use of asymptotic formulae, and not to use R's standard functions such as qnorm, pnorm, ... For example, there is Mills Ratio, for which (in RF notation) x*(1 - pnorm(x))/dnorm(x) -- 1 as x -- Inf So, for large x, proceed as though it was exactly 1. Then log(x) + log(1 - pnorm(x)) = log(dnorm(x)) = -0.5*log(2*pi) - 0.5*x^2 so, with (e.g.) pnorm(x) = 1-1e-100, you have log(x) + 0.5*x^2 = 100 - 0.5*log(2*pi) More generally, with pnorm(x) = 1-1e-X where X is large, log(x) + 0.5*x^2 = X - 0.5*log(2*pi) so you now need to write a function, say Qnorm(X), which solves this equation for x, given X. The above is only a suggestion. Probably others know a better approach! Ted. - E-Mail: (Ted Harding) ted.hard...@wlandres.net Date: 19-Jun-2012 Time: 00:07:11 This message was sent by XFMail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Inconsistency using seq
FYI, isZero - function(x, neps=1, eps=.Machine$double.eps, ...) { + (abs(x) neps * eps) + } x - seq(from=0, to=4, by=0.1) isZero(x[4]-0.3) [1] TRUE isZero(x[4]-0.3, neps=1) [1] TRUE isZero(x[4]-0.3, neps=0.1) [1] FALSE You could also have called isZero() isValueSmallEnoughForWhatINeed(). My $.02 /Henrik On Mon, Jun 18, 2012 at 2:29 PM, Bert Gunter gunter.ber...@gene.com wrote: Nope. round() is not failsafe either. Basically, there is theoretically no way to guarantee immunity to floating point error in conditional comparisons. You need to either switch to integers -- which **are** exactly represented -- or figure out another way. Of course, practically speaking, sufficient rounding will work. It's just that it **can** always break. ... and you know Murphy's first law. -- Bert On Mon, Jun 18, 2012 at 1:54 PM, hamoreno hamor...@asu.edu wrote: Thanks everyone... Seems that I will have to use round before seq to make sure everything has the correct precision. -- View this message in context: http://r.789695.n4.nabble.com/Inconsistency-using-seq-tp4633739p4633750.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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] Trying to speed up an if/else statement in simulations
Hello, Try creating an index vector. In this case, I've called it 'one'. Then, 'n.one' is the number of ones in flag1. (Since data is an R function, I've renamed your example dat). n - 10 # number of observations # First make up some data set.seed(123) dat - data.frame(flag1=rbinom(n, 1, 0.5)) dat$flag2 - integer(n) # creates flag2, all zeros. one - dat$flag1 == 1 # logical index vector n.one - sum(ix) # how many dat$flag2[one] - rbinom(n.one, 1, 0.95)# whenever TRUE, set dat$flag2[!one] - rbinom(n - n.one, 1, 0.50) # negation of 'one' dat Simple, no? And always faster. Hope this helps, Rui Barradas Em 18-06-2012 18:29, nqf escreveu: Dear R-help, I am trying to write a function to simulate datasets of size n which contain two time-to-event outcome variables with associated 'Event'/'Censored' indicator variables (flag1 and flag2 respectively). One of these indicator variables needs to be dependent on the other, so I am creating the first and trying to use this to create the second using an if/else statement. My data structure needs to follow this algorithm (for each row of the data): If flag1=1 then flag2 should be 1 with probability 0.95 and zero otherwise Else if flag1=0 then flag2 should be 1 with probability 0.5 and zero otherwise I can set up this example quite simply using if else statements, but this is incredibly inefficient when running thousands of datasets: data-as.data.frame(rbinom(10,1,0.5)) colnames(data)-'flag1' for (i in 1:n) { if (data$flag1[i]==1) {data$flag2[i]-rbinom(1,1,0.95)} else {data$flag2[i]-rbinom(1,1,0.5)} } I think to speed up the simulations I would be better changing to vectorisation and using something like: ifelse(data$flag1==1,rbinom(1,1,0.95),rbinom(1,1,0.5)) but the rbinom statements here generate one value and repeat this draw for every element of flag2 that matches the 'if' statement on flag1. Is there a way to assign flag2 to a new bernoulli draw for each subject in the data frame with flag1=1? I hope my question is clear, and thank you in advance for your help. Thanks, Natalie PhD student, Reading University P.S. I am using R 2.12.1 on Windows 7. -- View this message in context: http://r.789695.n4.nabble.com/Trying-to-speed-up-an-if-else-statement-in-simulations-tp4633725.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] Efficient distance calculation on big matrix
It so happens I have been looking at very similar changes, as well as adding multi-threading support for dist(); these should make it into R-devel later this summer. That's good to hear! I was thinking about giving OpenMP a try in my package, but am not sure whether it's worth the overhead and risk of compatibility problems. Are there any plans to expand dist() to calculate cross-distances between two different sets of vectors? If so, I'd be able to do away with my custom implementation once your improved dist() has made it into a stable R release. (I need cross-distances for nearest neighbour search in large sets of vectors.) Best, Stefan __ 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.