Re: [R] Power analysis
Hi: Just to add to the discussion, see the following article by Russell Lenth on the subject: http://www.stat.uiowa.edu/techrep/tr378.pdf Dennis On Thu, Sep 2, 2010 at 3:59 PM, C Peng peng.cheng...@hotmail.com wrote: Agree with Greg's point. In fact it does not make logical sense in many cases. Similar to the use of the statistically unreliable reliability measure Cronbach's alpha in some non-statistical fields. -- View this message in context: http://r.789695.n4.nabble.com/Power-analysis-tp2524729p2524907.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. [[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] calculate monthly mean
Hello Ali, It looks to me like you have two questions: 1) the error you get from scatterplot3d 2) how to calculate the monthly mean. If you could provide some sample data that would make it a lot easier to help you understand why the error occurred and what to do about it. For now, maybe this will get you started on calculating the monthly mean. # Create a data frame with the data in 'x' and the dates in 'y' sampdat - data.frame(x = 1:365, y = Sys.Date() + 1:365) # convert 'y' to a factor by cut()ing the dates by month sampdat$y - cut.Date(x = sampdat$y, breaks = month, include.lowest = TRUE, right = TRUE) # now just find the mean of 'x' for each level of 'y' by(data = sampdat$x, INDICES = sampdat$y, FUN = mean) # For some documentation ?Date ?cut.Date #cut() will call the right method, but I wanted to be explicit ?by Cheers, Josh On Thu, Sep 2, 2010 at 5:06 PM, Ali Alsamawi ali.alsam...@unsw.edu.au wrote: Hello group Im trying to plot 3d with scatterplot packages, i got error say length(color) must be equal length(x) or 1 may data has dimensions (lon,lat,lev,time) ,the time in month i want to calculate the monthly mean for the time how can i make that , is there any function doing that Thanks a lot ##load rgl package library(rgl) library(fields) library(ncdf) library(scatterplot3d) ## open binary file to read nc - open.ncdf(/srv/ccrc/data05/z3236814/mm5/co2/2000/q.21.mon.nc) v1 - nc$var [[1]] v2 - nc$var [[2]] v3 - nc$var [[3]] data1 - get.var.ncdf(nc,v1) data2 - get.var.ncdf(nc,v2) data3 - get.var.ncdf(nc,v3) coldat = data1[1:111,1:101,23,1:60] ## creat colour hcol = cumsum(coldat) coldat = hcol hcol = hcol/max(hcol,na.rm=TRUE) col - hsv(h=hcol,s=1,v=1) X -scatterplot3d(data3[1:111,1:101],data2[1:111,1:101],data1[1:111,1:101,23,1:60],color=col) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] define colors for groups in lattice xyplot
Dear all, Lattice provides automatic coloring for subgroups on each panel by the simple use of a groups statement. For an application I want to change these colors to a predifined set. This works well using a panel function in stead of the default as long as there are only points in the graphs. When I set type=b things get messed up. Any idea why? I include sample code for illustration below. Thanks for your ideas. Geert dataset - data.frame ( time = rep(1:5,times=9), genotype = factor(rep(rep (c(A,B,C),each=5),times=3 )), location= factor(rep (paste(LOC,1:3),each=15)), color = rep (rep (c(red,green,blue),each=5),times=3 ), result = rnorm (45)) library(lattice) xyplot( result ~ time | location, data=dataset,groups=genotype,pch=19, type=b) xyplot( result ~ time | location, data=dataset,groups=genotype, fill.color = dataset$color, panel = function(x, y,fill.color,...,subscripts) { fill = fill.color [subscripts] panel.xyplot(x, y,pch=19, col=fill)} ) xyplot( result ~ time | location, data=dataset,groups=genotype, fill.color = dataset$color, panel = function(x, y,fill.color,...,subscripts) { fill = fill.color [subscripts] panel.xyplot(x, y,pch=19, col=fill, type =b)} ) The information contained in this e-mail is for the excl...{{dropped:14}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why is vector assignment in R recreates the entire vector ?
NM == Norm Matloff matl...@cs.ucdavis.edu on Thu, 2 Sep 2010 12:20:44 -0700 writes: NM Tal wrote: A friend recently brought to my attention that vector assignment actually recreates the entire vector on which the assignment is performed. NM ... NM I brought this up in r-devel a few months ago. yes, thank you Norm, for the pointer. Indeed this whole topic really belongs to R-devel not R-help. Martin Maechler NM You can read my posting, NM and the various replies, at NM http://www.mail-archive.com/r-de...@r-project.org/msg20089.html NM Some of the replies not only explain the process, but list lines in the NM source code where this takes place, enabling a closer look at how/when NM duplication occurs. NM Norm Matloff __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Select.list
Hi R, I am using select.list names=c(Ravi, Raj,Shubha,Nivriti) select.list(names) provides a drop down to choose one of the 4 names. However I would like to know if it is possible to create a classification something like this select.list(names) should give Boys Ravi Raj Girls Shubha Nivriti I should be able to choose only one of the names. Any help would be appreciated. R version 2.10.1 (2009-12-14) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices datasets utils methods base other attached packages: [1] clim.pact_2.2-41 akima_0.5-4 ncdf_1.6.1 rcom_2.2-3 [5] rscproxy_1.3-1 loaded via a namespace (and not attached): [1] tools_2.10.1 Thank you Regards Ravi 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] Using library and lib.loc
o == omerle ome...@laposte.net on Thu, 2 Sep 2010 10:30:49 +0200 (CEST) writes: o Hi, o I didn't find any post on this subject so I ll ask you some advices. o Let's say that I have two library trees. o Number 1 is the default R library tree on path1 o Number 2 is another library tree on a server with all packages on path2. o When I set library(aaMI,lib.loc=paths2) it loads the package even if its not on default R library o When I set library(fOptions,lib.loc=paths2) it doesn't load because timeSeries is not on default R library (timeSeries is a required package for fOptions) library(fOptions,lib.loc=.lib.loc) o Le chargement a nécessité le package : timeDate o Le chargement a nécessité le package : timeSeries o Erreur : le package 'timeSeries' ne peut être chargé o De plus : Message d'avis : o In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : o  aucun package nommé 'timeSeries' n'est trouvé o (Sorry for french error message. By the way, how can I set error in French (setting language in English in R installation is not sufficient !) o How can I set lib.loc for every package that I will load ? o Or is there any global way of doing this ? There are several possibilities .. You can set .libPaths() in your Rprofile or you can set R_LIBS in yourRenviron and there are variations and combinations of the above. See ?Startup to learn about Rprofile and Renviron settings. Martin Maechler, ETH Zurich o Thanks, o Olivier __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 'seq' help page: seq_length - seq_len?
In the Value section of the 'seq' help page it says 'seq_along' and 'seq_length' always return an integer vector. I believe it should be 'seq_along' and 'seq_len' always return an integer vector. as there are no seq_length function? Best, Niels -- Niels Richard Hansen Web: www.math.ku.dk/~richard Associate Professor Email: niels.r.han...@math.ku.dk Department of Mathematical Sciences nielsrichardhan...@gmail.com University of Copenhagen Skype: nielsrichardhansen.dk Universitetsparken 5 Phone: +45 353 20783 (office) 2100 Copenhagen Ø +45 2859 0765 (mobile) Denmark __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] define colors for groups in lattice xyplot
Hi Geert ### dataset - data.frame ( time = rep(1:5,times=9), genotype = factor(rep(rep (c(A,B,C),each=5),times=3 )), location= factor(rep (paste(LOC,1:3),each=15)), color = rep (rep (c(red,green,blue),each=5),times=3 ), result = rnorm (45)) library(lattice) # The black, red, green behaviour you were seeing is because # dataset$color is a factor dataset$color # which is coded 1, 2, 3 levels = (red, green, blue). # This is being interpreted as the first three colours of the palette pallete() # coerce the vector to a character vector as.character(dataset$color) # gives you xyplot( result ~ time | location, data=dataset,groups=genotype, fill.color = as.character(dataset$color), panel = function(x, y,fill.color,...,subscripts) { fill = fill.color [subscripts] panel.xyplot(x, y,pch=19, col=fill, type =b)} ) # Lines only take a single value so only the first value of the vector, # red, is passed to line colour. # these are simple alternatives xyplot( result ~ time | location, data=dataset, groups=genotype, pch=c(1,2,3), type=b, col=c(red,blue,green)) xyplot( result ~ time | location, data=dataset, groups=genotype, pch=c(1,2,3), type=b, col=dataset$color) # or use par.settings - list(superpose.symbol = list(col = c(red, green, blue), fill = c(red, green, blue)), superpose.line = list(col = c(red, green, blue)) ) xyplot( result ~ time | location, data=dataset,groups=genotype,pch=19, type = b, par.settings = par.settings) ### Hope this helps Chris ### Hadley Wickham, Creator of ggplot2 - teaching in the UK. 1st - 2nd November 2010. To book your seat please go to http://mango-solutions.com/news.html Chris Campbell MANGOSOLUTIONS R consulting and training T: +44 (0)1249 767700 Ext: 233 F: +44 (0)1249 767707 M: +44 (0)7967 028876 www.mango-solutions.com Unit 2 Greenways Business Park Bellinger Close Chippenham Wilts SN15 1BN UK -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of geert.deme...@bayercropscience.com Sent: 03 September 2010 07:44 To: r-help@r-project.org Subject: [R] define colors for groups in lattice xyplot Dear all, Lattice provides automatic coloring for subgroups on each panel by the simple use of a groups statement. For an application I want to change these colors to a predifined set. This works well using a panel function in stead of the default as long as there are only points in the graphs. When I set type=b things get messed up. Any idea why? I include sample code for illustration below. Thanks for your ideas. Geert dataset - data.frame ( time = rep(1:5,times=9), genotype = factor(rep(rep (c(A,B,C),each=5),times=3 )), location= factor(rep (paste(LOC,1:3),each=15)), color = rep (rep (c(red,green,blue),each=5),times=3 ), result = rnorm (45)) library(lattice) xyplot( result ~ time | location, data=dataset,groups=genotype,pch=19, type=b) xyplot( result ~ time | location, data=dataset,groups=genotype, fill.color = dataset$color, panel = function(x, y,fill.color,...,subscripts) { fill = fill.color [subscripts] panel.xyplot(x, y,pch=19, col=fill)} ) xyplot( result ~ time | location, data=dataset,groups=genotype, fill.color = dataset$color, panel = function(x, y,fill.color,...,subscripts) { fill = fill.color [subscripts] panel.xyplot(x, y,pch=19, col=fill, type =b)} ) The information contained in this e-mail is for the\ exc...{{dropped:19}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] define colors for groups in lattice xyplot
Hi: The 'easy' solution is to define the colors corresponding to the genotypes directly in lattice: xyplot( result ~ time | location, data=dataset, groups=genotype, pch=19, type=b, col = c('red', 'green', 'blue')) The problem with trying to use color as a variable to 'match' to genotype is that both genotype and color are factors, but the default ordering of factor levels is alphabetic. This is no problem for genotype, but it is for color, so the matching of genotype-color pairs in dataset doesn't actually occur; instead, R will render colors blue, green and red, respectively, to match to genotypes A-C. To fix that problem, make color an ordered factor: dataset$color - ordered(dataset$color, levels = c('red', 'green', 'blue')) xyplot( result ~ time | location, data=dataset, groups=genotype, pch=19, type=b, col = levels(dataset$color)) HTH, Dennis On Thu, Sep 2, 2010 at 11:43 PM, geert.deme...@bayercropscience.com wrote: Dear all, Lattice provides automatic coloring for subgroups on each panel by the simple use of a groups statement. For an application I want to change these colors to a predifined set. This works well using a panel function in stead of the default as long as there are only points in the graphs. When I set type=b things get messed up. Any idea why? I include sample code for illustration below. Thanks for your ideas. Geert dataset - data.frame ( time = rep(1:5,times=9), genotype = factor(rep(rep (c(A,B,C),each=5),times=3 )), location= factor(rep (paste(LOC,1:3),each=15)), color = rep (rep (c(red,green,blue),each=5),times=3 ), result = rnorm (45)) library(lattice) xyplot( result ~ time | location, data=dataset,groups=genotype,pch=19, type=b) xyplot( result ~ time | location, data=dataset,groups=genotype, fill.color = dataset$color, panel = function(x, y,fill.color,...,subscripts) { fill = fill.color [subscripts] panel.xyplot(x, y,pch=19, col=fill)} ) xyplot( result ~ time | location, data=dataset,groups=genotype, fill.color = dataset$color, panel = function(x, y,fill.color,...,subscripts) { fill = fill.color [subscripts] panel.xyplot(x, y,pch=19, col=fill, type =b)} ) The information contained in this e-mail is for the ex...{{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] define colors for groups in lattice xyplot
Geert, thanks for providing a nice example. When use see groups in xyplot, you should switch to the documentation (and use) panel.superpose. Which has a somewhat different philosophy (your looks more like ggplot2 would do it). The docs of panel.superpose say (tersely...) col: graphical parameters, replicated to be as long as the number of groups. These are eventually passed down to panel.groups, but as scalars rather than vectors. When panel.groups is called for the i-th level of groups, the corresponding element of each graphical parameter is passed to it. dataset - data.frame ( time = rep(1:5,times=9), genotype = factor(rep(rep (c(A,B,C),each=5),times=3 )), location= factor(rep (paste(LOC,1:3),each=15)), color = rep (rep (c(red,green,blue),each=5),times=3 ), result = rnorm (45)) library(lattice) # color in the data frame is not needed, just defined it for the group mycol = c(red,green,blue) # The complex way with an explicit panel.superpose xyplot( result ~ time | location, data=dataset,groups=genotype, fill.color = dataset$color, type=b, panel = function(x, y,...) { panel.superpose(x, y,...,pch=19, col = mycol) }) # The easy way out xyplot( result ~ time | location, data=dataset,groups=genotype, fill.color = dataset$color, col=mycol, type=b,pch=19 ) Dieter -- View this message in context: http://r.789695.n4.nabble.com/define-colors-for-groups-in-lattice-xyplot-tp2525197p2525321.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] Power analysis
Lewis G. Dean wrote: post-hoc power analysis on a Wilcoxon test. There is a (somewhat dated) list of why-not papers in http://www.childrens-mercy.org/stats/size/posthoc.asp Dieter -- View this message in context: http://r.789695.n4.nabble.com/Power-analysis-tp2524729p2525333.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] Ordering data by variable
On Thu, Sep 2, 2010 at 2:33 PM, Greg Snow greg.s...@imail.org wrote: Suggestion: use the power of R. If x and y are independent then sorting y based on x is meaningless. If sorting y based on x is meaningful, then they are not independent. Trying to force non-independent things to pretend that they are independent just causes future headaches. Part of the great power of R is the ability to group things together that should be grouped. The wise learn this and use it (in some cases (mine) that wisdom comes at the expense of not having properly grouped in the past). Yes, this is an excellent suggestion. My workspace used to be like a rock pile that my poor brain had to dig through, trying to remember some truly awful combinations of capitalizations, '.' , '_' , and numerals from my vain efforts to organize variables. Dataframes (and lists for those pesky variables with irregular lengths) were the rake that brought peace and tranquility to the rock garden of my workspace. Josh Learn the power of with/within, data= arguments, and apply style functions, then you will be eager to combine things into data frames (or lists or ...) when appropriate. descend from soapbox -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] define colors for groups in lattice xyplot
Thanks to Chris and Dennis. My problem is solved although it will take some additional time before I fully understand the solution. Cheers Geert De Meyer _ Bayer BioScience N.V. BioInformation Management Zwijnaarde Company Identification Number BE0422529921 The information contained in this e-mail is for the excl...{{dropped:14}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] change the type of lines and colours in interaction.plot
Dear all, I want to plot 8 chemical variables in the same plot. I have used the interaction.plot command: interaction.plot(speclong$Date,speclong$time2,speclong$outcome,xaxt=n,type=l,pch=20,xlab=, log=y, ylab=Concentration (ug/L),trace.label=,col=rainbow(8)) However, what it gives me is dotted lines and the colours are very fade. I was wondering if I can change the lines to be solid and as well to specify for each line the colour that I want. Thanks a lot. Maria [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] testing for emptyenv
Peng, C wrote: Is there a complete list of these very handy and power functions in the base R? ls(package:base) will list all the objects exported from base, but it doesn't rate them to let you know which ones are handy and which ones are a waste of space. We like to think they're all useful. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R CMD check Package(Windows): Error in inDL(x, as.logical(local), as.logical(now), ...) :
raje...@cse.iitm.ac.in wrote: After the R CMD check is done and an R CMD INSTALL is done, where does the external dll have to be? See my message below. ..what can i do to make it move around with the package? can I zip it with the package? if so in what folder? R isn't designed to handle closed source binary includes, but you could probably install one by putting the right code into Makevars in your package. You want the .dll to end up in the libs directory of the installed package. You might be able to get away with this by putting it into inst/libs, but this is explicitly against the rules. After-install editing of the .zip file would probably work, but would be a maintenance problem. See Writing R Extensions for details. Duncan Murdoch - Original Message - From: Duncan Murdoch murdoch.dun...@gmail.com To: raje...@cse.iitm.ac.in Cc: r-help r-help@r-project.org Sent: Thu, 02 Sep 2010 16:42:31 +0530 (IST) Subject: Re: [R] R CMD check Package(Windows): Error in inDL(x, as.logical(local), as.logical(now), ...) : On 02/09/2010 6:46 AM, raje...@cse.iitm.ac.in wrote: It is dependent on another dll but it did not give compilation errors. It seemed to link fine at that point. Why does it have a problem at this stage? Windows needs to be able to find the other DLL at load time. It will find it if it's in the same directory or on the PATH. Duncan Murdoch From: Duncan Murdoch To: raje...@cse.iitm.ac.in Cc: r-help Sent: Thursday, September 2, 2010 4:05:14 PM Subject: Re: [R] R CMD check Package(Windows): Error in inDL(x, as.logical(local), as.logical(now), ...) : On 02/09/2010 2:29 AM, raje...@cse.iitm.ac.in wrote: Hi, I've built my own package in windows and when I run R CMD check Package-Name I get, * install options are ' --no-html' * installing *source* package 'AceTest' ... ** libs making DLL ... g++ ...etc. installing to ... done ** R ** preparing package for lazy loading ** help Warning: ./man/AceTest-package.Rd:34: All text must be in a section Warning: ./man/AceTest-package.Rd:35: All text must be in a section *** installing help indices ** building package indices ... ** testing if installed package can be loaded Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'H:/RTick/Project/Client/AceTest.Rcheck/AceTest/libs/AceTest.dll': LoadLibrary failure: The specified module could not be found. ERROR: loading failed The message The specified module could not be found comes from Windows. It probably means that your dll depends on some other dll and the other one is unavailable, but it might mean that AceTest.dll itself can't be loaded (permission problems, defective dll, etc.) In some cases Windows will pop up a dialog box with more information than that skimpy message, e.g. if you install the package and try to run library(AceTest) from within Rgui. Duncan Murdoch * removing 'H:/RTick/Project/Client/AceTest.Rcheck/AceTest' can someone point out what went wrong? [[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] specify the covariance matrix for random effect
Ben Bolker bbolker at gmail.com writes: Qiu, Weiyu weiyu at ualberta.ca writes: Hi, I'm doing a generalized linear mixed model, and I currently use an R function called glmm. If you could get by with an AR or ARMA structure then you could use lme() with the 'correlation' argument from the nlme package. If you have enough data/are willing to fit a completely unstructured correlation matrix, you could use corSymm. See ?corStruct in the nlme package documentation: it is *in principle* possible to write functions to implement your own correlation structures, e.g. see [snip] oops. I neglected the fact that you're doing a GLMM. nlme only does LMMs. You may be able to follow my advice regarding setting up the autocorrelation structure and then use glmmPQL in the MASS package (which is built on top of nlme). __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Help on Select.list
On Sep 3, 2010, at 3:55 AM, Ravi S. Shankar wrote: Hi R, I am using select.list names=c(Ravi, Raj,Shubha,Nivriti) select.list(names) provides a drop down to choose one of the 4 names. However I would like to know if it is possible to create a classification something like this select.list(names) should give See if these beginnings get you any further: ifelse( names %in% c(Ravi, Raj) ,Boys, Girls) [1] Boys Boys Girls Girls names[names %in% c(Ravi, Raj)] [1] Ravi Raj names[!(names %in% c(Ravi, Raj))] [1] Shubha Nivriti In any case you will need to provided a master list of either (or both) boy names and girl names. Boys Ravi Raj Girls Shubha Nivriti I should be able to choose only one of the names. I'm afraid that did not make much sense to me. -- David. Any help would be appreciated. R version 2.10.1 (2009-12-14) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices datasets utils methods base other attached packages: [1] clim.pact_2.2-41 akima_0.5-4 ncdf_1.6.1 rcom_2.2-3 [5] rscproxy_1.3-1 loaded via a namespace (and not attached): [1] tools_2.10.1 Thank you Regards Ravi 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. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matrix to list
Dear all, suppose I have following matrix: mat - matrix(rnorm(25), 5) mat [,1] [,2] [,3] [,4] [,5] [1,] 0.97056228 -1.3278509 -0.73511792 2.1650629 -0.4411997 [2,] 0.58613700 -0.2559899 -1.18334248 -1.4990907 1.8138846 [3,] -1.0313 2.0227887 0.89622681 0.6483973 -1.5523283 [4,] 0.38968833 0.2490004 -0.02301061 -0.2705150 -0.9237268 [5,] 0.03306289 -0.4022751 -0.44404905 -1.6810542 -0.1016683 Now from mat I would like to create a list object where i-th column of mat will represent i-th element of that list object. I am looking for some way to avoid for loop. It will be really helpful if somebody points me on that. Thanks, [[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] Help on Select.list
Hi David, Thank you for your response. But that wasn't what I was looking for. names=c(Ravi, Raj,Shubha,Nivriti) select.list(names) gives a pop up with the 4 names. I just wanted in the pop up a heading (say BOYS) followed by two names and another heading (say GIRLS) and the remaining two names. Is there a way I can include headings in the select.list() Thank you once again for the help. Regards Ravi -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Friday, September 03, 2010 6:14 PM To: Ravi S. Shankar Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Help on Select.list On Sep 3, 2010, at 3:55 AM, Ravi S. Shankar wrote: Hi R, I am using select.list names=c(Ravi, Raj,Shubha,Nivriti) select.list(names) provides a drop down to choose one of the 4 names. However I would like to know if it is possible to create a classification something like this select.list(names) should give See if these beginnings get you any further: ifelse( names %in% c(Ravi, Raj) ,Boys, Girls) [1] Boys Boys Girls Girls names[names %in% c(Ravi, Raj)] [1] Ravi Raj names[!(names %in% c(Ravi, Raj))] [1] Shubha Nivriti In any case you will need to provided a master list of either (or both) boy names and girl names. Boys Ravi Raj Girls Shubha Nivriti I should be able to choose only one of the names. I'm afraid that did not make much sense to me. -- David. Any help would be appreciated. R version 2.10.1 (2009-12-14) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices datasets utils methods base other attached packages: [1] clim.pact_2.2-41 akima_0.5-4 ncdf_1.6.1 rcom_2.2-3 [5] rscproxy_1.3-1 loaded via a namespace (and not attached): [1] tools_2.10.1 Thank you Regards Ravi 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. David Winsemius, MD West Hartford, CT This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] change the type of lines and colours in interaction.plot
On Sep 3, 2010, at 7:02 AM, Lathouri, Maria wrote: Dear all, I want to plot 8 chemical variables in the same plot. I have used the interaction.plot command: interaction.plot(speclong$Date,speclong$time2,speclong $outcome,xaxt=n,type=l,pch=20,xlab=, log=y, ylab=Concentration (ug/L),trace.label=,col=rainbow(8)) However, what it gives me is dotted lines and the colours are very fade. I was wondering if I can change the lines to be solid and as well to specify for each line the colour that I want. Since you provided no workable example, I am just using the second example in the help page to illustrate specifying col, lwd, and lty: with(ToothGrowth,interaction.plot(dose, supp, len, fixed=TRUE, col = c(red,blue), lty=1, leg.bty = o)) with(ToothGrowth,interaction.plot(dose, supp, len, fixed=TRUE, col = c(red,blue), lty=1,lwd=3, leg.bty = o) ) It appears that lwd is not passed on to the legend call. You should carefully review the help page for further information and details: ?par -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix to list
On Sep 3, 2010, at 7:48 AM, Ron Michael wrote: Dear all, suppose I have following matrix: mat - matrix(rnorm(25), 5) mat [,1] [,2][,3] [,4] [,5] [1,] 0.97056228 -1.3278509 -0.73511792 2.1650629 -0.4411997 [2,] 0.58613700 -0.2559899 -1.18334248 -1.4990907 1.8138846 [3,] -1.0313 2.0227887 0.89622681 0.6483973 -1.5523283 [4,] 0.38968833 0.2490004 -0.02301061 -0.2705150 -0.9237268 [5,] 0.03306289 -0.4022751 -0.44404905 -1.6810542 -0.1016683 Now from mat I would like to create a list object where i-th column of mat will represent i-th element of that list object. I am looking for some way to avoid for loop. It will be really helpful if somebody points me on that. Thanks, Try this: set.seed(1) mat - matrix(rnorm(25), 5) mat [,1] [,2] [,3][,4][,5] [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 0.91897737 [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 0.78213630 [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 0.07456498 [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 -1.98935170 [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 0.61982575 # Coerce 'mat' to a data frame, then to a 'normal' list as.list(as.data.frame(mat)) $V1 [1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078 $V2 [1] -0.8204684 0.4874291 0.7383247 0.5757814 -0.3053884 $V3 [1] 1.5117812 0.3898432 -0.6212406 -2.2146999 1.1249309 $V4 [1] -0.04493361 -0.01619026 0.94383621 0.82122120 0.59390132 $V5 [1] 0.91897737 0.78213630 0.07456498 -1.98935170 0.61982575 You can argue that the coercion to a list is redundant, since a data frame is a list, but it may depend upon what you then want to do with the data. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix to list
Try this: unclass(as.data.frame(mat)) On Fri, Sep 3, 2010 at 9:48 AM, Ron Michael ron_michae...@yahoo.com wrote: Dear all, suppose I have following matrix: mat - matrix(rnorm(25), 5) mat [,1] [,2][,3] [,4] [,5] [1,] 0.97056228 -1.3278509 -0.73511792 2.1650629 -0.4411997 [2,] 0.58613700 -0.2559899 -1.18334248 -1.4990907 1.8138846 [3,] -1.0313 2.0227887 0.89622681 0.6483973 -1.5523283 [4,] 0.38968833 0.2490004 -0.02301061 -0.2705150 -0.9237268 [5,] 0.03306289 -0.4022751 -0.44404905 -1.6810542 -0.1016683 Now from mat I would like to create a list object where i-th column of mat will represent i-th element of that list object. I am looking for some way to avoid for loop. It will be really helpful if somebody points me on that. Thanks, [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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 get row name of matrix when result is a vector
Hi, the R code: a - matrix(c(1,5,4,3,7,10,34,4,3,8,6,5,12,17,45,3,2,45,46,47,3,4,22,12,21), nrow=5) rownames(a) - c(a,b,c,d,e) a a[which(a[,3] 8), ] a[which(a[,3] 6), ] produces the following output: a [,1] [,2] [,3] [,4] [,5] a1 10633 b5 34524 c44 12 45 22 d33 17 46 12 e78 45 47 21 a[which(a[,3] 8), ] [,1] [,2] [,3] [,4] [,5] a1 10633 b5 34524 a[which(a[,3] 6), ] [1] 5 34 5 2 4 I actually thought it must be rather easy to somehow extract the row name when the result is just a vector as in the second example and not a matrix. I tried several ways but without any success. Any advice? Best, syrvn -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-row-name-of-matrix-when-result-is-a-vector-tp2525631p2525631.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get row name of matrix when result is a vector
Try this: a[a[,3] 6,, drop = FALSE] On Fri, Sep 3, 2010 at 10:08 AM, syrvn ment...@gmx.net wrote: Hi, the R code: a - matrix(c(1,5,4,3,7,10,34,4,3,8,6,5,12,17,45,3,2,45,46,47,3,4,22,12,21), nrow=5) rownames(a) - c(a,b,c,d,e) a a[which(a[,3] 8), ] a[which(a[,3] 6), ] produces the following output: a [,1] [,2] [,3] [,4] [,5] a1 10633 b5 34524 c44 12 45 22 d33 17 46 12 e78 45 47 21 a[which(a[,3] 8), ] [,1] [,2] [,3] [,4] [,5] a1 10633 b5 34524 a[which(a[,3] 6), ] [1] 5 34 5 2 4 I actually thought it must be rather easy to somehow extract the row name when the result is just a vector as in the second example and not a matrix. I tried several ways but without any success. Any advice? Best, syrvn -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-row-name-of-matrix-when-result-is-a-vector-tp2525631p2525631.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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] Help on Select.list
On Sep 3, 2010, at 8:59 AM, Ravi S. Shankar wrote: Hi David, Thank you for your response. But that wasn't what I was looking for. names=c(Ravi, Raj,Shubha,Nivriti) select.list(names) gives a pop up with the 4 names. I just wanted in the pop up a heading (say BOYS) followed by two names and another heading (say GIRLS) and the remaining two names. Is there a way I can include headings in the select.list() Sorry. that function was not in my experience. You could include the headings in the list perhaps with some message saying that the headings are not a legitimate choice. I looked at the code for select.list and doubt that you can enforce the advice with anything in the select.list parameters. The vector gets handed off pretty quickly to .Internal functions You would need to handle undesired user behavior programatically: names=c(Boys~(Do not choose), Ravi, Raj,Girls~(Do not choose), Shubha,Nivriti) select.list(names) If you wanted more control ove rthe behavior I think you would need to work with : tk_select.list {tcltk} -- David Thank you once again for the help. Regards Ravi -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Friday, September 03, 2010 6:14 PM To: Ravi S. Shankar Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Help on Select.list On Sep 3, 2010, at 3:55 AM, Ravi S. Shankar wrote: Hi R, I am using select.list names=c(Ravi, Raj,Shubha,Nivriti) select.list(names) provides a drop down to choose one of the 4 names. However I would like to know if it is possible to create a classification something like this select.list(names) should give See if these beginnings get you any further: ifelse( names %in% c(Ravi, Raj) ,Boys, Girls) [1] Boys Boys Girls Girls names[names %in% c(Ravi, Raj)] [1] Ravi Raj names[!(names %in% c(Ravi, Raj))] [1] Shubha Nivriti In any case you will need to provided a master list of either (or both) boy names and girl names. Boys Ravi Raj Girls Shubha Nivriti I should be able to choose only one of the names. I'm afraid that did not make much sense to me. -- David. Any help would be appreciated. R version 2.10.1 (2009-12-14) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices datasets utils methods base other attached packages: [1] clim.pact_2.2-41 akima_0.5-4 ncdf_1.6.1 rcom_2.2-3 [5] rscproxy_1.3-1 loaded via a namespace (and not attached): [1] tools_2.10.1 Thank you Regards Ravi 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. David Winsemius, MD West Hartford, CT This e-mail may contain confidential and/or privileged...{{dropped:15}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get row name of matrix when result is a vector
Hi, I do not understand the code right now but it does its job. Thanks a lot! Best, syrvn -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-row-name-of-matrix-when-result-is-a-vector-tp2525631p2525657.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get row name of matrix when result is a vector
R doesn't simply treat a row vector as a matrix. -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-row-name-of-matrix-when-result-is-a-vector-tp2525631p2525666.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get row name of matrix when result is a vector
Hi! I don't really understand your goal, but if you want to extract the row names, rownames(a[which(a[,3] 8), ]) does it. But I think you've already tried it. Maybe it's just me... HTH Ivan Le 9/3/2010 15:08, syrvn a écrit : Hi, the R code: a- matrix(c(1,5,4,3,7,10,34,4,3,8,6,5,12,17,45,3,2,45,46,47,3,4,22,12,21), nrow=5) rownames(a)- c(a,b,c,d,e) a a[which(a[,3] 8), ] a[which(a[,3] 6), ] produces the following output: a [,1] [,2] [,3] [,4] [,5] a1 10633 b5 34524 c44 12 45 22 d33 17 46 12 e78 45 47 21 a[which(a[,3] 8), ] [,1] [,2] [,3] [,4] [,5] a1 10633 b5 34524 a[which(a[,3] 6), ] [1] 5 34 5 2 4 I actually thought it must be rather easy to somehow extract the row name when the result is just a vector as in the second example and not a matrix. I tried several ways but without any success. Any advice? Best, syrvn -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[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] function to compare numbers
Hi, all is there a built-in function to compare two numbers? something like following function cmp - function(x, y){ value - 0 if (x y){ value - 1 }else if (x == y){ value - 0 }else { value - -1 } return(value) } Thanks in advance, Hyunchul [[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] draw a graph of the semi-partial R-squared /CAH
Dear r-help, I am using CAH. I would cut my dendogram. What is the command in R that allows draw a graph of the semi-partial R-squared ? I did this: d3=read.table(dd.txt, header=TRUE,dec=',',row.names='variable') don-scale(d3, center = TRUE, scale = TRUE) #Calcul du Matrice de similarité dc-dist(don,method =euclidean,upper=FALSE) dc #Classification hc-hclust(dc,ward) Now, how can I caculate the semi-partial R-squared ?? Best Regards [[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] Matrix to list
Thanks Henrique and Marc for your reply, both worked. However I need one more suggestion on from list to matrix dat - vector(list, 3) dat[[1]] - rnorm(5) dat[[2]] - rnorm(15) dat[[3]] - rnorm(3) dat [[1]] [1] 0.7615421 0.4151374 0.6534402 1.5999338 1.4131837 [[2]] [1] 0.7364765 2.0786904 -1.1087768 1.5091391 -0.1448301 1.6015788 1.8039138 1.1194863 1.4907951 0.5324749 [11] 0.6792318 -0.8328359 -1.8009706 -0.8523432 0.5314461 [[3]] [1] -0.4350899 -0.2610924 -0.6489858 Now I want to convert dat to a matrix. I tried following: Reduce(cbind, dat) init [1,] 0.7615421 0.7364765 -0.4350899 [2,] 0.4151374 2.0786904 -0.2610924 [3,] 0.6534402 -1.1087768 -0.6489858 [4,] 1.5999338 1.5091391 -0.4350899 [5,] 1.4131837 -0.1448301 -0.2610924 [6,] 0.7615421 1.6015788 -0.6489858 [7,] 0.4151374 1.8039138 -0.4350899 [8,] 0.6534402 1.1194863 -0.2610924 [9,] 1.5999338 1.4907951 -0.6489858 [10,] 1.4131837 0.5324749 -0.4350899 [11,] 0.7615421 0.6792318 -0.2610924 [12,] 0.4151374 -0.8328359 -0.6489858 [13,] 0.6534402 -1.8009706 -0.4350899 [14,] 1.5999338 -0.8523432 -0.2610924 [15,] 1.4131837 0.5314461 -0.6489858 Here you see values of vector with smaller length is getting repeated. Instead of repetition, I would like to fill those with NA (or possibly some predefined fixed value) Would you please suggest me how to do that? Thanks, --- On Fri, 3/9/10, Henrique Dallazuanna www...@gmail.com wrote: From: Henrique Dallazuanna www...@gmail.com Subject: Re: [R] Matrix to list To: Ron Michael ron_michae...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Friday, 3 September, 2010, 8:07 PM Try this: unclass(as.data.frame(mat)) On Fri, Sep 3, 2010 at 9:48 AM, Ron Michael ron_michae...@yahoo.com wrote: Dear all, suppose I have following matrix: mat - matrix(rnorm(25), 5) mat [,1] [,2] [,3] [,4] [,5] [1,] 0.97056228 -1.3278509 -0.73511792 2.1650629 -0.4411997 [2,] 0.58613700 -0.2559899 -1.18334248 -1.4990907 1.8138846 [3,] -1.0313 2.0227887 0.89622681 0.6483973 -1.5523283 [4,] 0.38968833 0.2490004 -0.02301061 -0.2705150 -0.9237268 [5,] 0.03306289 -0.4022751 -0.44404905 -1.6810542 -0.1016683 Now from mat I would like to create a list object where i-th column of mat will represent i-th element of that list object. I am looking for some way to avoid for loop. It will be really helpful if somebody points me on that. Thanks, [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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 use lm() output for systemfit() 'Seemingly unrelated regression'
I am having problem using output of lm() function for further analysing using systemfit package. Basicaly, the problem s following - I generate several formulas using lm() fo1 - lm(r98[,2] ~ f98[,1] + f98[,2] + ... + f98[,43]) fo2 - lm(r98[,1] ~ f98[,1] + f98[,2] + ... + f98[,43]) and than I want to estimate a general model using package systemfit. fitsur - systemfit(SUR,list(as.formula(fo),as.formula(foo))) and I get following error: Error in systemfit(SUR, list(as.formula(fo), as.formula(foo))) : argument 'formula' must be an object of class 'formula' or a list of objects of class 'formula' and I am not able to find where the problem is. The problem remains even when I try: fo1 - r98[,2] ~ f98[,1] + f98[,2] + ... + f98[,43] fo2 - r98[,1] ~ f98[,1] + f98[,2] + ... + f98[,43] instead of using lm() Could someone give me a hand? I am quite new to R, so possibly the solutions is simple:) Thanks Zbynek Janoska -- View this message in context: http://r.789695.n4.nabble.com/How-to-use-lm-output-for-systemfit-Seemingly-unrelated-regression-tp2525418p2525418.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] Generation of uniform random numbers
Dear R helpers I have following dataset rate_number = matrix(c(5, 15, 60, 15, 5, 0, 20, 60, 20,0, 10, 20, 40, 20, 10), nrow = 5, ncol = 3) range_mat = matrix(c(6.25, 6.75, 7.25, 8.75, 9.25, 9.75, 8.5, 9, 9.5, 10.5, 11, 11.5, 4.25, 4.75, 5.25, 5.75, 6.25, 6.75), nrow = 6, ncol = 3) rate_number [,1] [,2] [,3] [1,] 5 0 10 [2,] 15 20 20 [3,] 60 60 40 [4,] 15 20 20 [5,] 5 0 10 range_mat [,1] [,2] [,3] [1,] 6.25 8.5 4.25 [2,] 6.75 9.0 4.75 [3,] 7.25 9.5 5.25 [4,] 8.75 10.5 5.75 [5,] 9.25 11.0 6.25 [6,] 9.75 11.5 6.75 My problem is to generate random numbers in line with rate_number and using the range_mat. E.g. I need to generate (5, 15, 60, 15, 5 i.e. the first column of rate_number) uniform random numbers (using 1st column of range_mat) s.t the first 5 numbers will be in the range (6.25 - 6.75), next 15 numbers should be in the range (6.75 to 7.25), next 60 numbers should be in the range (7.25 to 8.75), next 15 numbers in the range (8.75 to 9.25) and last 5 numbers in the range (9.25 to 9.75). Similarily, I need to generate (0, 20, 60, 20, 0 i.e. 2nd column of rate_number) uniform random numbers in the range (using 2nd column of range_mat) i.e. (8.5 to 9), (9 to 9.5), (9.5 to 10.5), (10.5 to 11), (11 to 11.5) respectively. I could have generated these random numbers Individually using runif, but main problem is range_number could be anything i.e. there may be 50 rates but for each rate, no of rate combination will always be 5 i.e. rate_number will always have 5 rows only and also range_mat will always have 6 rows only. I tried writing loops and even tapply etc. but just can't get through. I sincerely request you to kindly guide me. Regards Sarah [[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] function to compare numbers
Hi! Maybe something like this: x - 2 y - 3 #since FALSE will be converted to 0 and TRUE to 1 you can do as.numeric(xy) as.numeric(xy) HTH Ivan Le 9/3/2010 15:33, Hyunchul Kim a écrit : Hi, all is there a built-in function to compare two numbers? something like following function cmp- function(x, y){ value- 0 if (x y){ value- 1 }else if (x == y){ value- 0 }else { value- -1 } return(value) } Thanks in advance, Hyunchul [[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. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get row name of matrix when result is a vector
On Sep 3, 2010, at 9:08 AM, syrvn wrote: Hi, the R code: a - matrix (c(1,5,4,3,7,10,34,4,3,8,6,5,12,17,45,3,2,45,46,47,3,4,22,12,21), nrow=5) rownames(a) - c(a,b,c,d,e) a a[which(a[,3] 8), ] a[which(a[,3] 6), ] It wasn't exactly clear and possible that you wanted only rownames that satisfied those criteria rownames(a)[which(a[,3] 8)] [1] a b rownames(a)[which(a[,3] 6)] [1] b rownames(a)[which(a[,3] 4)] character(0) Sometimes which() is needed, and others it is not. This appears to be one where it is not needed: rownames(a)[a[,3] 4] character(0) rownames(a)[a[,3] 6] [1] b rownames(a)[a[,3] 8] [1] a b -- David. produces the following output: a [,1] [,2] [,3] [,4] [,5] a1 10633 b5 34524 c44 12 45 22 d33 17 46 12 e78 45 47 21 a[which(a[,3] 8), ] [,1] [,2] [,3] [,4] [,5] a1 10633 b5 34524 a[which(a[,3] 6), ] [1] 5 34 5 2 4 I actually thought it must be rather easy to somehow extract the row name when the result is just a vector as in the second example and not a matrix. I tried several ways but without any success. Any advice? Best, syrvn -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-row-name-of-matrix-when-result-is-a-vector-tp2525631p2525631.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix to list
Try this: sapply(dat, '[', 1:max(sapply(dat, length))) On Fri, Sep 3, 2010 at 10:31 AM, Ron Michael ron_michae...@yahoo.comwrote: Thanks Henrique and Marc for your reply, both worked. However I need one more suggestion on from list to matrix dat - vector(list, 3) dat[[1]] - rnorm(5) dat[[2]] - rnorm(15) dat[[3]] - rnorm(3) dat [[1]] [1] 0.7615421 0.4151374 0.6534402 1.5999338 1.4131837 [[2]] [1] 0.7364765 2.0786904 -1.1087768 1.5091391 -0.1448301 1.6015788 1.8039138 1.1194863 1.4907951 0.5324749 [11] 0.6792318 -0.8328359 -1.8009706 -0.8523432 0.5314461 [[3]] [1] -0.4350899 -0.2610924 -0.6489858 Now I want to convert dat to a matrix. I tried following: Reduce(cbind, dat) init [1,] 0.7615421 0.7364765 -0.4350899 [2,] 0.4151374 2.0786904 -0.2610924 [3,] 0.6534402 -1.1087768 -0.6489858 [4,] 1.5999338 1.5091391 -0.4350899 [5,] 1.4131837 -0.1448301 -0.2610924 [6,] 0.7615421 1.6015788 -0.6489858 [7,] 0.4151374 1.8039138 -0.4350899 [8,] 0.6534402 1.1194863 -0.2610924 [9,] 1.5999338 1.4907951 -0.6489858 [10,] 1.4131837 0.5324749 -0.4350899 [11,] 0.7615421 0.6792318 -0.2610924 [12,] 0.4151374 -0.8328359 -0.6489858 [13,] 0.6534402 -1.8009706 -0.4350899 [14,] 1.5999338 -0.8523432 -0.2610924 [15,] 1.4131837 0.5314461 -0.6489858 Here you see values of vector with smaller length is getting repeated. Instead of repetition, I would like to fill those with NA (or possibly some predefined fixed value) Would you please suggest me how to do that? Thanks, --- On *Fri, 3/9/10, Henrique Dallazuanna www...@gmail.com* wrote: From: Henrique Dallazuanna www...@gmail.com Subject: Re: [R] Matrix to list To: Ron Michael ron_michae...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Friday, 3 September, 2010, 8:07 PM Try this: unclass(as.data.frame(mat)) On Fri, Sep 3, 2010 at 9:48 AM, Ron Michael ron_michae...@yahoo.comhttp://aa.mc638.mail.yahoo.com/mc/compose?to=ron_michae...@yahoo.com wrote: Dear all, suppose I have following matrix: mat - matrix(rnorm(25), 5) mat [,1] [,2][,3] [,4] [,5] [1,] 0.97056228 -1.3278509 -0.73511792 2.1650629 -0.4411997 [2,] 0.58613700 -0.2559899 -1.18334248 -1.4990907 1.8138846 [3,] -1.0313 2.0227887 0.89622681 0.6483973 -1.5523283 [4,] 0.38968833 0.2490004 -0.02301061 -0.2705150 -0.9237268 [5,] 0.03306289 -0.4022751 -0.44404905 -1.6810542 -0.1016683 Now from mat I would like to create a list object where i-th column of mat will represent i-th element of that list object. I am looking for some way to avoid for loop. It will be really helpful if somebody points me on that. Thanks, [[alternative HTML version deleted]] __ R-help@r-project.orghttp://aa.mc638.mail.yahoo.com/mc/compose?to=r-h...@r-project.orgmailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] function to compare numbers
x - 2 y - 3 ifelse(x y, 1, ifelse(x y, -1, 0)) [1] -1 On Fri, Sep 3, 2010 at 9:33 AM, Hyunchul Kim hyunchul.kim@gmail.com wrote: Hi, all is there a built-in function to compare two numbers? something like following function cmp - function(x, y){ value - 0 if (x y){ value - 1 }else if (x == y){ value - 0 }else { value - -1 } return(value) } Thanks in advance, Hyunchul [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] function to compare numbers
You could potentially use sign() sign(3 - 5) [1] -1 sign(5 - 3) [1] 1 sign(5 - 5) [1] 0 But... this could fail when you think two numbers are equal and the computer doesn't, due to floating point precision. (Your version could fail in exactly the same way.) x - .3 - .2 x [1] 0.1 sign(x - .1) [1] -1 So how you implement this will depend on what you need it for. Something like this should work, if you choose the appropriate level of precision: sign(round(x - .1, 9)) [1] 0 Sarah On Fri, Sep 3, 2010 at 9:33 AM, Hyunchul Kim hyunchul.kim@gmail.com wrote: Hi, all is there a built-in function to compare two numbers? something like following function cmp - function(x, y){ value - 0 if (x y){ value - 1 }else if (x == y){ value - 0 }else { value - -1 } return(value) } Thanks in advance, Hyunchul -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] function to compare numbers
On Sep 3, 2010, at 9:33 AM, Hyunchul Kim wrote: Hi, all is there a built-in function to compare two numbers? something like following function cmp - function(x, y){ value - 0 if (x y){ value - 1 }else if (x == y){ value - 0 }else { value - -1 } return(value) } Not that I know of, but there is an obvious application of sign(): cmp -function(x,y) sign(y-x) -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generation of uniform random numbers
Try this: result - list() # holds the numbers for each column for (i in seq(ncol(rate_number))){ + ans - NULL + for (j in seq(nrow(rate_number))){ + ans - c(ans, runif(rate_number[j, i], range_mat[j, i], range_mat[j + 1, i])) + } + result[[i]] - ans + } result [[1]] [1] 6.498850 6.608809 6.745953 6.440018 6.638723 7.217353 6.856071 7.075837 [9] 6.812778 6.883610 6.943057 6.756695 6.941194 7.184845 6.920174 6.991040 [17] 7.049783 6.996771 6.843109 7.163687 8.252700 8.441360 7.411915 8.335566 [25] 7.866912 8.481419 8.220590 8.424399 8.079554 8.044579 8.434034 7.284997 [33] 7.965845 8.348471 8.289097 7.966429 8.541814 7.907146 7.617196 7.356019 [41] 7.399199 7.724408 8.027951 8.243008 7.860245 8.619314 7.690405 7.938599 [49] 7.748592 8.226306 7.637025 7.967818 8.399466 7.376370 8.562982 7.758609 [57] 8.509161 7.770025 7.750662 7.964527 8.588298 8.546509 7.834984 8.415981 [65] 8.690927 7.901989 8.318772 7.849992 7.738028 8.385631 7.554038 8.316682 [73] 7.432538 7.618233 7.464957 7.609444 7.338402 8.213432 8.564404 8.418372 [81] 9.148654 8.977637 8.955042 9.155435 9.052467 9.077362 8.926599 8.885130 [89] 9.246342 9.066747 8.856604 8.814686 8.989059 9.212037 9.049380 9.738085 [97] 9.615896 9.428363 9.465737 9.324106 [[2]] [1] 9.006539 9.357783 9.051592 9.223142 9.320051 9.495919 9.247797 [8] 9.242175 9.086721 9.377410 9.226948 9.255585 9.103773 9.114329 [15] 9.297856 9.287436 9.038532 9.017770 9.321398 9.464308 10.098092 [22] 10.060901 10.026028 10.485095 10.007642 10.182788 10.101541 9.738869 [29] 9.758166 10.229310 9.952571 9.675127 10.246698 9.604988 10.364545 [36] 10.114645 10.057160 9.828777 9.953131 10.000441 9.680866 10.029631 [43] 9.575276 9.56 9.712700 9.784790 10.395094 9.946235 10.279985 [50] 10.380619 9.913124 9.563808 9.835487 10.223726 9.837615 10.130414 [57] 10.340615 10.356132 9.891359 9.880494 10.395445 10.144316 10.241079 [64] 10.105303 10.403082 9.793730 9.691260 10.386451 10.003339 10.377058 [71] 9.689194 10.258103 10.224499 10.443725 10.047647 10.211744 9.888905 [78] 9.600873 10.427302 9.783233 10.795287 10.555180 10.920254 10.658982 [85] 10.891426 10.633754 10.609323 10.758398 10.634475 10.590584 10.759288 [92] 10.781391 10.564578 10.628184 10.858968 10.980705 10.550070 10.881611 [99] 10.973983 10.909317 [[3]] [1] 4.404146 4.574790 4.726678 4.726866 4.419990 4.381237 4.332727 4.411084 [9] 4.505063 4.711984 5.005480 4.878811 4.773230 4.958928 5.177001 4.923615 [17] 4.815721 4.937243 5.065710 4.945039 5.094814 5.094707 5.027450 4.964812 [25] 4.976360 4.903222 5.039177 5.205185 4.821302 4.957524 5.355463 5.464375 [33] 5.316345 5.480048 5.721479 5.630987 5.716455 5.485339 5.551794 5.492495 [41] 5.304403 5.373863 5.499257 5.436433 5.717346 5.511993 5.408572 5.388983 [49] 5.643770 5.601231 5.332514 5.282229 5.627353 5.560205 5.334788 5.281107 [57] 5.304515 5.440858 5.334655 5.399326 5.346105 5.378585 5.340616 5.488657 [65] 5.635369 5.263894 5.513655 5.690160 5.436532 5.273980 5.819314 5.910746 [73] 5.827416 5.816114 5.860653 5.863190 5.815708 6.240782 5.913507 6.003470 [81] 6.090721 5.799585 5.809451 5.775220 6.214627 6.086856 5.797429 5.996298 [89] 5.980776 5.937608 6.745550 6.338175 6.656718 6.284223 6.450225 6.320572 [97] 6.346655 6.670676 6.609957 6.383606 On Fri, Sep 3, 2010 at 6:32 AM, Sarah Sanchez sarah_sanche...@yahoo.com wrote: Dear R helpers I have following dataset rate_number = matrix(c(5, 15, 60, 15, 5, 0, 20, 60, 20,0, 10, 20, 40, 20, 10), nrow = 5, ncol = 3) range_mat = matrix(c(6.25, 6.75, 7.25, 8.75, 9.25, 9.75, 8.5, 9, 9.5, 10.5, 11, 11.5, 4.25, 4.75, 5.25, 5.75, 6.25, 6.75), nrow = 6, ncol = 3) rate_number [,1] [,2] [,3] [1,] 5 0 10 [2,] 15 20 20 [3,] 60 60 40 [4,] 15 20 20 [5,] 5 0 10 range_mat [,1] [,2] [,3] [1,] 6.25 8.5 4.25 [2,] 6.75 9.0 4.75 [3,] 7.25 9.5 5.25 [4,] 8.75 10.5 5.75 [5,] 9.25 11.0 6.25 [6,] 9.75 11.5 6.75 My problem is to generate random numbers in line with rate_number and using the range_mat. E.g. I need to generate (5, 15, 60, 15, 5 i.e. the first column of rate_number) uniform random numbers (using 1st column of range_mat) s.t the first 5 numbers will be in the range (6.25 - 6.75), next 15 numbers should be in the range (6.75 to 7.25), next 60 numbers should be in the range (7.25 to 8.75), next 15 numbers in the range (8.75 to 9.25) and last 5 numbers in the range (9.25 to 9.75). Similarily, I need to generate (0, 20, 60, 20, 0 i.e. 2nd column of rate_number) uniform random numbers in the range (using 2nd column of range_mat) i.e. (8.5 to 9), (9 to 9.5), (9.5 to 10.5), (10.5 to 11), (11 to 11.5) respectively. I could have generated these random numbers Individually using runif, but main problem is range_number could be anything i.e. there may be 50 rates but for
Re: [R] R CMD check Package(Windows): Error in inDL(x, as.logical(local), as.logical(now), ...) :
After the R CMD check is done and an R CMD INSTALL is done, where does the external dll have to be?..what can i do to make it move around with the package? can I zip it with the package? if so in what folder? - Original Message - From: Duncan Murdoch murdoch.dun...@gmail.com To: raje...@cse.iitm.ac.in Cc: r-help r-help@r-project.org Sent: Thu, 02 Sep 2010 16:42:31 +0530 (IST) Subject: Re: [R] R CMD check Package(Windows): Error in inDL(x, as.logical(local), as.logical(now), ...) : On 02/09/2010 6:46 AM, raje...@cse.iitm.ac.in wrote: It is dependent on another dll but it did not give compilation errors. It seemed to link fine at that point. Why does it have a problem at this stage? Windows needs to be able to find the other DLL at load time. It will find it if it's in the same directory or on the PATH. Duncan Murdoch From: Duncan Murdoch To: raje...@cse.iitm.ac.in Cc: r-help Sent: Thursday, September 2, 2010 4:05:14 PM Subject: Re: [R] R CMD check Package(Windows): Error in inDL(x, as.logical(local), as.logical(now), ...) : On 02/09/2010 2:29 AM, raje...@cse.iitm.ac.in wrote: Hi, I've built my own package in windows and when I run R CMD check Package-Name I get, * install options are ' --no-html' * installing *source* package 'AceTest' ... ** libs making DLL ... g++ ...etc. installing to ... done ** R ** preparing package for lazy loading ** help Warning: ./man/AceTest-package.Rd:34: All text must be in a section Warning: ./man/AceTest-package.Rd:35: All text must be in a section *** installing help indices ** building package indices ... ** testing if installed package can be loaded Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'H:/RTick/Project/Client/AceTest.Rcheck/AceTest/libs/AceTest.dll': LoadLibrary failure: The specified module could not be found. ERROR: loading failed The message The specified module could not be found comes from Windows. It probably means that your dll depends on some other dll and the other one is unavailable, but it might mean that AceTest.dll itself can't be loaded (permission problems, defective dll, etc.) In some cases Windows will pop up a dialog box with more information than that skimpy message, e.g. if you install the package and try to run library(AceTest) from within Rgui. Duncan Murdoch * removing 'H:/RTick/Project/Client/AceTest.Rcheck/AceTest' can someone point out what went wrong? [[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] Interactions in GAM
Hello R users, I am working with the GAM to inspect the effect of some factors (year, area) and continuous variables (length, depth, latitude and longitude) on the intensity and prevalence of the common parasite Anisakis. I would like introduce interaction in my models, both continuous variables-continuous variables and continuous variables-factor. I have read some questions-answers regard to this subject but I still have doubts. The solution that I have seen to introduce an interaction continuous covariate-factor is using by (explained in ?gam.models). Below, I show an example of my model with the interactions using by both to prevalence (distribution=binomial) and to intensity (distribution=negative binomial): gam(prevalence~s(length)+factor(year)+factor(area)+s(length,by=area)+s(length,by=year), family=binomial,data=X) gam(intensity~s(length)+factor(year)+factor(area)+s(length,by=area)+s(length,by=year), family=negbin(c(1,10)),data=X) The solution that I have seen to introduce an interaction continuous covariate- continuous covariate is using the function te. Below, I show an example of my model with the interactions using te both to prevalence (distribution=binomial) and to intensity (distribution=negative binomial): gam(prevalence~s(length)+s(depth)+s(latitude)+s(longitude)+te(depth,length)+ te(latitude,length)+ te(longitude,length),family=binomial,data=X) gam(intensity~s(length)+s(depth)+s(latitude)+s(longitude)+te(depth,length)+ te(latitude,length)+ te(longitude,length),family= negbin(c(1,10)),data=X) My main doubts are: 1. Is the use of by and te right with the negative binomial distribution and with the binomial distribution? 2. Do these interactions have the same meaning that the interaction factor*continuous covariate and continuous covariate* continuous covariate used in the GLM? 3. Is right to introduce in the model the continuous covariates and the factor moreover their interactions? Thanks in advance. Best regards, Lucía Cañás Lucía Cañás Ferreiro Instituto Español de Oceanografía Centro Oceanográfico de A Coruña Paseo Marítimo Alcalde Francisco Vázquez, nº 10 15001 - A Coruña, SPAIN e-mail: lucia.ca...@co.ieo.es Tel: +34981205362; Fax: +34981229077 http://www.ieo.es [[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] Generation of uniform random numbers
On Sep 3, 2010, at 6:32 AM, Sarah Sanchez wrote: Dear R helpers I have following dataset rate_number = matrix(c(5, 15, 60, 15, 5, 0, 20, 60, 20,0, 10, 20, 40, 20, 10), nrow = 5, ncol = 3) range_mat = matrix(c(6.25, 6.75, 7.25, 8.75, 9.25, 9.75, 8.5, 9, 9.5, 10.5, 11, 11.5, 4.25, 4.75, 5.25, 5.75, 6.25, 6.75), nrow = 6, ncol = 3) rate_number [,1] [,2] [,3] [1,]5 0 10 [2,] 15 20 20 [3,] 60 60 40 [4,] 15 20 20 [5,]5 0 10 range_mat [,1] [,2] [,3] [1,] 6.25 8.5 4.25 [2,] 6.75 9.0 4.75 [3,] 7.25 9.5 5.25 [4,] 8.75 10.5 5.75 [5,] 9.25 11.0 6.25 [6,] 9.75 11.5 6.75 My problem is to generate random numbers in line with rate_number and using the range_mat. E.g. I need to generate (5, 15, 60, 15, 5 i.e. the first column of rate_number) uniform random numbers (using 1st column of range_mat) s.t the first 5 numbers will be in the range (6.25 - 6.75), next 15 numbers should be in the range (6.75 to 7.25), next 60 numbers should be in the range (7.25 to 8.75), next 15 numbers in the range (8.75 to 9.25) and last 5 numbers in the range (9.25 to 9.75). This should do it for the first column and modifying to for additional columns should be straightforward: mapply(runif, rate_number[,1], range_mat[1:5,1], range_mat[2:6,1]) #- rlist - list() for (i in 1:ncol(rate_number) ) rlist[[i]] -mapply(runif, rate_number[,i], range_mat[1:5,i], range_mat[2:6,i]) str(rlist) List of 3 $ :List of 5 ..$ : num [1:5] 6.38 6.66 6.65 6.27 6.69 ..$ : num [1:15] 6.81 7.05 6.98 7.03 7.12 ... ..$ : num [1:60] 7.34 8.4 7.95 8.53 8.12 ... ..$ : num [1:15] 9.25 8.91 8.91 8.77 9.01 ... ..$ : num [1:5] 9.58 9.49 9.34 9.61 9.29 $ :List of 5 ..$ : num(0) ..$ : num [1:20] 9.23 9.47 9.42 9.36 9.06 ... ..$ : num [1:60] 10.06 9.81 9.58 10.28 9.69 ... ..$ : num [1:20] 10.9 10.8 10.6 10.5 11 ... ..$ : num(0) $ :List of 5 ..$ : num [1:10] 4.36 4.58 4.56 4.27 4.72 ... ..$ : num [1:20] 5.15 5.09 4.99 4.98 5.06 ... ..$ : num [1:40] 5.71 5.35 5.26 5.41 5.58 ... ..$ : num [1:20] 5.87 5.93 5.87 6.22 5.96 ... ..$ : num [1:10] 6.38 6.62 6.74 6.53 6.45 ... Similarily, I need to generate (0, 20, 60, 20, 0 i.e. 2nd column of rate_number) uniform random numbers in the range (using 2nd column of range_mat) i.e. (8.5 to 9), (9 to 9.5), (9.5 to 10.5), (10.5 to 11), (11 to 11.5) respectively. I could have generated these random numbers Individually using runif, but main problem is range_number could be anything i.e. there may be 50 rates but for each rate, no of rate combination will always be 5 i.e. rate_number will always have 5 rows only and also range_mat will always have 6 rows only. I tried writing loops and even tapply etc. but just can't get through. I sincerely request you to kindly guide me. Regards David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] readLines and writeLines
Hi, I have a socket connection where I do -socketConnection -writeLines and then wait for the server to send data through the socket. so I have to wait on a readLines.But when I say str-readLines(con) it executes immediately and str gets nothing.what do i do for this? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use lm() output for systemfit() 'Seemingly unrelated regression'
On 3 September 2010 12:03, zbynek.jano...@gmail.com zbynek.jano...@centrum.cz wrote: I am having problem using output of lm() function for further analysing using systemfit package. Basicaly, the problem s following - I generate several formulas using lm() fo1 - lm(r98[,2] ~ f98[,1] + f98[,2] + ... + f98[,43]) fo2 - lm(r98[,1] ~ f98[,1] + f98[,2] + ... + f98[,43]) and than I want to estimate a general model using package systemfit. fitsur - systemfit(SUR,list(as.formula(fo),as.formula(foo))) and I get following error: Error in systemfit(SUR, list(as.formula(fo), as.formula(foo))) : argument 'formula' must be an object of class 'formula' or a list of objects of class 'formula' and I am not able to find where the problem is. The problem remains even when I try: fo1 - r98[,2] ~ f98[,1] + f98[,2] + ... + f98[,43] fo2 - r98[,1] ~ f98[,1] + f98[,2] + ... + f98[,43] instead of using lm() Could someone give me a hand? I am quite new to R, so possibly the solutions is simple:) Yes, the formula(s) must be the *first* argument of the systemfit() command, e.g.: R fitsur - systemfit( list(as.formula(fo),as.formula(foo)), method = SUR ) /Arne -- Arne Henningsen http://www.arne-henningsen.name __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] general question on binomial test / sign test
Ted, I agree that we are measuring discrepancies and that large discrepancies correspond to p-values near 0 and small discrepancies correspond to large p-values. But interpreting discrepancies on a p-value scale leads more to confusion than understanding. If you are interested in the discrepancy, then focus on the meaningful discrepancy scale (confidence intervals are great in many of these cases). I also agree that small p-values corresponding to large discrepancies is meaningful in saying that the large discrepancy is indicative of a real difference rather than just luck. My point was more focused on the over interpretation of differences in large p-values (remember this thread started with the original poster misinterpreting a p-value of 1). Try this exercise: Consider a sample of size 100 from a normal population with known standard deviation of 1. The null hypothesis is that the true mean is 50, what sample mean(s) will result in a p-value of 0.4? a p-value of 0.9? Is the difference between the 2 discrepancies worth getting excited about? Compare what conclusions you would draw by comparing the 2 confidence intervals to what might be concluded by comparing the 2 p-values. The difference between a p-value of 0.01 and 0.1 is very meaningful (if using an alpha=0.05 or close), the difference between a p-value of 0.4 and 0.9 is much less meaningful even though the difference is bigger. Also for alpha=0.05, I don't think it is worth getting any more excited over a p-value of 0.1 than one of 0.0001, but people do. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Ted Harding [mailto:ted.hard...@manchester.ac.uk] Sent: Thursday, September 02, 2010 3:59 PM To: Greg Snow Cc: r-help@r-project.org; Kay Cecil Cichini Subject: Re: [R] general question on binomial test / sign test On 02-Sep-10 18:01:55, Greg Snow wrote: Just to add to Ted's addition to my response. I think you are moving towards better understanding (and your misunderstandings are common), but to further clarify: [Wise words about P(A|B), P(B|A), P-values, etc., snipped] The real tricky bit about hypothesis testing is that we compute a single p-value, a single observation from a distribution, and based on that try to decide if the process that produced that observation is a uniform distribution or something else (that may be close to a uniform or very different). Indeed. And this is precisely why I began my original reply as follows: Zitat von ted.hard...@manchester.ac.uk: [...] The general logic of a singificance test is that a test statistic (say T) is chosen such that large values represent a discrepancy between possible data and the hypothesis under test. When you have the data, T evaluates to a value (say t0). The null hypothesis (NH) implies a distribution for the statistic T if the NH is true. Then the value of Prob(T = t0 | NH) can be calculated. If this is small, then the probability of obtaining data at least as discrepant as the data you did obtain is small; if sufficiently small, then the conjunction of NH and your data (as assessed by the statistic T) is so unlikely that you can decide to not believe that it is possible. If you so decide, then you reject the NH because the data are so discrepant that you can't believe it! The point is that the test statistic T represents *discrepancy* between data and NH in some sense. In what sense? That depends on what you are interested in finding out; and, whatever it is, there will be some T that represents it. It might be whether two samples come from distributions with equal means, or not. Then you might use T = mean(Ysample) - mean(Xsample). Large values of |T| represent discrepancy (in either direction) between data and an NH that the true means are equal. Large values of T, discrepancy in the positive direction, large values of -T diuscrepancy in the negative direction. Or it might be whether or not the two samples are drawn from populations with equal variances, when you might use T = var(Ysample)/var(Xsample). Or it might be whether the distribution from which X was sampled is symmetric, in which case you might use skewness(Xsample). Or you might be interested in whether the numbers falling into disjoint classes are consistent with hypothetical probabilities p1,...,pk of falling into these classes -- in which case you might use the chi-squared statistic T = sum(((ni - N*pi)^2)/(N*pi)). And so on. Once you have decided on what discrepant means, and chosen a statistic T to represent discrepancy, then the NH implies a distribution for T and you can calculate P-value = Prob(T = t0 | NH) where t0 is the value of T calculated from the data. *THEN* small P-value is in direct correspondence with large T, i.e. small P is equivalent to large discrepancy. And it
Re: [R] testing for emptyenv
Thanks -- View this message in context: http://r.789695.n4.nabble.com/testing-for-emptyenv-tp2432922p2525757.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] Interactions in GAM
My main doubts are: 1.Is the use of by and te right with the negative binomial distribution and with the binomial distribution? -- yes! These things specify the `linear predictor' of the model --- the correctness of the linear predictor does not usually depend on the response distribution. 2.Do these interactions have the same meaning that the interaction factor*continuous covariate and continuous covariate* continuous covariate used in the GLM? -- Only at a rather general level. The factor*continuous case uses a separate smooth function of the continuous variable for each level of the factor (although you can force all the smoothing parameter to be the same). The continuous*continous interaction uses a single smooth function of both continuous variables as the interaction. 3.Is right to introduce in the model the continuous covariates and the factor moreover their interactions? -- Your models all look potentially sensible, with the continuous and factor variables dealt with in reasonable ways (of course I can't tell whether they are actually appropriate for the data you have). best, Simon On Friday 03 September 2010 15:06, Lucia Cañas wrote: Hello R users, I am working with the GAM to inspect the effect of some factors (year, area) and continuous variables (length, depth, latitude and longitude) on the intensity and prevalence of the common parasite Anisakis. I would like introduce interaction in my models, both continuous variables-continuous variables and continuous variables-factor. I have read some questions-answers regard to this subject but I still have doubts. The solution that I have seen to introduce an interaction continuous covariate-factor is using by (explained in ?gam.models). Below, I show an example of my model with the interactions using by both to prevalence (distribution=binomial) and to intensity (distribution=negative binomial): gam(prevalence~s(length)+factor(year)+factor(area)+s(length,by=area)+s(leng th,by=year), family=binomial,data=X) gam(intensity~s(length)+factor(year)+factor(area)+s(length,by=area)+s(lengt h,by=year), family=negbin(c(1,10)),data=X) The solution that I have seen to introduce an interaction continuous covariate- continuous covariate is using the function te. Below, I show an example of my model with the interactions using te both to prevalence (distribution=binomial) and to intensity (distribution=negative binomial): gam(prevalence~s(length)+s(depth)+s(latitude)+s(longitude)+te(depth,length) + te(latitude,length)+ te(longitude,length),family=binomial,data=X) gam(intensity~s(length)+s(depth)+s(latitude)+s(longitude)+te(depth,length)+ te(latitude,length)+ te(longitude,length),family= negbin(c(1,10)),data=X) Thanks in advance. Best regards, Luc�a Ca��s Luc�a Ca��s Ferreiro Instituto Espa�ol de Oceanograf�a Centro Oceanogr�fico de A Coru�a Paseo Mar�timo Alcalde Francisco V�zquez, n� 10 15001 - A Coru�a, SPAIN e-mail: lucia.ca...@co.ieo.es Tel: +34981205362; Fax: +34981229077 http://www.ieo.es [[alternative HTML version deleted]] -- Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK +44 1225 386603 www.maths.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] general question on binomial test / sign test
Ah, the plot thickens! The p-value imbroglio again. I won't comment except to note that all of this so far assumes a simple null. What if you have a composite null? --e.g. My null is that the data are drawn from a normal with unknown mean and variance versus they are drawn from mixture of 2 normals with 2 different unknown means but the same unknown variance. Constructing appropriate tests gets dicier and dicier in these situations. Cheers, Bert On Fri, Sep 3, 2010 at 7:19 AM, Greg Snow greg.s...@imail.org wrote: Ted, I agree that we are measuring discrepancies and that large discrepancies correspond to p-values near 0 and small discrepancies correspond to large p-values. But interpreting discrepancies on a p-value scale leads more to confusion than understanding. If you are interested in the discrepancy, then focus on the meaningful discrepancy scale (confidence intervals are great in many of these cases). I also agree that small p-values corresponding to large discrepancies is meaningful in saying that the large discrepancy is indicative of a real difference rather than just luck. My point was more focused on the over interpretation of differences in large p-values (remember this thread started with the original poster misinterpreting a p-value of 1). Try this exercise: Consider a sample of size 100 from a normal population with known standard deviation of 1. The null hypothesis is that the true mean is 50, what sample mean(s) will result in a p-value of 0.4? a p-value of 0.9? Is the difference between the 2 discrepancies worth getting excited about? Compare what conclusions you would draw by comparing the 2 confidence intervals to what might be concluded by comparing the 2 p-values. The difference between a p-value of 0.01 and 0.1 is very meaningful (if using an alpha=0.05 or close), the difference between a p-value of 0.4 and 0.9 is much less meaningful even though the difference is bigger. Also for alpha=0.05, I don't think it is worth getting any more excited over a p-value of 0.1 than one of 0.0001, but people do. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Ted Harding [mailto:ted.hard...@manchester.ac.uk] Sent: Thursday, September 02, 2010 3:59 PM To: Greg Snow Cc: r-help@r-project.org; Kay Cecil Cichini Subject: Re: [R] general question on binomial test / sign test On 02-Sep-10 18:01:55, Greg Snow wrote: Just to add to Ted's addition to my response. I think you are moving towards better understanding (and your misunderstandings are common), but to further clarify: [Wise words about P(A|B), P(B|A), P-values, etc., snipped] The real tricky bit about hypothesis testing is that we compute a single p-value, a single observation from a distribution, and based on that try to decide if the process that produced that observation is a uniform distribution or something else (that may be close to a uniform or very different). Indeed. And this is precisely why I began my original reply as follows: Zitat von ted.hard...@manchester.ac.uk: [...] The general logic of a singificance test is that a test statistic (say T) is chosen such that large values represent a discrepancy between possible data and the hypothesis under test. When you have the data, T evaluates to a value (say t0). The null hypothesis (NH) implies a distribution for the statistic T if the NH is true. Then the value of Prob(T = t0 | NH) can be calculated. If this is small, then the probability of obtaining data at least as discrepant as the data you did obtain is small; if sufficiently small, then the conjunction of NH and your data (as assessed by the statistic T) is so unlikely that you can decide to not believe that it is possible. If you so decide, then you reject the NH because the data are so discrepant that you can't believe it! The point is that the test statistic T represents *discrepancy* between data and NH in some sense. In what sense? That depends on what you are interested in finding out; and, whatever it is, there will be some T that represents it. It might be whether two samples come from distributions with equal means, or not. Then you might use T = mean(Ysample) - mean(Xsample). Large values of |T| represent discrepancy (in either direction) between data and an NH that the true means are equal. Large values of T, discrepancy in the positive direction, large values of -T diuscrepancy in the negative direction. Or it might be whether or not the two samples are drawn from populations with equal variances, when you might use T = var(Ysample)/var(Xsample). Or it might be whether the distribution from which X was sampled is symmetric, in which case you might use skewness(Xsample). Or you might be interested in whether the numbers falling into disjoint classes are consistent
Re: [R] readLines and writeLines
On Sep 3, 2010, at 8:39 AM, raje...@cse.iitm.ac.in wrote: I have a socket connection where I do -socketConnection -writeLines and then wait for the server to send data through the socket. so I have to wait on a readLines.But when I say str-readLines(con) it executes immediately and str gets nothing.what do i do for this? Have you looked at the penultimate example on the connections help page? -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generation of uniform random numbers
Sarah, Here's a version using two nested loops: rate_number = matrix(c(5, 15, 60, 15, 5, 0, 20, 60, 20,0, 10, 20, 40, 20, 10), nrow = 5, ncol = 3) range_mat = matrix(c(6.25, 6.75, 7.25, 8.75, 9.25, 9.75, 8.5, 9, 9.5, 10.5, 11, 11.5, 4.25, 4.75, 5.25, 5.75, 6.25, 6.75), nrow = 6, ncol = 3) set.seed(123) res - vector(mode = list, length = NCOL(rate_number)) rateSum - colSums(rate_number) for(i in seq_len(NCOL(rate_number))) { res[[i]] - numeric(length = rateSum[i]) rates - rate_number[,i] rates - rates[(want - which(rates 0))] for(j in seq_along(rates)) { if(j == 1) { from - 1 to - rates[1] } else { from - sum(rates[1:(j-1)]) + 1 to - sum(rates[1:j]) } res[[i]][from:to] - runif(rates[j], min = range_mat[want[j],i], max = range_mat[want[j]+1, i]) } } str(res) head(res) Not the most elegant code but it works... Most of the fiddling about in there is to work round the fact that you have 0's in some cells of rate_number and I wanted to avoid concatenating vectors to enlarge them, so allocate storage first. HTH G On Fri, 2010-09-03 at 03:32 -0700, Sarah Sanchez wrote: Dear R helpers I have following dataset rate_number = matrix(c(5, 15, 60, 15, 5, 0, 20, 60, 20,0, 10, 20, 40, 20, 10), nrow = 5, ncol = 3) range_mat = matrix(c(6.25, 6.75, 7.25, 8.75, 9.25, 9.75, 8.5, 9, 9.5, 10.5, 11, 11.5, 4.25, 4.75, 5.25, 5.75, 6.25, 6.75), nrow = 6, ncol = 3) rate_number [,1] [,2] [,3] [1,] 5 0 10 [2,] 15 20 20 [3,] 60 60 40 [4,] 15 20 20 [5,] 5 0 10 range_mat [,1] [,2] [,3] [1,] 6.25 8.5 4.25 [2,] 6.75 9.0 4.75 [3,] 7.25 9.5 5.25 [4,] 8.75 10.5 5.75 [5,] 9.25 11.0 6.25 [6,] 9.75 11.5 6.75 My problem is to generate random numbers in line with rate_number and using the range_mat. E.g. I need to generate (5, 15, 60, 15, 5 i.e. the first column of rate_number) uniform random numbers (using 1st column of range_mat) s.t the first 5 numbers will be in the range (6.25 - 6.75), next 15 numbers should be in the range (6.75 to 7.25), next 60 numbers should be in the range (7.25 to 8.75), next 15 numbers in the range (8.75 to 9.25) and last 5 numbers in the range (9.25 to 9.75). Similarily, I need to generate (0, 20, 60, 20, 0 i.e. 2nd column of rate_number) uniform random numbers in the range (using 2nd column of range_mat) i.e. (8.5 to 9), (9 to 9.5), (9.5 to 10.5), (10.5 to 11), (11 to 11.5) respectively. I could have generated these random numbersIndividually using runif, but main problem is range_number could be anything i.e. there may be 50 rates but for each rate, no of rate combination will always be 5 i.e. rate_number will always have 5 rows only and also range_mat will always have 6 rows only. I tried writing loops and even tapply etc. but just can't get through. I sincerely request you to kindly guide me. Regards Sarah [[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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] vglm help
Hi All, I am using vglm the fitted values is NA. As in the R documentation that for Pareto1, if the estimate of k is less than or equal to unity then the fitted values will be NA. what is NA means ? how to solve it ? how to get the k estimate ? (in the R document the estimate of alpha is f...@extra). Thank you [[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] density() with confidence intervals
Hello R users R friends, I just want to ask you if density() can produce a confidence interval, indicating how certain the density() line follows the true frequency distribution based on the sample you feed into density(). I've heard of loess.predict(loess(y ~ x), se=TRUE) which gives you a SE estimate of the smoothed scatterplot - but density() kernel smoothing is not the same as locally-weighted polynomial scatterplot smoothing... Feel free to ask me if I did not put my question into clear words :) Kind regards thanks in advance, David -- Sicherer, schneller und einfacher. Die aktuellen Internet-Browser - jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/chbrowser __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Function Gini or Ineq
Hi listers, Does it necessary to install any package in order to use the GINI or INEQ functions. If I use the following command the R tells me that didn't find the GINI function. x-c(541, 1463, 2445, 3438, 4437, 5401, 6392, 8304, 11904, 22261) G-gini(x) Thanks in advance, Marcio -- View this message in context: http://r.789695.n4.nabble.com/Function-Gini-or-Ineq-tp2525852p2525852.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] 3d graph surface
Hello I have and 11 by 2 by 1200 matrix from which I would like to make a surface graph. the first element of the first column represents the date, which means I've got 1200 dates. I would like to graph the 11 elements of the second column for each date. Does anybody know how can I do this? attached I'm sending the matrix, its called MCurvaCOP, thank you Felipe Parra __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 'seq' help page: seq_length - seq_len?
On 2010-09-03 2:05, Niels Richard Hansen wrote: In the Value section of the 'seq' help page it says 'seq_along' and 'seq_length' always return an integer vector. I believe it should be 'seq_along' and 'seq_len' always return an integer vector. as there are no seq_length function? Best, Niels Looks like that's fixed in R2.12.0. (It's always a good idea to check the development version.) -Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Function Gini or Ineq
for the Gini coefficient you can use this function: gini - function(x, unbiased = TRUE, na.rm = FALSE){ if (!is.numeric(x)) { warning('x' is not numeric; returning NA) return(as.numeric(NA)) } if (any(na.ind - is.na(x))) { if (!na.rm) stop('x' contain NAs) else x - x[!na.ind] } n - length(x) mu - mean(x) N - if (unbiased) n*(n - 1) else n*n ox - x[order(x)] dd - drop(crossprod(2 * 1:n - n - 1, ox)) dd / (mu * N) } x - c(541, 1463, 2445, 3438, 4437, 5401, 6392, 8304, 11904, 22261) G - gini(x) I hope it helps. Best, Dimitris On 9/3/2010 5:37 PM, Mestat wrote: Hi listers, Does it necessary to install any package in order to use the GINI or INEQ functions. If I use the following command the R tells me that didn't find the GINI function. x-c(541, 1463, 2445, 3438, 4437, 5401, 6392, 8304, 11904, 22261) G-gini(x) Thanks in advance, Marcio -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Function Gini or Ineq
Hi Dimitris, I have already seen your code in another post. But, I would like to weight my data. So, I wish I could use the following command: gini(x, weights=rep(1,length=length(x))) Thanks anyway and I am trying to understand your gini function in order to apply a weigth. Marcio -- View this message in context: http://r.789695.n4.nabble.com/Function-Gini-or-Ineq-tp2525852p2525896.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] Making plots in big scatterplot matrix large enough to see
Some thoughts on your question about having pairs increase the size of the device: The pairs function is fairly old (and plot even older) and fully adjustable graphics devices are actually fairly recent. I remember a time when the only way to get high quality color plots was to send the plot to a pen plotter (Last I checked S-PLUS still has a graphics driver for some plotters, I don't think R ever did or likely will), this had a mechanical arm that would move a pen around on a piece of paper (this is also why colors were originally designated by number not color name, the program did not know which pen was red (you could move them around), so you would just say use pen number 2). How would a plotting function in a computer program resize a physical piece of paper? There are advantages to keeping graphics devices and plotting functions separate. There are probably more than I know, but one simple one is that I was able to write the pairs2 function (well the pieces that I did not steal from pairs) without knowing anything about controlling devices. If I would have had to think about sizes of devices, I probably would not have even tried writing the function. With the ability to specify your own panel functions, that is asking quite a bit of the programmers of pairs to figure out what is too small, some panel functions could easily be meaningful even at small sizes (single pixels where the main information is in the color). See fortune(226). Resizing devices may be a good idea for your specific case, but I am uncomfortable with the program in general taking that control away from me (but then I really dislike calculators that don't have an off button, I want the illusion of control of at least being able to turn it off, not let it decide when to shut itself off (I'm not paranoid if the machines really are out to get me, right?)) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Jocelyn Paine [mailto:p...@j-paine.org] Sent: Thursday, September 02, 2010 10:16 PM To: Greg Snow Cc: r-help@r-project.org Subject: RE: [R] Making plots in big scatterplot matrix large enough to see Greg, thanks for the suggestion. That's useful to know for future work. It's not so good in this case, because I'm making the plots for a colleague who doesn't know R, and it would be a bother for me to have to send him several files and him reassemble them. What I did was to use pairs.panels, as suggested by William Revelle on this thread. I'd like to ask a general question about the interface though. There's a size below which individual scatterplots are not legible. It makes no sense at all for a scatterplot routine to plot them at that size or smaller. So why didn't the author(s) of 'pairs' program it so that it always makes them at least legible size, and expands the image window until it can fit them all in? Regards, Jocelyn Paine http://www.j-paine.org +44 (0)7768 534 091 Jocelyn's Cartoons: http://www.j-paine.org/blog/jocelyns_cartoons/ On Tue, 31 Aug 2010, Greg Snow wrote: Look at the pairs2 function in the TeachingDemos package, this lets you produce smaller portions of the total scatterplot matrix at a time (with bigger plots), you could print the smaller portions then assemble the full matrix on a large wall, or just use it to look at potentially interesting parts. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Jocelyn Paine Sent: Monday, August 30, 2010 10:21 PM To: r-help@r-project.org Subject: [R] Making plots in big scatterplot matrix large enough to see I've got a data frame with 23 columns, and wanted to plot a scatterplot matrix of it. I called pairs( df ) where 'df' is my data frame. This did generate the matrix, but the plotting window did not expand to make the individual plots large enough to see. Each one was only about 10 pixels high and wide. I tried sending the plot to a file, with a high and wide image, by doing png( plot.png, width = 4000, height = 4000 ) but I got these errors: Error in png( plot.png, width = 4000, height = 4000 ) : unable to start device In addition: Warning messages: 1: In png( plot.png, width = 4000, height = 4000 ) : Unable to allocate bitmap 2: In png( plot.png, width = 4000, height = 4000 ) : opening device failed The messages aren't helpful, because they don't tell you _why_ R can't start the device, allocate it, or open it. The documentation for png says: Windows imposes limits on the size of bitmaps: these are not documented in the SDK and may depend on the version of Windows. It seems that width
Re: [R] 3d graph surface
Luis Felipe Parra wrote: Hello I have and 11 by 2 by 1200 matrix from which I would like to make a surface graph. Check the example in the docs of surface3d or persp3d from the rgl package. Note that attachments cannot be sent to the list (pdf and a few others are the exception) Dieter -- View this message in context: http://r.789695.n4.nabble.com/3d-graph-surface-tp2525859p2525919.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] 3d graph surface
?persp -- View this message in context: http://r.789695.n4.nabble.com/3d-graph-surface-tp2525859p2525958.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] Function Gini or Ineq
you need install and load package {reldist} before you call function gini(). HTH. -- View this message in context: http://r.789695.n4.nabble.com/Function-Gini-or-Ineq-tp2525852p2525966.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] Function Gini or Ineq
Hi Peng, I did that i installed the package RELDIST, but nothing happened. R does not recognize this function. Still looking for the solution. Thanks, Marcio -- View this message in context: http://r.789695.n4.nabble.com/Function-Gini-or-Ineq-tp2525852p2525981.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] general question on binomial test / sign test
Bert, Your null is still simple (it is your alternative that does not fit the standard), for any test statistic you just need to estimate the distribution of it under the null. If you cannot do this theoretically it is easy enough to simulate. Then all the theory around p-values still holds. If you choose a poor test statistic, then you will have low power, but the theory still holds and the test will be correctly sized (?TeachingDemos::SnowsCorrectlySizedButOtherwiseUselessTestOfAnything). Debating the relative merits of various test statistics for this case sounds like homework from a graduate level theory class, but since I am neither taking nor teaching any such class currently or in the near future, I will leave this debate to those who are. My first thought for your problem would be: ?TeachingDemos::vis.test -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Friday, September 03, 2010 8:46 AM To: Greg Snow Cc: ted.hard...@manchester.ac.uk; r-help@r-project.org; Kay Cecil Cichini Subject: Re: [R] general question on binomial test / sign test Ah, the plot thickens! The p-value imbroglio again. I won't comment except to note that all of this so far assumes a simple null. What if you have a composite null? --e.g. My null is that the data are drawn from a normal with unknown mean and variance versus they are drawn from mixture of 2 normals with 2 different unknown means but the same unknown variance. Constructing appropriate tests gets dicier and dicier in these situations. Cheers, Bert On Fri, Sep 3, 2010 at 7:19 AM, Greg Snow greg.s...@imail.org wrote: Ted, I agree that we are measuring discrepancies and that large discrepancies correspond to p-values near 0 and small discrepancies correspond to large p-values. But interpreting discrepancies on a p- value scale leads more to confusion than understanding. If you are interested in the discrepancy, then focus on the meaningful discrepancy scale (confidence intervals are great in many of these cases). I also agree that small p-values corresponding to large discrepancies is meaningful in saying that the large discrepancy is indicative of a real difference rather than just luck. My point was more focused on the over interpretation of differences in large p-values (remember this thread started with the original poster misinterpreting a p-value of 1). Try this exercise: Consider a sample of size 100 from a normal population with known standard deviation of 1. The null hypothesis is that the true mean is 50, what sample mean(s) will result in a p-value of 0.4? a p-value of 0.9? Is the difference between the 2 discrepancies worth getting excited about? Compare what conclusions you would draw by comparing the 2 confidence intervals to what might be concluded by comparing the 2 p-values. The difference between a p-value of 0.01 and 0.1 is very meaningful (if using an alpha=0.05 or close), the difference between a p-value of 0.4 and 0.9 is much less meaningful even though the difference is bigger. Also for alpha=0.05, I don't think it is worth getting any more excited over a p-value of 0.1 than one of 0.0001, but people do. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Ted Harding [mailto:ted.hard...@manchester.ac.uk] Sent: Thursday, September 02, 2010 3:59 PM To: Greg Snow Cc: r-help@r-project.org; Kay Cecil Cichini Subject: Re: [R] general question on binomial test / sign test On 02-Sep-10 18:01:55, Greg Snow wrote: Just to add to Ted's addition to my response. I think you are moving towards better understanding (and your misunderstandings are common), but to further clarify: [Wise words about P(A|B), P(B|A), P-values, etc., snipped] The real tricky bit about hypothesis testing is that we compute a single p-value, a single observation from a distribution, and based on that try to decide if the process that produced that observation is a uniform distribution or something else (that may be close to a uniform or very different). Indeed. And this is precisely why I began my original reply as follows: Zitat von ted.hard...@manchester.ac.uk: [...] The general logic of a singificance test is that a test statistic (say T) is chosen such that large values represent a discrepancy between possible data and the hypothesis under test. When you have the data, T evaluates to a value (say t0). The null hypothesis (NH) implies a distribution for the statistic T if the NH is true. Then the value of Prob(T = t0 | NH) can be calculated. If this is small, then the probability of obtaining data at least as discrepant as the data
[R] how can I plot bar plots with all the bars (negative and positive) in the same direction????
Dear r-help mailing list, this seems stupid, but I actually don't find the solution: if I have a vector of numbers x of length n, ranging, say, from -3 to 4, if I do barplot (x) all the values below 0 go downwards, and all the positive values go upward. How can I make them all begin from the minimum pointing upwards? Thanks! Gabriele Zoppoli, MD Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of Genova, Genova, Italy Guest Researcher, LMP, NCI, NIH, Bethesda MD Work: 301-451-8575 Mobile: 301-204-5642 Email: zoppo...@mail.nih.gov __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] running an exe in the background
?system #look at the wait parameter ?.First.lib I only checked the above for windows, you did not specify what platform you are using but referring to .exe implies windows. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of raje...@cse.iitm.ac.in Sent: Thursday, September 02, 2010 11:23 PM To: r-help Subject: [R] running an exe in the background Hi, I'd like to be able to run a .exe in the background whenever library(package-x) is called. Is this possible? ~Aks [[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] density() with confidence intervals
One can write an R function to produce a kernel density curve with a confidence band. See, for example, the steps of doing this in a technical report at http://fmwww.bc.edu/repec/usug2003/bsciker.pdf -- View this message in context: http://r.789695.n4.nabble.com/density-with-confidence-intervals-tp2525837p2526008.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how can I plot bar plots with all the bars (negative and positive) in the same direction????
In the bar plot, the vertical axis is a numerical axis representing the frequency (the height of the vertival bar -= frequency). If you really want to have vertical bar corresponding to the negative values go downward, you need to make your own function to achieve the goal. -- View this message in context: http://r.789695.n4.nabble.com/how-can-I-plot-bar-plots-with-all-the-bars-negative-and-positive-in-the-same-direction-tp2526006p2526021.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how can I plot bar plots with all the bars (negative and positive) in the same direction????
Dear Gabriele, I suspect the reason you are having difficulty finding the solution is because barplots were meant to be anchored at 0. What information are you really trying to convey? There is probably a very clear, aesthetically pleasing way to achieve your goal without a barplot. For instance, what about a simple scatter plot? dat - (-3:4) plot(x = 1:length(dat), y = dat, xaxt = n, xlab = My Groups) axis(side = 1, at = 1:length(dat), labels = LETTERS[1:8]) Alternately, you could add the minimum to your data so it started at 0... barplot(dat + abs(min(dat))) Hadley will never forgive me for mentioning this but, if you have a desperate need to use bars that are anchored at the minimum value, you could use geom_rect() in package ggplot2... mydf - data.frame(x = 1:8, y = dat) library(ggplot2) ggplot(mydf, aes(xmin = x, xmax = x + 1, ymin = min(y), ymax = y)) + geom_rect() HTH, Josh On Fri, Sep 3, 2010 at 10:12 AM, Zoppoli, Gabriele (NIH/NCI) [G] zoppo...@mail.nih.gov wrote: Dear r-help mailing list, this seems stupid, but I actually don't find the solution: if I have a vector of numbers x of length n, ranging, say, from -3 to 4, if I do barplot (x) all the values below 0 go downwards, and all the positive values go upward. How can I make them all begin from the minimum pointing upwards? Thanks! Gabriele Zoppoli, MD Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of Genova, Genova, Italy Guest Researcher, LMP, NCI, NIH, Bethesda MD Work: 301-451-8575 Mobile: 301-204-5642 Email: zoppo...@mail.nih.gov __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how can I plot bar plots with all the bars (negative and positive) in the same direction????
On Sep 3, 2010, at 1:12 PM, Zoppoli, Gabriele (NIH/NCI) [G] wrote: Dear r-help mailing list, this seems stupid, but I actually don't find the solution: if I have a vector of numbers x of length n, ranging, say, from -3 to 4, if I do barplot (x) all the values below 0 go downwards, and all the positive values go upward. How can I make them all begin from the minimum pointing upwards? grp.n -c(0, -1, -2, -3, -5, -1, 3, -2, 2, 0) barplot(grp.n-min(grp.n), axes=FALSE) axis(2, grp.n-min(grp.n), labels=as.character(grp.n)) Compare barplot(grp.n, axes=FALSE) -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how can I plot bar plots with all the bars (negative and
On 03-Sep-10 17:12:55, Zoppoli, Gabriele (NIH/NCI) [G] wrote: Dear r-help mailing list, this seems stupid, but I actually don't find the solution: if I have a vector of numbers x of length n, ranging, say, from -3 to 4, if I do barplot (x) all the values below 0 go downwards, and all the positive values go upward. How can I make them all begin from the minimum pointing upwards? Thanks! Gabriele Zoppoli, MD It's not completely clear what you want to see, given the vector. However, the reason you are seeing the bars go upwards and downwards is given at the beginning of '?barplot': barplot(height, width = 1, space = NULL, ... ) Therefore, if x is a vector of positive and negative numbers, barplot(x) will correctly draw bars with negative heightslues (downwards) at negative values of x, and with positive heights (upwards) for positive values of x. On the other hand, possibly you want to see a barplot which corresponds to a histogram, i.e. for each distinct value of x you get a bar pointing upwards with height equal to the count of that value. For example: set.seed(54321) x-sample(((-3):4),100,replace=TRUE) x ### Have a look at the values in x barplot(x) ### A barplot with bar heights given by x barplot(table(x)) ### a barplot of the counts of the values of x Hoping this helps, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 03-Sep-10 Time: 19:08:34 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What solve() does?
If A is a squared matrix, solve(A) gives the inverse of A; if you have a system of linear equation AX=B, solve(A,B) gives the solution to this system of equations. For example: x-2y =1 -2x+3y=-3 A=matrix(c(1,-2,-2,3), ncol=2, byrow=T) B=c(1,-3) # to get the inverse of A solve(A) [,1] [,2] [1,] -3 -2 [2,] -2 -1 # to get the solution to the system of equation solve(A,B) [1] 3 1 -- View this message in context: http://r.789695.n4.nabble.com/What-solve-does-tp2402922p2526066.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] Function Gini or Ineq
You installed the package but probably forgot to load the library. This works fine for me. = library(reldist) x-c(541, 1463, 2445, 3438, 4437, 5401, 6392, 8304, 11904, 22261) G-gini(x) --- On Fri, 9/3/10, Mestat mes...@pop.com.br wrote: From: Mestat mes...@pop.com.br Subject: Re: [R] Function Gini or Ineq To: r-help@r-project.org Received: Friday, September 3, 2010, 1:07 PM Hi Peng, I did that i installed the package RELDIST, but nothing happened. R does not recognize this function. Still looking for the solution. Thanks, Marcio -- View this message in context: http://r.789695.n4.nabble.com/Function-Gini-or-Ineq-tp2525852p2525981.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] how can I plot bar plots with all the bars (negative and positive) in the same direction????
As is often the case in R, just because you shouldn't do something, doesn't mean you can't do it. Still, I'd urge you to consider the visual honesty of what you propose. If you're still insistent: dat - (-3:4) dat1=dat-min(dat) barplot(dat1,axes=FALSE) axis(2,dat1,labels=dat) Typically, zero is a reference point and/or the identity element for addition. Your plot audience will interpret it this way. If you want to look at difference scores from the minimal value, shouldn't that be exactly how you label your y-axis, and not with the pre-transformed numbers? Are you still sure you don't like the default behavior? Rob Baer - Original Message - From: Zoppoli, Gabriele (NIH/NCI) [G] zoppo...@mail.nih.gov To: r-help@r-project.org Sent: Friday, September 03, 2010 12:12 PM Subject: [R] how can I plot bar plots with all the bars (negative and positive) in the same direction Dear r-help mailing list, this seems stupid, but I actually don't find the solution: if I have a vector of numbers x of length n, ranging, say, from -3 to 4, if I do barplot (x) all the values below 0 go downwards, and all the positive values go upward. How can I make them all begin from the minimum pointing upwards? Thanks! Gabriele Zoppoli, MD Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of Genova, Genova, Italy Guest Researcher, LMP, NCI, NIH, Bethesda MD Work: 301-451-8575 Mobile: 301-204-5642 Email: zoppo...@mail.nih.gov __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Package wavelets
Hi user's Does anybody work with wavelets on R? Please I need some help. Atte Marize Simões -- View this message in context: http://r.789695.n4.nabble.com/Package-wavelets-tp2526023p2526023.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Package wavelets
The package or wavelets in general? What do you want to do? 2010/9/3 Marize Simões rizesim...@uol.com.br: Hi user's Does anybody work with wavelets on R? Please I need some help. Atte Marize Simões -- View this message in context: http://r.789695.n4.nabble.com/Package-wavelets-tp2526023p2526023.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. -- Stephen Sefick | Auburn University | | Department of Biological Sciences | | 331 Funchess Hall | | Auburn, Alabama | | 36849 | |___| | sas0...@auburn.edu | | http://www.auburn.edu/~sas0025 | |___| Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis A big computer, a complex algorithm and a long time does not equal science. -Robert Gentleman __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] density() with confidence intervals
Here is a simple approach that uses bootstrapping (this could probably be improved by using better bootstrap estimates and not ignoring the dependence between points): xx - faithful$eruptions fit1 - density(xx) fit2 - replicate(1, { x - sample(xx, replace=TRUE); density(x, from=min(fit1$x), to=max(fit1$x))$y } ) fit3 - apply(fit2, 1, quantile, c(0.025,0.975) ) plot(fit1, ylim=range(fit3)) polygon( c(fit1$x, rev(fit1$x)), c(fit3[1,], rev(fit3[2,])), col='grey', border=F) lines(fit1) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of David Croll Sent: Friday, September 03, 2010 9:23 AM To: r-help@r-project.org Subject: [R] density() with confidence intervals Hello R users R friends, I just want to ask you if density() can produce a confidence interval, indicating how certain the density() line follows the true frequency distribution based on the sample you feed into density(). I've heard of loess.predict(loess(y ~ x), se=TRUE) which gives you a SE estimate of the smoothed scatterplot - but density() kernel smoothing is not the same as locally-weighted polynomial scatterplot smoothing... Feel free to ask me if I did not put my question into clear words :) Kind regards thanks in advance, David -- Sicherer, schneller und einfacher. Die aktuellen Internet-Browser - jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/chbrowser __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] how can I plot bar plots with all the bars (negative and positive) in the same direction????
I believe that you will have to draw them in ggplot2 as someone mentioned or in base graphics. Here is a rough first attempt that may give you some ideas. xx - -3:4 yy - rep(-3,length(xx)) plot(xx,xx, type=n, xlim=c(-4, 5)) rect(xx, yy, xx+.5, xx ) --- On Fri, 9/3/10, Zoppoli, Gabriele (NIH/NCI) [G] zoppo...@mail.nih.gov wrote: From: Zoppoli, Gabriele (NIH/NCI) [G] zoppo...@mail.nih.gov Subject: [R] how can I plot bar plots with all the bars (negative and positive) in the same direction To: r-help@r-project.org r-help@r-project.org Received: Friday, September 3, 2010, 1:12 PM Dear r-help mailing list, this seems stupid, but I actually don't find the solution: if I have a vector of numbers x of length n, ranging, say, from -3 to 4, if I do barplot (x) all the values below 0 go downwards, and all the positive values go upward. How can I make them all begin from the minimum pointing upwards? Thanks! Gabriele Zoppoli, MD Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of Genova, Genova, Italy Guest Researcher, LMP, NCI, NIH, Bethesda MD Work: 301-451-8575 Mobile: 301-204-5642 Email: zoppo...@mail.nih.gov __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] rgl windows binary
Folks, the rgl 0.91 binary for windows seems corrputed. WinZip complains the downloaded zip file is not a valid archive. I had no luck with R-forge either. Could someone point me to the latest production ready binary? Thks. H [[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] density() with confidence intervals
Thank you very much for your help, Greg! Here's my ludicrous vision/attempt/whatever :o) ### Idea for making a density() with confidence interval ### xx - faithful$eruptions xx.hist - hist(xx, breaks=FD, freq=F) # plot(xx.hist$mids, xx.hist$density) # gives a rough plot(density(xx)) output # xx.hist$counts is later used to repeat observations # for loess(), making the CI band narrower where there # are more observations (or data in each histogram bin) x - c() # preparing variables... y - c() for (i in 1:length(xx.hist$mids)) { # going through each xx.hist$mids/xx.hist$density pair for (j in 1:xx.hist$counts[i]) { # ...and repeating observations according to xx.hist$counts x - append(x, xx.hist$mids[i]) y - append(y, xx.hist$density[i]) } } xx.loess - loess(y ~ x, span=1) xx.predict - predict(xx.loess, se=T) plot(x,y) lines(x, xx.predict$fit, col=red) lines(x, xx.predict$fit + 1.96 * xx.predict$s, col=red, lty=5) lines(x, xx.predict$fit - 1.96 * xx.predict$s, col=red, lty=5) # Kind regards, David Here is a simple approach that uses bootstrapping (this could probably be improved by using better bootstrap estimates and not ignoring the dependence between points): xx - faithful$eruptions fit1 - density(xx) fit2 - replicate(1, { x - sample(xx, replace=TRUE); density(x, from=min(fit1$x), to=max(fit1$x))$y } ) fit3 - apply(fit2, 1, quantile, c(0.025,0.975) ) plot(fit1, ylim=range(fit3)) polygon( c(fit1$x, rev(fit1$x)), c(fit3[1,], rev(fit3[2,])), col='grey', border=F) lines(fit1) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] date conversion
Hello, I have a dataframe with data such as: dat$BEGINDATUM[3] [1] 13-09-2007 dat$BEGINDATUM[4] [1] 01-11-2007 class(dat$BEGINDATUM[3]) [1] factor Now I need to make calculation with these dates. But I get these result: as.date(as.character(dat$BEGINDATUM[3])) [1] NA as.date(as.character(dat$BEGINDATUM[4])) [1] 11Jan2007 How can i convert these factors to make calculations possible. Thanks for the answer, Andre [[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] date conversion
Hi, I think you just need to add the format = argument. Does this help? x - factor(01-11-2007) as.character(x) [1] 01-11-2007 as.Date(as.character(x), format = %d-%m-%Y) [1] 2007-11-01 Cheers, Josh On Fri, Sep 3, 2010 at 2:11 PM, André de Boer rnie...@gmail.com wrote: Hello, I have a dataframe with data such as: dat$BEGINDATUM[3] [1] 13-09-2007 dat$BEGINDATUM[4] [1] 01-11-2007 class(dat$BEGINDATUM[3]) [1] factor Now I need to make calculation with these dates. But I get these result: as.date(as.character(dat$BEGINDATUM[3])) [1] NA as.date(as.character(dat$BEGINDATUM[4])) [1] 11Jan2007 How can i convert these factors to make calculations possible. Thanks for the answer, Andre [[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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R program google search
Hi, Can someone help as how to use R to program google search in the R code? I know that other languages can allow or have the google search API If someone can give me some links or sample code I would greatly appreciate. Thanks. -- Waverley @ Palo Alto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rmate osascript workaround for e-texteditor on windows?
First, thanks very much for making rmate available. I'm having trouble porting it to e-texteditor for windows, though, (specifically the send-line command) because osascript is mac-only. Is there a way to send selections in e-texteditor to the windows version of R.app? Thanks! Dan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how can I plot bar plots with all the bars (negative andpositive) in the same direction????
It occurred to me after my initial post that you will need a little more fixing of your axis labels if you have data that is not trivial integers as in your example. Consider the following solution for some irrational random numbers: dat=rnorm(20) dat1=dat-min(dat) barplot(dat1,axes=FALSE) axis(2, round(seq(from=min(dat1),to=max(dat1),length.out=10), digits=1), round(seq(from=min(dat),to=max(dat),length.out=10), digits=1)) Rob Baer I believe that you will have to draw them in ggplot2 as someone mentioned or in base graphics. Here is a rough first attempt that may give you some ideas. xx - -3:4 yy - rep(-3,length(xx)) plot(xx,xx, type=n, xlim=c(-4, 5)) rect(xx, yy, xx+.5, xx ) --- On Fri, 9/3/10, Zoppoli, Gabriele (NIH/NCI) [G] zoppo...@mail.nih.gov wrote: From: Zoppoli, Gabriele (NIH/NCI) [G] zoppo...@mail.nih.gov Subject: [R] how can I plot bar plots with all the bars (negative and positive) in the same direction To: r-help@r-project.org r-help@r-project.org Received: Friday, September 3, 2010, 1:12 PM Dear r-help mailing list, this seems stupid, but I actually don't find the solution: if I have a vector of numbers x of length n, ranging, say, from -3 to 4, if I do barplot (x) all the values below 0 go downwards, and all the positive values go upward. How can I make them all begin from the minimum pointing upwards? Thanks! Gabriele Zoppoli, MD Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of Genova, Genova, Italy Guest Researcher, LMP, NCI, NIH, Bethesda MD Work: 301-451-8575 Mobile: 301-204-5642 Email: zoppo...@mail.nih.gov __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] R code output issues
Hi all, I have a short R code file that I am using to perform calculations on a dataset. I am having a few issues with output: 1. Although my input data file is 2149 lines long, when I type results.df from the command line, I get the appropriate calculation results for only the first 46 rows. Same result if I sink the output to a file, and type results.df at the command line. This creates a file with the first 46 entries. I do get the entire input data file back if I type data, and I can't see anything in my input file around line 46 that would account for this. 2. If I run the code from a file using the command source(TransmissionCalc2) with the results.df command embedded in the file, there is no output to the terminal at all (or to the output file, if I use sink). Sink just creates an empty file. So, not sure why my results dataframe seems to only include a small fraction of the data, or why the write commands are ignored when embedded in the code and called by source(etc CODE rm(list = ls(all = TRUE)) alldata -read.table(/Users/marcel/Desktop/V1V2TransmAnalysis/3_transmissiondata, header=T) #sink(/Users/marcel/Desktop/V1V2TransmAnalysis/4_output) data - data.frame(alldata) V1V2means - with(data, tapply(V1V2, list(Pair, DR), mean)) V1V4means - with(data, tapply(V1V4, list(Pair, DR), mean)) results.df - data.frame(V1V2means, V1V4means, V1V2dif = V1V2means[, R] - V1V2means[, D], V1V4dif = V1V4means[, R] - V1V4means[, D] ) data SAMPLE OF INPUT DATA FILE PairDRV1V2V1V4 1D63277 1D63277 1D63277 . Thoughts greatly appreciated. Marcel -- View this message in context: http://r.789695.n4.nabble.com/R-code-output-issues-tp2526415p2526415.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] rgl windows binary
On 03/09/2010 4:28 PM, Horace Tso wrote: Folks, the rgl 0.91 binary for windows seems corrputed. WinZip complains the downloaded zip file is not a valid archive. I had no luck with R-forge either. Could someone point me to the latest production ready binary? Why would you use WinZip? Just install the package. The one on cran.r-project.org is fine, as is the one on my local (Canada, ON) mirror. I think the problem is at your end. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R code output issues
first of all if you are 'sourcing' the file, put explicit print calls on your data frame; e.g., print(dataframe). Just because your input is 2149 lines long does not mean you results will necessarily be that long. You are using 'tapply' which will be aggregating your data. You need to provide some reproducible data and code so we can see what is happening. My best guess is you are getting the results from the tapply that you were not expecting. Some simple debugging on your part looking at the partial results would point you in the right direction. What does 'str' of you data fram say; I bet it says you have 46 observations. On Fri, Sep 3, 2010 at 8:32 PM, Marcel Curlin cemar...@u.washington.edu wrote: Hi all, I have a short R code file that I am using to perform calculations on a dataset. I am having a few issues with output: 1. Although my input data file is 2149 lines long, when I type results.df from the command line, I get the appropriate calculation results for only the first 46 rows. Same result if I sink the output to a file, and type results.df at the command line. This creates a file with the first 46 entries. I do get the entire input data file back if I type data, and I can't see anything in my input file around line 46 that would account for this. 2. If I run the code from a file using the command source(TransmissionCalc2) with the results.df command embedded in the file, there is no output to the terminal at all (or to the output file, if I use sink). Sink just creates an empty file. So, not sure why my results dataframe seems to only include a small fraction of the data, or why the write commands are ignored when embedded in the code and called by source(etc CODE rm(list = ls(all = TRUE)) alldata -read.table(/Users/marcel/Desktop/V1V2TransmAnalysis/3_transmissiondata, header=T) #sink(/Users/marcel/Desktop/V1V2TransmAnalysis/4_output) data - data.frame(alldata) V1V2means - with(data, tapply(V1V2, list(Pair, DR), mean)) V1V4means - with(data, tapply(V1V4, list(Pair, DR), mean)) results.df - data.frame(V1V2means, V1V4means, V1V2dif = V1V2means[, R] - V1V2means[, D], V1V4dif = V1V4means[, R] - V1V4means[, D] ) data SAMPLE OF INPUT DATA FILE Pair DR V1V2 V1V4 1 D 63 277 1 D 63 277 1 D 63 277 . Thoughts greatly appreciated. Marcel -- View this message in context: http://r.789695.n4.nabble.com/R-code-output-issues-tp2526415p2526415.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] pairs with same xlim and ylim scale
Well done! I was totally misled and trapped by the error message. Acturally the absence of 1.00 in the upper panel is an implicit indication that error occurred there. On 2010-9-3 13:02, Shi, Tao wrote: Hi Dejian, Thanks for the reply! I finally found the problem. It is actually in the panel.cor function. Adding ... in the function and text call fixed everything. Best, ...Tao - Original Message From: Dejian Zhaodejian.z...@gmail.com To: r-help@r-project.org Sent: Thu, September 2, 2010 7:57:55 PM Subject: Re: [R] pairs with same xlim and ylim scale When pairs draws plots, lower.panel invokes f.xy. Maybe there is something in f.xy incompatible with pairs. You can read the code of pairs to see what happens. pairs has two methods, as you can see in the help message (?pairs). According to your code, pairs is supposed to invoke Default S3 method. methods(pairs) [1] pairs.default pairs.formula* Non-visible functions are asterisked Therefore, you should check the code of the function pairs.default to see how error occurs. Just type pairs.default at the R command prompt and enter, you can get the source code of pairs.default. On 2010-9-2 15:15, Shi, Tao wrote: Hi Dejian, You're right on this! Do you know how to pass those two argument into lower.panel? Thanks! ...Tao From: Dejian Zhaozha...@ioz.ac.cn To:r-help@r-project.org Sent: Tue, August 31, 2010 6:10:16 PM Subject: Re: [R] pairs with same xlim and ylim scale I think you have successfully passed the xlim and ylim into the function pairs1. Compare the two graphs produced by the codes you provided, you can find the xlim and ylim in the second graph have been reset to the assigned value. It seems that the program halted in producing the second plot after adding xlim and ylim. According to the error message, the two added parameters were not used in lower.panel, or the customized function f.xy. On 2010-9-1 2:26, Shi, Tao wrote: Hi list, I have a function which basically is a wrapper of pairs with some useful panel functions. However, I'm having trouble to pass the xlim and ylim into the function so the x and y axes are in the same scale and 45 degree lines are exactly diagonal. I've looked at some old posts, they didn't help much. I [[elided Yahoo spam]] Thanks! ...Tao pairs1- function(x, ...) { f.xy- function(x, y, ...) { points(x, y, ...) abline(0, 1, col = 2) } panel.cor- function(x, y, digits=2, prefix=, cex.cor) { usr- par(usr); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r- abs(cor(x, y, method=p, use=pairwise.complete.obs)) txt- format(c(r, 0.123456789), digits=digits)[1] txt- paste(prefix, txt, sep=) if(missing(cex.cor)) cex- 0.8/strwidth(txt) text(0.5, 0.5, txt, cex = cex * r) } panel.hist- function(x, ...) { usr- par(usr); on.exit(par(usr)) par(usr = c(usr[1:2], 0, 1.5) ) h- hist(x, plot = FALSE) breaks- h$breaks; nB- length(breaks) y- h$counts; y- y/max(y) rect(breaks[-nB], 0, breaks[-1], y, col=cyan, ...) } pairs(x, lower.panel=f.xy, upper.panel=panel.cor, diag.panel=panel.hist, ...) } x- rnorm(100, sd=0.2) x- cbind(x=x-0.1, y=x+0.1) pairs1(x) pairs1(x, xlim=c(-1,1), ylim=c(-1,1)) Error in lower.panel(...) : unused argument(s) (xlim = c(-1, 1), ylim = c(-1, 1)) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://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 guidehttp://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 guidehttp://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
Re: [R] R code output issues
Thanks for the input Adding print took care of the first problem. The output looks like what I would expect, so I think the code is doing what I would like it to for the first 44 observations. print(results.df) DR D.1 R.1 V1V2dif V1V4dif 1 68.92500 75.0 284.5250 296. 6.075 11.475 2 68.81081 67.0 287.7568 283. -1.8108108 -4.7567568 3 65.43902 62.0 282.5366 279. -3.4390244 -3.5365854 4 66.6 67.25000 286.7000 288.2500 0.650 1.550 5 68.94872 71.0 297.8462 305. 2.0512821 7.1538462 Etc.. When I use str(results.df) it does seem to indicate a short file of 44 observations. 'data.frame':44 obs. of 6 variables: $ D : num 68.9 68.8 65.4 66.6 68.9 ... $ R : num 75 67 62 67.2 71 ... $ D.1: num 285 288 283 287 298 ... $ R.1: num 296 283 279 288 305 ... $ V1V2dif: num 6.08 -1.81 -3.44 0.65 2.05 ... $ V1V4dif: num 11.48 -4.76 -3.54 1.55 7.15 ... So I am still left with that question.. -- View this message in context: http://r.789695.n4.nabble.com/R-code-output-issues-tp2526415p2526469.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] Generation of uniform random numbers
Hi: Here's a slightly different approach, using both mapply() in base (a la David) and mlply() in plyr. My thought was to put the arguments together into a three column data frame; the names were chosen to correspond to the first three arguments of runif(): params - data.frame(n = as.vector(rate_number), min = as.vector(range_mat[-6, ]), max = as.vector(range_mat[-1, ])) params n min max [1,] 5 6.25 6.75 [2,]15 6.75 7.25 [3,]60 7.25 8.75 [4,]15 8.75 9.25 [5,] 5 9.25 9.75 [6,] 0 8.50 9.00 [7,]20 9.00 9.50 [8,]60 9.50 10.50 [9,]20 10.50 11.00 [10,] 0 11.00 11.50 [11,]10 4.25 4.75 [12,]20 4.75 5.25 [13,]40 5.25 5.75 [14,]20 5.75 6.25 [15,]10 6.25 6.75 Since the sample sizes are to be unequal, we need to output them to a list, which can be collapsed at the end if a vector is preferred. # mapply() approach: ll - list() ll - with(params, mapply(runif, n, min, max)) sapply(ll, length) [1] 5 15 60 15 5 0 20 60 20 0 10 20 40 20 10 sum(sapply(ll, length) ) [1] 300 myUniformSample1 - unlist(ll)# collapse to vector # mlply approach: the input data frame is the first argument, followed by the function name library(plyr) samp - mlply(params, runif) sapply(samp, length) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 5 15 60 15 5 0 20 60 20 0 10 20 40 20 10 sum(sapply(smp, length)) [1] 300 myUniformSample2 - unlist(samp) HTH, Dennis On Fri, Sep 3, 2010 at 3:32 AM, Sarah Sanchez sarah_sanche...@yahoo.comwrote: Dear R helpers I have following dataset rate_number = matrix(c(5, 15, 60, 15, 5, 0, 20, 60, 20,0, 10, 20, 40, 20, 10), nrow = 5, ncol = 3) range_mat = matrix(c(6.25, 6.75, 7.25, 8.75, 9.25, 9.75, 8.5, 9, 9.5, 10.5, 11, 11.5, 4.25, 4.75, 5.25, 5.75, 6.25, 6.75), nrow = 6, ncol = 3) rate_number [,1] [,2] [,3] [1,]5 0 10 [2,] 15 20 20 [3,] 60 60 40 [4,] 15 20 20 [5,]5 0 10 range_mat [,1] [,2] [,3] [1,] 6.25 8.5 4.25 [2,] 6.75 9.0 4.75 [3,] 7.25 9.5 5.25 [4,] 8.75 10.5 5.75 [5,] 9.25 11.0 6.25 [6,] 9.75 11.5 6.75 My problem is to generate random numbers in line with rate_number and using the range_mat. E.g. I need to generate (5, 15, 60, 15, 5 i.e. the first column of rate_number) uniform random numbers (using 1st column of range_mat) s.t the first 5 numbers will be in the range (6.25 - 6.75), next 15 numbers should be in the range (6.75 to 7.25), next 60 numbers should be in the range (7.25 to 8.75), next 15 numbers in the range (8.75 to 9.25) and last 5 numbers in the range (9.25 to 9.75). Similarily, I need to generate (0, 20, 60, 20, 0 i.e. 2nd column of rate_number) uniform random numbers in the range (using 2nd column of range_mat) i.e. (8.5 to 9), (9 to 9.5), (9.5 to 10.5), (10.5 to 11), (11 to 11.5) respectively. I could have generated these random numbers Individually using runif, but main problem is range_number could be anything i.e. there may be 50 rates but for each rate, no of rate combination will always be 5 i.e. rate_number will always have 5 rows only and also range_mat will always have 6 rows only. I tried writing loops and even tapply etc. but just can't get through. I sincerely request you to kindly guide me. Regards Sarah [[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] how to free memory? (gc() doesn't work for me)
Hi, all I have a huge object that use almost all of available memory. R rm(a_huge_object) R gc() doesn't free memory and ?gc doesn't show anything. Are there any suggestion? Thanks in advance, Regards, Hyunchul [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R program google search
Hi: Do you mean something like RSiteSearch('loess predict') [opens up a web page with 53 matches to the request] or package(sos) findFn('multiple imputation') ? If not, could you be more specific about what you're after? HTH, Dennis On Fri, Sep 3, 2010 at 2:23 PM, Waverley @ Palo Alto waverley.paloa...@gmail.com wrote: Hi, Can someone help as how to use R to program google search in the R code? I know that other languages can allow or have the google search API If someone can give me some links or sample code I would greatly appreciate. Thanks. -- Waverley @ Palo Alto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R program google search
On Sep 4, 2010, at 1:20 AM, Dennis Murphy wrote: Hi: Do you mean something like RSiteSearch('loess predict') [opens up a web page with 53 matches to the request] or package(sos) findFn('multiple imputation') ? If not, could you be more specific about what you're after? One further option: type ... RSiteSearch at the command prompt and you will be given a worked example of working code that could be modified to open up a Google search. -- David HTH, Dennis On Fri, Sep 3, 2010 at 2:23 PM, Waverley @ Palo Alto waverley.paloa...@gmail.com wrote: Hi, Can someone help as how to use R to program google search in the R code? I know that other languages can allow or have the google search API If someone can give me some links or sample code I would greatly appreciate. Thanks. -- Waverley @ Palo Alto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R program google search
My question is how to use R to program google search. I found this information: The SOAP Search API was created for developers and researchers interested in using Google Search as a resource in their applications. Unfortunately google no longer supports that. They are supporting the AJAX Search API. What about R? Thanks. On Fri, Sep 3, 2010 at 2:23 PM, Waverley @ Palo Alto waverley.paloa...@gmail.com wrote: Hi, Can someone help as how to use R to program google search in the R code? I know that other languages can allow or have the google search API If someone can give me some links or sample code I would greatly appreciate. Thanks. -- Waverley @ Palo Alto -- Waverley @ Palo Alto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.