[R] Accessing Havers data from R?
Hi R, Do we have R package to extract data from Havers data provider? For example, just like we have RBloomberg package to extract data from Bloomberg. If not are there any other mechanisms to extract the data from Havers? Thanks and Regards, Shubha. This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Permission denied in Windows 7
On Wed, 8 Jun 2011, steven mosher wrote: I'm using package.skeleton() windows 7, 64 bit. When I try to specify the code_files package_skeleton(code_files = some directory) I get a warning that that the connection cannot be opened and I get a Permissions denied error. Which connection? Please copy-and-paste exactly what you did and what the output was. I'm running R as admin and I've given everybody full permissions on the folder. What am I missing There can be more to that on Windows 7. Is it read-only, for example? One thing which often catches users of POSIX operating systems (like me) is that read-only files are also no-delete files. [[alternative HTML version deleted]] Please don't keep sending HTML when the posting guide expressly asked you not to. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Can we prepare a questionaire in R
Hai everyone, 1) Is there a way to populate html form element values directly into R or is it only possible to get the values into a db or an excel file or a csv file and import it for data analysis. If possible , please anyone reply to this mail. Am a beginner in R. [[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] Resources for utilizing multiple processors
On Wed, 8 Jun 2011, Robin Jeffries wrote: Hello, I know of some various methods out there to utilize multiple processors but am not sure what the best solution would be. First some things to note: I'm running dependent simulations, so direct parallel coding is out (multicore, doSnow, etc). I'm on Windows, and don't know C. I don't plan on learning C or any of the *nix languages. By restricting yourself to one of the least capable OS R runs on, you are making this harder for yourself. My main concern deals with Multiple analyses on large data sets. By large I mean that when I'm done running 2 simulations R is using ~3G of RAM, the remaining ~3G is chewed up when I try to create the Gelman-Rubin statistic to compare the two resulting samples, grinding the process to a halt. I'd like to have separate cores simultaneously run each analysis. That will save on time and I'll have to ponder the BGR calculation problem another way. Can R temporarily use HD space to write calculations to instead of RAM? By using virtual memory (R does not in fact use RAM, it always uses virtual memory). With a 64bit R you can use up to terabytes of VM. Because Windows' disc access is so slow, you will need to set a max-memory-size larger than your RAM size to enable this. The second concern boils down to whether or not there is a way to split up dependent simulations. For example at iteration (t) I feed a(t-2) into FUN1 to generate a(t), then feed a(t), b(t-1) and c(t-1) into FUN2 to simulate b(t) and c(t). I'd love to have one core run FUN1 and another run FUN2, As stated, that is pointless. The core running FUN2 would be waiting for the resuls of FUN1. However, at time t FUN1 could generate a(t+1) from a(t-1) whilst FUN2 generates b(t) and c(t). and better yet, a third to run all the pre-and post- processing tidbits! Look into package snow (with socket clusters). The overhead of what you ask may be too high (POSIX OSes can use package multicore, which has a much lower overhead), but if the calculations are slow enough it may be worthwhile. There are Windows-oriented examples in package RSiena. So if anyone has any suggestions as to a direction I can look into, it would be appreciated. Robin Jeffries MS, DrPH Candidate Department of Biostatistics UCLA 530-633-STAT(7828) [[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. -- 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] Can we prepare a questionaire in R
1) Is there a way to populate html form element values directly into R or is it only possible to get the values into a db or an excel file or a csv file and import it for data analysis. I realise this isn't exactly what you are asking, but it is a possible solution. If you google or search these forums you will find information on linking R to the spreadsheet in Google Docs. With GoogleDocs you can create forms that can be filled in online or via email, which automatically populate a google spreadsheet. Running the R code for the analysis then automatically updates with the latest data from the spreadsheet. So the analysis is always based on the latest data. Not sure if that helps, but it may be worth exploring. Graham [[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] Histogram
On 09/06/11 16:39, nandini_bn wrote: Hi Sam,This is exactly what I wanted. Could you please explain the code ? what does 15, 0.65 and 0.25 stand for ?Nandini Date: Wed, 8 Jun 2011 15:16:45 -0700 From: ml-node+3583766-897200094-233...@n4.nabble.com To: nandini...@hotmail.com Subject: Re: Histogram I think the command you want is barplot x = rbinom(10,15,0.65) y = rbinom(10,15,0.25) barplot(rbind(x,y),beside=TRUE) RTFM. I.e. execute ?rbinom cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] a bug in heatmap.plus?
No idea, and no time to debug this unfortunately. I'd like to hand off maintenance of this package if anyone is using it. -Allen On Wed, Jun 8, 2011 at 9:50 PM, Shi, Tao shida...@yahoo.com wrote: Hi Allen and list, See the code below. I've tried it on R2.13 and R2.8.0 using either heatmap.plus 1.3 or the latest. All gave the same results. The problem is in the last line: when I tried to plot two different color bars, the one corresponding to cm.colors(10) is not correct (it starts with one black and one red. Not sure where they're from?) Any ideas? Thanks! ...Tao library(heatmap.plus) set.seed(1234) x - matrix(rnorm(400), ncol=10) heatmap(x, ColSideColors= cm.colors(10), Colv=NA) heatmap.plus(x, ColSideColors=cbind(cm.colors(10), cm.colors(10)), Colv=NA) heatmap.plus(x, ColSideColors=cbind(rep(1:2,each=5), cm.colors(10)), Colv=NA) [[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] Reshape:cast; error using ... in formula expression.
Whenever I use ... in the formula of the cast function, from the reshape package, I get the following error: Error in `[.data.frame`(data, , variables, drop = FALSE) : undefined columns selected For example: data(french_fries) #available in the reshape package head(french_fries) time treatment subject rep potato buttery grassy rancid painty 611 1 3 12.9 0.00.00.05.5 251 1 3 2 14.0 0.00.01.10.0 621 1 10 1 11.0 6.40.00.00.0 261 1 10 29.9 5.92.92.20.0 631 1 15 11.2 0.10.01.15.1 271 1 15 28.8 3.03.61.52.3 cast(french_fries, ...~ subject) Using painty as value column. Use the value argument to cast to override this choice Error in `[.data.frame`(data, , variables, drop = FALSE) : undefined columns selected -- View this message in context: http://r.789695.n4.nabble.com/Reshape-cast-error-using-in-formula-expression-tp3584721p3584721.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] Data projection in correspondence analysis
Hi, I have two data binary dataset. I want to applied correspondence analysis into the first data, and then project the second data into the CA space defined by the first dataset. Can we use the ca package or anacor package to project new data? If not, are there some ways to do this ? Thank you in advance!!! [[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] SOM for binary data
Hi, I know that usually SOM (self-organizing map) is just for continuous data. But I want to apply the SOM into binary data. It seems that some algorithms can handle this. How to implement it in R? Or are there some packages in R for binary data SOM? Thank you in advance!! [[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] Permission denied in Windows 7
Prof, Ripley. I think I figured it out. I took the instructions for code_files to mean that you had to supply the path to the directory and not the paths to all the files within that directory. I'll show my work below which should make clear the mistake that I made sessionInfo()R version 2.13.0 (2011-04-13) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] R.utils_1.7.5 R.oo_1.8.0R.methodsS3_1.2.1 loaded via a namespace (and not attached): [1] tools_2.13.0 getwd()[1] C:/Users/steve/Documents/GHCNPackage list.files(full.names=TRUE)[1] ./d.R ./f.R filePath - getwd() filePath[1] C:/Users/steve/Documents/GHCNPackage package.skeleton(name=testpackage,code_files=filePath)Error in file(file, r) : cannot open the connectionIn addition: Warning message:In file(file, r) : cannot open file 'C:/Users/steve/Documents/GHCNPackage': Permission denied # Looks like I need a path all the way to the file. # start with one file to test testFile -file.path(filePath,d.R,fsep=.Platform$file.sep) package.skeleton(name=testpackage,code_files=testFile)Creating directories ...Creating DESCRIPTION ...Creating Read-and-delete-me ...Copying code files ...Making help files ...Done.Further steps are described in './testpackage/Read-and-delete-me'. ?package.skeleton() testFile2 -file.path(filePath,f.R,fsep=.Platform$file.sep) package.skeleton(name=testpackage,code_files=c(testFile,testFile2))Creating directories ...Error in package.skeleton(name = testpackage, code_files = c(testFile, : directory './testpackage' already exists package.skeleton(name=testpackage,code_files=c(testFile,testFile2))Creating directories ...Creating DESCRIPTION ...Creating Read-and-delete-me ...Copying code files ...Making help files ...Done.Further steps are described in './testpackage/Read-and-delete-me'. Success. I assumed that you just passed in the directory that contained all the source Files and that all the files in that directory ending in .R would be used. Thanks On Wed, Jun 8, 2011 at 11:44 PM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote: On Wed, 8 Jun 2011, steven mosher wrote: I'm using package.skeleton() windows 7, 64 bit. When I try to specify the code_files package_skeleton(code_files = some directory) I get a warning that that the connection cannot be opened and I get a Permissions denied error. Which connection? Please copy-and-paste exactly what you did and what the output was. I'm running R as admin and I've given everybody full permissions on the folder. What am I missing There can be more to that on Windows 7. Is it read-only, for example? One thing which often catches users of POSIX operating systems (like me) is that read-only files are also no-delete files. [[alternative HTML version deleted]] Please don't keep sending HTML when the posting guide expressly asked you not to. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[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] Reshape:cast; error using ... in formula expression.
Hi: Short answer: use one dot, not three: cast(french_fries, . ~ subject) Using painty as value column. Use the value argument to cast to override this choice Aggregation requires fun.aggregate: length used as default value 3 10 15 16 19 31 51 52 63 78 79 86 1 (all) 54 60 60 60 60 54 60 60 60 60 54 54 Long answer: It's the same as using . in a model formula. The ... construct is used as a formal argument in a function *definition* to allow passage of needed arguments in a function call that are not part of the list of formal arguments. I noticed args(cast) function (data, formula = ... ~ variable, fun.aggregate = NULL, ..., margins = FALSE, subset = TRUE, df = FALSE, fill = NULL, add.missing = FALSE, value = guess_value(data)) so I can see where you may have gotten confused. Here's an example using the same data frame where the ... argument comes into play: # melt the response variables (the sensory attributes) into # a factor variable for the attributes themselves and a value # variable for their corresponding values. ffm - melt(french_fries, id = c('subject', 'time', 'treatment', 'rep')) head(ffm) # Recast the data so that the average score per subject/treatment score is produced. # However, there are NAs in the data frame, so we need to pass na.rm = TRUE: cast(ffm, subject + treatment ~ variable, value_var = 'value', fun.aggregate = 'mean', na.rm = TRUE) # To average over all subjects, treatments, times and reps, cast(ffm, . ~ variable, value_var = 'value', fun.aggregate = 'mean', na.rm = TRUE) value potato butterygrassy rancid painty 1 (all) 6.952518 1.823699 0.6641727 3.85223 2.521758 na.rm is not part of the formal argument list to cast(), but because the ... construct is present, we can pass na.rm = TRUE to the mean() function used to aggregate the data in the actual call. Observe that args(mean.default) function (x, trim = 0, na.rm = FALSE, ...) so the na.rm = TRUE argument in the call to cast() is actually passed to mean(). [To understand how this works, you need to do some study about function writing; the R Language Definition manual is one place where this is described in detail. The formal arguments to mean.default() are x, trim, na.rm and ...; trim and na.rm have default values 0 and FALSE than can be overridden in an actual call to that function.] You should never need to use ... in an actual function call; in a formula, use of . on one side of ~ means to use all variables in the data frame except those used on the other side (the side where one or more variables are specified). For example, in a linear regression context, lm(y ~ ., data = mydata) would use all variables in mydata except y as covariates in the model. HTH, Dennis On Thu, Jun 9, 2011 at 12:10 AM, misterbray misterb...@gmail.com wrote: Whenever I use ... in the formula of the cast function, from the reshape package, I get the following error: Error in `[.data.frame`(data, , variables, drop = FALSE) : undefined columns selected For example: data(french_fries) #available in the reshape package head(french_fries) time treatment subject rep potato buttery grassy rancid painty 61 1 1 3 1 2.9 0.0 0.0 0.0 5.5 25 1 1 3 2 14.0 0.0 0.0 1.1 0.0 62 1 1 10 1 11.0 6.4 0.0 0.0 0.0 26 1 1 10 2 9.9 5.9 2.9 2.2 0.0 63 1 1 15 1 1.2 0.1 0.0 1.1 5.1 27 1 1 15 2 8.8 3.0 3.6 1.5 2.3 cast(french_fries, ...~ subject) Using painty as value column. Use the value argument to cast to override this choice Error in `[.data.frame`(data, , variables, drop = FALSE) : undefined columns selected -- View this message in context: http://r.789695.n4.nabble.com/Reshape-cast-error-using-in-formula-expression-tp3584721p3584721.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] Results of CFA with Lavaan
On 06/08/2011 11:56 PM, R Help wrote: Yes, that is the difference. For the last SEM I built I fixed the factor variances to 1, and I think that's what I want to do for the CFA I'm doing now. Does that make sense for a CFA? If you have a latent variable in your model (like a factor in CFA), you need to define its metric/scale. There are typically two ways to do this: 1) fix the variance of the latent variable to a constant (typically 1.0), or 2) fix the factor loading of one of the indicators of the factor (again to 1.0). For CFA with a single group, it should not matter which method you choose. The fit measures will be identical. Lavaan by default uses the second option. If you prefer the first (fixing the variances), you can simply add the 'std.lv=TRUE' option to the cfa() call, and lavaan will take care of the rest. I'll try figuring out how to do that with lavaan later, but my model takes so long to fit that I can't try it right now. You can use the 'verbose=TRUE' argument to monitor progress. You may also use the options se=none (no standard errors) and test=none (no test statistic) to speed things up, if you are still constructing your model. Or the model does not convergence, but I should see both the model and the data to determine the possible cause. Hope this helps, Yves Rosseel http://lavaan.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] Variable in file name png
On 08.06.2011 16:11, Aaron Coutino wrote: Hi, I'm having trouble with getting the png function to properly produce multiple graphs. RIght now I have: for (z in data) { you probably meant for(z in seq_along(data)) and the rest should be fine. Uwe Ligges png(file=z,bg=white) thisdf-data[[z]] plot(thisdf$rc,thisdf$psi) dev.off() } Which should take the data object, a list of data sets and produce a graph of each with respect to the two variables rc and psi. I want the names to change for each graph, but am not sure how to do it, any help would be apreciated. Thanks, -Acoutino __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 3D-plotting a 2D-matrix that contains z-values (3rd dimension)
Well, persp(x, y, z) does exactly what you asked for: it plots tha matrix z along the values given by the vectors x and y. If you need to calculate z values from x and y using some function foo, outer(x, y, foo) is typically your friend. Uwe Ligges On 08.06.2011 16:57, Oliver wrote: Hello, say I have a 2D-matrix (indexed by x and y), which contains z values, which I want to plot over x-y. Either dotted, or if possible as a landscape. I tried around with persp and plot3d (from rgl) and persp3d (from rgl). I sometimes get something that looks good and a while later, when trying some new data I need to worry about that again. Is there something lika a convenience function that can be used to feed the data into persp, rgl::plot3d and rgl::persp3d? At least persp3d is picky about the order of the input data, and I somehow always start again. (plot3d seems to be most mathcing how I think). Isn't that a very common case, where my z_x_y = mydata[x,y] ? Maybe I just don't know the right function that helps me. Any idea about that? Ciao, Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Classifying boolean values
Convert it to a factor? Uwe Ligges On 08.06.2011 10:44, Grifone wrote: Thanks Sarah for the response; with the command str(echoknn.train) the coloumn class is a logi value (i think without any immagination that is a logical value ). So, how can I handle this type of data? Thanks a lot. P.S. Yes, is a course assignment and i was hoping to solve this problem (that i consider just a beginner problem) without asking my teacher . -- View this message in context: http://r.789695.n4.nabble.com/Classifying-boolean-values-tp3579993p3581980.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 Installing or Updating Packages (Maybe because of a proxy)
Back again, just tried at work (through a proxy, same R version, should be same Debian Linux version = Debian Testing recently updated but one on a Macbook computer (at home, does not work), the other on a Desktop PC (at work, works flawlessly)). Will try to investigate further... Majid, did you locate the source of your problem ? Thanks. Olivier. -Le Wed, 8 Jun 2011 17:32:36 +0200, Olivier Crouzet a écrit : Dear all, I receive the very same error message on a Debian computer (testing) with R 2.13.0 also. install.packages('emu') Installing package(s) into ‘/home/olivier/R/i486-pc-linux-gnu-library/2.13’ (as ‘lib’ is unspecified) Error in ret[i, ] - c(pkgs[i], lib, desc) : number of items to replace is not a multiple of replacement length I have no proxy settings on this computer (neither in .bashrc / .bash_profile, nor in my desktop environment, and I'm doing it at home where I'm not using any proxy). I can download a file on the web from within R (using both download.file () or download.packages ('emu','/home/olivier/R/i486-pc-linux-gnu-library/2.13')... and finally I can also use install.packages() on this downloaded file and the install works flawlessly. I can't find any old R base package in the various directories indicated by .libPaths(). .libPaths() [1] /home/olivier/R/i486-pc-linux-gnu-library/2.13 [2] /usr/local/lib/R/site-library [3] /usr/lib/R/site-library [4] /usr/lib/R/library The only place where I can think there may be one are the local trees ([1] and [2]) as the 2 others are (should be) updated automatically when updating R with the Debian pkg mngmt system and there's nothing inside them. Only [4] contains a base/ subdirectory (a single one) but I suppose this is the current one for R 2.13.0 I can install a package once it's been downloaded locally (through R CMD INSTALL pkg) but can't succeed in installing the same package from the CRAN mirrors using install.packages(). I experience the very same issue with all related instructions (old.packages(), update.packages()) I also could do that several months ago on a different Debian computer (but with an older R version than the current one). Any hints (including what kind of information I should give to enhance the description of this issue)? Olivier. On Wed, 20 Apr 2011 10:29:17 +0200 Uwe Ligges lig...@statistik.tu-dortmund.de wrote: If the internet connection from R works, can you please verify that you do not have any R base package from an old R version in a current R library that you may have in the .libPaths() already? Uwe Ligges On 20.04.2011 09:25, Majid Einian wrote: Dear R Helpers, (I am using Ubuntu lucid and R 2.13.0 When I try to update packages I get this error: update.packages() --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done Error in ret[i, ]- c(pkgs[i], lib, desc) : number of items to replace is not a multiple of replacement length I had no problem before (case 1) but now (case 2) I cannot get it to work, googleing did not help: case 1: * connecting directly without any proxy setting (at my university) * using R 2.12.2 case 2: * connecting through proxy setting (at my workplace) * using R 2.13.0 I set the proxy in terminal too but it does not help (echo $http_proxy gives me http://192.168.0.1:8080/) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Olivier Crouzet, PhD Laboratoire de Linguistique -- EA3827 Département de Sciences du Langage UFR Lettres et Langages Université de Nantes Chemin de la Censive du Tertre - BP 81227 44312 Nantes cedex 3 France phone:(+33) 02 40 14 14 05 (lab.) (+33) 02 40 14 14 36 (office) fax: (+33) 02 40 14 13 27 e-mail: olivier.crou...@univ-nantes.fr http://www.lling.fr/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Can we prepare a questionaire in R
I will explain more clearly I have an online feedback form which has all the form elements like radiobuttons,checkboxes,textareas,textboxes etc. I have to get the values of these form elements and use it for data analysis in R. It will be huge amount of data. 1) Is it possible in R to retrieve the values of these form elements directly. 2) Is there any storage mechanism in R to store the values. 2) Do i have to store the data in some files or db and then import them in R and use for data analysis. Is this better? Amrita [[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] Resources for utilizing multiple processors
From: rjeffr...@ucla.edu Date: Wed, 8 Jun 2011 20:54:45 -0700 To: r-help@r-project.org Subject: [R] Resources for utilizing multiple processors Hello, I know of some various methods out there to utilize multiple processors but am not sure what the best solution would be. First some things to note: I'm running dependent simulations, so direct parallel coding is out (multicore, doSnow, etc). the *nix languages. Well, for the situation below you seem to want a function server. You could consider Rapache and just write this like a big web application. A web server, like a DB, is not the first thing you think of with high performance computing but if your computationally intenstive tasks are in native code this could be a reasoanble overhead that requires little learning. If you literally means cores instead of machines keep in mind that cores can end up fighting over resources, like memory ( this cites IEEE article with cores making things worse in non-contrived case) http://lists.boost.org/boost-users/2008/11/42263.php I think people have mentioned some classes like bigmemory, I forget the names exactly, that let you handle larger things. Launching a bunch of threads and letting VM thrash can easily make things slower quickly. I guess a better approach would be to get an implementation that is block oriented and you can do the memory/file stuff in R until they get a data frame that uses disk transparently and with hints on expected access patterns ( prefetch etc). My main concern deals with Multiple analyses on large data sets. By large I mean that when I'm done running 2 simulations R is using ~3G of RAM, the remaining ~3G is chewed up when I try to create the Gelman-Rubin statistic to compare the two resulting samples, grinding the process to a halt. I'd like to have separate cores simultaneously run each analysis. That will save on time and I'll have to ponder the BGR calculation problem another way. Can R temporarily use HD space to write calculations to instead of RAM? The second concern boils down to whether or not there is a way to split up dependent simulations. For example at iteration (t) I feed a(t-2) into FUN1 to generate a(t), then feed a(t), b(t-1) and c(t-1) into FUN2 to simulate b(t) and c(t). I'd love to have one core run FUN1 and another run FUN2, and [[elided Hotmail spam]] So if anyone has any suggestions as to a direction I can look into, it would be appreciated. Robin Jeffries MS, DrPH Candidate Department of Biostatistics UCLA 530-633-STAT(7828) [[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 with geomap in googleVis
To: r-h...@stat.math.ethz.ch From: mjphi...@tpg.com.au Date: Wed, 8 Jun 2011 10:14:01 + Subject: Re: [R] error with geomap in googleVis SNV Krishna primps.com.sg writes: Hi All, I am unable to get the plot geomap in googleVis package. data is as follows head(index.ret) country ytd 1 Argentina -10.18 2 Australia -3.42 3 Austria -2.70 4 Belgium 1.94 5 Brazil -7.16 6 Canada 0.56 map1 = gvisGeoMap(index.ret,locationvar = 'country', numvar = 'ytd') plot(map1) But it just displays a blank page, showing an error symbol at the right bottom corner. I tried demo(googleVis), it also had a similar problem. The demo showed all other plots/maps except for those geomaps. Could any one please hint me what/where could be the problem? Many thanks for the idea and support. I had never used this until yesterday but it seems to generate html. I didn't manage to get a chart to display but if you are familiar with this package and html perhaps you could look at map1$html and see if anything is obvious. One great thing about html/js is that it is human readable and you can integrate it well with other page material without much in the way of special tools. Regards, SNV Krishna [[alternative HTML version deleted]] Hi All, I have also encountered this problem. I have tested the problem in Windows XP 3.0. I have latest java and flash and I have tried both Firefox and IE (both latest k just fine. I too would like to know how to solve this problem. Kind regards, Michael Phipps __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Installing or Updating Packages (Maybe because of a proxy)
Le Thu, 9 Jun 2011 12:14:55 +0200, Olivier Crouzet a écrit : Back again again, actually, the big difference between the two computers is in the library path. On the computer where package installation works, .libPaths() returns: .libPaths() [1] /usr/local/lib/R/site-library /usr/lib/R/site-library [3] /usr/lib/R/library With no path being part of my local home directory... and the install puts the installed packages into the first one (/usr/local/lib/R/site-library/) as expected. I will try to change the destination directory for the install on the other computer. Olivier. just tried at work (through a proxy, same R version, should be same Debian Linux version = Debian Testing recently updated but one on a Macbook computer (at home, does not work), the other on a Desktop PC (at work, works flawlessly)). Will try to investigate further... Majid, did you locate the source of your problem ? Thanks. Olivier. -Le Wed, 8 Jun 2011 17:32:36 +0200, Olivier Crouzet a écrit : Dear all, I receive the very same error message on a Debian computer (testing) with R 2.13.0 also. install.packages('emu') Installing package(s) into ‘/home/olivier/R/i486-pc-linux-gnu-library/2.13’ (as ‘lib’ is unspecified) Error in ret[i, ] - c(pkgs[i], lib, desc) : number of items to replace is not a multiple of replacement length I have no proxy settings on this computer (neither in .bashrc / .bash_profile, nor in my desktop environment, and I'm doing it at home where I'm not using any proxy). I can download a file on the web from within R (using both download.file () or download.packages ('emu','/home/olivier/R/i486-pc-linux-gnu-library/2.13')... and finally I can also use install.packages() on this downloaded file and the install works flawlessly. I can't find any old R base package in the various directories indicated by .libPaths(). .libPaths() [1] /home/olivier/R/i486-pc-linux-gnu-library/2.13 [2] /usr/local/lib/R/site-library [3] /usr/lib/R/site-library [4] /usr/lib/R/library The only place where I can think there may be one are the local trees ([1] and [2]) as the 2 others are (should be) updated automatically when updating R with the Debian pkg mngmt system and there's nothing inside them. Only [4] contains a base/ subdirectory (a single one) but I suppose this is the current one for R 2.13.0 I can install a package once it's been downloaded locally (through R CMD INSTALL pkg) but can't succeed in installing the same package from the CRAN mirrors using install.packages(). I experience the very same issue with all related instructions (old.packages(), update.packages()) I also could do that several months ago on a different Debian computer (but with an older R version than the current one). Any hints (including what kind of information I should give to enhance the description of this issue)? Olivier. On Wed, 20 Apr 2011 10:29:17 +0200 Uwe Ligges lig...@statistik.tu-dortmund.de wrote: If the internet connection from R works, can you please verify that you do not have any R base package from an old R version in a current R library that you may have in the .libPaths() already? Uwe Ligges On 20.04.2011 09:25, Majid Einian wrote: Dear R Helpers, (I am using Ubuntu lucid and R 2.13.0 When I try to update packages I get this error: update.packages() --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done Error in ret[i, ]- c(pkgs[i], lib, desc) : number of items to replace is not a multiple of replacement length I had no problem before (case 1) but now (case 2) I cannot get it to work, googleing did not help: case 1: * connecting directly without any proxy setting (at my university) * using R 2.12.2 case 2: * connecting through proxy setting (at my workplace) * using R 2.13.0 I set the proxy in terminal too but it does not help (echo $http_proxy gives me http://192.168.0.1:8080/) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Olivier Crouzet, PhD Laboratoire de Linguistique -- EA3827 Département de Sciences du Langage UFR Lettres et Langages Université de Nantes Chemin de la Censive du Tertre - BP 81227 44312 Nantes cedex 3 France phone:(+33) 02 40 14 14 05 (lab.) (+33) 02 40 14 14 36 (office) fax: (+33) 02 40 14 13 27 e-mail: olivier.crou...@univ-nantes.fr
[R] Any tests/exams freely available with answers to test basic R knowledge
Hello, I have the responsibility of ensuring that a colleague who is just learning R knows the basics before a course where that is a requirement. The colleague has gone through a couple of tutorials so hopefully she is ok, but I would like to give her a test to gauge it. I was therefore wondering if anyone knew if there were any materials on the web that would be suitable? and is possible had both questions and answers. Many thanks Dan PS Cross-posted to http://stats.stackexchange.com -- ** Daniel Brewer, Ph.D. Institute of Cancer Research Molecular Carcinogenesis MUCRC 15 Cotswold Road Sutton, Surrey SM2 5NG United Kingdom Tel: +44 (0) 20 8722 4109 ** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the a...{{dropped:2}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Can we prepare a questionaire in R
You question has multiple answers that you can choose from and the group has been trying to help you. My suggestion would be to write it to the database using PHP and use R to extract and analyze (and write back) the data. The integration of R with web functionality is quite nascent but the Rapache seems to be working quite well. (You could check it out and post your questions to the rapache mailing list after doing some homework). You might want to try out these ideas hands-on and evaluate them for yourself. On Thu, Jun 9, 2011 at 3:39 PM, amrita gs ammasamri...@gmail.com wrote: I will explain more clearly I have an online feedback form which has all the form elements like radiobuttons,checkboxes,textareas,textboxes etc. I have to get the values of these form elements and use it for data analysis in R. It will be huge amount of data. 1) Is it possible in R to retrieve the values of these form elements directly. 2) Is there any storage mechanism in R to store the values. 2) Do i have to store the data in some files or db and then import them in R and use for data analysis. Is this better? Amrita [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lattice plot query
Dear R Group I have the following data for which I am trying to create subject wise lattice plot for a given attribute and product . though the lattice plot is generated, for some reasons that i dont understand in each plot the subject panels take a random order, I would rather want all the plots to display the subject order in the same order as how i have ordered this particular factor level. Would appreciate if someone would provide me the parameter that i need to pass to the xyplot function of library(lattice) to get this sorted out. ##the data for illustrative purpose..is as follows: MyData- structure(list(Subj = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L), .Label = c(S1, S10, S11, S12, S13, S3, S4, S5, S6, S8, S9 ), class = factor), Product = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(a, b), class = factor), Arm = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
Re: [R] 3D-plotting a 2D-matrix that contains z-values (3rd dimension)
On Thu, Jun 09, 2011 at 11:22:54AM +0200, Uwe Ligges wrote: Well, persp(x, y, z) does exactly what you asked for: it plots tha matrix z along the values given by the vectors x and y. But I don't have these vectors x and y, so I have to create them just to call persp(). And persp also needs the values only to rise. But if I have x and y, and I want to have only rising numbers for x and y,m I need somehow to create those values, and expand.grid() would not create value combinations that are only rising. (Or did I miss an option for expand.grid, which does that?) If you need to calculate z values from x and y using some function foo, outer(x, y, foo) is typically your friend. OK. And what, if I want to generate the mathcing x- and y- values for a matrix, that has x- and y implicitly, but I only have the z-values inside the matrix? So, my problem is the other way around. I don't want to calc the z for my x-and y, I want to generate the x- and y- values for my matrix of z-values. Ciao, Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 3D-plotting a 2D-matrix that contains z-values (3rd dimension)
On 09.06.2011 13:37, oliver wrote: On Thu, Jun 09, 2011 at 11:22:54AM +0200, Uwe Ligges wrote: Well, persp(x, y, z) does exactly what you asked for: it plots tha matrix z along the values given by the vectors x and y. But I don't have these vectors x and y, so I have to create them just to call persp(). And persp also needs the values only to rise. But if I have x and y, and I want to have only rising numbers for x and y,m I need somehow to create those values, and expand.grid() would not create value combinations that are only rising. (Or did I miss an option for expand.grid, which does that?) If you need to calculate z values from x and y using some function foo, outer(x, y, foo) is typically your friend. OK. And what, if I want to generate the mathcing x- and y- values for a matrix, that has x- and y implicitly, but I only have the z-values inside the matrix? So, my problem is the other way around. I don't want to calc the z for my x-and y, I want to generate the x- and y- values for my matrix of z-values. Actually you just need to pass the matrix Z if the scale of the axes is irrelevant: persp(Z) Uwe Ligges Ciao, Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] k-nn hierarchical clustering
Hi there, is there any R-function for k-nearest neighbour agglomerative hierarchical clustering? By this I mean standard agglomerative hierarchical clustering as in hclust or agnes, but with the k-nearest neighbour distance between clusters used on the higher levels where there are at least k1 distances between two clusters (single linkage is 1-nearest neighbour clustering)? Best regards, Christian *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 3D-plotting a 2D-matrix that contains z-values (3rd dimension)
On Thu, Jun 09, 2011 at 01:50:17PM +0200, Uwe Ligges wrote: On 09.06.2011 13:37, oliver wrote: On Thu, Jun 09, 2011 at 11:22:54AM +0200, Uwe Ligges wrote: Well, persp(x, y, z) does exactly what you asked for: it plots tha matrix z along the values given by the vectors x and y. But I don't have these vectors x and y, so I have to create them just to call persp(). And persp also needs the values only to rise. But if I have x and y, and I want to have only rising numbers for x and y,m I need somehow to create those values, and expand.grid() would not create value combinations that are only rising. (Or did I miss an option for expand.grid, which does that?) If you need to calculate z values from x and y using some function foo, outer(x, y, foo) is typically your friend. OK. And what, if I want to generate the mathcing x- and y- values for a matrix, that has x- and y implicitly, but I only have the z-values inside the matrix? So, my problem is the other way around. I don't want to calc the z for my x-and y, I want to generate the x- and y- values for my matrix of z-values. Actually you just need to pass the matrix Z if the scale of the axes is irrelevant: persp(Z) [...] nice. Thank you! (this also works with rgl::persp3d() which I like even more) You made my day! :) Ciao, Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Histogram
Nice graphs there. Thanks. I too am looking to make a similar plot, with a difference: I need only the top parts of the many 'histograms' (a step-function like plot for histogram/bar-plots). I already have values for heights of bars for x1-x2 intervals computed from a large survey data; I want steps to be left-continuous; and step-functions to be plotted with different lines and symbols for each of many groups. I also want to make similar plots for cumulative 'histograms/bar-plots' to compare groups. I have cumulative heights for x1-x2 intervals, left-continuous. Any idea how to do this? -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steven Kennedy Sent: Thursday, June 09, 2011 3:28 AM To: nandini_bn Cc: r-help@r-project.org Subject: Re: [R] Histogram Have a look at: http://addictedtor.free.fr/graphiques/thumbs.php One of the graph examples they have is exactly what you are after. On Wed, Jun 8, 2011 at 11:14 PM, nandini_bn nandini...@hotmail.com wrote: Hello , I am trying to create a histogram in order to compare between two groups and would like it to be similar to the figure attached. How can I generate this using R ? Thank you, Nandini http://r.789695.n4.nabble.com/file/n3582448/5634-15977-1-PB.gif -- View this message in context: http://r.789695.n4.nabble.com/Histogram-tp3582448p3582448.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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Results of CFA with Lavaan
Thanks for the help, the std.lv=TRUE command is exactly what I was looking for. As you stated, it doesn't matter in terms of overall model fit, but my client is more interested in the loadings than the factor variances. In terms of speed, it's just a very large model (7 factors, 90 observations, only ~560 subjects) with missing values, so I don't expect much in terms of speed. I think the overall conclusion for the project is that the model is poorly specified, but whether that's the model itself or the lack of samples is difficult to determine at this point. Thanks for your help, and I'll certainly be using lavaan in the future, Sam On Thu, Jun 9, 2011 at 6:19 AM, yrosseel yross...@gmail.com wrote: On 06/08/2011 11:56 PM, R Help wrote: Yes, that is the difference. For the last SEM I built I fixed the factor variances to 1, and I think that's what I want to do for the CFA I'm doing now. Does that make sense for a CFA? If you have a latent variable in your model (like a factor in CFA), you need to define its metric/scale. There are typically two ways to do this: 1) fix the variance of the latent variable to a constant (typically 1.0), or 2) fix the factor loading of one of the indicators of the factor (again to 1.0). For CFA with a single group, it should not matter which method you choose. The fit measures will be identical. Lavaan by default uses the second option. If you prefer the first (fixing the variances), you can simply add the 'std.lv=TRUE' option to the cfa() call, and lavaan will take care of the rest. I'll try figuring out how to do that with lavaan later, but my model takes so long to fit that I can't try it right now. You can use the 'verbose=TRUE' argument to monitor progress. You may also use the options se=none (no standard errors) and test=none (no test statistic) to speed things up, if you are still constructing your model. Or the model does not convergence, but I should see both the model and the data to determine the possible cause. Hope this helps, Yves Rosseel http://lavaan.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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Histogram
It's difficult to understand what exactly you're looking for without seeing an example, could you post a simple version? imgur.com is a website that lets you quickly upload pictures to share with others. I think your problem can be solved with the type='s' option to the general plot routine. Consider the following three plots, I think the third is the one you're looking for. x = runif(10,0,1) x2 = cumsum(x) plot(x2) plot(x2,type='l') plot(x2,type='s') Hope that helps, Sam Stewart On Thu, Jun 9, 2011 at 9:15 AM, Anupam anupa...@gmail.com wrote: Nice graphs there. Thanks. I too am looking to make a similar plot, with a difference: I need only the top parts of the many 'histograms' (a step-function like plot for histogram/bar-plots). I already have values for heights of bars for x1-x2 intervals computed from a large survey data; I want steps to be left-continuous; and step-functions to be plotted with different lines and symbols for each of many groups. I also want to make similar plots for cumulative 'histograms/bar-plots' to compare groups. I have cumulative heights for x1-x2 intervals, left-continuous. Any idea how to do this? -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steven Kennedy Sent: Thursday, June 09, 2011 3:28 AM To: nandini_bn Cc: r-help@r-project.org Subject: Re: [R] Histogram Have a look at: http://addictedtor.free.fr/graphiques/thumbs.php One of the graph examples they have is exactly what you are after. On Wed, Jun 8, 2011 at 11:14 PM, nandini_bn nandini...@hotmail.com wrote: Hello , I am trying to create a histogram in order to compare between two groups and would like it to be similar to the figure attached. How can I generate this using R ? Thank you, Nandini http://r.789695.n4.nabble.com/file/n3582448/5634-15977-1-PB.gif -- View this message in context: http://r.789695.n4.nabble.com/Histogram-tp3582448p3582448.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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Resources for utilizing multiple processors
On 06/08/2011 08:54 PM, Robin Jeffries wrote: Hello, I know of some various methods out there to utilize multiple processors but am not sure what the best solution would be. First some things to note: I'm running dependent simulations, so direct parallel coding is out (multicore, doSnow, etc). I'm on Windows, and don't know C. I don't plan on learning C or any of the *nix languages. My main concern deals with Multiple analyses on large data sets. By large I mean that when I'm done running 2 simulations R is using ~3G of RAM, the remaining ~3G is chewed up when I try to create the Gelman-Rubin statistic to compare the two resulting samples, grinding the process to a halt. I'd like to have separate cores simultaneously run each analysis. That will save on time and I'll have to ponder the BGR calculation problem another way. Can R temporarily use HD space to write calculations to instead of RAM? The second concern boils down to whether or not there is a way to split up dependent simulations. For example at iteration (t) I feed a(t-2) into FUN1 to generate a(t), then feed a(t), b(t-1) and c(t-1) into FUN2 to simulate b(t) and c(t). I'd love to have one core run FUN1 and another run FUN2, and better yet, a third to run all the pre-and post- processing tidbits! If FUN1 is independent of b() and c(), perhaps the example at the bottom of ?socketConnection points in a useful direction -- start one R to calculate a(t) and send the result to a socket connection, then move on to a(t+1). Start a second R to read from the socket connection and do FUN2(t), . You'll be able to overlap the computations and double throughput; the 'pipeline' could be extended with pre- and post-processing workers, too, though one would want to watch out for the complexity of managing this. Martin So if anyone has any suggestions as to a direction I can look into, it would be appreciated. Robin Jeffries MS, DrPH Candidate Department of Biostatistics UCLA 530-633-STAT(7828) [[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. -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 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] error with geomap in googleVis
Hi all, This issue occurs with googleVis 0.2.4 and RJSONIO 0.7.1. Version 0.2.5 of the googleVis package has been uploaded to CRAN two days ago and should have fixed this issue. Can you please try to update to that version, e.g. from http://cran.r-project.org/web/packages/googleVis/ Further version 0.2.5 provides new interfaces to more interactive Google charts: - gvisLineChart - gvisBarChart - gvisColumnChart - gvisAreaChart - gvisScatterChart - gvisPieChart - gvisGauge - gvisOrgChart - gvisIntensityMap Additionally a new demo 'AnimatedGeoMap' has been added which shows how a Geo Map can be animated with additional JavaScript. Thanks to Manoj Ananthapadmanabhan and Anand Ramalingam, who provided the idea and initial code. For more information and examples see: http://code.google.com/p/google-motion-charts-with-r/ I hope this helps Markus -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mike Marchywka Sent: 09 June 2011 11:19 To: mjphi...@tpg.com.au; r-h...@stat.math.ethz.ch Subject: Re: [R] error with geomap in googleVis To: r-h...@stat.math.ethz.ch From: mjphi...@tpg.com.au Date: Wed, 8 Jun 2011 10:14:01 + Subject: Re: [R] error with geomap in googleVis SNV Krishna primps.com.sg writes: Hi All, I am unable to get the plot geomap in googleVis package. data is as follows head(index.ret) country ytd 1 Argentina -10.18 2 Australia -3.42 3 Austria -2.70 4 Belgium 1.94 5 Brazil -7.16 6 Canada 0.56 map1 = gvisGeoMap(index.ret,locationvar = 'country', numvar = 'ytd') plot(map1) But it just displays a blank page, showing an error symbol at the right bottom corner. I tried demo(googleVis), it also had a similar problem. The demo showed all other plots/maps except for those geomaps. Could any one please hint me what/where could be the problem? Many thanks for the idea and support. I had never used this until yesterday but it seems to generate html. I didn't manage to get a chart to display but if you are familiar with this package and html perhaps you could look at map1$html and see if anything is obvious. One great thing about html/js is that it is human readable and you can integrate it well with other page material without much in the way of special tools. Regards, SNV Krishna [[alternative HTML version deleted]] Hi All, I have also encountered this problem. I have tested the problem in Windows XP 3.0. I have latest java and flash and I have tried both Firefox and IE (both latest k just fine. I too would like to know how to solve this problem. Kind regards, Michael Phipps __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. ** The information in this E-Mail and in any attachments is...{{dropped:27}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Classifying boolean values
Yes, it works! Thanks a lot! Now, i have another question... When i try to use the tree for predict the value of the class with the function predict the result is not a vector with TRUE or FALSE value (that is what i want for every row of my test set) but is a sort of matrix with a weight on the two possible values. For better understanding, I copy the commands and the result. I have two data frames, echoknn.train for growing the tree and echoknn.test for testing it, there is the str() result str(echoknn.test) 'data.frame': 32 obs. of 6 variables: $ age.at.heart.attack : num 55 57 68 60 54 55 66 54 55 55 ... $ pericardical.effusion: int 0 0 0 0 0 1 0 0 0 1 ... $ fractional.shortening: num 0.26 0.16 0.26 0.33 0.14 ... $ epss : num 4 22 5 8 13 ... $ lvdd : num 3.42 5.75 4.31 5.25 4.49 ... $ wall.motion.index: num 1 2.25 1 1 1.19 ... str(echoknn.train) 'data.frame': 64 obs. of 7 variables: $ age.at.heart.attack : num 70 65 51 62 63 46 63 70 79 59 ... $ pericardical.effusion: int 1 0 0 0 1 0 0 1 0 0 ... $ fractional.shortening: num 0.27 0.36 0.16 0.15 0.241 ... $ epss : num 4.7 8.8 13.2 0 10 ... $ lvdd : num 4.49 5.78 5.26 4.51 5.31 ... $ wall.motion.index: num 2 1 1 1.41 1 ... $ class: Factor w/ 2 levels TRUE,FALSE: 1 1 1 1 1 1 1 1 1 1 ... and these are the commands: echoknn.tree - tree(class ~ ., data=echoknn.train) predictedClass - predict(echoknn.tree,echoknn.test) but predicted classes are predictedClass TRUE FALSE 3 1.000 0.000 5 1.000 0.000 6 1.000 0.000 8 0.875 0.125 10 1.000 0.000 16 1.000 0.000 19 1.000 0.000 26 1.000 0.000 28 1.000 0.000 30 1.000 0.000 39 1.000 0.000 41 1.000 0.000 44 1.000 0.000 59 1.000 0.000 60 1.000 0.000 62 1.000 0.000 65 1.000 0.000 72 0.600 0.400 76 1.000 0.000 79 1.000 0.000 80 1.000 0.000 83 1.000 0.000 96 1.000 0.000 114 0.875 0.125 115 0.875 0.125 117 1.000 0.000 119 0.600 0.400 120 1.000 0.000 122 1.000 0.000 125 1.000 0.000 129 0.875 0.125 131 1.000 0.000 where I go wrong? Thanks. Fabio -- View this message in context: http://r.789695.n4.nabble.com/Classifying-boolean-values-tp3579993p3585459.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] any documents
Hi, I'm doing a textual analysis of several articles discussing the evolution of prices in order to give a forecast. if someone can give me a clear approach to this knowing that I work on the package tm. Thank you very much -- View this message in context: http://r.789695.n4.nabble.com/any-documents-tp3584961p3584961.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] booklet on using R for time series analysis
Dear all, I've written a small booklet on using R for time series analysis, available here : http://a-little-book-of-r-for-time-series.readthedocs.org/ http://a-little-book-of-r-for-time-series.readthedocs.org/ It is just a little booklet for beginners like myself (I am studying Stats, and mostly wrote it to help myself study and understand this material), but thought it could possibly be useful to some other Stats/R beginners.. I would be grateful for any suggestions for improvements. Kind Regards, Avril Avril Coghlan Cork, Ireland [[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] Histogram
I'm getting the impression that you're not overly familiar with R? If so then you should really try and read some of the manuals from r-project.org. R is a very complex language and has a steep learning curve. That being said, the command takes a 2xK array, where K is the number of observations you have, and 2 is the number of categories (in your case I picked two because your example has intervention and control). The first two lines in my example were just to create some sample data to work with. For the graph example you provided, you would create a 2x13 matrix, called dat, and then use the command barplot(dat,beside=TRUE) In terms of setting the x and y axis labels, and the tick-marks as they are defined in the figure, see the options provided by ?barplot, or type help.start() and search for barplot from there. And to Rolf: I understand the frustration with posts that are simple like this, but just because your type RTFM instead of the full sentence doesn't mean you're not swearing at strangers on the Internet. Try being a little more constrained in your responses. Hope that helps, Sam On Thu, Jun 9, 2011 at 1:38 AM, Nandini B nandini...@hotmail.com wrote: Hi Sam, This is exactly what I wanted. Could you please explain the code ? what does 15, 0.65 and 0.25 stand for ? Nandini Date: Wed, 8 Jun 2011 19:16:06 -0300 Subject: Re: [R] Histogram From: rhelp.st...@gmail.com To: nandini...@hotmail.com CC: r-help@r-project.org I think the command you want is barplot x = rbinom(10,15,0.65) y = rbinom(10,15,0.25) barplot(rbind(x,y),beside=TRUE) Sam On Wed, Jun 8, 2011 at 10:14 AM, nandini_bn nandini...@hotmail.com wrote: Hello , I am trying to create a histogram in order to compare between two groups and would like it to be similar to the figure attached. How can I generate this using R ? Thank you, Nandini http://r.789695.n4.nabble.com/file/n3582448/5634-15977-1-PB.gif -- View this message in context: http://r.789695.n4.nabble.com/Histogram-tp3582448p3582448.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] Adapting R code for different traps
Hi all, My code: temp-outer(release.days,collection.days,'-') temp-ifelse(temp=0,NA,temp) release.diff-apply(temp,2,max,na.rm=TRUE) works for one trap and does what I want. That is, it determines the time difference between the collection date of a trap and date of parasitoid release immediately before it, excluding releases that occurred on the same day as the collection. The code above, however, does not give the correct values - those that I have calculated for each trap individually. I am wondering how I can adapt this code for each trap ie. it uses only data associated with a particular trap ID. For instance: temp-outer(release.days[Trap],collection.days.2[Trap],'-') temp-ifelse(temp=0,NA,temp) release.diff.1-apply(temp,2,max,na.rm=TRUE) calculates the same value for each trap, irrespective of collection day. Thanks in advance Ben -- View this message in context: http://r.789695.n4.nabble.com/Adapting-R-code-for-different-traps-tp3585215p3585215.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] (no subject)
# # Generate the figures (on screen) # # Image generation - function definition pic_onscr-function(matrix, title, cex_val=1) + {x11() + par(mgp=c(5,2,0), # axis margins + # (title, labels, line) + mar=c(7,4,4,2), # plot margins (b,l,t,r) + las=1) # horizontal labels + plot(matrix, # data to plot + cex=cex_val, # font size + dimen=2 # dimensions to plot + ) + title(main=title) # title of plot + } # Plot LDA scores with sample names pic_onscr(lda_result,Linear Discriminant Analysis) Error in plot(matrix, cex = cex_val, dimen = 2) : error in evaluating the argument 'x' in selecting a method for function 'plot': Error: object 'lda_result' not found # For plotting with larger font size, use a different value of cex: # pic_onscr(lda_result, LDA Plot, dimen=2, cex=3) # # Generate figures as image files # # (Uncomment blocks as necessary) # jpeg # # pic_jpg-function(filename, matrix, title, cex_val=1) # {# Start jpeg device with basic settings # jpeg(filename, # quality=100, # image quality (percent) # bg=white, # background colour # res=300, # image resolution (dpi) # units=in, width=8.3, height=5.8 # image dimensions (inches) # ) # par(mgp=c(5,2,0), # axis margins # # (title, labels, line) # mar=c(7,4,4,2), # plot margins (b,l,t,r) # las=1 # horizontal labels # ) # # Draw the plot # plot(matrix, # data to plot # cex=cex_val, # font size # dimen=2 # dimensions to plot # ) # title(main=title) # title of plot # # dev.off() # } # pic_jpg(LDA.jpg, lda_result, Linear Discriminant Analysis) # end jpeg # # png # # pic_png-function(filename, matrix, title, cex_val=1) # {# Start png device with basic settings # png(filename, # bg=white, # background colour # res=300, # image resolution (dpi) # units=in, width=8.3, height=5.8 # image dimensions (inches) # ) # par(mgp=c(5,2,0), # axis margins # # (title, labels, line) # mar=c(7,4,4,2), # plot margins (b,l,t,r) # las=1 # horizontal labels # ) # # Draw the plot # plot(matrix, # data to plot # cex=cex_val, # font size # dimen=2 # dimensions to plot # ) # title(main=title) # title of plot # # dev.off() # } # pic_png(LDA.png, lda_result, Linear Discriminant Analysis) # end png # # tiff # # pic_tiff-function(filename, matrix, title, cex_val=1) # {# Start tiff device with basic settings # tiff(filename, # bg=white, # background colour # res=300, # image resolution (dpi) # units=in, width=8.3, height=5.8, # image dimensions (inches) # compression=none # image compression # # (one of none, lzw, zip) # ) # par(mgp=c(5,2,0), # axis margins # # (title, labels, line) # mar=c(7,4,4,2), # plot margins (b,l,t,r) # las=1 # horizontal labels # ) # # Draw the plot # plot(matrix, # data to plot # cex=cex_val, # font size # dimen=2 # dimensions to plot # ) # title(main=title) # title of plot # # dev.off() # } # pic_tiff(LDA.tif, lda_result, Linear Discriminant Analysis) # end tiff # could you show me howto use the LDA.R.. the graph not display [[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] assign a cluster based on a variable
Hi Uwe, thanks for your help. I didn't know that function (mea culpa)... With merge() it works what I want to do. But I'm still interessted, for a learning purpose, why the loop didn't work. So here are the str() results: str(cluster) int [1:18, 1:2] 12051000 12052000 12053000 12054000 1206 12061000 12062000 12063000 12064000 12065000 ... - attr(*, dimnames)=List of 2 ..$ : chr [1:18] 1 2 3 4 ... ..$ : chr [1:2] Kreis Cluster str(KreisSA) num [1:2302, 1:2] 12069000 12072000 12067000 1206 1207 ... - attr(*, dimnames)=List of 2 ..$ : NULL ..$ : chr [1:2] Kreis Cluster Thanks for your help. On Tue, 07 Jun 2011 22:49:04 +0200, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 07.06.2011 16:24, Dominik P.H. Kalisch wrote: Hi, I have two matrices of the following form: cluster (n=18): 12062 1 12063 2 12064 2 12065 3 12066 5 KreisSA (n=2304) 12062 12062 12067 12065 12063 12067 I try to assign the cluster[,2] to KreisSAa by the follwoing loop: n - nrow(cluster) KreisSAa - numeric() for(i in 1:n){ KreisSAa[KreisSA == cluster[i,1]] - cluster[i,2] } The result is a vector of the length n=4608 where after the entry 2304 are just NA's Has someone an idea what I do wrong? Since we do not know the structure of your objects, we cannot say easily. You may want to provide str(cluster) and str(KreisSA) Anyway: I'd just use merge() Uwe Ligges Thanks for your help. 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rtools - The setup files are corrupted message when trying to install
Hi, Apologies if this is the wrong list to be sending this question to. I am trying to install a copy of the R tools required to create / compile packages on windows. After downloading Rtools from http://www.murdoch-sutherland.com/Rtools/ windows keeps complaining that The setup files are corrupted. This has happened with both the Rtools213.exe and the Rtools212.exe downloads, and on both 32 and 64 bit Windows 7. Does any one know what I might be doing incorrectly, or where else I should be downloading them from. Cheers Martyn The version of R that I want to eventually use these tools with is platform x86_64-pc-mingw32 arch x86_64 os mingw32 system x86_64, mingw32 status major 2 minor 13.0 year 2011 month 04 day13 svn rev55427 language R version.string R version 2.13.0 (2011-04-13) The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. Th...{{dropped:4}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] what is the mistake?? the coding still not function. no result display
#lda.r # #Author:Amsha Nahid, Jairus Bowne, Gerard Murray #Purpose:Perform Linear Discriminant Analysis (LDA) # #Input:Data matrix as specified in Data-matrix-format.pdf #Output:LDA plot # #Notes:Missing values (if any) are replaced by the half of the lowest # value in the entire data matrix. # #Load necessary libraries, and install them if they are missing # tryCatch(library(MASS), error=function(err) + # if this produces an error: + install.packages(MASS,repos=http://cran.ms.unimelb.edu.au/;)) # #Prepare the data matrix # # Read in the .csv file data-read.csv(C:/Users/nadya/Desktop/praktikal UTM/TASK2/new(40data)S2 100 EMS EPI 300-399.csv, sep=,, row.names=1, header=TRUE) # Get groups information groups-data[,1] # Remove groups for data processing lda_data-data[,-1] # Replace any missing values (see Notes) lda_data[is.na(lda_data)]-0.5*(min(lda_data,na.rm=TRUE)) # #Perform the LDA # lda_result-lda(lda_data,groups) Error in lda.default(x, grouping, ...) : variables 1 3 5 8 10 15 17 20 27 29 34 appear to be constant within groups # #Generate the figures (on screen) # #Image generation - function definition pic_onscr-function(matrix, title, cex_val=1) + {x11() + par(mgp=c(5,2,0), # axis margins + # (title, labels, line) + mar=c(7,4,4,2), # plot margins (b,l,t,r) + las=1) # horizontal labels + plot(matrix,# data to plot + cex=cex_val,# font size + dimen=2 # dimensions to plot + ) + title(main=title) # title of plot + } # Plot LDA scores with sample names pic_onscr(lda_result,Linear Discriminant Analysis) Error in plot(matrix, cex = cex_val, dimen = 2) : error in evaluating the argument 'x' in selecting a method for function 'plot': Error: object 'lda_result' not found # For plotting with larger font size, use a different value of cex: # pic_onscr(lda_result, LDA Plot, dimen=2, cex=3) # #Generate figures as image files # #(Uncomment blocks as necessary) # jpeg # # pic_jpg-function(filename, matrix, title, cex_val=1) # {# Start jpeg device with basic settings # jpeg(filename, # quality=100,# image quality (percent) # bg=white, # background colour # res=300,# image resolution (dpi) # units=in, width=8.3, height=5.8 # image dimensions (inches) # ) # par(mgp=c(5,2,0), # axis margins # # (title, labels, line) # mar=c(7,4,4,2), # plot margins (b,l,t,r) # las=1 # horizontal labels # ) # # Draw the plot # plot(matrix,# data to plot # cex=cex_val,# font size # dimen=2 # dimensions to plot # ) # title(main=title) # title of plot # # dev.off() # } # pic_jpg(LDA.jpg, lda_result, Linear Discriminant Analysis) # end jpeg # # png # # pic_png-function(filename, matrix, title, cex_val=1) # {# Start png device with basic settings # png(filename, # bg=white, # background colour # res=300,# image resolution (dpi) # units=in, width=8.3, height=5.8 # image dimensions (inches) # ) # par(mgp=c(5,2,0), # axis margins # # (title, labels, line) # mar=c(7,4,4,2), # plot margins (b,l,t,r) # las=1 # horizontal labels # ) # # Draw the plot # plot(matrix,# data to plot # cex=cex_val,# font size # dimen=2 # dimensions to plot # ) # title(main=title) # title of plot # # dev.off() # } # pic_png(LDA.png, lda_result, Linear Discriminant Analysis) # end png # # tiff # # pic_tiff-function(filename, matrix, title, cex_val=1) # {# Start tiff device with basic settings # tiff(filename, # bg=white, # background colour # res=300,# image resolution (dpi) # units=in, width=8.3, height=5.8, # image dimensions (inches) #
Re: [R] assign a cluster based on a variable
On 09.06.2011 14:31, Dominik P.H. Kalisch wrote: Hi Uwe, thanks for your help. I didn't know that function (mea culpa)... With merge() it works what I want to do. But I'm still interessted, for a learning purpose, why the loop didn't work. So here are the str() results: str(cluster) int [1:18, 1:2] 12051000 12052000 12053000 12054000 1206 12061000 12062000 12063000 12064000 12065000 ... - attr(*, dimnames)=List of 2 ..$ : chr [1:18] 1 2 3 4 ... ..$ : chr [1:2] Kreis Cluster str(KreisSA) num [1:2302, 1:2] 12069000 12072000 12067000 1206 1207 ... - attr(*, dimnames)=List of 2 ..$ : NULL ..$ : chr [1:2] Kreis Cluster So KreisSA is a 2 column matrix rather than a vector. Hence you also get 2 column matrix (logical) from the comparison KreisSA == cluster[i,1] and so you are assigning into KreisSAa. Uwe Ligges Thanks for your help. On Tue, 07 Jun 2011 22:49:04 +0200, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 07.06.2011 16:24, Dominik P.H. Kalisch wrote: Hi, I have two matrices of the following form: cluster (n=18): 12062 1 12063 2 12064 2 12065 3 12066 5 KreisSA (n=2304) 12062 12062 12067 12065 12063 12067 I try to assign the cluster[,2] to KreisSAa by the follwoing loop: n- nrow(cluster) KreisSAa- numeric() for(i in 1:n){ KreisSAa[KreisSA == cluster[i,1]]- cluster[i,2] } The result is a vector of the length n=4608 where after the entry 2304 are just NA's Has someone an idea what I do wrong? Since we do not know the structure of your objects, we cannot say easily. You may want to provide str(cluster) and str(KreisSA) Anyway: I'd just use merge() Uwe Ligges Thanks for your help. 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] assign a cluster based on a variable
Oh, right. Now I see. Thanks for your help. Dominik On Thu, 09 Jun 2011 15:33:43 +0200, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 09.06.2011 14:31, Dominik P.H. Kalisch wrote: Hi Uwe, thanks for your help. I didn't know that function (mea culpa)... With merge() it works what I want to do. But I'm still interessted, for a learning purpose, why the loop didn't work. So here are the str() results: str(cluster) int [1:18, 1:2] 12051000 12052000 12053000 12054000 1206 12061000 12062000 12063000 12064000 12065000 ... - attr(*, dimnames)=List of 2 ..$ : chr [1:18] 1 2 3 4 ... ..$ : chr [1:2] Kreis Cluster str(KreisSA) num [1:2302, 1:2] 12069000 12072000 12067000 1206 1207 ... - attr(*, dimnames)=List of 2 ..$ : NULL ..$ : chr [1:2] Kreis Cluster So KreisSA is a 2 column matrix rather than a vector. Hence you also get 2 column matrix (logical) from the comparison KreisSA == cluster[i,1] and so you are assigning into KreisSAa. Uwe Ligges Thanks for your help. On Tue, 07 Jun 2011 22:49:04 +0200, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 07.06.2011 16:24, Dominik P.H. Kalisch wrote: Hi, I have two matrices of the following form: cluster (n=18): 12062 1 12063 2 12064 2 12065 3 12066 5 KreisSA (n=2304) 12062 12062 12067 12065 12063 12067 I try to assign the cluster[,2] to KreisSAa by the follwoing loop: n- nrow(cluster) KreisSAa- numeric() for(i in 1:n){ KreisSAa[KreisSA == cluster[i,1]]- cluster[i,2] } The result is a vector of the length n=4608 where after the entry 2304 are just NA's Has someone an idea what I do wrong? Since we do not know the structure of your objects, we cannot say easily. You may want to provide str(cluster) and str(KreisSA) Anyway: I'd just use merge() Uwe Ligges Thanks for your help. 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rtools - The setup files are corrupted message when trying to install
Still fine when downloading from my location ... Uwe Ligges On 09.06.2011 15:12, Martyn Byng wrote: Hi, Apologies if this is the wrong list to be sending this question to. I am trying to install a copy of the R tools required to create / compile packages on windows. After downloading Rtools from http://www.murdoch-sutherland.com/Rtools/ windows keeps complaining that The setup files are corrupted. This has happened with both the Rtools213.exe and the Rtools212.exe downloads, and on both 32 and 64 bit Windows 7. Does any one know what I might be doing incorrectly, or where else I should be downloading them from. Cheers Martyn The version of R that I want to eventually use these tools with is platform x86_64-pc-mingw32 arch x86_64 os mingw32 system x86_64, mingw32 status major 2 minor 13.0 year 2011 month 04 day13 svn rev55427 language R version.string R version 2.13.0 (2011-04-13) The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. Th...{{dropped:4}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Adapting R code for different traps
Hi Ben, Unfortunately, I left the usb cable for my crystal ball at home, and thus have no idea how your data is organized. Could you post an example along with what you expect the output to be? Jon On Thu, Jun 9, 2011 at 7:22 AM, bjmjarrett bjmjarr...@gmail.com wrote: Hi all, My code: temp-outer(release.days,collection.days,'-') temp-ifelse(temp=0,NA,temp) release.diff-apply(temp,2,max,na.rm=TRUE) works for one trap and does what I want. That is, it determines the time difference between the collection date of a trap and date of parasitoid release immediately before it, excluding releases that occurred on the same day as the collection. The code above, however, does not give the correct values - those that I have calculated for each trap individually. I am wondering how I can adapt this code for each trap ie. it uses only data associated with a particular trap ID. For instance: temp-outer(release.days[Trap],collection.days.2[Trap],'-') temp-ifelse(temp=0,NA,temp) release.diff.1-apply(temp,2,max,na.rm=TRUE) calculates the same value for each trap, irrespective of collection day. Thanks in advance Ben -- View this message in context: http://r.789695.n4.nabble.com/Adapting-R-code-for-different-traps-tp3585215p3585215.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. -- === Jon Daily Technician === #!/usr/bin/env outside # It's great, trust me. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Histogram
Thanks. That is the type of graph I want, except with more options and combinations. Here is an example with percent on Y-axis: http://i.imgur.com/pr8M3.jpg This combines both 'histogram' and 'cumulative histogram' type of data. In place of straight lines connecting the points I want step-functions. I already have heights (y) and end points of x intervals in a file (except for the last, x1-x2, where I only have x1). The points are heights, left-continuous (they are at the end of the x1-x2 interval, and do not include x2). -Original Message- From: R Help [mailto:rhelp.st...@gmail.com] Sent: Thursday, June 09, 2011 5:58 PM To: Anupam Cc: Steven Kennedy; r-help@r-project.org Subject: Re: [R] Histogram It's difficult to understand what exactly you're looking for without seeing an example, could you post a simple version? imgur.com is a website that lets you quickly upload pictures to share with others. I think your problem can be solved with the type='s' option to the general plot routine. Consider the following three plots, I think the third is the one you're looking for. x = runif(10,0,1) x2 = cumsum(x) plot(x2) plot(x2,type='l') plot(x2,type='s') Hope that helps, Sam Stewart On Thu, Jun 9, 2011 at 9:15 AM, Anupam anupa...@gmail.com wrote: Nice graphs there. Thanks. I too am looking to make a similar plot, with a difference: I need only the top parts of the many 'histograms' (a step-function like plot for histogram/bar-plots). I already have values for heights of bars for x1-x2 intervals computed from a large survey data; I want steps to be left-continuous; and step-functions to be plotted with different lines and symbols for each of many groups. I also want to make similar plots for cumulative 'histograms/bar-plots' to compare groups. I have cumulative heights for x1-x2 intervals, left-continuous. Any idea how to do this? -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steven Kennedy Sent: Thursday, June 09, 2011 3:28 AM To: nandini_bn Cc: r-help@r-project.org Subject: Re: [R] Histogram Have a look at: http://addictedtor.free.fr/graphiques/thumbs.php One of the graph examples they have is exactly what you are after. On Wed, Jun 8, 2011 at 11:14 PM, nandini_bn nandini...@hotmail.com wrote: Hello , I am trying to create a histogram in order to compare between two groups and would like it to be similar to the figure attached. How can I generate this using R ? Thank you, Nandini http://r.789695.n4.nabble.com/file/n3582448/5634-15977-1-PB.gif -- View this message in context: http://r.789695.n4.nabble.com/Histogram-tp3582448p3582448.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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] set.seed and for loop
Dear All, This is hard to describe so I made a simple example. set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } Let's call a data set runif(50). While the for loop is running, 100 data sets are generated. I want to restore 23th data set (the data set generated in 23th for loop) without the loop. I've tried set.seed(1023) runif(50) but this is different data from the data set gotten from 23th for loop. How can I get 23th data set without the loop? Thank you, Soyeon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with a if statement inside a function
I have a really long functions, and at the end of the function, I am using a if statement to tag certain keywords based on whether they have certain values contained in them. However, the if statement doesn't seem to work. When I had split up the commands into various functions, it worked fine, but I'm not sure what going on now that it's combined into a single function. myfunc - function(lst) { options(max.print=10) setwd(~/Desktop/RStuff) state - c(Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Deleware, Florida, Georgia, Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Ohio, Oklahoma, Oregon, Pennsylvania, Rhode Island, South Carolina, South Dakota, Tenessee, Texas, Utah, Vermont, Virginia, Washington, West Virginia, Wisconsin, Wyoming, AL, AK, AZ, AR, CA, CO, CT, DE, FL, GA, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI, SC, SD, TN, TX, UT, VT, VA, WA, WV, WI, WY) inscompany - c(21st Century, AAA, Alliance United, Allied, American Automobile Association, AARP, AIG, American International Group, Allstate, All State, All-state, American States, American Income, AMICA, American Family, ANPAC, American National Property and Casualty, AutoOne, Auto One, Auto-One, Auto-Owners, Auto Owners, AutoOwners, Balboa, Chubb Corporation, Commerce, Conseco, Country Financial, DeerBrook, Eastwood, East Wood, East-Wood, Encompass, Erie, Esurance, E-surance, Evergreen, Farmers, Geico, General, GMAC, Hanover, Hartford, Infinity, Kemper, Liberty Mutual, Loya, Mercury, MetLife, Met Life, Met-Life, Mid-Century, Mid Century, Nationwide, OldAmerican, Old-American, Old American, Pemco, Progressive, Regence Group, Reliance, Response, Safe, Safe Auto, SafeAuto, Safe-Auto, Safeco, SafeCo, Safeway, Santa Fe, Santa-Fe, SantaFe, Sentry, Shelter, Standard, State Farm, StateFarm, State-Farm, Titan, Travelers, Unitrin, USAA, Wells Fargo, Western, Westfield, West Coast, West-Coast, WestCoast) agency - c(Eastwood, Tompkins, ABC, United, Trusted Choice) city = c(New York City, Los Angeles, Chicago, Houston, Philadelphia, Phoenix, San Diego, San Antonio, Dallas, Detroit, San Jose, Indianapolis, Jacksonville, San Francisco, Columbus, Austin, Memphis, Baltimore, Milwaukee, Fort Worth, Charlotte, El Paso, Boston, Seattle, Washington DC, Denver, Nashville, Portland, Oklahoma City, Las Vegas, Tucson, Long Beach, Albuquerque, New Orleans, Cleveland, Fresno, Sacramento, Kansas City, Virginia Beach, Mesa, Atlanta, Omaha, Oakland, Tulsa, Honolulu, Miami, Minneapolis, Colorado Springs, Arlington, Wichita, Santa Ana, Anaheim, St. Louis, Pittsburgh, Tampa, Cincinnati, Raleigh, Toledo, Aurora, Buffalo, Riverside, St. Paul, Corpus Christi, Newark, Stockton, Bakersfield, Anchorage, Lexington, Louisville, St. Petersburg, Plano, Norfolk, Birmingham, Lincoln, Glendale, Greensboro, Hialeah, Baton Rouge, Fort Wayne, Madison, Garland, Scottsdale, Rochester, Henderson, Akron, Chandler, Chesapeake, Modesto, Lubbock, Fremont, Glendale, Montgomery, Orlando, Chula Vista, Durham, Shreveport, Laredo, Yonkers, Tacoma, Anaconda, Butte, Suffolk, Buckeye, Augusta, Cusseta, Huntsville, Boulder City, Goodyear, Hibbing, Norman, Sierra Vista, Georgetown, Carson City, Chattanooga, Lynchburg, Columbia, Mobile, Athens, Little Rock, Yuma, Babbitt, Cape Coral, Abilene, Palmdale, Jackson, Plymouth, Clarksville, Palm Springs, Lancaster, Ellsworth, Knoxville, Amarillo, Dothan, Oak Ridge, Edmond, Beaumont, Waco, Port Arthur, Toledo, Brownsville, El Reno, Henderson, Jonesboro, Caribou, Ellsworth, Fort Wayne, Independence, Des Moines, Lawton, Rome, North Port, Savannah, Lincoln, Apple Valley, Springfield, Victorville, Marana, Eloy, Sarasota, Concord, Grand Rapids, Mission Viejo, New Haven, McAllen, Worcester, Syracuse, Scranton, Flint, Harrisburg, Poughkeepsie, Spokane, Cape Coral, Fort Wayne, Santa Rosa, Ann Arbor, South Bend, Daytona Beach, Peoria, Atlantic City, Antioch, Thousand Oaks) cityst = c(New York City, NY, Los Angeles, CA, Chicago, IL, Houston, TX, Philadelphia, PA, Phoenix, AR, San Diego, CA, San Antonio, TX, Dallas, TX, Detroit, MI, San Jose, CA, Indianapolis, IN, Jacksonville, FL, San Francisco, CA, Columbus, OH, Austin, TX, Memphis, TN, Baltimore, MD,
Re: [R] Rtools - The setup files are corrupted message when trying to install
FYI, Rtools212.exe: File size: 44,224,666 bytes MD5:15ce69dcfc989c43825bedeaa8389aa6 Rtools213.exe: File size: 38,122,354 bytes MD5: 09052655da7c6e8a81f2d398ed6004b5 /Henrik On Thu, Jun 9, 2011 at 6:12 AM, Martyn Byng martyn.b...@nag.co.uk wrote: Hi, Apologies if this is the wrong list to be sending this question to. I am trying to install a copy of the R tools required to create / compile packages on windows. After downloading Rtools from http://www.murdoch-sutherland.com/Rtools/ windows keeps complaining that The setup files are corrupted. This has happened with both the Rtools213.exe and the Rtools212.exe downloads, and on both 32 and 64 bit Windows 7. Does any one know what I might be doing incorrectly, or where else I should be downloading them from. Cheers Martyn The version of R that I want to eventually use these tools with is platform x86_64-pc-mingw32 arch x86_64 os mingw32 system x86_64, mingw32 status major 2 minor 13.0 year 2011 month 04 day 13 svn rev 55427 language R version.string R version 2.13.0 (2011-04-13) The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. Th...{{dropped:4}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] set.seed and for loop
There are certainly people that would know how the random functions work better than I, but I believe you would need to simulate 22 datasets and then get the 23rd dataset. So to restore the 23rd: set.seed(1001) for(i in 1:22){ garbage = runif(50) } data[[23]] = runif(50) Hope that helps, Sam On Thu, Jun 9, 2011 at 12:14 PM, Soyeon Kim yunni0...@gmail.com wrote: Dear All, This is hard to describe so I made a simple example. set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } Let's call a data set runif(50). While the for loop is running, 100 data sets are generated. I want to restore 23th data set (the data set generated in 23th for loop) without the loop. I've tried set.seed(1023) runif(50) but this is different data from the data set gotten from 23th for loop. How can I get 23th data set without the loop? Thank you, Soyeon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Results of CFA with Lavaan
Ok, I think this is the last question I have. My model is producing an estimate of intercepts for my variables along with my loadings. From the documentation it appears that this is controlled by the meanstructure option in cfa. It says that setting it to TRUE includes the intercepts, and setting it to default means thatthe value is set based on the user-specified model, and/or the values of other arguments. I've included my model specification below, and I would prefer not to fit intercepts, but setting it to FALSE does not seem to achieve this. Thanks, Sam F1 =~ reFDE + ReFUIDGreg + reFDRwithDDRV + reparD + reparDR + reparRisk + reWDD + reWDH + reWSP + reWDIS + reWCell + reWFAT + reAanx + reDanx + reDstress + reAstress F2 =~ reSI1 + reSI2 + reSI3 + reSI4 + reSimDE + reSimDD + reSimDrug + reSimDRD F3 =~ RENOINTEND + RETRYNOTD + RENOSTARTD + REUSEDD + REWILLD1 + REDU1 + REDA1 + RERIDE1 + REAFTER1 + REUSEC1 + REUSESP1 + REUM1 + REABUSE1 + RESB1 + REMIGHT1 F4 =~ retrydrink + RetryDope + reNoD + reLeaveD + reDeDR + reDopeNo + reDopeleave + reDopeDD + reP3D F5 =~ reP3DA + reP3DD + reP3DRD + reP3Equip + reP3UC + reP3SP + reP3UM + reP3Abuse + reP3SB + reP3helmet + reP1DADR + reP1DRUG + reP1SP F6 =~ reinjwhileDU + reinjwhileWDUDRV + reinjwhileDA + reinjwhileDRafterD + reinjwhileUcrack + reinjwhileUM + reinjwhileabusePRDG + reinjwhilenoSB + reinjwhilenohelmet F7 =~ relikeDR + relikeSP + relikeDIS + relikeCELL + relikeDROW + relikeDRUG + restupid + reimmature + takerisksFthinkcool + takeriskFthinkIMP + takeriskFthinkbrave + takeriskFthinkexciting + reSELF + reNORISK + reNOPERSON + reNOCONSE + reWRONG + reGEAR + reCONSEQ + reSUCES On Thu, Jun 9, 2011 at 6:19 AM, yrosseel yross...@gmail.com wrote: On 06/08/2011 11:56 PM, R Help wrote: Yes, that is the difference. For the last SEM I built I fixed the factor variances to 1, and I think that's what I want to do for the CFA I'm doing now. Does that make sense for a CFA? If you have a latent variable in your model (like a factor in CFA), you need to define its metric/scale. There are typically two ways to do this: 1) fix the variance of the latent variable to a constant (typically 1.0), or 2) fix the factor loading of one of the indicators of the factor (again to 1.0). For CFA with a single group, it should not matter which method you choose. The fit measures will be identical. Lavaan by default uses the second option. If you prefer the first (fixing the variances), you can simply add the 'std.lv=TRUE' option to the cfa() call, and lavaan will take care of the rest. I'll try figuring out how to do that with lavaan later, but my model takes so long to fit that I can't try it right now. You can use the 'verbose=TRUE' argument to monitor progress. You may also use the options se=none (no standard errors) and test=none (no test statistic) to speed things up, if you are still constructing your model. Or the model does not convergence, but I should see both the model and the data to determine the possible cause. Hope this helps, Yves Rosseel http://lavaan.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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] set.seed and for loop
On 09/06/2011 11:14 AM, Soyeon Kim wrote: Dear All, This is hard to describe so I made a simple example. set.seed(1001) total- 0 data- vector(list, 30) for(i in 1:30) { data[[i]]- runif(50) } Let's call a data set runif(50). While the for loop is running, 100 data sets are generated. I want to restore 23th data set (the data set generated in 23th for loop) without the loop. I've tried set.seed(1023) runif(50) but this is different data from the data set gotten from 23th for loop. How can I get 23th data set without the loop? You can't. To get the 23rd value again, set the seed to 1001, run the loop 22 times, then the next one will be the 23rd. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cairoDevice on Windows: succesful installation but does not load
Hi! I've tried to install playwith on Windows XP but, install.packages(cairoDevice) trying URL 'http://cran.at.r-project.org/bin/windows/contrib/2.13/cairoDevice_2.15.zip' Content type 'application/zip' length 52371 bytes (51 Kb) opened URL downloaded 51 Kb package 'cairoDevice' successfully unpacked and MD5 sums checked The downloaded packages are in d:\Documents and Settings\_llp_gr_interfase.UAB\Configuración local\Temp\RtmpOo5UAa\downloaded_packages require(playwith) Loading required package: playwith Loading required package: cairoDevice Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'C:/Archivos de programa/R/R-2.13.0/library/cairoDevice/libs/i386/cairoDevice.dll': LoadLibrary failure: No se puede encontrar el módulo especificado. Failed with error: ‘package 'cairoDevice' could not be loaded’ I've also tried installing cairoDevice but get the same problem. The dll 'C:/Archivos de programa/R/R-2.13.0/library/cairoDevice/libs/i386/cairoDevice.dll' is there despite the system claiming it's not sessionInfo() R version 2.13.0 (2011-04-13) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=Catalan_Spain.1252 LC_CTYPE=Catalan_Spain.1252 LC_MONETARY=Catalan_Spain.1252 LC_NUMERIC=C [5] LC_TIME=Catalan_Spain.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.19-23 rgdal_0.6-33raster_1.8-31 geoR_1.6-35 sp_0.9-82 loaded via a namespace (and not attached): [1] grid_2.13.0 tools_2.13.0 Thanks Agus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] set.seed and for loop
What about: set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } set.seed(1001) data[[23]] - runif(50) HTH Samuel -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Soyeon Kim Sent: 09 June 2011 16:15 To: r-help Subject: [R] set.seed and for loop Dear All, This is hard to describe so I made a simple example. set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } Let's call a data set runif(50). While the for loop is running, 100 data sets are generated. I want to restore 23th data set (the data set generated in 23th for loop) without the loop. I've tried set.seed(1023) runif(50) but this is different data from the data set gotten from 23th for loop. How can I get 23th data set without the loop? Thank you, Soyeon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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] Adapting R code for different traps
The below works for one trap. Surely there is a quick way to scale it to all of the traps? temp.ACAP1-outer(release.days[Trap==ACAP1],collection.days.2[Trap==ACAP1],'-') temp.ACAP1-ifelse(temp.ACAP1=0,NA,temp.ACAP1) diff.ACAP1-apply(temp.ACAP1,2,max,na.rm=TRUE) Thanks Ben -- View this message in context: http://r.789695.n4.nabble.com/Adapting-R-code-for-different-traps-tp3585215p3585531.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] Adapting R code for different traps
Hi Jon, Sorry about the lack of information. I'll give the data from one of my traps: (nb. all of the data for each trap is referenced to the start day of the trap. ie ACAP1 started collecting at day 0 but parasitoid releases occurred 266, 259, 225 etc days before collecting took place) Trapcollection.days.2 release.days days.since.last.release ACAP1 0 -266 -12 # this tells me that at day 0 the last parasitoid release occurred 12 days beforehand, and so on... ACAP1 9 -259-1 ACAP1 28 -225 -20 ACAP1 41 -216 -13 ACAP1 77 -28-36 ACAP1 97 -12-20 ACAP1 1060 -1 ACAP1 1258 -20 ACAP1 146 28-21 ACAP1 168 41-43 ACAP1 195 77-70 ACAP1 217 97-92 ACAP1 259 105-134 ACAP1 288 125-163 ACAP1 311 288 -23 ACAP1 337 311 -26 ACAP1 378 337 -41 ACAP1 400 378 -22 ACAP1 440 400 -26 ACAP1 464 414 -14 The output I want is days.since.last.release for all of the traps I have. Thanks so much, Ben -- View this message in context: http://r.789695.n4.nabble.com/Adapting-R-code-for-different-traps-tp3585215p3585823.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] Can we prepare a questionaire in R
On Thu, Jun 9, 2011 at 11:09 AM, amrita gs ammasamri...@gmail.com wrote: I will explain more clearly I have an online feedback form which has all the form elements like radiobuttons,checkboxes,textareas,textboxes etc. I have to get the values of these form elements and use it for data analysis in R. It will be huge amount of data. 1) Is it possible in R to retrieve the values of these form elements directly. 2) Is there any storage mechanism in R to store the values. 2) Do i have to store the data in some files or db and then import them in R and use for data analysis. Is this better? Are you analysing individual forms independently and giving rapid feedback? For example, a user puts some numbers in a box, clicks 'fit', and expects to see some parameters back and maybe a plot? Then you need R integrated with the server. Or are you doing summaries of many form submissions perhaps weekly or at the end of the study period? There's a problem with using R to store values coming from a web form - concurrency. Suppose two people submit the form at more or less the same time. If your web server back-end is using R to save the data you need to make sure the two processes aren't trying to write to the same file at the same time or you'll corrupt it. Databases such as Postgres sort this out by having clever locking mechanisms. If you are doing 'batch' analysis like this then you don't need R involved with the server at all, and things are much simpler. Just use a web server back end that suits you (java servlet, PHP, python web application framework) that takes the form data and adds it to a data base such as Postgres or MySQL. Then to do the analysis, R can get the data from such DBs and you can figure out how to produce your pie charts easily... You say you are a beginner in R, so best to leave it and use something else for the web side of things. What aren't you a beginner in? Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] gam() (in mgcv) with multiple interactions
I think that the main problem here is that smooths are not constrained to pass through the origin, so the covariate taking the value zero doesn't correspond to no effect in the way that you would like it to. Another way of putting this is that smooths are translation invariant, you get essentially the same inference from the model y_i = f(x_i) + e_i as from y_i = f(x_i + k) + e_i (which implies that x_i=0 can have no special status). All mgcv does in the case of te(a) + te(b) + te(d) + te(a, b) + te(a, d) is to remove the bases for te(a), te(b) and te(d) from the basis of te(a,b) and te(a,d). Further constraining te(a,b) and te(a,d) so that te(0,b) = te(a,0) = 0 etc wouldn't make much sense (in general 0 might not even be in the range of a and b). In general I find functional ANOVA not entirely intuitive to think about, but there is a very good book on it by Chong Gu (Smoothing spline ANOVA, 2002, Springer), and the associated package gss is on CRAN. best, Simon On 07/06/11 17:00, Ben Haller wrote: Hi! I'm learning mgcv, and reading Simon Wood's book on GAMs, as recommended to me earlier by some folks on this list. I've run into a question to which I can't find the answer in his book, so I'm hoping somebody here knows. My outcome variable is binary, so I'm doing a binomial fit with gam(). I have five independent variables, all continuous, all uniformly distributed in [0, 1]. (This dataset is the result of a simulation model.) Let's call them a,b,c,d,e for simplicity. I'm interested in interactions such as a*b, so I'm using tensor product smooths such as te(a,b). So far so good. But I'm also interested in, let's say, a*d. So ok, I put te(a,d) in as well. Both of these have a as a marginal basis (if I'm using the right terminology; all I mean is, both interactions involve a), and I would have expected them to share that basis; I would have expected them to be constrained such that the effect of a when b=0, for one, would be the same as the effect of a when d=0, for the other. This would be just as, in a GLM with formula a*b + a*d, that formula would expand to a + b + d + a:b + a:d, and there is only one a; a doesn't get to be different for the a*b interaction than it is for the! a*d interaction. But with tensor product smooths in gam(), that does not seem to be the case. I'm still just getting to know mgcv and experimenting with things, so I may be doing something wrong; but the plots I have done of fits of this type appear to show different marginal effects. I tried explicitly including terms for the marginal basis; in my example, I tried a formula like te(a) + te(b) + te(d) + te(a, b) + te(a, d). No dice; in this case, the main effect of a is different between all three places where it occurs in the model. I.e. te(a) shows a different effect of a than te(a, b) shows at b=0, which is again different from the effect shown by te(a, d) at d=0. I don't even know what that could possibly mean; it seems wrong to me that this could even be the case, but what do I know. :- I could move up to a higher-order tensor like te(a,b,d), but there are three problems with that. One, the b:d interaction (in my simplified example) is then also part of the model, and I'm not interested in it. Two, given the set of interactions that I *am* interested in, I would actually be forced to do the full five-way te(a,b,c,d,e), and with a 300,000 row dataset, I shudder to think how long that will take to run, since it would have something like 5^5 free parameters to fit; that doesn't seem worth pursuing. And three, interpretation of a five-way interaction would be unpleasant, to say the least; I'd much rather be able to stay with just the two-way (and one three-way) interactions that I know are of interest (I know this from previous logistic regression modelling of the dataset). For those who like to see the actual R code, here are two fits I've tried: gam(outcome ~ te(acl, dispersal) + te(amplitude, dispersal) + te(slope, curvature, amplitude), family=binomial, data=rla, method=REML) gam(outcome ~ te(slope) + te(curvature) + te(amplitude) + te(acl) + te(dispersal) + te(slope, curvature) + te(slope, amplitude) + te(curvature, amplitude) + te(acl, dispersal) + te(amplitude, dispersal) + te(slope, curvature, amplitude), family=binomial, data=rla, method=REML) So. Any advice? How can I correctly do a gam() fit involving multiple interactions that involve the same independent variable? Thanks! Ben Haller McGill University http://biology.mcgill.ca/grad/ben/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Simon Wood, Mathematical Science, University of Bath BA2 7AY UK +44 (0)1225 386603 http://people.bath.ac.uk/sw283
Re: [R] Problem with a if statement inside a function
Can you boil that down into a short reproducible example? For instance, when you run your function at the end newdf - myfunc(lst) I can't run it myself because I don't know what lst is. Although it seems not to matter - what are you passing as an argument to the function, since it seems to be completely overwritten. Also, calling setwd() within a function seems like a bad idea, because it guarantees that nobody but you can ever use it. And why would you, rather than passing the working directory as an argument if it's crucial? Sarah On Thu, Jun 9, 2011 at 11:14 AM, Abraham Mathew abra...@thisorthat.com wrote: I have a really long functions, and at the end of the function, I am using a if statement to tag certain keywords based on whether they have certain values contained in them. However, the if statement doesn't seem to work. When I had split up the commands into various functions, it worked fine, but I'm not sure what going on now that it's combined into a single function. myfunc - function(lst) { options(max.print=10) setwd(~/Desktop/RStuff) state - c(Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Deleware, Florida, Georgia, Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Ohio, Oklahoma, Oregon, Pennsylvania, Rhode Island, South Carolina, South Dakota, Tenessee, Texas, Utah, Vermont, Virginia, Washington, West Virginia, Wisconsin, Wyoming, AL, AK, AZ, AR, CA, CO, CT, DE, FL, GA, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI, SC, SD, TN, TX, UT, VT, VA, WA, WV, WI, WY) inscompany - c(21st Century, AAA, Alliance United, Allied, American Automobile Association, AARP, AIG, American International Group, Allstate, All State, All-state, American States, American Income, AMICA, American Family, ANPAC, American National Property and Casualty, AutoOne, Auto One, Auto-One, Auto-Owners, Auto Owners, AutoOwners, Balboa, Chubb Corporation, Commerce, Conseco, Country Financial, DeerBrook, Eastwood, East Wood, East-Wood, Encompass, Erie, Esurance, E-surance, Evergreen, Farmers, Geico, General, GMAC, Hanover, Hartford, Infinity, Kemper, Liberty Mutual, Loya, Mercury, MetLife, Met Life, Met-Life, Mid-Century, Mid Century, Nationwide, OldAmerican, Old-American, Old American, Pemco, Progressive, Regence Group, Reliance, Response, Safe, Safe Auto, SafeAuto, Safe-Auto, Safeco, SafeCo, Safeway, Santa Fe, Santa-Fe, SantaFe, Sentry, Shelter, Standard, State Farm, StateFarm, State-Farm, Titan, Travelers, Unitrin, USAA, Wells Fargo, Western, Westfield, West Coast, West-Coast, WestCoast) agency - c(Eastwood, Tompkins, ABC, United, Trusted Choice) city = c(New York City, Los Angeles, Chicago, Houston, Philadelphia, Phoenix, San Diego, San Antonio, Dallas, Detroit, San Jose, Indianapolis, Jacksonville, San Francisco, Columbus, Austin, Memphis, Baltimore, Milwaukee, Fort Worth, Charlotte, El Paso, Boston, Seattle, Washington DC, Denver, Nashville, Portland, Oklahoma City, Las Vegas, Tucson, Long Beach, Albuquerque, New Orleans, Cleveland, Fresno, Sacramento, Kansas City, Virginia Beach, Mesa, Atlanta, Omaha, Oakland, Tulsa, Honolulu, Miami, Minneapolis, Colorado Springs, Arlington, Wichita, Santa Ana, Anaheim, St. Louis, Pittsburgh, Tampa, Cincinnati, Raleigh, Toledo, Aurora, Buffalo, Riverside, St. Paul, Corpus Christi, Newark, Stockton, Bakersfield, Anchorage, Lexington, Louisville, St. Petersburg, Plano, Norfolk, Birmingham, Lincoln, Glendale, Greensboro, Hialeah, Baton Rouge, Fort Wayne, Madison, Garland, Scottsdale, Rochester, Henderson, Akron, Chandler, Chesapeake, Modesto, Lubbock, Fremont, Glendale, Montgomery, Orlando, Chula Vista, Durham, Shreveport, Laredo, Yonkers, Tacoma, Anaconda, Butte, Suffolk, Buckeye, Augusta, Cusseta, Huntsville, Boulder City, Goodyear, Hibbing, Norman, Sierra Vista, Georgetown, Carson City, Chattanooga, Lynchburg, Columbia, Mobile, Athens, Little Rock, Yuma, Babbitt, Cape Coral, Abilene, Palmdale, Jackson, Plymouth, Clarksville, Palm Springs, Lancaster, Ellsworth, Knoxville, Amarillo, Dothan, Oak Ridge, Edmond, Beaumont, Waco, Port Arthur, Toledo, Brownsville, El Reno, Henderson, Jonesboro, Caribou, Ellsworth, Fort Wayne, Independence, Des Moines, Lawton, Rome, North Port, Savannah, Lincoln, Apple
Re: [R] set.seed and for loop
If you feel the need to go back and recreate a random series, then same the seed (.Random.seed) and restore it: set.seed(1001) total - 0 data - vector(list, 30) seeds - vector(list, 30) for(i in 1:30) { + seeds[[i]] - .Random.seed + data[[i]] - runif(50) + } .Random.seed - seeds[[23]] # restore data.23 - runif(50) data.23 [1] 0.684727876 0.592993730 0.879359238 0.454304600 0.754685981 0.119436749 0.527867847 0.265443455 [9] 0.887112712 0.043309227 0.001381898 0.403483404 0.042224167 0.698174037 0.334604909 0.059465646 [17] 0.374227434 0.014508142 0.265783354 0.023154917 0.668829829 0.184914632 0.479524914 0.644859846 [25] 0.497644242 0.569325789 0.257636746 0.720526541 0.541526487 0.904469943 0.755720327 0.729912488 [33] 0.388004197 0.940454649 0.545474130 0.285013104 0.379244716 0.012338111 0.192581106 0.535863633 [41] 0.496777643 0.323488796 0.414391018 0.971135722 0.763092648 0.120187724 0.402572384 0.081896175 [49] 0.303378141 0.002711767 data[[23]] [1] 0.684727876 0.592993730 0.879359238 0.454304600 0.754685981 0.119436749 0.527867847 0.265443455 [9] 0.887112712 0.043309227 0.001381898 0.403483404 0.042224167 0.698174037 0.334604909 0.059465646 [17] 0.374227434 0.014508142 0.265783354 0.023154917 0.668829829 0.184914632 0.479524914 0.644859846 [25] 0.497644242 0.569325789 0.257636746 0.720526541 0.541526487 0.904469943 0.755720327 0.729912488 [33] 0.388004197 0.940454649 0.545474130 0.285013104 0.379244716 0.012338111 0.192581106 0.535863633 [41] 0.496777643 0.323488796 0.414391018 0.971135722 0.763092648 0.120187724 0.402572384 0.081896175 [49] 0.303378141 0.002711767 On Thu, Jun 9, 2011 at 11:23 AM, Samuel Le samuel...@srlglobal.com wrote: What about: set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } set.seed(1001) data[[23]] - runif(50) HTH Samuel -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Soyeon Kim Sent: 09 June 2011 16:15 To: r-help Subject: [R] set.seed and for loop Dear All, This is hard to describe so I made a simple example. set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } Let's call a data set runif(50). While the for loop is running, 100 data sets are generated. I want to restore 23th data set (the data set generated in 23th for loop) without the loop. I've tried set.seed(1023) runif(50) but this is different data from the data set gotten from 23th for loop. How can I get 23th data set without the loop? Thank you, Soyeon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 compute the multidimensional extension of the McDonald's omega by using R?
Hi, I need to perform a computation of reliability of a 5-point Likert scale having 6 items. From a factor analysis I found that my scale is a multidimensional scale (3 factors), so I cannot use Crobach's alpha to compute reliability. I have seen in several papers that it is possibile to use the multidimensional extension of the McDonald's omega. The omega function in the psych package allows to do this? thank you -- View this message in context: http://r.789695.n4.nabble.com/how-can-I-compute-the-multidimensional-extension-of-the-McDonald-s-omega-by-using-R-tp3585780p3585780.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] County map for Alaska, Hawaii, and Puerto Rico
I have been looking for a way to create a county level map of Alaska and Hawaii in R and cannot find any good example for the life of me. I also need to map Puerto Rico and cannot get a nice map of that either. I used the ggplot2 and maps package to create a perfect map of the mainland US, but I still need these three places to make it complete. Can anybody help me with this? -- View this message in context: http://r.789695.n4.nabble.com/County-map-for-Alaska-Hawaii-and-Puerto-Rico-tp3585512p3585512.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] Problem with a if statement inside a function
lst is a list within the function. Good point about the working directory. Thanks Abraham On Thu, Jun 9, 2011 at 9:35 AM, Sarah Goslee sarah.gos...@gmail.com wrote: Can you boil that down into a short reproducible example? For instance, when you run your function at the end newdf - myfunc(lst) I can't run it myself because I don't know what lst is. Although it seems not to matter - what are you passing as an argument to the function, since it seems to be completely overwritten. Also, calling setwd() within a function seems like a bad idea, because it guarantees that nobody but you can ever use it. And why would you, rather than passing the working directory as an argument if it's crucial? Sarah On Thu, Jun 9, 2011 at 11:14 AM, Abraham Mathew abra...@thisorthat.com wrote: I have a really long functions, and at the end of the function, I am using a if statement to tag certain keywords based on whether they have certain values contained in them. However, the if statement doesn't seem to work. When I had split up the commands into various functions, it worked fine, but I'm not sure what going on now that it's combined into a single function. myfunc - function(lst) { options(max.print=10) setwd(~/Desktop/RStuff) state - c(Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Deleware, Florida, Georgia, Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Ohio, Oklahoma, Oregon, Pennsylvania, Rhode Island, South Carolina, South Dakota, Tenessee, Texas, Utah, Vermont, Virginia, Washington, West Virginia, Wisconsin, Wyoming, AL, AK, AZ, AR, CA, CO, CT, DE, FL, GA, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI, SC, SD, TN, TX, UT, VT, VA, WA, WV, WI, WY) inscompany - c(21st Century, AAA, Alliance United, Allied, American Automobile Association, AARP, AIG, American International Group, Allstate, All State, All-state, American States, American Income, AMICA, American Family, ANPAC, American National Property and Casualty, AutoOne, Auto One, Auto-One, Auto-Owners, Auto Owners, AutoOwners, Balboa, Chubb Corporation, Commerce, Conseco, Country Financial, DeerBrook, Eastwood, East Wood, East-Wood, Encompass, Erie, Esurance, E-surance, Evergreen, Farmers, Geico, General, GMAC, Hanover, Hartford, Infinity, Kemper, Liberty Mutual, Loya, Mercury, MetLife, Met Life, Met-Life, Mid-Century, Mid Century, Nationwide, OldAmerican, Old-American, Old American, Pemco, Progressive, Regence Group, Reliance, Response, Safe, Safe Auto, SafeAuto, Safe-Auto, Safeco, SafeCo, Safeway, Santa Fe, Santa-Fe, SantaFe, Sentry, Shelter, Standard, State Farm, StateFarm, State-Farm, Titan, Travelers, Unitrin, USAA, Wells Fargo, Western, Westfield, West Coast, West-Coast, WestCoast) agency - c(Eastwood, Tompkins, ABC, United, Trusted Choice) city = c(New York City, Los Angeles, Chicago, Houston, Philadelphia, Phoenix, San Diego, San Antonio, Dallas, Detroit, San Jose, Indianapolis, Jacksonville, San Francisco, Columbus, Austin, Memphis, Baltimore, Milwaukee, Fort Worth, Charlotte, El Paso, Boston, Seattle, Washington DC, Denver, Nashville, Portland, Oklahoma City, Las Vegas, Tucson, Long Beach, Albuquerque, New Orleans, Cleveland, Fresno, Sacramento, Kansas City, Virginia Beach, Mesa, Atlanta, Omaha, Oakland, Tulsa, Honolulu, Miami, Minneapolis, Colorado Springs, Arlington, Wichita, Santa Ana, Anaheim, St. Louis, Pittsburgh, Tampa, Cincinnati, Raleigh, Toledo, Aurora, Buffalo, Riverside, St. Paul, Corpus Christi, Newark, Stockton, Bakersfield, Anchorage, Lexington, Louisville, St. Petersburg, Plano, Norfolk, Birmingham, Lincoln, Glendale, Greensboro, Hialeah, Baton Rouge, Fort Wayne, Madison, Garland, Scottsdale, Rochester, Henderson, Akron, Chandler, Chesapeake, Modesto, Lubbock, Fremont, Glendale, Montgomery, Orlando, Chula Vista, Durham, Shreveport, Laredo, Yonkers, Tacoma, Anaconda, Butte, Suffolk, Buckeye, Augusta, Cusseta, Huntsville, Boulder City, Goodyear, Hibbing, Norman, Sierra Vista, Georgetown, Carson City, Chattanooga, Lynchburg, Columbia, Mobile, Athens, Little Rock, Yuma, Babbitt, Cape Coral, Abilene, Palmdale, Jackson, Plymouth, Clarksville, Palm Springs, Lancaster,
[R] scatterplot3d - help assign colors based on multiple conditions
Hi I am relatively new to R and am trying to figure out to plot 3d scatter plot using defined colors based on x-axis and y-axis values. Right now in the code below, I assign colors based on certain values in the names of the x-axis. Now if I want to extend the condition to assign a color based on the names of both x-axis and y-axis values, what should I be doing? Any help or ideas would be greatly appreciated. For e.g. in my 3 column matrix below, if I want to assign red to all the values whose first column and second column contain Anterior_nares and assign black to any other combination. Thanks! Karthik library(scatterplot3d) chd1=read.table(file=test.out, header=F, sep=\t) col=as.vector(chd1[,1]) xlabels=as.vector(chd1[,1]) ylabels=as.vector(chd1[,2]) mycols-c(red,blue,green,chocolate,orange, brown) col[grep(_Stool, xlabels) ]-mycols[1] #col[grep(_Stool, xlabels) grep(_Stool, ylabels) ]-mycols[1] col[grep(_Tongue_dorsum, xlabels) ]-mycols[2] col[grep(_Posterior_fornix, xlabels) ]-mycols[3] col[grep(_Anterior_nares, xlabels) ]-mycols[4] col[grep(_Buccal_mucosa, xlabels) ]-mycols[5] col[grep(_Supragingival_plaque, xlabels) ]-mycols[6] png(file=3dplot_test.png, w=700,h=700) scatterplot3d(chd1[, 1], chd1[, 2], chd1[, 3], main=test, xlab=sample, ylab=sample, zlab=kmers, color=col,type=p) dev.off () my test.out matrix looks something like this: A011132_Anterior_nares A011263_Anterior_nares 50130 A011132_Anterior_nares A011397_Stool 34748 A011132_Anterior_nares A012291_Tongue 40859 A011132_Anterior_nares A012663_Buccal_mucosa 76213 A011132_Anterior_nares A013155_Anterior_nares 36841 A011132_Anterior_nares A013269_Anterior_nares 45619 A011132_Anterior_nares A013637_Anterior_nares 56995 [[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 creating a scatterplot with errorbars using gplot
I am having a problem creating a scatterplot with error bars using gplot. This is only my second day using R so I am very much a newbie. My x-values (OD600) are: 0.0040 0.0187 0.0473 0.0873 0.2247 0.4240 0.8207 1.3923 1.6110 My y-values (cellconc) are: 2e+06 5e+06 1e+07 2e+07 5e+07 1e+08 2e+08 5e+08 1e+09 And my standard deviations (stdev) are: 0.001154701 0.00300 0.002081666 0.009865766 0.015716234 0.040253364 0.017691806 0.013868429 0.007234178 I use the command: plotCI(OD600, cellconc, uiw=stdev) And I receive a graph that looks correct but without any error bars. I also receive these warnings: 1: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 2: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 3: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 4: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 5: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 6: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 7: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 8: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 9: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 10: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 11: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 12: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 13: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 14: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 15: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 16: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 17: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped 18: In arrows(...) : zero-length arrow is of indeterminate angle and so skipped Thank you for your help. [[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] any documents
Date: Thu, 9 Jun 2011 02:21:21 -0700 From: wa7@gmail.com To: r-help@r-project.org Subject: [R] any documents Hi, I'm doing a textual analysis of several articles discussing the evolution of prices in order to give a forecast. if someone can give me a clear approach to this knowing that I work on the package tm. LOL, are you talking about the computer generated analysis such as the thin text platititudes around bandwagon stats such as is trading xx above 30 day moving average etc etc. This sounds funny but is actually an interesting test case as the hidden structured nature of the documents should be easier to analyse than, say, poetry. The field is very much researchy AFAIK and you will need to define an algorithm of do a literature search to get much in the way of helpful response beyond ?tm Absent that, you are almost asking for someone to invent an algorithm. I've refered many posters to terms like computational lingquistics but people who have used these kinds of things don't seem to post here much. If you can give us more details or source article maybe someone can point you in useful direction. Thank you very much -- View this message in context: http://r.789695.n4.nabble.com/any-documents-tp3584961p3584961.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] Results of CFA with Lavaan
On 06/09/2011 05:21 PM, R Help wrote: Ok, I think this is the last question I have. My model is producing an estimate of intercepts for my variables along with my loadings. From the documentation it appears that this is controlled by the meanstructure option in cfa. It says that setting it to TRUE includes the intercepts, and setting it to default means thatthe value is set based on the user-specified model, and/or the values of other arguments. I've included my model specification below, and I would prefer not to fit intercepts, but setting it to FALSE does not seem to achieve this. Several arguments of the cfa() function force meanstructure=TRUE (and indeed, silently overriding the meanstructure=FALSE option if specified by the user; perhaps, lavaan should spit out a warning if this happens). The following argument choices force meanstructure to be TRUE (if there is only a single group): - estimator = mlm or mlf or mlr - missing = ml or fiml Did you use any one of those arguments? But why would you prefer not to fit the intercepts? If there are no restrictions on the intercepts/means, fitting them should have no effect on your model fit whatsoever. Yves Rosseel http://lavaan.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] Results of CFA with Lavaan
I am using missing = 'fiml', which would require estimating intercepts. I figured they would effect my overall model fit, but can I still estimate my loading coefficients the same way? The warning would be helpful, but if I had looked closer into the 'fiml' option I might have been able to figure it out myself. Thanks, Sam On Thu, Jun 9, 2011 at 1:02 PM, yrosseel yross...@gmail.com wrote: On 06/09/2011 05:21 PM, R Help wrote: Ok, I think this is the last question I have. My model is producing an estimate of intercepts for my variables along with my loadings. From the documentation it appears that this is controlled by the meanstructure option in cfa. It says that setting it to TRUE includes the intercepts, and setting it to default means thatthe value is set based on the user-specified model, and/or the values of other arguments. I've included my model specification below, and I would prefer not to fit intercepts, but setting it to FALSE does not seem to achieve this. Several arguments of the cfa() function force meanstructure=TRUE (and indeed, silently overriding the meanstructure=FALSE option if specified by the user; perhaps, lavaan should spit out a warning if this happens). The following argument choices force meanstructure to be TRUE (if there is only a single group): - estimator = mlm or mlf or mlr - missing = ml or fiml Did you use any one of those arguments? But why would you prefer not to fit the intercepts? If there are no restrictions on the intercepts/means, fitting them should have no effect on your model fit whatsoever. Yves Rosseel http://lavaan.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] cairoDevice on Windows: succesful installation but does not load
On Thu, 9 Jun 2011, Agustin Lobo wrote: Hi! I've tried to install playwith on Windows XP but, install.packages(cairoDevice) trying URL 'http://cran.at.r-project.org/bin/windows/contrib/2.13/cairoDevice_2.15.zip' Content type 'application/zip' length 52371 bytes (51 Kb) opened URL downloaded 51 Kb package 'cairoDevice' successfully unpacked and MD5 sums checked The downloaded packages are in d:\Documents and Settings\_llp_gr_interfase.UAB\Configuración local\Temp\RtmpOo5UAa\downloaded_packages require(playwith) Loading required package: playwith Loading required package: cairoDevice Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'C:/Archivos de programa/R/R-2.13.0/library/cairoDevice/libs/i386/cairoDevice.dll': LoadLibrary failure: No se puede encontrar el módulo especificado. Failed with error: ‘package 'cairoDevice' could not be loaded’ I've also tried installing cairoDevice but get the same problem. The dll 'C:/Archivos de programa/R/R-2.13.0/library/cairoDevice/libs/i386/cairoDevice.dll' is there despite the system claiming it's not No, it is not claiming that. It does not say which the module is it cannot find (although Windows often does in a popup), and it is almost certainly not cairoDevice.dll. Welcome to the wondrous world of Microsoft error messages! I strongly suspect though that you failed to install the external software required and listed at http://cran.r-project.org/bin/windows/contrib/2.13/@ReadMe -- 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] Problem with a if statement inside a function
I would start out by checking out ?switch and getting rid of most of those ifs . Next: I apologize for the harshness of this, but your code really does qualify for http://thedailywtf.com . Creating a zillion variables dXY, for example, is really poor programming practice. Create a list or something. And, this probably should be first: you did not supply an example of what your input lst looks like, AND you didn't tell us what your expected result is, nor what the unexpected result was. At the risk of speculating wildly, the fact that lst is defined inside the function would suggest there's something fundamentally wrong here. Carl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fwd: Re: residual checking for GAM (mgcv)
The plots look reasonable to me. The plot of residuals against linear predictor always looks scary when many of the fitted values are very close to zero, so I tend to look at residuals against sqrt(fitted) in such cases. I don't think that the presence of the zero curve is a reason to reject the model --- it's easy to produce such plots by fitting a completely correct model to simulated count data. best, Simon On 08/06/11 15:50, Samuel Turgeon wrote: Dear list, i'm checking the residuals plots of a gam model after a processus of model selection. I found the best model, all my terms are significant, the r-square and the deviance explained are good, but I have strange residuals plots: http://dl.dropbox.com/u/1169100/gam.check.png http://dl.dropbox.com/u/1169100/residuals_vs_fitted.png The curve is caused by the zeroes in my data. I've also plotted each explanatory variables included in the model against residuals and everything looks fine. Is this curve does not allow me to accept this model? Does the use of an other family (eg negbin) would be the solution for fixing this problem? Currently I use the poisson family (and quasipoisson). I have a lot of 0 in my response variable, almost 65 % Should I use a specific function that allows me to use zero-inflated data?? Kind regards, Sam [[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. -- Simon Wood, Mathematical Science, University of Bath BA2 7AY UK +44 (0)1225 386603 http://people.bath.ac.uk/sw283 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] set.seed and for loop
That wouldn't work because the seed is for the first iteration. Random numbers are generated by a seed, after which the seed changes (I don't know the mechanism for changing the seed in R, but it's static) That means that, if you set the seed to 1001, and then run runif function 50 times, you'll get 50 different sets of random numbers. If you reset the seed to 1001 and then run runif again, the result will be the same as data[[1]], not [[23]]. And you can't just set the seed to 1023 because that's not how the seed changes. I think Jim's suggestion was the best. I was thinking of that but I couldn't remember how to extract the seed. Sam On Thu, Jun 9, 2011 at 12:23 PM, Samuel Le samuel...@srlglobal.com wrote: What about: set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } set.seed(1001) data[[23]] - runif(50) HTH Samuel -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Soyeon Kim Sent: 09 June 2011 16:15 To: r-help Subject: [R] set.seed and for loop Dear All, This is hard to describe so I made a simple example. set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } Let's call a data set runif(50). While the for loop is running, 100 data sets are generated. I want to restore 23th data set (the data set generated in 23th for loop) without the loop. I've tried set.seed(1023) runif(50) but this is different data from the data set gotten from 23th for loop. How can I get 23th data set without the loop? Thank you, Soyeon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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] Problem with a if statement inside a function
On Thu, Jun 9, 2011 at 11:53 AM, Abraham Mathew abra...@thisorthat.com wrote: lst is a list within the function. Then why is it passed as an argument to the function? You can have a function with no arguments, but in this case why, since it would do exactly the same thing every time? Arguments are for passing information to a function that varies each time the function is run. Sarah Good point about the working directory. Thanks Abraham On Thu, Jun 9, 2011 at 9:35 AM, Sarah Goslee sarah.gos...@gmail.com wrote: Can you boil that down into a short reproducible example? For instance, when you run your function at the end newdf - myfunc(lst) I can't run it myself because I don't know what lst is. Although it seems not to matter - what are you passing as an argument to the function, since it seems to be completely overwritten. Also, calling setwd() within a function seems like a bad idea, because it guarantees that nobody but you can ever use it. And why would you, rather than passing the working directory as an argument if it's crucial? Sarah __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] histogram - density on y axis and restriction to interval [0, 1]
Hello, To indicate probability densities instead of counts on a histogram, I specify freq = FALSE. However, I expect that summing all top y coordinates over all the intervals of the histogram will provide 1. 1) v - c(0.2885, 0.2988, 0.3139, 0.2615, 0.3179, 0.3163, 0.2583, 0.3052, 0.2527, 0.3147, 0.3235, 0.2408, 0.2480, 0.3108, 0.3577, 0.2829, 0.2694, 0.3275, 0.3314, 0.2639, 0.3076, 0.3346, 0.2933, 0.3585, 0.2678, 0.3338) hist(v, freq = FALSE) With the above example, roughly, I obtain 3 * 8 + 10 + 14 + 4 = 52 Besides, I do not understand the units on the y axis. I would have expected decimals. 2) In contrast, I am satisfied with the units on the y axis with the example below : v - c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9) hist(v, freq = FALSE) 3) Again, with the example below, I wonder why the unit axis does not show the interval [0,1] (or maybe [0%,100%]). Proportions are correct but the indication 1.4 is not usual. v - c(1,2,2,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4) hist(v, freq = FALSE) I thank you in advance for any explanation about the way to force the y axis to restrain to interval [0,1] on an histogram. Best regards, Christine Sinoquet __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] set.seed and for loop
On 09/06/2011 11:48 AM, jim holtman wrote: If you feel the need to go back and recreate a random series, then same the seed (.Random.seed) and restore it: This works in this example, but wouldn't work with all RNGs, because some of them save state outside of .Random.seed. See ?.Random.seed for details. Duncan Murdoch set.seed(1001) total- 0 data- vector(list, 30) seeds- vector(list, 30) for(i in 1:30) { + seeds[[i]]- .Random.seed + data[[i]]- runif(50) + } .Random.seed- seeds[[23]] # restore data.23- runif(50) data.23 [1] 0.684727876 0.592993730 0.879359238 0.454304600 0.754685981 0.119436749 0.527867847 0.265443455 [9] 0.887112712 0.043309227 0.001381898 0.403483404 0.042224167 0.698174037 0.334604909 0.059465646 [17] 0.374227434 0.014508142 0.265783354 0.023154917 0.668829829 0.184914632 0.479524914 0.644859846 [25] 0.497644242 0.569325789 0.257636746 0.720526541 0.541526487 0.904469943 0.755720327 0.729912488 [33] 0.388004197 0.940454649 0.545474130 0.285013104 0.379244716 0.012338111 0.192581106 0.535863633 [41] 0.496777643 0.323488796 0.414391018 0.971135722 0.763092648 0.120187724 0.402572384 0.081896175 [49] 0.303378141 0.002711767 data[[23]] [1] 0.684727876 0.592993730 0.879359238 0.454304600 0.754685981 0.119436749 0.527867847 0.265443455 [9] 0.887112712 0.043309227 0.001381898 0.403483404 0.042224167 0.698174037 0.334604909 0.059465646 [17] 0.374227434 0.014508142 0.265783354 0.023154917 0.668829829 0.184914632 0.479524914 0.644859846 [25] 0.497644242 0.569325789 0.257636746 0.720526541 0.541526487 0.904469943 0.755720327 0.729912488 [33] 0.388004197 0.940454649 0.545474130 0.285013104 0.379244716 0.012338111 0.192581106 0.535863633 [41] 0.496777643 0.323488796 0.414391018 0.971135722 0.763092648 0.120187724 0.402572384 0.081896175 [49] 0.303378141 0.002711767 On Thu, Jun 9, 2011 at 11:23 AM, Samuel Lesamuel...@srlglobal.com wrote: What about: set.seed(1001) total- 0 data- vector(list, 30) for(i in 1:30) { data[[i]]- runif(50) } set.seed(1001) data[[23]]- runif(50) HTH Samuel -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Soyeon Kim Sent: 09 June 2011 16:15 To: r-help Subject: [R] set.seed and for loop Dear All, This is hard to describe so I made a simple example. set.seed(1001) total- 0 data- vector(list, 30) for(i in 1:30) { data[[i]]- runif(50) } Let's call a data set runif(50). While the for loop is running, 100 data sets are generated. I want to restore 23th data set (the data set generated in 23th for loop) without the loop. I've tried set.seed(1023) runif(50) but this is different data from the data set gotten from 23th for loop. How can I get 23th data set without the loop? Thank you, Soyeon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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] set.seed and for loop
On 09/06/2011 11:48 AM, jim holtman wrote: If you feel the need to go back and recreate a random series, then same the seed (.Random.seed) and restore it: This works in this example, but wouldn't work with all RNGs, because some of them save state outside of .Random.seed. See ?.Random.seed for details. Duncan Murdoch set.seed(1001) total- 0 data- vector(list, 30) seeds- vector(list, 30) for(i in 1:30) { + seeds[[i]]- .Random.seed + data[[i]]- runif(50) + } .Random.seed- seeds[[23]] # restore data.23- runif(50) data.23 [1] 0.684727876 0.592993730 0.879359238 0.454304600 0.754685981 0.119436749 0.527867847 0.265443455 [9] 0.887112712 0.043309227 0.001381898 0.403483404 0.042224167 0.698174037 0.334604909 0.059465646 [17] 0.374227434 0.014508142 0.265783354 0.023154917 0.668829829 0.184914632 0.479524914 0.644859846 [25] 0.497644242 0.569325789 0.257636746 0.720526541 0.541526487 0.904469943 0.755720327 0.729912488 [33] 0.388004197 0.940454649 0.545474130 0.285013104 0.379244716 0.012338111 0.192581106 0.535863633 [41] 0.496777643 0.323488796 0.414391018 0.971135722 0.763092648 0.120187724 0.402572384 0.081896175 [49] 0.303378141 0.002711767 data[[23]] [1] 0.684727876 0.592993730 0.879359238 0.454304600 0.754685981 0.119436749 0.527867847 0.265443455 [9] 0.887112712 0.043309227 0.001381898 0.403483404 0.042224167 0.698174037 0.334604909 0.059465646 [17] 0.374227434 0.014508142 0.265783354 0.023154917 0.668829829 0.184914632 0.479524914 0.644859846 [25] 0.497644242 0.569325789 0.257636746 0.720526541 0.541526487 0.904469943 0.755720327 0.729912488 [33] 0.388004197 0.940454649 0.545474130 0.285013104 0.379244716 0.012338111 0.192581106 0.535863633 [41] 0.496777643 0.323488796 0.414391018 0.971135722 0.763092648 0.120187724 0.402572384 0.081896175 [49] 0.303378141 0.002711767 On Thu, Jun 9, 2011 at 11:23 AM, Samuel Lesamuel...@srlglobal.com wrote: What about: set.seed(1001) total- 0 data- vector(list, 30) for(i in 1:30) { data[[i]]- runif(50) } set.seed(1001) data[[23]]- runif(50) HTH Samuel -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Soyeon Kim Sent: 09 June 2011 16:15 To: r-help Subject: [R] set.seed and for loop Dear All, This is hard to describe so I made a simple example. set.seed(1001) total- 0 data- vector(list, 30) for(i in 1:30) { data[[i]]- runif(50) } Let's call a data set runif(50). While the for loop is running, 100 data sets are generated. I want to restore 23th data set (the data set generated in 23th for loop) without the loop. I've tried set.seed(1023) runif(50) but this is different data from the data set gotten from 23th for loop. How can I get 23th data set without the loop? Thank you, Soyeon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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] set.seed and for loop
On 09.06.2011 18:09, R Help wrote: That wouldn't work because the seed is for the first iteration. Random numbers are generated by a seed, after which the seed changes (I don't know the mechanism for changing the seed in R, but it's static) That means that, if you set the seed to 1001, and then run runif function 50 times, you'll get 50 different sets of random numbers. If you reset the seed to 1001 and then run runif again, the result will be the same as data[[1]], not [[23]]. And you can't just set the seed to 1023 because that's not how the seed changes. I think Jim's suggestion was the best. I was thinking of that but I couldn't remember how to extract the seed. Well set.seed() actually generates a seed. See ?set.seed that points us to .Random.seed (and relevant references!) which contains the actual current seed. Uwe Ligges Sam On Thu, Jun 9, 2011 at 12:23 PM, Samuel Lesamuel...@srlglobal.com wrote: What about: set.seed(1001) total- 0 data- vector(list, 30) for(i in 1:30) { data[[i]]- runif(50) } set.seed(1001) data[[23]]- runif(50) HTH Samuel -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Soyeon Kim Sent: 09 June 2011 16:15 To: r-help Subject: [R] set.seed and for loop Dear All, This is hard to describe so I made a simple example. set.seed(1001) total- 0 data- vector(list, 30) for(i in 1:30) { data[[i]]- runif(50) } Let's call a data set runif(50). While the for loop is running, 100 data sets are generated. I want to restore 23th data set (the data set generated in 23th for loop) without the loop. I've tried set.seed(1023) runif(50) but this is different data from the data set gotten from 23th for loop. How can I get 23th data set without the loop? Thank you, Soyeon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 6193 (20110609) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with a if statement inside a function
On Thu, Jun 9, 2011 at 12:27 PM, Abraham Mathew abra...@thisorthat.com wrote: I passed it as an argument to the function because every week I'll need to add keywords to the lst, and that function will make the process more automated. But it doesn't. lst is hard-coded within your function, so passing something, anything, named lst to your function is irrelevant. But back to your original question, you really need to provide the list with a short version that we can run. Diagnosing such a long mass of code without even being able to try it out is very difficult. Sarah On Thu, Jun 9, 2011 at 10:21 AM, Sarah Goslee sarah.gos...@gmail.com wrote: On Thu, Jun 9, 2011 at 11:53 AM, Abraham Mathew abra...@thisorthat.com wrote: lst is a list within the function. Then why is it passed as an argument to the function? You can have a function with no arguments, but in this case why, since it would do exactly the same thing every time? Arguments are for passing information to a function that varies each time the function is run. Sarah Good point about the working directory. Thanks Abraham On Thu, Jun 9, 2011 at 9:35 AM, Sarah Goslee sarah.gos...@gmail.com wrote: Can you boil that down into a short reproducible example? For instance, when you run your function at the end newdf - myfunc(lst) I can't run it myself because I don't know what lst is. Although it seems not to matter - what are you passing as an argument to the function, since it seems to be completely overwritten. Also, calling setwd() within a function seems like a bad idea, because it guarantees that nobody but you can ever use it. And why would you, rather than passing the working directory as an argument if it's crucial? Sarah __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] histogram - density on y axis and restriction to interval [0, 1]
Did you read the help for hist? freq: logical; if ‘TRUE’, the histogram graphic is a representation of frequencies, the ‘counts’ component of the result; if ‘FALSE’, probability densities, component ‘density’, are plotted (so that the histogram has a total area of one). Defaults to ‘TRUE’ _if and only if_ ‘breaks’ are equidistant (and ‘probability’ is not specified). freq=FALSE isn't doing what you think it is. But what I think you want is easy enough to accomplish. v.hist - hist(v, plot=FALSE) v.hist$counts - v.hist$counts/sum(v.hist$counts) plot(v.hist) Sarah On Thu, Jun 9, 2011 at 12:22 PM, Christine SINOQUET christine.sinoq...@univ-nantes.fr wrote: Hello, To indicate probability densities instead of counts on a histogram, I specify freq = FALSE. However, I expect that summing all top y coordinates over all the intervals of the histogram will provide 1. 1) v - c(0.2885, 0.2988, 0.3139, 0.2615, 0.3179, 0.3163, 0.2583, 0.3052, 0.2527, 0.3147, 0.3235, 0.2408, 0.2480, 0.3108, 0.3577, 0.2829, 0.2694, 0.3275, 0.3314, 0.2639, 0.3076, 0.3346, 0.2933, 0.3585, 0.2678, 0.3338) hist(v, freq = FALSE) With the above example, roughly, I obtain 3 * 8 + 10 + 14 + 4 = 52 Besides, I do not understand the units on the y axis. I would have expected decimals. 2) In contrast, I am satisfied with the units on the y axis with the example below : v - c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9) hist(v, freq = FALSE) 3) Again, with the example below, I wonder why the unit axis does not show the interval [0,1] (or maybe [0%,100%]). Proportions are correct but the indication 1.4 is not usual. v - c(1,2,2,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4) hist(v, freq = FALSE) I thank you in advance for any explanation about the way to force the y axis to restrain to interval [0,1] on an histogram. Best regards, Christine Sinoquet __ -- 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.
[R] Specifying grouping factor for augPred in nlme
Dear list, I have a seemingly simple problem with plotting predictions from nlme for which I have not been able to find an answer in the archives nor do I see any mention of this in Pinheiro Bates 2000. I am using the following model of chick growth for seven different species, with season, nest and individual chick as random effects (all of which are categorical). chickg-groupedData(nmass~age|fspecies, chick, order.groups=F) logistic-deriv(~A/(1+(((A-I)/I)*exp(-age*K))), c(A,I,K), function(age,A,I,K) {}) ab-nlme(nmass~logistic(age,A,I,K), chickg, fixed=A+I+K~fspecies, random=A+K~1|fseason/fnest/fchick, start=fab6) I would like a separate plot for each species (fspecies). As of yet, I have only been able to plot by fseason using plot(augPred(ab, level=0)) or by fchick when no level is set. getGroups(ab) returns 2295 levels, one for each individual. How does one specify that the fixed effect should be used as the grouping factor? Thank you, M [[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] Problem with a if statement inside a function
I passed it as an argument to the function because every week I'll need to add keywords to the lst, and that function will make the process more automated. On Thu, Jun 9, 2011 at 10:21 AM, Sarah Goslee sarah.gos...@gmail.comwrote: On Thu, Jun 9, 2011 at 11:53 AM, Abraham Mathew abra...@thisorthat.com wrote: lst is a list within the function. Then why is it passed as an argument to the function? You can have a function with no arguments, but in this case why, since it would do exactly the same thing every time? Arguments are for passing information to a function that varies each time the function is run. Sarah Good point about the working directory. Thanks Abraham On Thu, Jun 9, 2011 at 9:35 AM, Sarah Goslee sarah.gos...@gmail.com wrote: Can you boil that down into a short reproducible example? For instance, when you run your function at the end newdf - myfunc(lst) I can't run it myself because I don't know what lst is. Although it seems not to matter - what are you passing as an argument to the function, since it seems to be completely overwritten. Also, calling setwd() within a function seems like a bad idea, because it guarantees that nobody but you can ever use it. And why would you, rather than passing the working directory as an argument if it's crucial? Sarah WebRep Overall rating [[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] How to display the mean source?
How can I show the mean source in an Anova table, the one which has always degree of freedom 1? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] set.seed and for loop
On Thu, Jun 09, 2011 at 10:14:48AM -0500, Soyeon Kim wrote: Dear All, This is hard to describe so I made a simple example. set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } Let's call a data set runif(50). While the for loop is running, 100 data sets are generated. I want to restore 23th data set (the data set generated in 23th for loop) without the loop. I've tried set.seed(1023) runif(50) but this is different data from the data set gotten from 23th for loop. How can I get 23th data set without the loop? It is possible to save a bit (not much) over the loop, since a sequence of calls of runif() creates the numbers from the same sequence of numbers. So it is possible to get more numbers in one call not changing the rest of the sequence. I mean the following set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } set.seed(1001) garbage - runif(22*50) recomp - runif(50) identical(data[[23]], recomp) [1] TRUE There are algorithms for jumping ahead in the sequence without generating all intermediate numbers, but i do not know about an efficient available implementation. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Adapting R code for different traps
OK, Assume all your trap names are stored in a vector trap.names. Does: sapply(trap.names, FUN = function(x) { tmp. - outer(release.days[Trap==x],collection.days.2[Trap==x],'-') tmp - ifelse(temp.ACAP1=0,NA,temp.ACAP1) return(apply(temp.ACAP1,2,max,na.rm=TRUE)) } ) Work? I feel there has to be a more elegant way to do it. If you want to invest the time, there are some good dataset manipulation tools in the packages reshape and plyr. HTH, Jon On Thu, Jun 9, 2011 at 11:03 AM, bjmjarrett bjmjarr...@gmail.com wrote: Hi Jon, Sorry about the lack of information. I'll give the data from one of my traps: (nb. all of the data for each trap is referenced to the start day of the trap. ie ACAP1 started collecting at day 0 but parasitoid releases occurred 266, 259, 225 etc days before collecting took place) Trap collection.days.2 release.days days.since.last.release ACAP1 0 -266 -12 # this tells me that at day 0 the last parasitoid release occurred 12 days beforehand, and so on... ACAP1 9 -259 -1 ACAP1 28 -225 -20 ACAP1 41 -216 -13 ACAP1 77 -28 -36 ACAP1 97 -12 -20 ACAP1 106 0 -1 ACAP1 125 8 -20 ACAP1 146 28 -21 ACAP1 168 41 -43 ACAP1 195 77 -70 ACAP1 217 97 -92 ACAP1 259 105 -134 ACAP1 288 125 -163 ACAP1 311 288 -23 ACAP1 337 311 -26 ACAP1 378 337 -41 ACAP1 400 378 -22 ACAP1 440 400 -26 ACAP1 464 414 -14 The output I want is days.since.last.release for all of the traps I have. Thanks so much, Ben -- View this message in context: http://r.789695.n4.nabble.com/Adapting-R-code-for-different-traps-tp3585215p3585823.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. -- === Jon Daily Technician === #!/usr/bin/env outside # It's great, trust me. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 with geomap in googleVis
I still got blanks with Firefox with the two examples below, I put html up here if you want to look at it, http://98.129.232.232/xxx.html I just downloaded googlevis from mirror 68 and it claimed it was 0.2.5 ( I thought, but maybe I should check again). install.packages(googleVis,dep=T) library(googleVis) df-data.frame(foo=c(Brazil,Canada), bar=c(123,456)) map1-gvisGeoMap(df,locationvar='foo',numvar='bar') cat(map1$html$header,filename=xxx.html,append=F) cat(map1$html$header,file=xxx.html,append=F) cat(map1$html$chart,file=xxx.html,append=T) cat(map1$html$caption,file=xxx.html,append=T) cat(map1$html$footer,file=xxx.html,append=T) m-gvisMotionChart(Fruits,idvar=Fruit,timevar=Year) str(m) cat(m$html$header,file=xxx.html,append=F) cat(m$html$chart,file=xxx.html,append=T) cat(m$html$caption,file=xxx.html,append=T) cat(m$html$footer,file=xxx.html,append=T) Subject: RE: [R] error with geomap in googleVis Date: Thu, 9 Jun 2011 14:06:22 +0100 From: markus.gesm...@lloyds.com To: marchy...@hotmail.com; mjphi...@tpg.com.au; r-h...@stat.math.ethz.ch Hi all, This issue occurs with googleVis 0.2.4 and RJSONIO 0.7.1. Version 0.2.5 of the googleVis package has been uploaded to CRAN two days ago and should have fixed this issue. Can you please try to update to that version, e.g. from http://cran.r-project.org/web/packages/googleVis/ Further version 0.2.5 provides new interfaces to more interactive Google charts: - gvisLineChart - gvisBarChart - gvisColumnChart - gvisAreaChart - gvisScatterChart - gvisPieChart - gvisGauge - gvisOrgChart - gvisIntensityMap Additionally a new demo 'AnimatedGeoMap' has been added which shows how a Geo Map can be animated with additional JavaScript. Thanks to Manoj Ananthapadmanabhan and Anand Ramalingam, who provided the idea and initial code. For more information and examples see: http://code.google.com/p/google-motion-charts-with-r/ I hope this helps Markus -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mike Marchywka Sent: 09 June 2011 11:19 To: mjphi...@tpg.com.au; r-h...@stat.math.ethz.ch Subject: Re: [R] error with geomap in googleVis To: r-h...@stat.math.ethz.ch From: mjphi...@tpg.com.au Date: Wed, 8 Jun 2011 10:14:01 + Subject: Re: [R] error with geomap in googleVis SNV Krishna primps.com.sg writes: Hi All, I am unable to get the plot geomap in googleVis package. data is as follows head(index.ret) country ytd 1 Argentina -10.18 2 Australia -3.42 3 Austria -2.70 4 Belgium 1.94 5 Brazil -7.16 6 Canada 0.56 map1 = gvisGeoMap(index.ret,locationvar = 'country', numvar = 'ytd') plot(map1) But it just displays a blank page, showing an error symbol at the right bottom corner. I tried demo(googleVis), it also had a similar problem. The demo showed all other plots/maps except for those geomaps. Could any one please hint me what/where could be the problem? Many thanks for the idea and support. I had never used this until yesterday but it seems to generate html. I didn't manage to get a chart to display but if you are familiar with this package and html perhaps you could look at map1$html and see if anything is obvious. One great thing about html/js is that it is human readable and you can integrate it well with other page material without much in the way of special tools. Regards, SNV Krishna [[alternative HTML version deleted]] Hi All, I have also encountered this problem. I have tested the problem in 3.0. I have latest java and flash and I have tried both Firefox and IE (both latest k just fine. I too would like to know how to solve this problem. Kind regards, Michael Phipps __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. ** The information in this E-Mail and in any attachments is CONFIDENTIAL and may be privileged. If you are NOT the intended recipient, please destroy this message and notify the sender immediately. You should NOT retain, copy or use this E-mail for any purpose, nor disclose all or any part of its contents to any other person or persons. Any views expressed in this message are those of the individual sender, EXCEPT where the
Re: [R] Results of CFA with Lavaan
On 06/09/2011 06:06 PM, R Help wrote: I am using missing = 'fiml', which would require estimating intercepts. I figured they would effect my overall model fit, but can I still estimate my loading coefficients the same way? Yes, no problem. Yves Rosseel http://lavaan.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.
[R] Help on survival analysis
Hi, I need a help in a survival analysis using survreg function with weibull distribution from survival package. Look the data sample: ## Start of script dados - structure(list(TFD = c(20L, 34L, 1L, 2L, 3L, 3L, 50L, 26L, 1L, 50L, 21L, 3L, 13L, 11L, 22L, 50L, 50L, 1L, 50L, 9L, 50L, 1L, 13L, 50L, 50L, 1L, 6L, 50L, 50L, 50L, 36L, 3L, 46L, 10L, 50L, 1L, 18L, 3L, 36L, 37L, 50L, 7L, 1L, 1L, 7L, 24L, 4L, 50L, 12L, 17L), Censor = c(1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1)), .Names = c(TFD, Censor), class = data.frame, row.names = c(NA, -50L)) summary(dados) TFDCensor Min. : 1.00 Min. :0.00 1st Qu.: 3.00 1st Qu.:0.00 Median :17.50 Median :1.00 Mean :23.08 Mean :0.72 3rd Qu.:50.00 3rd Qu.:1.00 Max. :50.00 Max. :1.00 ### TFD is the time for death attach(dados) m - survreg(Surv(TFD,Censor)~1) summary(m) #Call: #survreg(formula = Surv(TFD, Censor) ~ 1) #Value Std. Error zp #(Intercept) 3.466 0.250 13.87 9.67e-44 #Log(scale) 0.403 0.144 2.81 4.98e-03 # #Scale= 1.5 # #Weibull distribution #Loglik(model)= -156.2 Loglik(intercept only)= -156.2 #Number of Newton-Raphson Iterations: 5 #n= 50 ### Calculating the mean time for death, the time that 50% of population is dead. mu - exp(3.466) mu #[1] 32.00845 ### In this example the mean time for death (\mu) is 32.00845. ### Now the alpha calculation based on scale parameter alpha - 1/1.5 alpha #[1] 0.667 ### Making the curve curve(exp((-mu^(-alpha))*(x^alpha)),from=0,to=50,ylim=c(0,1),col=1,ylab=Survival,xlab=Time) ### Adding lines in graphic to show the point corresponding to the coordinates, y=0.5 (50% of mortality) and x=32 that is the time to death for 50% of population. abline(h=0.5,lty=2) abline(v=mu,lty=2) points(mu,0.5,cex=2) The problem is, I expected that the estimated curve from weibull cross this point(32,0.5) but it is not really. What is the problem with this analysis? Thanks Ronaldo -- 1ª lei - Suas férias começam após a defesa e entrega de sua dissertação. --Herman, I. P. 2007. Following the law. NATURE, Vol 445, p. 228. Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8192 | ronaldo.r...@unimontes.br | http://www.ppgcb.unimontes.br/lecc | LinuxUser#: 205366 [[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] scatterplot3d - help assign colors based on multiple conditions
On 09.06.2011 16:51, Karthik Kota wrote: Hi I am relatively new to R and am trying to figure out to plot 3d scatter plot using defined colors based on x-axis and y-axis values. Right now in the code below, I assign colors based on certain values in the names of the x-axis. Now if I want to extend the condition to assign a color based on the names of both x-axis and y-axis values, what should I be doing? Any help or ideas would be greatly appreciated. For e.g. in my 3 column matrix below, if I want to assign red to all the values whose first column and second column contain Anterior_nares and assign black to any other combination. Both question and answer are not really scatterplot3d related: You probably want col - ifelse(grepl(_Anterior_nares, xlabels) grepl(_Anterior_nares, ylabels), red, black) Best, Uwe Ligges Thanks! Karthik library(scatterplot3d) chd1=read.table(file=test.out, header=F, sep=\t) col=as.vector(chd1[,1]) xlabels=as.vector(chd1[,1]) ylabels=as.vector(chd1[,2]) mycols-c(red,blue,green,chocolate,orange, brown) col[grep(_Stool, xlabels) ]-mycols[1] #col[grep(_Stool, xlabels) grep(_Stool, ylabels) ]-mycols[1] col[grep(_Tongue_dorsum, xlabels) ]-mycols[2] col[grep(_Posterior_fornix, xlabels) ]-mycols[3] col[grep(_Anterior_nares, xlabels) ]-mycols[4] col[grep(_Buccal_mucosa, xlabels) ]-mycols[5] col[grep(_Supragingival_plaque, xlabels) ]-mycols[6] png(file=3dplot_test.png, w=700,h=700) scatterplot3d(chd1[, 1], chd1[, 2], chd1[, 3], main=test, xlab=sample, ylab=sample, zlab=kmers, color=col,type=p) dev.off () my test.out matrix looks something like this: A011132_Anterior_nares A011263_Anterior_nares 50130 A011132_Anterior_nares A011397_Stool 34748 A011132_Anterior_nares A012291_Tongue 40859 A011132_Anterior_nares A012663_Buccal_mucosa 76213 A011132_Anterior_nares A013155_Anterior_nares 36841 A011132_Anterior_nares A013269_Anterior_nares 45619 A011132_Anterior_nares A013637_Anterior_nares 56995 [[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] Rcpp and Object Factories
Hello, I'm not exactly sure how to ask this question, but let me give it a shot... Is it possible (easy) to use Rcpp Modules in conjunction with object factories? For example what I am trying to do is something like this: // c++ classes class Foo { public: void do_something() {}; }; class Foo_Factory { public: Foo * create_foo() { return new Foo(); } }; ## R Code library(Rcpp) ff - Module(Foo_Factory) foo - ff$create_foo() foo$do_something() It appears after scouring some message boards that it is doable via boost python, but i'm not literate enough yet about how this works to know if the same logic holds for R. Thanks for the help. -Mike King [[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.skeleton() does not create 'data' folder
Hi again, yesterday I mailed this query however I could not see this on the mail list. Therefore, I am reposting it again. I was using package.skeleton() function to create the skeleton of my package in windows. Here is my attempt: rm(list = ls()) setwd(F:/R_PackageBuild) package.skeleton(trial1, namespace = TRUE, code_files = F:/R_PackageBuild/trial.r) In the trial.r file, there are 2 objects, one is a function and another is data. Here they are: fn1 - Vectorize(function(x,y,z) { return(x + y +z) }, SIMPLIFY = TRUE) Data - rnorm(20) However my problem is that package.skeleton() does not create any data folder in the skeleton tree. However in the man folder there are 3 Rd files (as expected), naming: Data, fn1, trial1-package However on the contrary if my code is like below then, package.skeleton() creates data folder. fn1 - Vectorize(function(x,y,z) { + return(x + y +z) + }, SIMPLIFY = TRUE) Data - rnorm(20) setwd(F:/R_PackageBuild) package.skeleton(trial2) So is it that if I use 'code_files ' argument then, R would not create data folder? Can somebody help me what I am missing in this process? Till now, I create ___manually the data folder and within that folder manually put a RData file where only object is that 'Data'. However I believe there must be more elegant way to doing that. While searching over net to settle this issue, I found a thread with hesding 'How to create .rda file to be used in package building', however this is not answering my question. Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Coercing Output from mget() into Proper Data Frame
Hello R-philes: I have the following function that gets the output of mget() and converts it to a data frame to return. What I am finding is that the dimensions are wrong. Basically, I get: bridesmaid wed u see m gt lt like love X.0 dress pagetrack one go X3 get 1 56 35 27 30 24 20 20 23 28 172516 16 28 15 26 Instead, I want something like: [1] bridesmaid 56 In other words, I want the word in the first column and the frequency in the second column. Any help would be very much appreciated. Regards, Na'im library(Rstem) # make a data frame of stems and their frequencies stem_freq_list - function(freqFile) { stem_dict - new.env(parent=emptyenv(), hash=TRUE) freq_dist - read.csv(freqFile,header=TRUE) words - as.character(freq_dist[,1]) freqs - as.numeric(freq_dist[,2]) stems - wordStem(words, language=english) uniq_stems - c() # make a hash table of stems and their frequencies for (i in 1:length(words)) { word - words[i]; stem - stems[i]; freq - freqs[i] if (exists(stem, envir=stem_dict)) { cnt - get(stem, envir=stem_dict) cnt - cnt + freqs[i] assign(stem,cnt,envir=stem_dict) } else { assign(stem, freq, envir=stem_dict) uniq_stems - append(uniq_stems, stem) } } # return data frame of stems and their frequencies stem_freqs_list - mget(uniq_stems,stem_dict) stem_freqs - do.call(rbind,stem_freqs_list) return(stem_freqs_list) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Coercing Output from mget() into Proper Data Frame
Hello R-philes: I have the following function that gets the output of mget() and converts it to a data frame to return. What I am finding is that the dimensions are wrong. Basically, I get: bridesmaid wed u see m gt lt like love X.0 dress pagetrack one go X3 get 1 56 35 27 30 24 20 20 23 28 172516 16 28 15 26 Instead, I want something like: [1] bridesmaid 56 In other words, I want the word in the first column and the frequency in the second column. Any help would be very much appreciated. Regards, Na'im library(Rstem) # make a data frame of stems and their frequencies stem_freq_list - function(freqFile) { stem_dict - new.env(parent=emptyenv(), hash=TRUE) freq_dist - read.csv(freqFile,header=TRUE) words - as.character(freq_dist[,1]) freqs - as.numeric(freq_dist[,2]) stems - wordStem(words, language=english) uniq_stems - c() # make a hash table of stems and their frequencies for (i in 1:length(words)) { word - words[i]; stem - stems[i]; freq - freqs[i] if (exists(stem, envir=stem_dict)) { cnt - get(stem, envir=stem_dict) cnt - cnt + freqs[i] assign(stem,cnt,envir=stem_dict) } else { assign(stem, freq, envir=stem_dict) uniq_stems - append(uniq_stems, stem) } } # return data frame of stems and their frequencies stem_freqs_list - mget(uniq_stems,stem_dict) stem_freqs - do.call(rbind,stem_freqs_list) return(stem_freqs_list) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Decision Trees /Decision Analysis with R?
thanks for the hint, Kjetil. That looks more like what I am looking for. Thanks for all your mails! Best, Stefan On Wed, Jun 8, 2011 at 11:25 PM, Kjetil Halvorsen kjetilbrinchmannhalvor...@gmail.com wrote: see inline below. On Wed, Jun 8, 2011 at 12:37 PM, Anupam anupa...@gmail.com wrote: It is difficult for someone from a statistical frame of mind to understand what this is about --- you need to think a bit differently. It is mostly a simulation and decision analysis, with some use of statistical functions to draw random samples to simulate the fact that outcome of interest can take any value from a known or unknown distribution. For example, you may be comparing two interventions and a do-nothing decision to improve some health outcome of interest. The decision maker is interested in *relative* effectiveness and costs of the interventions to improve the outcome of interest. You have results from published literature that you can use as inputs into a simulation exercise to compare relative costs and benefits/effectiveness of the three options. A small decision tree can be easily simulated in a spreadsheet; for long trees with many decision nodes it is useful to have a specialized software. There are some Excel plugins that are sold about $100. Others are more expensive. I think R is not well suited for this kind of work. A decision analysis Not necessarily! A desicion tree model is a kind of graphical model. See the CRAN task view gR (graphical models in R) and maybe ask on the special interest mailing list R-sig-gR kjetil package in R may require user to write code like the one used in LaTeX or related programs (Metapost) to draw graphs of trees (e.g. complicated organizational trees, or hierarchical trees). However, in such a package there can be useful outputs, measures and graphs generated by R using code that may already exist for other packages. Look up journal Medical Decision Making to know what is being discussed. This method is used extensively in medicine and public health to study decisions. It even uses MCMC, though with a different flavor --- it may even be a different kind of food. Anupam. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan Daily Sent: Wednesday, June 08, 2011 7:47 PM To: stefan.d...@gmail.com Cc: r-help@r-project.org Subject: Re: [R] Decision Trees /Decision Analysis with R? So TreeAge fits models but won't predict from them? That seems like bizarre behavior. I suppose I would recommend, then, looking at the source code from the aforementioned packages for how they store their split data. It sounds like you would have to write code to hack TreeAge outputs into another packages' format (e.g. look at ?rpart.object). Sorry I couldn't help more, Jon On Wed, Jun 8, 2011 at 9:47 AM, stefan.d...@gmail.com stefan.d...@gmail.com wrote: Thank you so much for reply. But I am looking for the exact opposite. I do not have a data set which I want to partition. But already a sequence/tree-like set of decision rules and with which I want to simulate what is my expected outcome/pay-off given a particular scenario. As far as I understand it, those packages could calculate the expected outcome AFTER having fit them to a particular data set and not construct a synthetic tree with exogenously defined decision nods/rules. Or am I wrong? Thanks and best, Stefan On Wed, Jun 8, 2011 at 2:03 PM, Jonathan Daily biomathjda...@gmail.com wrote: See packages rpart, randomForest, party. Also, typing R Decision Trees produced good google results. http://www.google.com/search?aq=fsourceid=chromeie=UTF-8q=R+Decisi on+Trees On Wed, Jun 8, 2011 at 7:02 AM, stefan.d...@gmail.com stefan.d...@gmail.com wrote: Hello, this question is a bit out of the blue. I am a big R fan and user and in my new job I do some decision modeling (mostly health economics). For that decision trees are often used (I guess the most classic example is the investment decision A, B, and C with different probabilities, what is the expected payoff). We use a specialized software called TreeAge that some might know. The basic setup of such simulations is actually very simple and I guess useful in many fields. So I was wondering whether there is already a package out there in R that is doing such a thing? Thanks for any hints! Best, Stefan PS (By decision tree I don't mean cluster-like analysis of a data set splitting by identifying decision nods, but the other way around: I have decision nodes, what is my expected outcome.) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- === Jon Daily
[R] missing values and error message
Hello forum, I am using R to do some Exploratory analysis on my data resulting in the following 4 plots. #1- Histogram of the variable; #2- Kernel density estimation of the variable; #3- Normal Q-Q plot ; #4- Box-plot of the variable. The error message comes in when i try to plot # 2 above when there are missing values in a specific column. For other subjects with non missing values in each variable, i can plot using the code and then i can proceeed to the other plots using the code below: The code is as follows: Chair002OD-read.csv(Chair002OD.csv, header=TRUE) attach(Chair002OD) names(Chair002OD) oldpar-par(mfrow=c(2,2),oma=c(0,0,2,0) 0.1) truehist(SDANN5mins,SDANN5mins=FD,col=blue,main=Histogram of SDANN5mins, ylab=Frequency,prob=FALSE) box() plot(density(SDANN5mins,lwd=1, main=Density estimation,font.main=1) rug() Error in density.default(SDANN5mins) : 'x' contains missing values If there are no missing values, i can proceed with getting all 4 plots as needed. If i use na.action=na.omit, where do i put this for example: plot(density(SDANN5mins,lwd=1, main=Density estimation,font.main=1,na.action=na.omit) Any help would be appreciated. Thanks. MAA Doctoral candidate Newcastle University This message may contain confidential information. If yo...{{dropped:25}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reshape:cast; error using ... in formula expression.
Wow---Dennis, your answer makes me feel good about humanity. Thank you; you've made my day. Yours, Rob -- View this message in context: http://r.789695.n4.nabble.com/Reshape-cast-error-using-in-formula-expression-tp3584721p3586482.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 make code more efficient
I have a repetative task in R and i'm trying to find a more efficient way to perform the following task. lst - list(roots = c(car insurance, auto insurance), roots2 = c(insurance), prefix = c(cheap, budget), prefix2 = c(low cost), suffix = c(quote, quotes), suffix2 = c(rate, rates), suffix3 = c(comparison), state = c(state), inscompany = c(inscompany), city=c(city), cityst = c(cityst), agency=c(agency)) myone - function(x, y) { m1 - do.call(paste, expand.grid(lst[[x]], lst[[y]])) mydf - data.frame(keyword=c(m1)) } mytwo - function(x, y, z){ m2 - do.call(paste, expand.grid(lst[[x]], lst[[y]], lst[[z]])) mydf2 - data.frame(keyword=c(m2)) } d1 = mytwo(prefix, roots, suffix) d2 = mytwo(prefix, roots, suffix2) d3 = mytwo(prefix, roots, suffix3) d4 = mytwo(prefix2, roots, suffix) d5 = mytwo(prefix2, roots, suffix2) d6 = mytwo(prefix2, roots, suffix3) d7 = mytwo(prefix, roots2, suffix) d8 = mytwo(prefix, roots2, suffix2) d9 = mytwo(prefix, roots2, suffix3) d10 = mytwo(prefix2, roots2, suffix) d11 = mytwo(prefix2, roots2, suffix2) d12 = mytwo(prefix2, roots2, suffix3) d13 = myone(prefix, roots) d14 = myone(prefix2, roots) d15 = myone(prefix, roots2) d16 = myone(prefix2, roots2) d17 = myone(roots, suffix) d18 = myone(roots, suffix2) d19 = myone(roots, suffix3) d20 = myone(roots2, suffix) d21 = myone(roots2, suffix2) d22 = myone(roots2, suffix3) d23 = myone(state, roots) d24 = myone(city, roots) d25 = myone(cityst, roots) d26 = myone(inscompany, roots) d27 = myone(state, roots2) d28 = myone(city, roots2) d29 = myone(cityst, roots2) d30 = myone(inscompany, roots2) d31 = mytwo(state, roots, suffix) d32 = mytwo(city, roots, suffix) d33 = mytwo(cityst, roots, suffix) d34 = mytwo(inscompany, roots, suffix) d35 = mytwo(state, roots, suffix2) d36 = mytwo(city, roots, suffix2) d37 = mytwo(cityst, roots, suffix2) d38 = mytwo(inscompany, roots, suffix2) d39 = mytwo(state, roots, suffix3) d40 = mytwo(city, roots, suffix3) d41 = mytwo(cityst, roots, suffix3) d42 = mytwo(inscompany, roots, suffix3) d43 = mytwo(state, roots2, suffix) d44 = mytwo(city, roots2, suffix) d45 = mytwo(cityst, roots2, suffix) d46 = mytwo(inscompany, roots2, suffix) d47 = mytwo(state, roots2, suffix2) d48 = mytwo(city, roots2, suffix2) d49 = mytwo(cityst, roots2, suffix2) d50 = mytwo(inscompany, roots2, suffix2) d51 = mytwo(state, roots2, suffix3) d52 = mytwo(city, roots2, suffix3) d53 = mytwo(cityst, roots2, suffix3) d54 = mytwo(inscompany, roots2, suffix3) d55 = mytwo(prefix, state, roots) d56 = mytwo(prefix, city, roots) d57 = mytwo(prefix, cityst, roots) d58 = mytwo(prefix, inscompany, roots) d59 = mytwo(prefix2, state, roots) d60 = mytwo(prefix2, city, roots) d61 = mytwo(prefix2, cityst, roots) d62 = mytwo(prefix2, inscompany, roots) d63 = mytwo(prefix, state, roots2) d64 = mytwo(prefix, city, roots2) d65 = mytwo(prefix, cityst, roots2) d66 = mytwo(prefix, inscompany, roots2) d67 = mytwo(prefix2, state, roots2) d68 = mytwo(prefix2, city, roots2) d69 = mytwo(prefix2, cityst, roots2) d70 = mytwo(prefix2, inscompany, roots2) d71 = mytwo(prefix, inscompany, suffix) d72 = mytwo(prefix, inscompany, suffix2) d73 = mytwo(prefix, inscompany, suffix3) d74 = mytwo(prefix2, inscompany, suffix) d75 = mytwo(prefix2, inscompany, suffix2) d76 = mytwo(prefix2, inscompany, suffix3) Obviously, this code gets rather repetative, even with the function, and I was wondering if there's a shortcut that I should consider to simplify the process. Thanks, I'm running R 2.13 on Ubuntu 10.10 [[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] How to subset based on column name that is a number ?
Hi, I have a data frame with column names 1, 2, 3, ... and I'd like to extract a subset based on the values in the first column. None of the methods I tried worked (below). x - subset(dframe, 1 = = My Text) x - subset(dframe, 1 = = My Text) x - subset(dframe, names(dframe)[1] = = My Text) Q - dframe[1 = = FY11_Q4,] Q - dframe['1'==FY11_Q4,] Q - dframe[names(dframe)[1]==FY11_Q4,] Might anyone have a suggestion? Many thanks, Mauricio [[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] Reshape:cast; error using ... in formula expression.
Dennis, doing some more research, and it seems you actually can include the ... term directly in the formula: cf. page 8 of http://www.had.co.nz/reshape/introduction.pdf (that article also explains why you might want to do so). It seems including the ... term only works, however, when your value column actually has the name value (e.g. using the value=my.val option yields the error). This was the bug that was catching me up yesterday. Thank you again Dennis, Yours, Rob -- View this message in context: http://r.789695.n4.nabble.com/Reshape-cast-error-using-in-formula-expression-tp3584721p3586597.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] Coercing Output from mget() into Proper Data Frame
That's not enough information for us to be able to help you, since there's no reproducible code. Here's the crucial bit: stem_freqs_list - mget(uniq_stems,stem_dict) stem_freqs - do.call(rbind,stem_freqs_list) What does stem_freqs_list look like? What does stem_freqs look like? dim() and str() would both be helpful here. Sarah On Thu, Jun 9, 2011 at 3:48 PM, nty...@clovermail.net wrote: Hello R-philes: I have the following function that gets the output of mget() and converts it to a data frame to return. What I am finding is that the dimensions are wrong. Basically, I get: bridesmaid wed u see m gt lt like love X.0 dress pagetrack one go X3 get 1 56 35 27 30 24 20 20 23 28 17 25 16 16 28 15 26 Instead, I want something like: [1] bridesmaid 56 In other words, I want the word in the first column and the frequency in the second column. Any help would be very much appreciated. Regards, Na'im library(Rstem) # make a data frame of stems and their frequencies stem_freq_list - function(freqFile) { stem_dict - new.env(parent=emptyenv(), hash=TRUE) freq_dist - read.csv(freqFile,header=TRUE) words - as.character(freq_dist[,1]) freqs - as.numeric(freq_dist[,2]) stems - wordStem(words, language=english) uniq_stems - c() # make a hash table of stems and their frequencies for (i in 1:length(words)) { word - words[i]; stem - stems[i]; freq - freqs[i] if (exists(stem, envir=stem_dict)) { cnt - get(stem, envir=stem_dict) cnt - cnt + freqs[i] assign(stem,cnt,envir=stem_dict) } else { assign(stem, freq, envir=stem_dict) uniq_stems - append(uniq_stems, stem) } } # return data frame of stems and their frequencies stem_freqs_list - mget(uniq_stems,stem_dict) stem_freqs - do.call(rbind,stem_freqs_list) return(stem_freqs_list) } -- 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.