Re: [R] package lattice can't be loeaded
The error message is: Error in library(lattice) : there is no package called 'lattice' I have installed it twice because it did not work the first time, so I was not sure if it worked. And YES, the folder lattice is in the folder library. What's the error message? Why do you have to install twice? Did you check if the package is actually in the R library folder? On Thu, Jul 30, 2009 at 10:02 AM, Stein, Luba (AIM SE) luba.st...@allianz.commailto:luba.st...@allianz.com wrote: I try to load the package lattice by library(lattice). Although I have installed it through CRAN by internet as well as from a local directory using the zip-file, it can't be loaded into the editor. Can anyone give advice, please. I am using R 2.9.1 on Widows XP. Thanks a lot, Luba [[alternative HTML version deleted]] __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[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] (no subject)
The error message is: Error in library(lattice) : there is no package called 'lattice' I have installed it twice because it did not work the first time, so I was not sure if the installation worked out. The strange thing is that the folder lattice is in the folder library. Luba library(lattice) It loads just fine. On Thu, Jul 30, 2009 at 11:08 AM, Stein, Luba (AIM SE)luba.st...@allianz.com wrote: I try to load the package lattice by library(lattice). Although I have installed it through CRAN by internet as well as from a local directory using the zip-file, it can't be loaded into the editor. Can anyone give advice, please. I am using R 2.9.1 on Widows XP. Thanks a lot, Luba [[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.
[R] constrained input for optimization algorithm
It seems that optimization algorithm, optim, tries to find optimized parameters within defined lower and upper bounds. In my problem, all the parameters are integers but mutual exclusive. My question is that if there is any means that I can let optim only tries mutual exclusive integers. To be specific, I am giving an example here. I tried to find a set parameters with five elements with the lowest value for the cost function. The parameter set that optim returned is 5, 5, 49, 51, 51. However, I only wanted to search unique parameter values, such as 5, 6, 49, 50, 51. Many thanks, Zhi Xie Johns Hopkins School of Medicine Baltimore, MD __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.9.1: Error building target 'front'
loris.benn...@fu-berlin.de (Loris Bennett) writes: Hi, I am getting the following error # (R-2.9.1/src/library/methods): gmake front /bin/sh: 0403-057 Syntax error at line 1 : `;' is not expected. gmake: *** [front] Error 2 However, I am not sure what script sh is trying to execute at this point. I am building on AIX 5.3. Here is some more information on this problem. Running gmake -n front produces for f in ; do \ if test -f ./${f}; then \ /usr/local/bin/install -c -m 644 ./${f} \ ../../../library/methods; \ fi; \ done This seems to come from the following line in share/make/basepkg.mk @for f in $(FRONTFILES); do \ Grepping for FRONTFILES yields library/stats/Makefile.in:FRONTFILES = COPYRIGHTS.modreg SOURCES.ts library/stats/Makefile.win:FRONTFILES = COPYRIGHTS.modreg SOURCES.ts library/stats/Makefile:FRONTFILES = COPYRIGHTS.modreg SOURCES.ts Is something similar missing from the makefiles in src/library/methods? Loris -- Dr. Loris Bennett Computer Centre Freie Universität Berlin Berlin, Germany __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] what is the meaning of this error message?
Hi, I need your help :: what i the meaning of this error messageMissing value where true / false needed?? 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.
Re: [R] Problem with RGtk2 Rattle
This error comes from using an old version of the GTK+ libraries. Download the latest version for Windows from http://gladewin32.sourceforge.net/ -Felix 2009/7/31 Graham Williams graham.willi...@togaware.com: Hi Wayne - but what version of the other tools have you installed? Regards, Graham 2009/7/30 Wayne Murray wayne.mur...@medicareaustralia.gov.au HI Graham Thanks for responding so promptly - unfortunately downloading and running this new version of Rattle did not alter the outcome - I am however running on Windows XP Regards Wayne Wayne Murray wrote: HI Apologies for previously trying to post this question onto the Dev forum. I have recently update my versions of R and related packages. When I try to use rattle the following message appears Error in .RGtkCall(R_setGObjectProps, obj, value, PACKAGE = RGtk2) : Invalid property tooltip-text! I have downloaded and installed the latest available version of RGtk2, so I am at a loss to explain this error, or more importantly what I need to do to overcome it Thanks for any suggestions Regards Wayne - Dr D. W. Murray Canberra, Australia -- View this message in context: http://www.nabble.com/Problem-with-RGtk2---Rattle-tp24734447p24736985.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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Parameters of Logistic Distribution and (3 Parameter) Log Logistic Distribution
Dear R Helpers Please guide me how one can estimate the parameters of Logistic Distribution and 3 Parameter Log-logistic distribution for a given data. data - c(2987.43,2990.12,3023.52,2964.79,3019.60,3051.07,3080.16,2944.15,3035.19,3023.46,2985.05,2970.95,3192.36,3084.39,2926.23,2952.15,3064.15,3003.20,2980..35,2980.45,3043.12,3115.53,3006.90,2946.03,3039.97,3064.01,3000.56,3049.57,3042.54,3037.63,2982.03,2889.74,3043.83,2930.95,3020.65,3009.21,3084.16,2954.05,2991.04,3083.10,3007.26,2949.58,2995.65,3078.36,3031.64,3001.28,3103.32,3015.04,2994.45,2963.71,2932.90,3021.31,3074.72,2980.15,3002.29,3088.18,2991.39,2942.90,3057.91,3023.25,3192.67,2966.49,3049.31,2915.38,3045.27,2852.72,2999.25,2978.52,3040.07,2945.50,3047.47,2915.95,3012.24,2985.80,2971.04,3035.72,3025.40,3014.76,2979.62,3029.20,2938.38,2966.47,3017.81,3016.43,2989.60,2941.22,3038.30,3033.44,3003.77,2950.02,3053.19,3011.69,2916.34,2918..10,3049.98,3062.46,2948.55,3072.90,3113.52,2987.61) Thanking in advance. With regards Madhavi Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with RGtk2 Rattle
Hi Graham I used the update packages option to get the latest version of all the packages I use in R - so whatever the latest versions is what I have. I am not sure if I can ascertain the versions of the various component packages. Regards, Wayne Graham Williams wrote: Hi Wayne - but what version of the other tools have you installed? Regards, Graham 2009/7/30 Wayne Murray wayne.mur...@medicareaustralia.gov.au HI Graham Thanks for responding so promptly - unfortunately downloading and running this new version of Rattle did not alter the outcome - I am however running on Windows XP Regards Wayne Wayne Murray wrote: HI Apologies for previously trying to post this question onto the Dev forum. I have recently update my versions of R and related packages. When I try to use rattle the following message appears Error in .RGtkCall(R_setGObjectProps, obj, value, PACKAGE = RGtk2) : Invalid property tooltip-text! I have downloaded and installed the latest available version of RGtk2, so I am at a loss to explain this error, or more importantly what I need to do to overcome it Thanks for any suggestions Regards Wayne - Dr D. W. Murray Canberra, Australia -- View this message in context: http://www.nabble.com/Problem-with-RGtk2---Rattle-tp24734447p24736985.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. - Dr D. W. Murray Canberra, Australia -- View this message in context: http://www.nabble.com/Problem-with-RGtk2---Rattle-tp24734447p24752306.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 lattice can't be loeaded
Hi r-help-boun...@r-project.org napsal dne 31.07.2009 08:27:24: The error message is: Error in library(lattice) : there is no package called 'lattice' I have installed it twice because it did not work the first time, so I was not sure if it worked. And YES, the folder lattice is in the folder library. In that case the you were not successful with correct installation. Either the package is corrupted or something went seriously wrong. Do you have problems only with lattice? The other packages like MASS can be loaded without problems? It should not be necessary to install lattice as it come with base installation together with some other recommended packages. I would try to get the new version of R fresh from internet and reinstall it. You can view it as overkill but I never needed install lattice myself. Regards Petr What's the error message? Why do you have to install twice? Did you check if the package is actually in the R library folder? On Thu, Jul 30, 2009 at 10:02 AM, Stein, Luba (AIM SE) luba.st...@allianz.com mailto:luba.st...@allianz.com wrote: I try to load the package lattice by library(lattice). Although I have installed it through CRAN by internet as well as from a local directory using the zip-file, it can't be loaded into the editor. Can anyone give advice, please. I am using R 2.9.1 on Widows XP. Thanks a lot, Luba [[alternative HTML version deleted]] __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[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] what is the meaning of this error message?
Without your script we can't figure out what went wrong. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Inchallah Yarab Verzonden: vrijdag 31 juli 2009 9:30 Aan: r-help@r-project.org Onderwerp: [R] what is the meaning of this error message? Hi, I need your help :: what i the meaning of this error messageMissing value where true / false needed?? 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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 is the meaning of this error message?
Inchallah Yarab wrote: Hi, I need your help :: what i the meaning of this error messageMissing value where true / false needed?? Probably that in your function call there was a missing value where TRUE or FALSE needed? Uwe Ligges 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Trouble with R proxy
Hi there, I am having some trouble getting download.file to work. I have been searching for the answer but my raw coding ability is not at the same level as the solutions I am getting. I have checked my environment and the proxy settings are in line with what I expected: Sys.getenv(http_proxy) http_proxy http://proxy-lon2.macbank; Sys.getenv(USERNAME) USERNAME epieters I then use a quantmod function, getSymols(GOOG). I am very close to getting a result, because I am promted with a input box for a username and password. Unfortunately I get the following error once I have entered both: Proxy authentication failed: please re-enter the credentials or hit Cancel Error in download.file(paste(yahoo.URL, s=, Symbols.name, a=, from.m, : cannot open URL 'http://chart.yahoo.com/table.csv?s=GOOGa=0b=01c=2007d=6e=31f=2009g=dq=qy=0z=GOOGx=.csv' In addition: Warning message: In download.file(paste(yahoo.URL, s=, Symbols.name, a=, from.m, : cannot open: HTTP status was '407 Proxy Authentication Required' Can someone please point me in the right direction? I feel like I am really close in getting this to work. Many thanks, Eduard -- View this message in context: http://www.nabble.com/Trouble-with-R-proxy-tp24752525p24752525.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] lmer() and $ operator is invalid for atomic vectors
Dear Angela, I think you have to omit the last lamba in the lmer code. Is there a reason for putting it there? lmer.lamda - lmer(lamda ~ Age*Item + ( 1 | Subject), data=new4) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Angela Radulescu Verzonden: donderdag 30 juli 2009 23:38 Aan: r-help@r-project.org Onderwerp: [R] lmer() and $ operator is invalid for atomic vectors Hi all, I am a bit mystified by this error message that I get when I try to apply lmer() to a simple dataset with one between factor (age) and one within factor (item): $ operator is invalid for atomic vectors I'll just provide the code, because I don't see where the problem is: library(lme4) options(contrasts=c(contr.helmert,contr.poly)) data = read.csv(C:/Users/Angela/Desktop/Summer_at_CDS/aging_JDM_Martine/datase ts/lamda.data_07.27.09.csv, header=TRUE) attach(data) new-data.frame(lamda, age.o_1, Item.l2_2,Subject) new Subject - factor(Subject) Age - factor(age.o_1,levels=c(0,1),labels=c(young,old)) Item - factor(Item.l2_2,levels=c(1,2),labels=c(lamda1,lamda2)) new2-data.frame(lamda, Subject, Age, Item) new2 new3 - na.omit(new2) new3 new4=as.data.frame(new3) (lmer.lamda - lmer(lamda ~ Age*Item + ( 1 | Subject), lamda, data=new4)) Error in family$family : $ operator is invalid for atomic vectors Here are the first 25 values of the dataframe lmer() should operate on: lamda Subject Age Item 1 1.600 1 old lamda1 2 1.0434783 2 old lamda1 3 0.960 3 old lamda1 4 3.4285714 4 old lamda1 5 1.1428571 5 old lamda1 6 2.1818182 6 old lamda1 7 0.960 7 old lamda1 8 1.8461538 8 old lamda1 9 2.1818182 9 old lamda1 101.8461538 10 old lamda1 111.8461538 11 old lamda1 121.8461538 12 old lamda1 132.667 13 old lamda1 142.667 14 old lamda1 151.8461538 15 old lamda1 161.0434783 16 old lamda1 171.8461538 17 old lamda1 182.667 18 old lamda1 192.667 19 old lamda1 208.000 20 old lamda1 211.8461538 21 old lamda1 228.000 22 old lamda1 231.8461538 23 old lamda1 242.667 24 old lamda1 252.1818182 25 old lamda1 Any help would be much appreciated this one. I am in the dark and tried pretty much everything... Many thanks, Angela -- View this message in context: http://www.nabble.com/lmer%28%29-and-%22%24-operator-is-invalid-for-atom ic-vectors%22-tp24747770p24747770.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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] CRAN + geography = Cranography
Nice, Maybe this could be combined with the map of the R empire as shown at useR! Romain On 07/30/2009 06:39 PM, Barry Rowlingson wrote: In response to an earlier discussion about finding the fastest/best/nearest CRAN site, I geocoded (using my geonames package) the locations of the CRAN sites returned by getCRANmirrors. I've mapped them here: http://www.maths.lancs.ac.uk/~rowlings/R/Cranography/ The geocoding may have got it wrong, so if CRAN site maintainers want to send me a real lat-long (in WGS 84 aka EPSG:4326) I'll update my map. Maybe eventually lat-long can go in the CRAN csv file distributed with R. Note this is just for fun. No warranties. Maybe I should use a little 'R' as a marker. Maybe I should get a life. Barry -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/tlNb : RGG#155, 156 and 157 |- http://tr.im/rw0p : useR! slides `- http://tr.im/rw0b : RGG#154: demo of atomic functions __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] concatenating multiple columns from files
You can do something like mat - do.call(cbind, lapply(list.files(.data),read.table)) ## explanation: lapply(list.files(.data),read.table) will store all tables in a list do.call(cbind,...) will bind all the columns stored in the list created above. - Original Message From: ferreirafm ferreir...@lim12.fm.usp.br To: r-help@r-project.org Sent: Thursday, July 30, 2009 5:29:46 PM Subject: [R] concatenating multiple columns from files R-users, I want to concatenate columns from different files in a single object. I'm doing bad. My peace of code is as follow: rawdata - list.files(./data) for (i in rawdata) { mat[ ] - read.table(paste(i ,sep=)) } At the end of the loop I have just one column. What I'm doing wrong? Thanks, Fred -- View this message in context: http://www.nabble.com/concatenating-multiple-columns-from-files-tp24748542p24748542.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Install R on Cygwin
Hello, I should use R on cygwin. I have ever install cygwin and now I try to install R. I have read the R manual and particularly the part : Installation R under Unix but I improved some difficulties for succeed in this task. Actually I have create a R repertory where I have unzipped the file R-2.9.1.tar.gz. In this repertory I do ./configure in cygwin but some errors appear and I don't understant them. I would specify that I'm a beginner on cygwin. # $ ./configure checking build system type... i686-pc-cygwin checking host system type... i686-pc-cygwin loading site script './config.site' loading build specific script './config.site' checking for pwd... /usr/bin/pwd checking whether builddir is srcdir... yes checking for working aclocal... missing checking for working autoconf... missing checking for working automake... missing checking for working autoheader... missing checking for gawk... gawk checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking whether ln -s works... yes checking for bison... no checking for byacc... no checking for ar... ar checking for a BSD-compatible install... /usr/bin/install -c checking for sed... /usr/bin/sed checking for less... /usr/bin/less checking for perl... /usr/bin/perl checking whether perl version is at least 5.8.0... yes checking for dvips... /usr/bin/dvips checking for tex... /usr/bin/tex checking for latex... /usr/bin/latex checking for makeindex... /usr/bin/makeindex checking for pdftex... /usr/bin/pdftex checking for pdflatex... /usr/bin/pdflatex checking for makeinfo... /usr/bin/makeinfo checking whether makeinfo version is at least 4.7... yes checking for texi2dvi... /usr/bin/texi2dvi checking for unzip... /cygdrive/c/Program Files (x86)/Insightful/splus80/cmd/unz ip checking for zip... /cygdrive/c/Program Files (x86)/Insightful/splus80/cmd/zip checking for gzip... /usr/bin/gzip checking for firefox... no checking for mozilla... no checking for galeon... no checking for opera... no checking for xdg-open... no checking for kfmclient... no checking for gnome-moz-remote... no checking for open... no configure: WARNING: I could not determine a browser checking for acroread... no checking for acroread4... no checking for evince... no checking for xpdf... no checking for gv... no checking for gnome-gv... no checking for ggv... no checking for kghostview... no checking for open... no checking for gpdf... no configure: WARNING: I could not determine a PDF viewer checking for pkg-config... /usr/bin/pkg-config checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking whether gcc needs -traditional... no checking how to run the C preprocessor... gcc -E checking for g77... g77 ### Next I wrote : make on cygwin # $ make make: *** No targets specified and no makefile found. Stop. # Thanks for helping Créez votre adresse électronique prenom@laposte.net 1 Go d'espace de stockage, anti-spam et anti-virus intégrés. [[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] Install R on Cygwin (correction)
Hello, I should use R on cygwin. I have ever install cygwin and now I try to install R. I have read the R manual and particularly the part : Installation R under Unix but I improved some difficulties for succeed in this task. Actually I have create a R repertory where I have unzipped the file R-2.9.1.tar.gz. In this repertory I do ./configure in cygwin but some errors appear and I don't understant them. I would specify that I'm a beginner on cygwin. # $ ./configure checking build system type... i686-pc-cygwin checking host system type... i686-pc-cygwin loading site script './config.site' loading build specific script './config.site' checking for pwd... /usr/bin/pwd checking whether builddir is srcdir... yes checking for working aclocal... missing checking for working autoconf... missing checking for working automake... missing checking for working autoheader... missing checking for gawk... gawk checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking whether ln -s works... yes checking for bison... no checking for byacc... no checking for ar... ar checking for a BSD-compatible install... /usr/bin/install -c checking for sed... /usr/bin/sed checking for less... /usr/bin/less checking for perl... /usr/bin/perl checking whether perl version is at least 5.8.0... yes checking for dvips... /usr/bin/dvips checking for tex... /usr/bin/tex checking for latex... /usr/bin/latex checking for makeindex... /usr/bin/makeindex checking for pdftex... /usr/bin/pdftex checking for pdflatex... /usr/bin/pdflatex checking for makeinfo... /usr/bin/makeinfo checking whether makeinfo version is at least 4.7... yes checking for texi2dvi... /usr/bin/texi2dvi checking for unzip... /cygdrive/c/Program Files (x86)/Insightful/splus80/cmd/unz ip checking for zip... /cygdrive/c/Program Files (x86)/Insightful/splus80/cmd/zip checking for gzip... /usr/bin/gzip checking for firefox... no checking for mozilla... no checking for galeon... no checking for opera... no checking for xdg-open... no checking for kfmclient... no checking for gnome-moz-remote... no checking for open... no configure: WARNING: I could not determine a browser checking for acroread... no checking for acroread4... no checking for evince... no checking for xpdf... no checking for gv... no checking for gnome-gv... no checking for ggv... no checking for kghostview... no checking for open... no checking for gpdf... no configure: WARNING: I could not determine a PDF viewer checking for pkg-config... /usr/bin/pkg-config checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking whether gcc needs -traditional... no checking how to run the C preprocessor... gcc -E checking for g77... g77 checking whether we are using the GNU Fortran 77 compiler... yes checking whether g77 accepts -g... yes checking for g++... no checking for c++... no checking for gpp... no checking for aCC... no checking for CC... CC checking whether we are using the GNU C++ compiler... no checking whether CC accepts -g... no checking how to run the C++ preprocessor... /lib/cpp configure: error: C++ preprocessor /lib/cpp fails sanity check See `config.log' for more details. ### Next I wrote : make on cygwin # $ make make: *** No targets specified and no makefile found. Stop. # Thanks for helping Créez votre adresse électronique prenom@laposte.net 1 Go d'espace de stockage, anti-spam et anti-virus intégrés. Créez votre adresse électronique prenom@laposte.net 1 Go d'espace de stockage, anti-spam et anti-virus intégrés. [[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] Forecasting Inflation
On Mon, Jul 27, 2009 at 4:51 PM, Dilip Bayas agrikonnect.dilipba...@gmail.com wrote: Dear All, I wanted to forecast Inflation for Indian Economy. please send what techniques to be used after the variable selection. WPI, CPI, Money supply, IIP, Interest rate and so on..How i can use R for the same [[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] CRAN + geography = Cranography
Barry Rowlingson b.rowling...@lancaster.ac.uk writes: http://www.maths.lancs.ac.uk/~rowlings/R/Cranography/ Absolutely beautiful! Note this is just for fun. No warranties. Maybe I should use a little 'R' as a marker. That would be cool. Maybe I should get a life. :-) -- Bjørn-Helge Mevik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] colored 3D pillar plots
hi, I'd like to do graphs like shown on the right panel on the following link: http://www.clinchem.org/cgi/content/full/53/8/1544/F1 (if link doesn't work see attached file) Any help and ideas highly appreciated, thanks in advance. Thomas von Känel Human Genetics Uni Berne __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 lattice can't be loeaded
You are right, the installation went wrong although I do not know why because this never occured to me before. So I unzipped lattice manually and afterwards everything worked fine. Thank you for your help, Luba -Urspr?ngliche Nachricht- Von: Petr PIKAL [mailto:petr.pi...@precheza.cz] Gesendet: Freitag, 31. Juli 2009 09:49 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] package lattice can't be loeaded Hi r-help-boun...@r-project.org napsal dne 31.07.2009 08:27:24: The error message is: Error in library(lattice) : there is no package called 'lattice' I have installed it twice because it did not work the first time, so I was not sure if it worked. And YES, the folder lattice is in the folder library. In that case the you were not successful with correct installation. Either the package is corrupted or something went seriously wrong. Do you have problems only with lattice? The other packages like MASS can be loaded without problems? It should not be necessary to install lattice as it come with base installation together with some other recommended packages. I would try to get the new version of R fresh from internet and reinstall it. You can view it as overkill but I never needed install lattice myself. Regards Petr What's the error message? Why do you have to install twice? Did you check if the package is actually in the R library folder? On Thu, Jul 30, 2009 at 10:02 AM, Stein, Luba (AIM SE) luba.st...@allianz.com mailto:luba.st...@allianz.com wrote: I try to load the package lattice by library(lattice). Although I have installed it through CRAN by internet as well as from a local directory using the zip-file, it can't be loaded into the editor. Can anyone give advice, please. I am using R 2.9.1 on Widows XP. Thanks a lot, Luba [[alternative HTML version deleted]] __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[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] gbm package: relationship between interaction.depth and number of features?
On Thu, 30-Jul-2009 at 12:36AM +0400, Boris Yangel wrote: | Hello. I'm currently stuck with the same what does interaction.depth really | mean stuff. Did you find out what the right answer is? | I stand to be corrected, but I think it is one fewer than the number of leaves in the final tree. Stumps will have and interaction.depth of 1 (and have two leaves). Adding 1 to it will give three leaves. HTH -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Logistic regression and R
Hi there, I take advantage of this chat to ask other question related to logistic regression. This is my first time as well. I have data that I want to model but Im not sure if glm() is the correct function to use. My problem is as follow, I used Oxford Instability Score of the shoulder (OIS, independent variable) as indicative of the outcome ( 12-20 best, to 41-60 worst outcome, 5 possible results). Looking for many independent variables like categorical and numerical I want to see their prognostic impact on the outcome. There is a function which I can use to model my problem? I heard about multinomial logistic regression but I did not able to find nothing related to it. Any help would be much appreciated. Marlene. 2009/7/31 G. Jay Kerns gke...@ysu.edu Dear Carlos, On Thu, Jul 30, 2009 at 6:11 PM, Carlos Lópeznato...@fisica.unam.mx wrote: Hello everybody :-) I have some data that I want to model with a logistic regression, most of the independent variables are numeric and the only dependent is categorical, I was thinking that I could apply a logistic regression using glm but I wanted to deepen my knowledge of this so I tried to do some reading and found the iris dataset, now I would like to ask two things, first if you know of any bibliography to read more about the logistic regression and R so I could understand and interpret better the output, See the following https://home.comcast.net/~lthompson221/https://home.comcast.net/%7Elthompson221/ and the following specific link on that page: https://home.comcast.net/~lthompson221/Splusdiscrete2.pdfhttps://home.comcast.net/%7Elthompson221/Splusdiscrete2.pdf which is a manual to accompany Agresti's _Categorical Data Analysis_. In particular, you may want to check out Chapter 5 (and also some of 4). and second, what could I do when I have some independent variables that are not only numerical but categorical too, i.e. mixed (categorical and numerical), can I still use a logistic regression? Easy peasy, lemon squeezy. See page 78. Hope this helps, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ http://www.cc.ysu.edu/%7Egjkerns/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] any advice on noparametric statistics
Dear R-lister and Prof. Harrell, To Prof. Harrell: I feel very sorry to bothering you. The ecological data usually do not follow strictly-defined normal distribution. So, there are many more works before any parametric testing or any regression modeling-fitting . Tens of days ago, when I ask for proper methodology of outliers treatment in the data processing, Prof. Harrell ever adviced me to turn to nonparametric test. Since then, I put my efforts on setting up of my nonparametric test techniques. But, still now I can not gain any progresses on that. I was trained as evolutionary biologist (with background of genetics and ecology), without solid statistical trainnings, especially on nonparametric test techniques. And, I was educated in China where it is very hard to reach the statistician's supports. In the last five year, I have builded up a perfect (in my view) dataset which integrated genotype assignment, more 50 ecological and morphological traits, georeference of each sample (more than 1000 in total), and various of environmental parameter (gained by GIS searching in geoinformatic databases). Although I have much experiences on parametric statistics, I have not ultilized any noparametric statistics on my research except on some black-box softwares. I am thirst for any advice on non-parametric statistics on ecological data analysis. Is there any example-oriented books on that? How it can be implemented in R? Best regards, Yours Mao J-F [[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] what is the meaning of this error message?
Inchallah Yarab wrote: Hi, I need your help :: what i the meaning of this error messageMissing value where true / false needed?? Hi Inchallah, This usually happens when you have a conditional (if or while) statement like this: if(var81 == 0) { ... } while(var73 0) { ... } ifelse(var13, ...) If one of the variables resolves to NA, you will get that error message. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Automatic datasets creation from multiple data sheets in a single excel file
Please let us know how to create automatic datasets from multiple data sheets in a single excel file... For example if there are 10 sheets in a single excel file, automatically 10 datasets need to be created at a time when i read an excel file as a whole at once. Please attach the necessary code if any... -- View this message in context: http://www.nabble.com/Automatic-datasets-creation-from-multiple-data-sheets-in-a-single-excel-file-tp24754120p24754120.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] Logistic regression and R
Dear Marlene, Have a look at the polr() function in the MASS package. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens marlene marchena Verzonden: vrijdag 31 juli 2009 12:04 Aan: r-help Onderwerp: Re: [R] Logistic regression and R Hi there, I take advantage of this chat to ask other question related to logistic regression. This is my first time as well. I have data that I want to model but I'm not sure if glm() is the correct function to use. My problem is as follow, I used Oxford Instability Score of the shoulder (OIS, independent variable) as indicative of the outcome ( 12-20 best, to 41-60 worst outcome, 5 possible results). Looking for many independent variables like categorical and numerical I want to see their prognostic impact on the outcome. There is a function which I can use to model my problem? I heard about multinomial logistic regression but I did not able to find nothing related to it. Any help would be much appreciated. Marlene. 2009/7/31 G. Jay Kerns gke...@ysu.edu Dear Carlos, On Thu, Jul 30, 2009 at 6:11 PM, Carlos Lópeznato...@fisica.unam.mx wrote: Hello everybody :-) I have some data that I want to model with a logistic regression, most of the independent variables are numeric and the only dependent is categorical, I was thinking that I could apply a logistic regression using glm but I wanted to deepen my knowledge of this so I tried to do some reading and found the iris dataset, now I would like to ask two things, first if you know of any bibliography to read more about the logistic regression and R so I could understand and interpret better the output, See the following https://home.comcast.net/~lthompson221/https://home.comcast.net/%7Elt hompson221/ and the following specific link on that page: https://home.comcast.net/~lthompson221/Splusdiscrete2.pdfhttps://home .comcast.net/%7Elthompson221/Splusdiscrete2.pdf which is a manual to accompany Agresti's _Categorical Data Analysis_. In particular, you may want to check out Chapter 5 (and also some of 4). and second, what could I do when I have some independent variables that are not only numerical but categorical too, i.e. mixed (categorical and numerical), can I still use a logistic regression? Easy peasy, lemon squeezy. See page 78. Hope this helps, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ http://www.cc.ysu.edu/%7Egjkerns/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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]] Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 User Group in Canberra
Please add AUSTRALIA Canberra: Canberra R Users Group (CANRUG) http://canrug.togaware.com/ Cheers john. John Maindonald email: john.maindon...@anu.edu.au phone : +61 2 (6125)3473fax : +61 2(6125)5549 Centre for Mathematics Its Applications, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200. On 31/07/2009, at 8:00 PM, r-help-requ...@r-project.org wrote: listings [[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 User Group listings
Further to my posting about R UG mailing lists etc., and David Smith's post about the list he is maintaining (I was aware of his blog, but not that he was updating -- good show), I'm in communication with him to try to ensure we get appropriate information out to useRs. Already there has been a posting asking if there is any group in Germany, and asking is the first step to getting a group going. I suspect we need to expand from just a listing to also include Desperately seeking R users... entries. Will see what we can do. JN __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] constrained input for optimization algorithm
As someone very involved with optim and its evolution I can say it is not at all suited to this sort of combinatoric optimization. I don't know if there are packages in R to help out -- it would be nice. If (this may be a big IF) your set of possible combinations is not too large, combn() generates the C(n,r) combinations and, assuming the function is not too expensive to compute, one can use enumeration and be certain of having the optimum. choose(60,5) shows about 5.5 million sets. A bit tedious, but likely doable over lunchtime. But choose(600,5) is 600 billion, and probably too heavy. John Nash From: Zhi Xie xie...@gmail.com It seems that optimization algorithm, optim, tries to find optimized parameters within defined lower and upper bounds. In my problem, all the parameters are integers. My question is that if there is any means that I can let optim only tries mutual exclusive integers. To be specific, I am giving an example here. I tried to find a set parameters with five elements with the lowest value for the cost function. The parameter set that optim returned is 5, 5, 49, 51, 51. However, I only wanted to search unique parameter values, such as 5, 6, 49, 50, 51. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] (no subject)
Type: library() at the prompt to see what libraries are known to your system. You might have a path name messed up or something. Here is part of the output that shows on my system with 'lattice' shown Packages in library 'C:/PROGRA~1/R/R-29~1.0/library': base The R Base Package boot Bootstrap R (S-Plus) Functions (Canty) class Functions for Classification clusterCluster Analysis Extended Rousseeuw et al. codetools Code Analysis Tools for R datasets The R Datasets Package foreignRead Data Stored by Minitab, S, SAS, SPSS, Stata, Systat, dBase, ... graphics The R Graphics Package grDevices The R Graphics Devices and Support for Colours and Fonts grid The Grid Graphics Package KernSmooth Functions for kernel smoothing for Wand Jones (1995) latticeLattice Graphics MASS Main Package of Venables and Ripley's MASS Matrix Sparse and Dense Matrix Classes and Met On Fri, Jul 31, 2009 at 2:30 AM, Stein, Luba (AIM SE)luba.st...@allianz.com wrote: The error message is: Error in library(lattice) : there is no package called 'lattice' I have installed it twice because it did not work the first time, so I was not sure if the installation worked out. The strange thing is that the folder lattice is in the folder library. Luba library(lattice) It loads just fine. On Thu, Jul 30, 2009 at 11:08 AM, Stein, Luba (AIM SE)luba.st...@allianz.com wrote: I try to load the package lattice by library(lattice). Although I have installed it through CRAN by internet as well as from a local directory using the zip-file, it can't be loaded into the editor. Can anyone give advice, please. I am using R 2.9.1 on Widows XP. Thanks a lot, Luba [[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? -- 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] how use the subset?
'scan' creates a 'list'; subset is typically used on dataframes. I can get a similar message below: x - list(a=1:10, b=1:10) subset(x, a5) Error in subset.default(x, a 5) : object 'a' not found # now convert the list to a dataframe x.df - as.data.frame(x) subset(x.df, a 5) a b 1 1 1 2 2 2 3 3 3 4 4 4 On Fri, Jul 31, 2009 at 12:02 AM, Jie TANGtotang...@gmail.com wrote: hi ,everyone I want subtract some dataset by subset. From the help running help(subset), ths information is *subset(airquality, Day == 1, select = -Temp)* while I running my script written as *g1data-subset(errdata, fac12) * ,it is wrong with the error information *subset.default(newerrdata, fac12),can not find fac* and g1 in read from the file as shown below *errdata-scan(err.dat,what = list(mon=0,day=0,err=0,fac=0))* While I changed to *g1data-subset(errdata, errdata$fac12)*, there is no error message any more but it seems that *g1data* dooes be selected. who can help me to subset the dataset? thank you .:) -- TANG Jie Email: totang...@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[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.
[R] what meaning missing value True /False needed
This is my code i don't understand the error message: library(rgenoud) rm(list=ls()) set.seed(666) # # As a first step, it is assumed that all input parameters are independent of ageing : # InputDim -20 # Max number of ageings in the inputs CPIRate - rep(0.02 , InputDim ) # CPI inflation rate LossInflaRate - rep(0.02 , InputDim) # inflation rate of losses RiskFreeRate - rep(0.04, InputDim ) # vector of risk free rate RiskRate - rep(0.06, InputDim ) # vector of risk free rate lapse param begin : LapseType - rep(linear , InputDim ) # type of the function used to calculate lapse rate= power, logistic, linear CentralLapseRate - rep(0.13 , InputDim ) # lapse rate for price factor = 1 ElasticityLeft - rep( 10, InputDim ) # left elasticity for price factor = 1 ElasticityRight - rep(10, InputDim ) # right elasticity for price factor = 1 WindowLeft - rep( 1 , InputDim ) # friction window price factor left bound WindowRight - rep( 1, InputDim ) # friction window price factor right bound MinLapseRate - rep( 0 , InputDim ) # min lapse rate MaxLapseRate - rep( 1 , InputDim ) # min lapse rate Alpha - 0.5 #acquisition operator ### lapse param end Price - rep(1 , InputDim ) # Axa price for central market position and price factor = 1 IndivMeanLossAmount - rep(0.97 , InputDim ) # mean individual loss amount Commission - rep(0 , InputDim ) # commision rate IndividualExp - rep(0 , InputDim ) # expense amount per risk ### # Market Expert Model parameter begin : ### LRUpBound - 1.01349495023810 # Upper bound of the loss ratio LRLowBound - 0.743806254238095 # Lower bound of the loss ratio TransitCoefMean - 1.03001118178481 # Mean of the coefficient of transition TransitCoefStdDev - 0.0187801387384363 # Standard deviation of the coefficient of transition ### # Optimization algorithm Monte-Carlo parameters : ### LTMeanComputYearNb - 1000 # Number of year used to simulate LR NbOfSimScenar - 1000 # Number Monte-Carlo scenarios GenAlgoIterNb - 100 # number of iteration for genetic algorithm ### # Problem size parameters : ### FirstYear -2009 # first year of renewal LastYear - 2018 # last year of projected renewal ## # Function giving the minimum x (price factor = 1+x ) : ## Xmin - function(LapseType, ElasticityLeft, WindowLeft, MinLapseRate ,CentralLapseRate) { InputDim - length(LapseType) x=numeric(InputDim) for (i in 1:InputDim) { if (LapseType[i]==power ) x[i] - WindowLeft [i]*(MinLapseRate[i] /CentralLapseRate[i])^(1/ElasticityLeft[i])-1 else if (LapseType[i]==linear) x [i]- (WindowLeft[i]/ElasticityLeft[i])*(ElasticityLeft[i]-1+MinLapseRate[i] /CentralLapseRate[i])-1 } x } ## # Function giving the maximum x (price factor = 1+x ) : ## Xmax - function(LapseType, ElasticityLeft, WindowLeft, MaxLapseRate ,CentralLapseRate) { InputDim - length(LapseType) x=numeric(InputDim) for (i in 1:InputDim) { if (LapseType[i]==power ) x[i] - WindowLeft[i] *(MaxLapseRate[i]/CentralLapseRate[i])^(1/ElasticityLeft[i])-1 else if (LapseType[i]==linear) x[i] - (WindowLeft[i]/ElasticityLeft[i])*(ElasticityLeft[i]-1+MaxLapseRate[i]/CentralLapseRate[i])-1 } x } ## # Function simulating a scenario of projected market loss ratio : ## LRScenar - function(PriorLR,Phase,LRUpBound ,LRLowBound,TransitCoefMean,TransitCoefStdDev,LTMeanComputYearNb) { initial - PriorLR LRScenar - NULL phase2 - Phase SigmaLog - (log(1+(TransitCoefStdDev /TransitCoefMean)^2))^0.5 MuLog - log(TransitCoefMean)-SigmaLog^2/2 for (i in 1:LTMeanComputYearNb) { kk - rlnorm(1, meanlog = MuLog, sdlog = SigmaLog) if (phase2!=1) kk - (1/kk) x_1 - initial*kk initial - x_1 if (((x_1 LRUpBound )(phase2==1))|((x_1LRLowBound)(phase2==-1))) phase2 - (-phase2) LRScenar - c(LRScenar,x_1) } LRScenar } # Function giving the lapse rate : LapseRate - function(x, LapseType,CentralLapseRate, ElasticityLeft, ElasticityRight,WindowLeft, WindowRight, MinLapseRate,MaxLapseRate ) { PriceFactor - 1+x if (LapseType==power) { if(PriceFactorWindowLeft) r - CentralLapseRate*(PriceFactor/WindowLeft)^ElasticityLeft else if((PriceFactor=WindowRight)(PriceFactor=WindowLeft )) r - CentralLapseRate else r
[R] have the value of variable in a function
hi , i need to know the value of variable used in a function i don't know if it is easy to do??? 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.
Re: [R] Retrieving original data frame after repetition
Hi Marc (et al) I've spoken too soon... Please, have a look at this chunk of real world data. The data frame a below contains the first ten records (and first two columns) of a survey dataset. It reads as follows: 1662 people have an income of 279, etc. If you see lines 2 and 3, there are 1956 people earning 218 but there are also 489 people earning the same amount. The difference between these two groups of people lies in a third column, not shown. (We could think of men and women, respectively, for example). a income grossing 1 279 1662 2 218 1956 3 218 489 4 378 278 5 420 278 6 200 289 7 149 191 8 256 1360 9 269 1348 10 1259 900 Now I create a vector of all people, one by one, with their respective incomes, by repeating income times grossing: aa - rep(a$income, a$grossing) length(aa) [1] 8751 If I apply Marc's suggestion, z - do.call(data.frame, rle(aa))[, c(2, 1)] colnames(z) - c(x, y) I obtain z xy 1 279 1662 2 218 2445 3 378 278 4 420 278 5 200 289 6 149 191 7 256 1360 8 269 1348 9 1259 900 That is, lines 2 and 3 in the original data frame have been merged. How can I retrieve the original data frame a? Do I need to use that 'missing' third column? And if so, how? I've read ?rle but it seems it only applies to vectors. Any help, once again, greatly appreciated... Regards, Jose -Original Message- From: Marc Schwartz [mailto:marc_schwa...@me.com] Sent: 30 July 2009 20:13 To: Jose Iparraguirre D'Elia Cc: r-help@r-project.org Subject: Re: [R] Retrieving original data frame after repetition On Jul 30, 2009, at 11:15 AM, Jose Iparraguirre D'Elia wrote: Dear R users, Consider the first two columns of a data frame like this: z[,1:2] x y 1 1 1 2 2 2 3 3 3 4 1 4 Imagine that y represents the times that the value x happens in a population. But z is not exactly a frequency table, because in z we have x=1 twice. So, the x=1 in the first line and the x=1 in the fourth are not the same, differing according to a third variable in the data frame. Now, I use the function rep() in order to obtain a vector of values of x in the population: x.pop - rep(x,y) x.pop [1] 1 2 2 3 3 3 1 1 1 1 How can I go from x.pop back to z? If I use table(x.pop), I obtain a frequency table like the one below, but not z. table(x.pop) x.pop 1 2 3 5 2 3 (I know I haven't deleted z, obviously, but I need to write a piece of code to do something very similar). Just in case anyone is wondering by now whether this is an assignment for college, etc.,-it is not. The real world problem I'm working on at the moment has to do with income distribution in Northern Ireland. I want to see how many people would leave poverty if the income of those currently below 60% median income increases by, say, £20 a week. I am working with the Family Resources Survey sample for Northern Ireland (n=2,263), which I have to gross up before increasing the incomes (grossed up n=1,712,886). Once I increased the income figures for those individuals in poverty, I need to 'un-gross' the data to get back to n=2,263 -and table() simply does not do the trick, because of exactly the same situation in the example above. So, please, how can I retrieve z? Many thanks, Jose Presuming that your larger case is similar in structure to 'x.pop', which is to say that each unique value is in sequential runs, you can use: z - do.call(data.frame, rle(x.pop))[, c(2, 1)] colnames(z) - c(x, y) z x y 1 1 1 2 2 2 3 3 3 4 1 4 See ?rle for more information on summarizing runs of values. The core of the first step above yields: rle(x.pop) Run Length Encoding lengths: int [1:4] 1 2 3 4 values : num [1:4] 1 2 3 1 which is a list of two elements, that we coerce to a data frame using do.call(), reversing the two columns to match your original order. 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] Retrieving original data frame after repetition
On Jul 31, 2009, at 5:52 AM, Jose Iparraguirre D'Elia wrote: Hi Marc (et al) I've spoken too soon... Please, have a look at this chunk of real world data. The data frame a below contains the first ten records (and first two columns) of a survey dataset. It reads as follows: 1662 people have an income of 279, etc. If you see lines 2 and 3, there are 1956 people earning 218 but there are also 489 people earning the same amount. The difference between these two groups of people lies in a third column, not shown. (We could think of men and women, respectively, for example). a income grossing 1 279 1662 2 218 1956 3 218 489 4 378 278 5 420 278 6 200 289 7 149 191 8 256 1360 9 269 1348 10 1259 900 Now I create a vector of all people, one by one, with their respective incomes, by repeating income times grossing: aa - rep(a$income, a$grossing) length(aa) [1] 8751 If I apply Marc's suggestion, z - do.call(data.frame, rle(aa))[, c(2, 1)] colnames(z) - c(x, y) I obtain z xy 1 279 1662 2 218 2445 3 378 278 4 420 278 5 200 289 6 149 191 7 256 1360 8 269 1348 9 1259 900 That is, lines 2 and 3 in the original data frame have been merged. How can I retrieve the original data frame a? Do I need to use that 'missing' third column? And if so, how? I've read ?rle but it seems it only applies to vectors. Any help, once again, greatly appreciated... Regards, Jose Presuming that you goal here is to generate the original raw data from the summarized table above, to enable descriptive summaries, I have previously posted a function called expand.dft(), which I post again below: expand.dft - function(x, var.names = NULL, freq = Freq, ...) { # allow: a table object, or a data frame in frequency form if(inherits(x, table)) x - as.data.frame.table(x, responseName = freq) freq.col - which(colnames(x) == freq) if (length(freq.col) == 0) stop(paste(sQuote(freq), not found in column names)) DF - sapply(1:nrow(x), function(i) x[rep(i, each = x[i, freq.col]), ], simplify = FALSE) DF - do.call(rbind, DF)[, -freq.col] for (i in 1:ncol(DF)) { DF[[i]] - type.convert(as.character(DF[[i]]), ...) } rownames(DF) - NULL if (!is.null(var.names)) { if (length(var.names) dim(DF)[2]) { stop(paste(Too few, sQuote(var.names), given.)) } else if (length(var.names) dim(DF)[2]) { stop(paste(Too many, sQuote(var.names), given.)) } else { names(DF) - var.names } } DF } You are going to need a 'third' column of data to differentiate your table when you have two successive income values that are the same, since this breaks the rle() based approach. Since you referenced gender, let's just go ahead and add third column to 'a' above so that at least here, the two 218 values have unique genders associated with them. This approach also provides a more generic process. a3 - cbind(a, gender = rep(c(Male, Female), 5)) a3 income grossing gender 1 279 1662 Male 2 218 1956 Female 3 218 489 Male 4 378 278 Female 5 420 278 Male 6 200 289 Female 7 149 191 Male 8 256 1360 Female 9 269 1348 Male 10 1259 900 Female Now expand a3, indicating that the count column to use is 'grossing': a.expanded - expand.dft(a3, freq = grossing) str(a.expanded) 'data.frame': 8751 obs. of 2 variables: $ income: int 279 279 279 279 279 279 279 279 279 279 ... $ gender: Factor w/ 2 levels Female,Male: 2 2 2 2 2 2 2 2 2 2 ... Notice that a.expanded has 8751 rows, which is the sum total of a $grossing. Now to begin to reverse the process and return the summarized table. See ?as.data.frame.table A - as.data.frame.table(table(a.expanded), responseName = grossing) A income gender grossing 1 149 Female0 2 200 Female 289 3 218 Female 1956 4 256 Female 1360 5 269 Female0 6 279 Female0 7 378 Female 278 8 420 Female0 91259 Female 900 10149 Male 191 11200 Male0 12218 Male 489 13256 Male0 14269 Male 1348 15279 Male 1662 16378 Male0 17420 Male 278 18 1259 Male0 A - subset(A, grossing 0) A income gender grossing 2 200 Female 289 3 218 Female 1956 4 256 Female 1360 7 378 Female 278 91259 Female 900 10149 Male 191 12218 Male 489 14269 Male 1348 15279 Male 1662 17420 Male 278 # Note that income is returned as a factor str(A) 'data.frame': 10 obs. of 3 variables: $ income : Factor w/ 9 levels 149,200,218,..: 1 2 3 3 4 5 6 7 8 9 $ grossing: int 191 289 1956 489 1360 1348 1662 278 278 900 $ gender
[R] Getting file name from pdf device?
Hi IU would like to modify the dev.off function, so that it automatically compresses the created pdf. I am thinking of doing the following in the modified dev.off: 1) Get the filename of the pdf device 2) close the device by calling the original dev.off() 3) compress the pdf file with a system call of pdftk. My question: how can I get the filename of the pdf from the device before it is closed? Thanks Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] have the value of variable in a function
Hello, Perhaps have a look at ?debug and ?browser... ... and at fortune(159) in the 'fortunes' package ;) ! Regards, François -Message d'origine- De : r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] De la part de Inchallah Yarab Envoyé : vendredi 31 juillet 2009 14:24 À : r-help@r-project.org Objet : [R] have the value of variable in a function hi , i need to know the value of variable used in a function i don't know if it is easy to do??? 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] colored 3D pillar plots
Hi Thomas, for a start you may use lattice, see fig 6.15 on http://lmdvr.r-forge.r-project.org/figures/figures.html hth. Thomas von Känel schrieb: hi, I'd like to do graphs like shown on the right panel on the following link: http://www.clinchem.org/cgi/content/full/53/8/1544/F1 (if link doesn't work see attached file) Any help and ideas highly appreciated, thanks in advance. Thomas von Känel Human Genetics Uni Berne __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universitätsklinikum Hamburg-Eppendorf Körperschaft des öffentlichen Rechts Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender) Dr. Alexander Kirstein Ricarda Klein Prof. Dr. Dr. Uwe Koch-Gromus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how can i delete a message in R-help?
Hi i need to delete a message that a send to r -help ?? Can you please tell me how? 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.
Re: [R] what meaning missing value True /False needed
You are far more likely to get helpful volunteers to answer your questions if you distill your problem down to the smallest point. That's a lot of code to wade through. But since I was waiting for something else to run, I took a stab at it. It also would have been helpful if you'd given the *complete* error message, since it tells you where exactly the problem is. In this case, the problem is in LapseRate(), where PriceFactor is compared to WindowLeft (as the actual error message says). I added two lines using cat() to print those two variables each time LapseRate() is called, and here's what I saw: Maximization Problem. PriceFactor: 0.9352139 WindowLeft: 1 PriceFactor: 1.627354 WindowLeft: 1 PriceFactor: NA WindowLeft: 1 Error in if (PriceFactor WindowLeft) r - CentralLapseRate * (1 + ElasticityLeft/WindowLeft * : missing value where TRUE/FALSE needed So indeed, LapseRate() is comparing a NA value to something else, resulting in NA, just as the error message stated. Figuring out why PriceFactor is NA after two iterations is left as an exercise for the reader. Sarah On Fri, Jul 31, 2009 at 8:21 AM, Inchallah Yarabinchallahya...@yahoo.fr wrote: This is my code i don't understand the error message: library(rgenoud) rm(list=ls()) set.seed(666) # # As a first step, it is assumed that all input parameters are independent of ageing : # InputDim -20 # Max number of ageings in the inputs CPIRate - rep(0.02 , InputDim ) # CPI inflation rate LossInflaRate - rep(0.02 , InputDim) # inflation rate of losses RiskFreeRate - rep(0.04, InputDim ) # vector of risk free rate RiskRate - rep(0.06, InputDim ) # vector of risk free rate lapse param begin : LapseType - rep(linear , InputDim ) # type of the function used to calculate lapse rate= power, logistic, linear CentralLapseRate - rep(0.13 , InputDim ) # lapse rate for price factor = 1 ElasticityLeft - rep( 10, InputDim ) # left elasticity for price factor = 1 ElasticityRight - rep(10, InputDim ) # right elasticity for price factor = 1 WindowLeft - rep( 1 , InputDim ) # friction window price factor left bound WindowRight - rep( 1, InputDim ) # friction window price factor right bound MinLapseRate - rep( 0 , InputDim ) # min lapse rate MaxLapseRate - rep( 1 , InputDim ) # min lapse rate Alpha - 0.5 #acquisition operator ### lapse param end Price - rep(1 , InputDim ) # Axa price for central market position and price factor = 1 IndivMeanLossAmount - rep(0.97 , InputDim ) # mean individual loss amount Commission - rep(0 , InputDim ) # commision rate IndividualExp - rep(0 , InputDim ) # expense amount per risk ### # Market Expert Model parameter begin : ### LRUpBound - 1.01349495023810 # Upper bound of the loss ratio LRLowBound - 0.743806254238095 # Lower bound of the loss ratio TransitCoefMean - 1.03001118178481 # Mean of the coefficient of transition TransitCoefStdDev - 0.0187801387384363 # Standard deviation of the coefficient of transition ### # Optimization algorithm Monte-Carlo parameters : ### LTMeanComputYearNb - 1000 # Number of year used to simulate LR NbOfSimScenar - 1000 # Number Monte-Carlo scenarios GenAlgoIterNb - 100 # number of iteration for genetic algorithm ### # Problem size parameters : ### FirstYear -2009 # first year of renewal LastYear - 2018 # last year of projected renewal ## # Function giving the minimum x (price factor = 1+x ) : ## Xmin - function(LapseType, ElasticityLeft, WindowLeft, MinLapseRate ,CentralLapseRate) { InputDim - length(LapseType) x=numeric(InputDim) for (i in 1:InputDim) { if (LapseType[i]==power ) x[i] - WindowLeft [i]*(MinLapseRate[i] /CentralLapseRate[i])^(1/ElasticityLeft[i])-1 else if (LapseType[i]==linear) x [i]- (WindowLeft[i]/ElasticityLeft[i])*(ElasticityLeft[i]-1+MinLapseRate[i] /CentralLapseRate[i])-1 } x } ## # Function giving the maximum x (price factor = 1+x ) : ## Xmax - function(LapseType, ElasticityLeft, WindowLeft, MaxLapseRate ,CentralLapseRate) { InputDim - length(LapseType) x=numeric(InputDim) for (i in 1:InputDim) { if (LapseType[i]==power ) x[i] - WindowLeft[i] *(MaxLapseRate[i]/CentralLapseRate[i])^(1/ElasticityLeft[i])-1 else if (LapseType[i]==linear) x[i] - (WindowLeft[i]/ElasticityLeft[i])*(ElasticityLeft[i]-1+MaxLapseRate[i]/CentralLapseRate[i])-1 } x }
[R] Preparing for multi-core CPUs and parallel processing applications
Hello I am fortunate (or in really big trouble) in that the research group I work with will soon be receiving several high end dual quad core machines. We will use the Ubuntu OS on these. We intend to use this cluster for some extensive modeling applications. Our programming guru has demonstrated the ability to link much simpler machines to share CPUs and we purchased the new ones to take advantage of this option. We have also begun exploration of the R CUDA and J CUDA functionality to push the processes to the graphics CPU which greatly speeds up the numerical processing. My question(s) to this group: 1) Which packages are suitable for parallel processing applications in R ? 2) Are these packages ready for prime time applications or are they developmental at this time? 3) Are we better off working in Java or C++ for the majority of this simulation work and linking to R for statistical analysis? 4) What are the pit falls, if any, that I need to be aware of ? 5) Can we take advantage of sharing the graphics CPU, via R CUDA, in a parallel distributed shared cluster of dedicated machines ? 6) Our statistical analysis and modeling applications address very large geographic issues. We generally work with 30-40 year daily time step data in a grided format. The grid is approximate 250 x 400 cells in extent, each representing approximately 500 meters x 500 meters. To this we a very large suite of ancillary information, both spatial and non-spatial, to simulate a variety of ecological state conditions. My question is - is this too large for R , given its use of memory? 7) I currently have a laptop with Ubuntu with R Version 2.6.2 (2008-02-08). What is the most recent R version for Ubuntu and what is the installation procedure ? These are just the initial questions that I'm sure to have. If these are being directed to the wrong help pages, I'm sorry to have taken your time. If you would be so kind as to direct me to the more appropriate help site I'd appreciate your assistance. Thanks in advance, Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Getting file name from pdf device?
Rainer M Krug-6 wrote: My question: how can I get the filename of the pdf from the device before it is closed? Setting a hook might work (not tried, though) http://finzi.psych.upenn.edu/R/Rhelp08/2009-February/188168.html Dieter -- View this message in context: http://www.nabble.com/Getting-file-name-from-pdf-device--tp24755915p24756308.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 delete a message in R-help?
I'm not sure it's possible, but a good place to start would be the mailman and posting guide links that appear at the bottom of each and every message to the list. Sarah On Fri, Jul 31, 2009 at 9:18 AM, Inchallah Yarabinchallahya...@yahoo.fr wrote: Hi i need to delete a message that a send to r -help ?? Can you please tell me how? 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. -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help in using gsub and ?
Hi all, I would like to strip the R prompt from a series of code lines and copy the resulting text into a R script. For example, consider the following : # str1- library(MASS) data(Cars93) attach(Cars93) imosaic(data.frame(AirBags,Cylinders,Origin)) str2-gsub('','',str1) ## This gives, as expected . str2 [1] \n library(MASS)\n data(Cars93)\n attach(Cars93)\n imosaic(data.frame(AirBags,Cylinders,Origin)) How can I now activate the newline character, \n, so that I get the following print-out : library(MASS) data(Cars93) attach(Cars93) imosaic(data.frame(AirBags,Cylinders,Origin)) I would appreciate any help that I can get. Thanking you, Ravi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Getting file name from pdf device?
Dear Rainer, You could have a look at ggsave() from the ggplot2 package. I guess that such an approach to save a plot is easier to combine with a tool like pdftk. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Rainer M Krug Verzonden: vrijdag 31 juli 2009 14:50 Aan: r-h...@stat.math.ethz.ch Onderwerp: [R] Getting file name from pdf device? Hi IU would like to modify the dev.off function, so that it automatically compresses the created pdf. I am thinking of doing the following in the modified dev.off: 1) Get the filename of the pdf device 2) close the device by calling the original dev.off() 3) compress the pdf file with a system call of pdftk. My question: how can I get the filename of the pdf from the device before it is closed? Thanks Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 delete a message in R-help?
On Jul 31, 2009, at 8:18 AM, Inchallah Yarab wrote: Hi i need to delete a message that a send to r -help ?? Can you please tell me how? Thank you You really can't. r-help is a public mailing list with live archives, not only stored by R's various servers, but by several other online archiving/list web sites (eg. gmane, nabble, google, etc.) There is not really a way to remove your post from every possible location on the web that may store a copy of it. Just be careful when you are posting, that you really want to send it... :-) 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] Automatic datasets creation from multiple data sheets in a single excel file
rajclinasia wrote: Please let us know how to create automatic datasets from multiple data sheets in a single excel file... For example if there are 10 sheets in a single excel file, automatically 10 datasets need to be created at a time when i read an excel file as a whole at once. The critical part is getting the names of the worksheets. http://tolstoy.newcastle.edu.au/R/e6/help/09/03/7736.html For reading individual worksheets, there is lots of code around. And a site search for read excel worksheet returns quite a few references. Dieter -- View this message in context: http://www.nabble.com/Automatic-datasets-creation-from-multiple-data-sheets-in-a-single-excel-file-tp24754120p24756406.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] automate multiple object creation
I appreciate all the help I have received from this list and also not being flamed because I am new to R. Many of my problems are in automation so far. I am trying to create multiple objects that are outputs of functions. Here are the tasks: aGAM-somers2(Pred_pres_a_indpdt[,3,,],population[,23]) aGBM-somers2(Pred_pres_a_indpdt[,4,,],population[,23]) cGLM-somers2(Pred_pres_a_indpdt[,5,,],population[,23]) cRF-somers2(Pred_pres_a_indpdt[,8,,],population[,23]) bGAM-somers2(Pred_pres_b_indpdt[,3,,],population[,24]) bGBM-somers2(Pred_pres_b_indpdt[,4,,],population[,24]) bGLM-somers2(Pred_pres_b_indpdt[,5,,],population[,24]) bRF-somers2(Pred_pres_b_indpdt[,8,,],population[,24]) ...and so on through the letter f. so the variables (x,y,z in this example) are as follows: xGAM-somers2(Pred_pres_x_indpdt[,y,,],population[,z]) the GAM, GBM, GLM, and RF are stored in a column y in Pred_pres_x_indpdt. x is denoting a species, which corresponds to column z in population, so a:f == 23:28 ~~~ This may be pushing it, but it would be great if I could get all of these in a matrix of dim[1,96] Here is what I have so far: x - c(a,b,c,d,e,f) nums - c(23:28) rank-function(x){ for(y in nums){ xGAM-somers2(Pred_pres_x_indpdt[,3,,],population[,y]) xGBM-somers2(Pred_pres_x_indpdt[,4,,],population[,y]) xGLM-somers2(Pred_pres_x_indpdt[,5,,],population[,y]) xRF-somers2(Pred_pres_x_indpdt[,8,,],population[,y]) rank(x) }} #for each species, there is 16 columns of output, so a total of 96 columns is needed x_matrix-matrix(c(xGAM[1:2],Evaluation.results.TSS[[1]][1,3:4],xGBM[1:2],Evaluation.results.TSS[[1]][2,3:4], xGLM[1:2],Evaluation.results.TSS[[1]][3,3:4],xRF[1:2],Evaluation.results.TSS[[1]][4,3:4]), nrow=1,ncol=16, dimnames=list(c(), c(x_gam_AUC, x_gam_Dxy,x_gam_TSS,x_gam_Cutoff,x_gbm_AUC, x_gbm_Dxy,x_gbm_TSS,x_gbm_Cutoff, x_glm_AUC, x_glm_Dxy,x_glm_TSS,x_glm_Cutoff,x_rf_AUC, x_rf_Dxy,x_rf_TSS,x_rf_Cutoff))) Thanks again for helping me out. Chris -- View this message in context: http://www.nabble.com/automate-multiple-object-creation-tp24756632p24756632.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 delete a message in R-help?
You can't delete post for the mailing list. The posting guide reads: Posters should be aware that the R lists are public discussion lists and anything you post will be archived and accessible via several websites for many years. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Inchallah Yarab Verzonden: vrijdag 31 juli 2009 15:19 Aan: r-help@r-project.org Onderwerp: [R] how can i delete a message in R-help? Hi i need to delete a message that a send to r -help ?? Can you please tell me how? 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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tweak a bit the legend wiht ggplot2
Hi Benoit, Unfortunately there's currently no way to do that - the legend automatically corresponds to the geom in the plot. Hadley On Thu, Jul 23, 2009 at 11:30 AM, Benoit Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote: Hi all, I've this ggplot2 graph (http://www.4shared.com/file/120101043/f3e9350/isotherm.html). I'd like to tweak the legend for the adsorbent part. I'd like to have full square of the colors instead of the full circles. I guess that I've to work on the scale_color_hue or fill somewhere but I haven't found my way yet. Here is my code to get the graph: pdf(isotherm.pdf,width=7,height=6) #windows(width=7,height=6) ads.graph-ggplot(Adsorp.DATA,aes(relative.p,ads.vol,shape=type ,color=adsorbent))+ geom_point(size=I(3)) + labs(x=expression(p/p[0]),y=N[2]~adsorbed~volume~(cc/g)) + scale_shape(name=Adsorption\nProcedure ,solid=F ,breaks=c(A,D) ,labels=c(Adsorp.,Desorp.) ) + scale_colour_hue(name=Adsorbent) + scale_x_continuous(limits=c(0,1),minor_breaks = seq(0,1,0.1)) + scale_y_continuous(limits=c(0,1000)) + opts(panel.grid.minor = theme_line(colour = grey94)) print(ads.graph) dev.off() Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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. -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question regarding sqldf
My sqldf package was already updated. The result from the example you ran is also missing 2 of the five days so something still isn't working correctly. | | From: | | | |milton ruser milton.ru...@gmail.com | | | | To:| | | |Michael Rizzo/RTP/USEPA/u...@epa | | | | Cc:| | | |r-help@r-project.org | | | | Date: | | | |07/30/2009 05:56 PM | | | | Subject: | | | |Re: [R] Question regarding sqldf | | How about update R/sqldf? require(sqlf) Loading required package: sqlf Warning message: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called 'sqlf' testframe-data.frame(sdate=rep(paste + (day,1:5,sep=),each=5),bext=runif(25,1,100),otherstuff=runif + (25,45,60),stuff=runif(25,3,25)) maxdays-sqldf(select distinct * from testframe group by sdate having bext=max(bext)) maxdays sdate bext otherstuff stuff 1 day1 77.20252 51.77503 12.045835 2 day2 91.37352 50.07259 4.468679 3 day5 74.29047 58.58456 10.027444 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re : what meaning missing value True /False needed
Thank you SARAH De : Sarah Goslee sarah.gos...@gmail.com rg Envoyé le : Vendredi, 31 Juillet 2009, 15h21mn 50s Objet : Re: [R] what meaning missing value True /False needed You are far more likely to get helpful volunteers to answer your questions if you distill your problem down to the smallest point. That's a lot of code to wade through. But since I was waiting for something else to run, I took a stab at it. It also would have been helpful if you'd given the *complete* error message, since it tells you where exactly the problem is. In this case, the problem is in LapseRate(), where PriceFactor is compared to WindowLeft (as the actual error message says). I added two lines using cat() to print those two variables each time LapseRate() is called, and here's what I saw: Maximization Problem. PriceFactor: 0.9352139 WindowLeft: 1 PriceFactor: 1.627354 WindowLeft: 1 PriceFactor: NA WindowLeft: 1 Error in if (PriceFactor WindowLeft) r - CentralLapseRate * (1 + ElasticityLeft/WindowLeft * : missing value where TRUE/FALSE needed So indeed, LapseRate() is comparing a NA value to something else, resulting in NA, just as the error message stated. Figuring out why PriceFactor is NA after two iterations is left as an exercise for the reader. Sarah rote: This is my code i don't understand the error message: library(rgenoud) rm(list=ls()) set.seed(666) # # As a first step, it is assumed that all input parameters are independent of ageing : # InputDim -20 # Max number of ageings in the inputs CPIRate - rep(0.02 , InputDim ) # CPI inflation rate LossInflaRate - rep(0.02 , InputDim) # inflation rate of losses RiskFreeRate - rep(0.04, InputDim ) # vector of risk free rate RiskRate - rep(0.06, InputDim ) # vector of risk free rate lapse param begin : LapseType - rep(linear , InputDim ) # type of the function used to calculate lapse rate= power, logistic, linear CentralLapseRate - rep(0.13 , InputDim ) # lapse rate for price factor = 1 ElasticityLeft - rep( 10, InputDim ) # left elasticity for price factor = 1 ElasticityRight - rep(10, InputDim ) # right elasticity for price factor = 1 WindowLeft - rep( 1 , InputDim ) # friction window price factor left bound WindowRight - rep( 1, InputDim ) # friction window price factor right bound MinLapseRate - rep( 0 , InputDim ) # min lapse rate MaxLapseRate - rep( 1 , InputDim ) # min lapse rate Alpha - 0.5 #acquisition operator ### lapse param end Price - rep(1 , InputDim ) # Axa price for central market position and price factor = 1 IndivMeanLossAmount - rep(0.97 , InputDim ) # mean individual loss amount Commission - rep(0 , InputDim ) # commision rate IndividualExp - rep(0 , InputDim ) # expense amount per risk ### # Market Expert Model parameter begin : ### LRUpBound - 1.01349495023810 # Upper bound of the loss ratio LRLowBound - 0.743806254238095 # Lower bound of the loss ratio TransitCoefMean - 1.03001118178481 # Mean of the coefficient of transition TransitCoefStdDev - 0.0187801387384363 # Standard deviation of the coefficient of transition ### # Optimization algorithm Monte-Carlo parameters : ### LTMeanComputYearNb - 1000 # Number of year used to simulate LR NbOfSimScenar - 1000 # Number Monte-Carlo scenarios GenAlgoIterNb - 100 # number of iteration for genetic algorithm ### # Problem size parameters : ### FirstYear -2009 # first year of renewal LastYear - 2018 # last year of projected renewal ## # Function giving the minimum x (price factor = 1+x ) : ## Xmin - function(LapseType, ElasticityLeft, WindowLeft, MinLapseRate ,CentralLapseRate) { InputDim - length(LapseType) x=numeric(InputDim) for (i in 1:InputDim) { if (LapseType[i]==power ) x[i] - WindowLeft [i]*(MinLapseRate[i] /CentralLapseRate[i])^(1/ElasticityLeft[i])-1 else if (LapseType[i]==linear) x [i]- (WindowLeft[i]/ElasticityLeft[i])*(ElasticityLeft[i]-1+MinLapseRate[i] /CentralLapseRate[i])-1 } x } ## # Function giving the maximum x (price factor = 1+x ) : ## Xmax - function(LapseType, ElasticityLeft, WindowLeft, MaxLapseRate ,CentralLapseRate) { InputDim - length(LapseType) x=numeric(InputDim) for (i in 1:InputDim) { if (LapseType[i]==power ) x[i] - WindowLeft[i] *(MaxLapseRate[i]/CentralLapseRate[i])^(1/ElasticityLeft[i])-1 else if (LapseType[i]==linear) x[i] -
Re: [R] Preparing for multi-core CPUs and parallel processing applications
Hi Steve -- steve_fried...@nps.gov wrote: Hello I am fortunate (or in really big trouble) in that the research group I work with will soon be receiving several high end dual quad core machines. We will use the Ubuntu OS on these. We intend to use this cluster for some extensive modeling applications. Our programming guru has demonstrated the ability to link much simpler machines to share CPUs and we purchased the new ones to take advantage of this option. We have also begun exploration of the R CUDA and J CUDA functionality to push the processes to the graphics CPU which greatly speeds up the numerical processing. My question(s) to this group: Last question first, the R-sig-hpc group might be more appropriate for an extended discussion. https://stat.ethz.ch/mailman/listinfo/r-sig-hpc see also the HighPerformanceComputing task view http://cran.fhcrc.org/web/views/HighPerformanceComputing.html 1) Which packages are suitable for parallel processing applications in R ? 2) Are these packages ready for prime time applications or are they developmental at this time? I use Rmpi for all my parallel computing, but if I had more time I'd explore multicore for more efficient use of several CPU on a single machine, and the new offerings from Revolution computing. If there were significant portions of C code I'd look into using openMP (as done in the pnmath library). Also using a parallel BLAS / LAPACK library if that was where significant computation was occurring. 3) Are we better off working in Java or C++ for the majority of this simulation work and linking to R for statistical analysis? 4) What are the pit falls, if any, that I need to be aware of ? With multiple core, it's important to remember that large memory is divided amongst cpu, so that huge-sounding 32GB 8 core machine has 'only' 4 GB / cpu when independent R processes are allocated to each cpu (as is the style with Rmpi). 5) Can we take advantage of sharing the graphics CPU, via R CUDA, in a parallel distributed shared cluster of dedicated machines ? 6) Our statistical analysis and modeling applications address very large geographic issues. We generally work with 30-40 year daily time step data in a grided format. The grid is approximate 250 x 400 cells in extent, each representing approximately 500 meters x 500 meters. To this we a very large suite of ancillary information, both spatial and non-spatial, to simulate a variety of ecological state conditions. My question is - is this too large for R , given its use of memory? Depending on the application, large data sets can often be managed effectively on disk, e.g., by using the ncdf package (for large numeric data) or a data base (R includes sqlite, for instance), and analyzing independent 'slices'. This fits well with common parallel computing paradigms. 7) I currently have a laptop with Ubuntu with R Version 2.6.2 (2008-02-08). What is the most recent R version for Ubuntu and what is the installation procedure ? These are just the initial questions that I'm sure to have. If these are being directed to the wrong help pages, I'm sorry to have taken your time. If you would be so kind as to direct me to the more appropriate help site I'd appreciate your assistance. Thanks in advance, Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Systematic resampling
Dear all, This is the sequel to a question of mine a couple of days ago about how to implement systematic resampling from a discrete distribution efficiently. (See below the original question and description of the problem - the problem, in a nutshell, is how to draw N points from a discrete distribution on N points). I did my homework and found an implementation of systematic resampling which is O(N) - my initial one was O(N^2). The code is given below. However, compared with multinomial resampling, the difference in execution time is huge. Is there anybody out there who sees a way of improving the efficiency of my code?? Is coding it in C my only option? Thank you in advance for your suggestions and insight, Giovanni # R example # ### Timing systematic resampling set.seed(2) N - 1e6 x - LETTERS[1 : N] # labels w - rexp(N) w - w / sum(w) # probabilities W - cumsum(w) # cdf system.time({ + u - (0 : (N - 1) + runif(1)) / N + indexNew - rep(0, N) + h - 1 + k - 1 + for (i in 1 : N) + { + j - h + while (u[h] W[k] h = N) h - h + 1 + indexNew[i] - h - j + k - k + 1 + } + (y - rep(x, indexNew)) + }) user system elapsed 12.791 0.073 12.887 ### ...while using multinomial resampling: system.time( + index - sample(N, N, replace = TRUE, prob = w) + ) user system elapsed 0.344 0.020 0.366 Date: Wed, 29 Jul 2009 13:32:14 -0500 (CDT) From: Giovanni Petris gpet...@uark.edu Sender: r-help-boun...@r-project.org Precedence: list Dear all, Here is a little coding problem. It falls in the category of how can I do this efficiently? rather than how can I do this? (I know how to do it inefficiently). So, if you want to take the challenge, keep reading, otherwise just skip to the next post - I won't be offended by that ;-) I am coding a particle filter and I want to use systematic resampling to regenerate particles. Basically, what this means is the following. 1. Start with a vector of labels, x, say, of length N and a vector of probabilities, w, say - w[i] is the probability attached to x[i]. 2. Draw N equally spaced random number in (0,1) as u = (1 : N + runif(1)) / N. 3. Define a new sample of labels, y, say, by inverting the cdf defined by the probabilities w. That is, set y[i] = x[k] if cumsum(w)[k-1] = u[i] cumsum(w)[k], i=1, ..., N. The following is a piece of R code that implements the procedure. ### Systematic resampling set.seed(2) x - LETTERS[1 : 6] # labels w - rexp(6) w - w / sum(w) # probabilities W - c(0, cumsum(w)) # cdf u - (1 : 6 + runif(1)) / 6 indNew - sapply(seq_along(u), + function(i) (sum(W[i] = u u W[i + 1]))) (y - rep(x, indNew)) [1] A B D D F ## graphically... plot(stepfun(seq_along(u), W), xaxt = n) axis(1, at = seq_along(u), x) abline(h = u, lty = dotted) The question is the following. I believe the way I compute newInd is of order N^2. Is there a smart way of doing it which is of order N? (I know there is one, I just cannot find it...) Thanks in advance, Giovanni __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] help in using gsub and ?
Try this: cat(str2, \n) On Fri, Jul 31, 2009 at 10:30 AM, ravi rv...@yahoo.se wrote: Hi all, I would like to strip the R prompt from a series of code lines and copy the resulting text into a R script. For example, consider the following : # str1- library(MASS) data(Cars93) attach(Cars93) imosaic(data.frame(AirBags,Cylinders,Origin)) str2-gsub('','',str1) ## This gives, as expected . str2 [1] \n library(MASS)\n data(Cars93)\n attach(Cars93)\n imosaic(data.frame(AirBags,Cylinders,Origin)) How can I now activate the newline character, \n, so that I get the following print-out : library(MASS) data(Cars93) attach(Cars93) imosaic(data.frame(AirBags,Cylinders,Origin)) I would appreciate any help that I can get. Thanking you, Ravi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Runtime Error with multinom
Well, I get multinom(formula(data),data=data[Z,]) # weights: 6 (0 variable) initial value 0.00 final value 0.00 converged Call: multinom(formula = formula(data), data = data[Z, ]) Coefficients: (Intercept) factor2f factor2g factor2h size Residual Deviance: 0 AIC: 0 Warning message: In multinom(formula(data), data = data[Z, ]) : groups b c d are empty and no error. This is clearly a nonsensical application of my work, as data[Z, ] factor1 factor2 size 1 a e3 1.1 a e3 1.2 a e3 contains no discriminatory information. By using valgrind I can see a possible crash, but really this needs a 'how dare you use my work so carelessly' message. On Mon, 20 Jul 2009, Uwe Ligges wrote: Andreas Wittmann wrote: Dear R-users, i try to fit a multinomial model in order to get an imputation for a missing value in factor1. library(nnet) factor1 - factor(c(a,b,c,d)) factor2 - factor(c(e,f,g,h)) size - c(3,8,2,1) factor1[3] - NA Z-ifelse(is.na(factor1), 0, 1) assign(data, cbind.data.frame(factor1,factor2,size),pos=1) multinom(formula(data),data=data[Z,]) when entering the last line i get a runtime error and R crashes down. my system is windows xp and R 2.9.1, i tried it also with ubuntu 9.04 and R.2.8.1 but i get a quite similar error. Many thanks if anyone could tell me what i do wrong and what is the problem here. Please report bugs in packages to the package maintainer (who in this case probably has read your message already, CCing anyway). -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Preparing for multi-core CPUs and parallel processing applications
Steve, Martin already mentioned r-sig-hpc and the HPC task view for the bulk of your questions. The Schmidbger et al paper (linked from the Task View) should address a few of your questions. Just two more quick add-ons: On 31 July 2009 at 09:22, steve_fried...@nps.gov wrote: | 5) Can we take advantage of sharing the graphics CPU, via R CUDA, in a | parallel distributed shared cluster of dedicated machines ? Besides the somewhat exploratory package 'gputools' from U Mich (linked from the Task View), there is no 'R CUDA' yet. | 7) I currently have a laptop with Ubuntu with R Version 2.6.2 | (2008-02-08). What is the most recent R version for Ubuntu and what is the | installation procedure ? The newest is R 2.9.1, see http://cran.r-project/bin/linux/ubuntu which explains things in more detail. For more questions, come to the r-sig-debian list is for Debian and Ubuntu specific questions. Debian and Ubuntu do have good support for Rmpi etc. | These are just the initial questions that I'm sure to have. If these are | being directed to the wrong help pages, I'm sorry to have taken your time. | If you would be so kind as to direct me to the more appropriate help site | I'd appreciate your assistance. There are 'special interest group' mailing lists for HPC (see above), Debian/Ubuntu and for geographic / spatial modelling. Hth, Dirk -- Three out of two people have difficulties with fractions. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 standardize matriz?
Yes, I was looking for something to convert to a Z matrix, (the var minus the mean, divided by the standard deviation). Thank you very much for your help! I'll take a look at that. On Thu, Jul 30, 2009 at 2:14 AM, bill.venab...@csiro.au wrote: scale? This transforms the columns of a matrix to z-scores. That's one kind of standardisation. Bill Venables http://www.cmis.csiro.au/bill.venables/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Sam Sent: Thursday, 30 July 2009 2:52 PM To: r-help@r-project.org Subject: [R] Function to standardize matriz? Hi, this is probably a very basic question but I'm just learning R and i cannot find a function to standardize a data matrix.. I'll be grateful for any tips or help you can provide me. Thank you very much! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] truncating values into separate categories
It appears that your difficulty lies in miscounting the number of intervals. cut(NP, breaks=c(0,1,2,3,4,max(NP))) [1] (0,1] (0,1] (1,2] (0,1] (0,1] (1,2] (1,2] (0,1] (3,4] (0,1] NA (4,6] (2,3] (2,3] (0,1] [16] (4,6] (2,3] (4,6] (0,1] (4,6] (0,1] (1,2] (1,2] (1,2] (3,4] (3,4] (0,1] (1,2] (0,1] (2,3] [31] (2,3] (0,1] (1,2] (1,2] (0,1] (1,2] (0,1] (1,2] (1,2] (2,3] (0,1] (0,1] (3,4] (3,4] (0,1] [46] (0,1] (0,1] (1,2] (1,2] (1,2] Levels: (0,1] (1,2] (2,3] (3,4] (4,6] cut(NP, breaks=c(0,1,2,3,max(NP)),labels=c(1,2,3,4+)) [1] 112112214+ 1NA 4+ 3 314+ 34+ [19] 14+ 12224+ 4+ 12133 12212 [37] 1223114+ 4+ 111222 Levels: 1 2 3 4+ a=cut(NP, breaks=c(0,1,2,3,max(NP)),labels=c(1,2,3,4+)) table(a,exclude=NULL) a 123 4+ NA 19 15691 Generally it is better to let R keep track of the NA's for you. albyn Quoting PDXRugger j_r...@hotmail.com: Hi all, Simple question which i thought i had the answer but it isnt so simple for some reason. I am sure someone can easily help. I would like to categorize the values in NP into 1 of the five values in Per, with the last category(4) representing values =4(hence 4:max(NP)). The problem is that R is reading max(NP) as multiple values instead of range so the lengths of the labels and the breaks are not matching. Suggestions? Per - c(NA, 1, 2, 3,4) NP=c(1 ,1 ,2 ,1, 1 ,2 ,2 ,1 ,4 ,1 ,0 ,5 ,3 ,3 ,1 ,5 ,3, 5, 1, 6, 1, 2, 2, 2, 4, 4, 1, 2, 1, 3, 3, 1 ,2 ,2 ,1 ,2, 1, 2, 2, 3, 1, 1, 4, 4, 1, 1, 1, 2, 2, 2) Person_CAT - cut(NP, breaks=c(0,1,2,3,4:max(NP)), labels=Per) -- View this message in context: http://www.nabble.com/truncating-values-into-separate-categories-tp24749046p24749046.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to stop an R script when running JGR on a Linux/SuSE system
When I need to stop a running R script on Windows or Mac I just use the esc key which kills the current script and returns the control to R interpreter. But when I run R from JGR the esc is useless as well as the other available keyboard keys. Just recently not even clicking on the STOP-symbol (a big red X) placed on JGR top menu bar could terminate a process that had entered a long loop. Eventually I could kill the process from bash comman line using # kill -KILL process-id I wonder whether there is a more gentle way to stop an R script running on top of JGR aother than ... unplugging the power cord. Thank you so much, Maura .html?pmk=footer [[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] automate multiple object creation
I believe this is a little bit closer: rank-function(i,j){ for(i in name1){ for(j in name2){ somers2(i,j) }}} rank(name1,name2) bu still not there waltzmiester wrote: I appreciate all the help I have received from this list and also not being flamed because I am new to R. Many of my problems are in automation so far. I am trying to create multiple objects that are outputs of functions. Here are the tasks: aGAM-somers2(Pred_pres_a_indpdt[,3,,],population[,23]) aGBM-somers2(Pred_pres_a_indpdt[,4,,],population[,23]) cGLM-somers2(Pred_pres_a_indpdt[,5,,],population[,23]) cRF-somers2(Pred_pres_a_indpdt[,8,,],population[,23]) bGAM-somers2(Pred_pres_b_indpdt[,3,,],population[,24]) bGBM-somers2(Pred_pres_b_indpdt[,4,,],population[,24]) bGLM-somers2(Pred_pres_b_indpdt[,5,,],population[,24]) bRF-somers2(Pred_pres_b_indpdt[,8,,],population[,24]) ...and so on through the letter f. so the variables (x,y,z in this example) are as follows: xGAM-somers2(Pred_pres_x_indpdt[,y,,],population[,z]) the GAM, GBM, GLM, and RF are stored in a column y in Pred_pres_x_indpdt. x is denoting a species, which corresponds to column z in population, so a:f == 23:28 ~~~ This may be pushing it, but it would be great if I could get all of these in a matrix of dim[1,96] Here is what I have so far: x - c(a,b,c,d,e,f) nums - c(23:28) rank-function(x){ for(y in nums){ xGAM-somers2(Pred_pres_x_indpdt[,3,,],population[,y]) xGBM-somers2(Pred_pres_x_indpdt[,4,,],population[,y]) xGLM-somers2(Pred_pres_x_indpdt[,5,,],population[,y]) xRF-somers2(Pred_pres_x_indpdt[,8,,],population[,y]) rank(x) }} #for each species, there is 16 columns of output, so a total of 96 columns is needed x_matrix-matrix(c(xGAM[1:2],Evaluation.results.TSS[[1]][1,3:4],xGBM[1:2],Evaluation.results.TSS[[1]][2,3:4], xGLM[1:2],Evaluation.results.TSS[[1]][3,3:4],xRF[1:2],Evaluation.results.TSS[[1]][4,3:4]), nrow=1,ncol=16, dimnames=list(c(), c(x_gam_AUC, x_gam_Dxy,x_gam_TSS,x_gam_Cutoff,x_gbm_AUC, x_gbm_Dxy,x_gbm_TSS,x_gbm_Cutoff, x_glm_AUC, x_glm_Dxy,x_glm_TSS,x_glm_Cutoff,x_rf_AUC, x_rf_Dxy,x_rf_TSS,x_rf_Cutoff))) Thanks again for helping me out. Chris -- View this message in context: http://www.nabble.com/automate-multiple-object-creation-tp24756632p24758036.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] automate multiple object creation
x-c(a,b,c,d,e,f) y-rep(c(3,4,5,8),6) z-rep(c(23,24,25,26,27,28),6) name1-sprintf(Pred_pres_%s_indpdt[,%s,,],x,y) name2-sprintf(population[,%s],z) rank-function(i,j){ for(i in name1){ for(j in name2){ somers2(i,j) }}} rank(name1,name2) waltzmiester wrote: I believe this is a little bit closer: rank-function(i,j){ for(i in name1){ for(j in name2){ somers2(i,j) }}} rank(name1,name2) bu still not there waltzmiester wrote: I appreciate all the help I have received from this list and also not being flamed because I am new to R. Many of my problems are in automation so far. I am trying to create multiple objects that are outputs of functions. Here are the tasks: aGAM-somers2(Pred_pres_a_indpdt[,3,,],population[,23]) aGBM-somers2(Pred_pres_a_indpdt[,4,,],population[,23]) cGLM-somers2(Pred_pres_a_indpdt[,5,,],population[,23]) cRF-somers2(Pred_pres_a_indpdt[,8,,],population[,23]) bGAM-somers2(Pred_pres_b_indpdt[,3,,],population[,24]) bGBM-somers2(Pred_pres_b_indpdt[,4,,],population[,24]) bGLM-somers2(Pred_pres_b_indpdt[,5,,],population[,24]) bRF-somers2(Pred_pres_b_indpdt[,8,,],population[,24]) ...and so on through the letter f. so the variables (x,y,z in this example) are as follows: xGAM-somers2(Pred_pres_x_indpdt[,y,,],population[,z]) the GAM, GBM, GLM, and RF are stored in a column y in Pred_pres_x_indpdt. x is denoting a species, which corresponds to column z in population, so a:f == 23:28 ~~~ This may be pushing it, but it would be great if I could get all of these in a matrix of dim[1,96] Here is what I have so far: x - c(a,b,c,d,e,f) nums - c(23:28) rank-function(x){ for(y in nums){ xGAM-somers2(Pred_pres_x_indpdt[,3,,],population[,y]) xGBM-somers2(Pred_pres_x_indpdt[,4,,],population[,y]) xGLM-somers2(Pred_pres_x_indpdt[,5,,],population[,y]) xRF-somers2(Pred_pres_x_indpdt[,8,,],population[,y]) rank(x) }} #for each species, there is 16 columns of output, so a total of 96 columns is needed x_matrix-matrix(c(xGAM[1:2],Evaluation.results.TSS[[1]][1,3:4],xGBM[1:2],Evaluation.results.TSS[[1]][2,3:4], xGLM[1:2],Evaluation.results.TSS[[1]][3,3:4],xRF[1:2],Evaluation.results.TSS[[1]][4,3:4]), nrow=1,ncol=16, dimnames=list(c(), c(x_gam_AUC, x_gam_Dxy,x_gam_TSS,x_gam_Cutoff,x_gbm_AUC, x_gbm_Dxy,x_gbm_TSS,x_gbm_Cutoff, x_glm_AUC, x_glm_Dxy,x_glm_TSS,x_glm_Cutoff,x_rf_AUC, x_rf_Dxy,x_rf_TSS,x_rf_Cutoff))) Thanks again for helping me out. Chris -- View this message in context: http://www.nabble.com/automate-multiple-object-creation-tp24756632p24758066.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] MLE estimation of constrained mean Singh-Maddala distribution
INTRODUCTION TO THE PROBLEM I am trying to fit a distribution to a dataset. The distribution that I am currently considering is the (3-parameter) Singh-Maddala (Burr) distribution. The final model will fix the mean of the distribution to a given value and estimate the remaining parameters accordingly; however, the code provided below ignores this. For this distribution the three parameters ('a': corresponding to 'a' in the function 'dsinmad' under the package 'VGAM'; 'b': corresponding to 'scale'; and 'q': corresponding to 'q.arg') are constrained to be strictly positive. For this I estimate parameters, first using 'optim' (and later 'nlm'), defined over the set of real numbers and then use the exponential function to convert them to positive values. For these constraints and the additional constraint: 'q-1/a0' the expected value is given as (as reported on the help page for the function 'sinmad'): E(Y) = b gamma(1 + 1/a) gamma(q - 1/a) / gamma(q). THE PROBLEM The problem I am having is constraining the search to the region where 'q-1/a0'. I was hoping not to just set the value of the negative log likelihood to 'Inf' (unless suggested otherwise) when 'optim' set the parameter at values that violated the constraint. I do not have much experience with simulated annealing so am not sure if the method 'SANN' would address this issue. I was also hoping to avoid using 'optim' recursively to solve this problem (unless otherwise suggested). Does 'R' have a function that can address the issue of the mentioned constraint in solving the maximum likelihood problem (that is applicable when the mean is fixed and other parameters estimated accordingly)? I have included code below to provide a better understanding of the problem (the dataset for 'y' is not included). Thanks, Josh Parcel ### R CODE ### library(VGAM) #Fit a Singh-Maddala distribution to 'y'. #Singh-Maddala Distribution #Parameters: a:shape ; b: scale; q: shape. #a0, b0, q0. To use given mean require -a1aq. #Use exponential function to ensure above constraints (except '-a1aq'. neg.LL_sinmad-function(p, y, x) { a_iter-exp(p[1]) b_iter-exp(p[2]) q_iter-exp(p[3]) #NEED TO PUT IN CONTITION ENSURING THAT 'q_iter-1/a_iter0'. z-(-sum(log(dsinmad(y, a=a_iter, scale=b_iter, q.arg=q_iter, log=FALSE } #Set values for initial guess of the parameters. a_guess-2 b_guess-3 q_guess-7 q_guess-1/a_guess p0-c(log(a_guess), log(b_guess), log(q_guess)) #Optimize to find minimum of the negative likelihood function est_p_A-optim(par=p0, fn=neg.LL_sinmad, y=y) est_p_A$par a_hat1-exp(est_p_A$par[1]) b_hat1-exp(est_p_A$par[2]) q_hat1-exp(est_p_A$par[3]) q_hat1-1/a_hat1 est_p_B-nlm(f=neg.LL_sinmad, p=c(est_p_A$par[1], est_p_A$par[2], est_p_A$par[3]), print.level=1, y=y) a_hat-exp(est_p_A$par[1]) b_hat-exp(est_p_A$par[2]) q_hat-exp(est_p_A$par[3]) q_hat-1/a_hat CONFIDENTIALITY NOTICE: This email, and any attachments hereto, contains information which may be CONFIDENTIAL. The information is intended to be for the use of the individual or entity named above. If you are not the intended recipient, please note that any unauthorized disclosure, copying, distribution or use of the information is prohibited. If you have received this electronic transmission in error, please return the e-mail to the sender and delete it from your computer. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matrix Integral
Hi, Any help on this would be appreciated: I need to integrate where K is a 4x4 matrix, and SIGMA is a 4x4 matrix from say a to b, i.e. 0 to 5: integral MatrixExp(-K * s) %*% SIGMA %*% t(SIGMA) %*% MatrixExp(t(-K) s) ds t is tranpose , %*% : matrix mult , MatrixExp : matrix exponential I've use integrate before on univariate functions like f(x) = x^2 which is fine but when doing this on a matrix I run into problems. All I intuitively need to do is do this element by element. Thanks, NH. -- View this message in context: http://www.nabble.com/Matrix-Integral-tp24757170p24757170.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Codes for fitting Logistic Regression for Multivaraite Data
usually i go thru the manuals of the libraries and the data attached with the libraries to get the code working for my data. not a good way but usually it works out. Nimal Fernando wrote: Hi It would be a great help if someone can direct me to access some existing R codes for fitting Logistic regression models for Multivariate data. I want to find some Robust Estimates (M) for these models. Thanks a lot Best Regards Nimal [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/R-Codes-for-fitting-Logistic-Regression-for-Multivaraite-Data-tp24706374p24757203.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] Tests for Two Independent Samples
Dear R users, I have got two samples: sample A with observation of 223: sample A has five categories: 1,2,3,4,5 (I use the numer 1,2,3,4,5 to define the five differen categories) there are 5 observations in category 1; 81 observations in category 2;110 observations in category 3; 27 observations in category 4; 0 observations in category 5; To present the sample in R: a-rep(1:5, c(5,81,110,27,0)) sample B with observation of 504: sample B also has the same five categories: 1,2,3,4,5 there are 6 observations in category 1; 127 observations in category 2;297 observations in category 3; 72 observations in category 4; 2 observations in category 5; To present the sample in R: b-rep(1:5, c(6,127,297,72,2)) I want to test weather these two samples have significant difference in distribution ( or Tests for Two Independent Samples). I find a webside in: http://faculty.chass.ncsu.edu/garson/PA765/mann.htm This page shows four nonparametric tests. Bust I can only find the test Kolmogorov-Smirnov Z Test. res-ks.test(a,b) Can any one tell me which package has the other 3 tests? or Is there any other test for my question? Thanks advance Ted -- View this message in context: http://www.nabble.com/Tests-for-Two-Independent-Samples-tp24756594p24756594.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] Antw: How to extract the upper xlim and ylim of my plot?
use hilox-range.x=range(x variable) and hiloy-range.y=range(y variable) or store these values in vectors to be later on user as xlim=hilox, ylim=hiloy Frank Bloos wrote: You may want to use the function corner.label from the plotrix-package. Frank Mark Na mtb...@gmail.com 21.07.2009 23:03 Dear R-helpers, I wish to place some text in a plot, at approx 10% of my upper xlim and approx 90% of my upper ylim, i.e. plot(log(all$SR,10)~log(all$AREA,10)) text(.1*max(xlim),.9*max(ylim),text to be placed) (I know how to give absolute coordinates for text location, but I wish to use relative coordinates). My code (above) doesn't work because I don't know how to properly extract the upper xlim and ylim values. Does anyone know how I could extract the upper xlim and ylim values (without using max(x-variable) or max (y-variable)...I wish to keep this as general as possible and not point to the original data. Thanks in advance, Mark [[alternative HTML version deleted]] Universitätsklinikum Jena Körperschaft des öffentlichen Rechts und Teilkörperschaft der Friedrich-Schiller-Universität Jena BachstraÃe 18, 07743 Jena Verwaltungsratsvorsitzender: Prof. Dr. Walter Bauer-Wabnegg; Medizinischer Vorstand: Prof. Dr. Klaus Höffken; Wissenschaftlicher Vorstand: Prof. Dr. Klaus Benndorf; Kaufmännischer Vorstand und Sprecher des Klinikumsvorstandes Rudolf Kruse Bankverbindung: Sparkasse Jena; BLZ: 830 530 30; Kto.: 221; Gerichtsstand Jena Steuernummer: 161/144/02978; USt.-IdNr. : DE 150545777 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Antw%3A--How-to-extract-the-upper-xlim-and-ylim-of-my-plot--tp24619947p24757330.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] Newbie in R: Reading .txt files and storing the 'numbers' in a vector
I am also a newbie, but here are the few thing i do eo=read.table(file=path where you have saved your text file/xxx.txt,header=T, ) #this will only read excelfiles saved as *.csv file attach(eo) #attach the data names(eo) go to this website http://www.statmethods.net/stats here is how to store numbers as vectors a-c(1,2,3,4,5,6,7) here is how i means as vector d-aggregate(LMMP8,list(PlateID,Self_T1D),mean, na.rm=T) I would suggest u to search for website for R tutorials here are some good ones go to this website http://www.statmethods.net/stats http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_ttest.html this one has all the codes you can change them according to your data http://www3.imperial.ac.uk/pls/portallive/docs/1/1171930.TXT http://www.mayin.org/ajayshah/KB/R/index.html also download the book by verjani it would be a great help to you. Patrick Schorderet wrote: Hello everybody, I'm a newbie in R and just went through an introduction class recently. Here's my problem. I have 2 text files (.txt) with plain numbers ('doubles' for those who know c++) ordered into 2 columns as below: coordinate1 value1 coordinate2 value2 coordinate3 value3 ... ... coordinateN valueN I would like to write a small programme in which i would: 1. take all values of file 1 and store them in a vector 2. substract to those all values of file 2 (one by one) and store the result in a new vector 3. Create a sliding window of chosen size and calculate the mathematical average and store these averages in a new vector 4. Plot the different graphes with a bar plot So I wrote a c++ script that does the first parts and writes the averages in a output.txt file (which I have up and running). Unfortunately, I seem to fail in reading these as numbers and putting them into a vector (in the R environment). I can read the file , but this is what I get: z=scan(file = /Users/NCCRGENETICS/Desktop/testRnumbers.txt, what = double) Read 19 items z [1] {\\rtf1\\ansi\\ansicpg1252\\cocoartf949\\cocoasubrtf430 [2] {\\fonttbl\\f0\\fswiss\\fcharset0 [3] Helvetica;} [4] {\\colortbl;\\red255\\green255\\blue255;} [5] \\paperw11900\\paperh16840\\margl1440\\margr1440\\vieww9000\ \viewh8400\\viewkind0 [6] \\pard\\tx566\\tx1133\\tx1700\\tx2267\\tx2834\\tx3401\\tx3968\ \tx4535\\tx5102\\tx5669\\tx6236\\tx6803\\ql\\qnatural\\pardirnatural [7] \\f0\\fs24 [8] \\cf0 [9] 13\\ // This is where my file should start reading the numbers I see in the window when I open it with textedit [10] 27\\ [11] 39\\ [12] 48\\ [13] 34\\ [14] 17\\ [15] 23\\ [16] 45\\ [17] 23\\ [18] 4\\ [19] } Thanks so much to any of you who could provoid a little help... I'm getting nuts. Patrick __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Newbie-in-R%3A-Reading-.txt-files-and-storing-the-%27numbers%27-in-a-vector-tp24714734p24757501.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] Fill dataframe from a table according to a criteria
Deare R users I am new to R. What I want to do is explained below;- I have table called States.Prob which is given below Prob of States Changes State1 State2 State3 State4 A Pa1 Pa2 Pa3 Pa4 B Pb1 Pb2 Pb3 Pb4 C Pc1 Pc2 Pc3 Pc4 D Pd1 Pd2 Pd3 Pd4 and I have a dataframe called mydata which is given below where I want to fill in the last four columns of probabilities taken from States.Prob according to the change and state in mydata4:- PxMid EU0006MIndex.x DMSW1Curncy.x DMSW2Curncy.x DMSW3Curncy.x 1 01/01/20032.801132.70702.89203.1720 2 01/01/20073.853504.07604.12504.1230 3 01/02/20023.415633.63854.08104.3587 4 01/02/20062.72.95453.16723.2792 5 01/05/20023.498633.79404.23004.4920 6 01/05/20063.035883.32543.59503.7380 DMSW4Curncy.x DMSW5Curncy.x DMSW6Curncy.x DMSW7Curncy.x DMSW8Curncy.x 13.43603.66403.86404.03604.1790 24.12304.12504.13504.14604.1620 34.54874.69884.83134.93385.0138 43.36273.43423.48993.54373.5941 54.76504.86755.05505.16005.2400 63.82903.90503.96904.02404.0750 Change State PState1 PState2 PState3 PState4 1 B State1 Pb1 2 A State4 Pa4 3 B State2Pb2 4 C State3 Pc3 5 D State1 Pd1 6 A State3 Pa3 What I want to do is highlighted in Red. How can I do this easily? Many thanks for your time. kind regards Meenu [[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] constrained input for optimization algorithm
CRAN task view on optimization and mathematical programming shows the following packages for integer programming: IP (Integer programming, 90C10): glpk, lpSolve, lpSolveAPI, Rcplex, Rglpk, Rsymphony MIP (Mixed integer programming and its variants MILP for LP and MIQP for QP, 90C11): glpk, lpSolve, lpSolveAPI, Rcplex, Rglpk, Rsymphony Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Prof. John C Nash Sent: Friday, July 31, 2009 7:04 AM To: r-help@r-project.org Subject: Re: [R] constrained input for optimization algorithm As someone very involved with optim and its evolution I can say it is not at all suited to this sort of combinatoric optimization. I don't know if there are packages in R to help out -- it would be nice. If (this may be a big IF) your set of possible combinations is not too large, combn() generates the C(n,r) combinations and, assuming the function is not too expensive to compute, one can use enumeration and be certain of having the optimum. choose(60,5) shows about 5.5 million sets. A bit tedious, but likely doable over lunchtime. But choose(600,5) is 600 billion, and probably too heavy. John Nash From: Zhi Xie xie...@gmail.com It seems that optimization algorithm, optim, tries to find optimized parameters within defined lower and upper bounds. In my problem, all the parameters are integers. My question is that if there is any means that I can let optim only tries mutual exclusive integers. To be specific, I am giving an example here. I tried to find a set parameters with five elements with the lowest value for the cost function. The parameter set that optim returned is 5, 5, 49, 51, 51. However, I only wanted to search unique parameter values, such as 5, 6, 49, 50, 51. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] function problem
I have a series of columns that need to be evaluated in various tables. I need to apply a function in the following manner somers2(name1,name2). name1 is a vector of x inputs for the function which correspond to a vector of y inputs in name2. y-rep(c(3,4,5,8),6) z-rep(c(23,24,25,26,27,28),4) name1-sprintf(Pred_pres_%s_indpdt[,%s,,],x,y) name2-sprintf(population[,%s],z) rank-function(i,j){ for(i in name1){ for(j in name2){ somers2(i,j) }}} Thanks Robert -- View this message in context: http://www.nabble.com/function-problem-tp24759253p24759253.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] Porting S code to R (USGS Library for S-PLUS for Windows)
I would like to port the code contained in http://water.usgs.gov/software/S-PLUS/. Especially the move.1 model. I have downloaded the software, but it doesn't seem to display correctly in smultron or text edit. This I believe is a windows binary distribution. I have sent a message through the USGS website, and hope that it filters to the authors. Does anyone have and tips or tricks that may help in this arena. I do not have access to S-plus. kind regards, -- Stephen Sefick 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 problem
Hi, On Jul 31, 2009, at 12:25 PM, RR! wrote: I have a series of columns that need to be evaluated in various tables. I need to apply a function in the following manner somers2(name1,name2). name1 is a vector of x inputs for the function which correspond to a vector of y inputs in name2. y-rep(c(3,4,5,8),6) z-rep(c(23,24,25,26,27,28),4) name1-sprintf(Pred_pres_%s_indpdt[,%s,,],x,y) name2-sprintf(population[,%s],z) rank-function(i,j){ for(i in name1){ for(j in name2){ somers2(i,j) }}} You're missing a value for x, so I'm finding it hard to understand what you're trying to do, exactly. From your double for loop, it seems like you just want to compute the function over all vals in X, and each x against all Y. Does this help? R x - LETTERS[1:3] R y - LETTERS[10:15] R all.vals - expand.grid(x,y, stringsAsFactors=F) R all.vals[1:3,] Var1 Var2 1AJ 2BJ 3CJ R ans - lapply(seq(nrow(all.vals)), function(i) paste(all.vals[i,1], all.vals[i,2], sep='(*)')) R ans[1:3] [[1]] [1] A(*)J [[2]] [1] B(*)J [[3]] [1] C(*)J -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Scatter Plot
please Cc. the list next time Two suggestions, 1) read the help page, e.g. ?points would have told you why pch=10 produces 1. 2) Try the following and see which you prefer, x = y = labels = 1:20 ?text plot(x, y, type='n') # empty plot text(x, y, paste(labels)) library(ggplot2) ?qplot qplot(x, y, geom=text, label=labels) library(lattice) ?xyplot xyplot(y~x, t=n, panel = function(...) { panel.text(..., label= labels) } ) HTH, baptiste 2009/7/31 amna khan amnakhan...@gmail.com: Hi Sir Your suggested code worked only for numbers 1 to 9 remaining points were marked by 1. I want to have numbers 1 to 22 instead of points on scatter plot. Suggest more. Kind Regards On Thu, Jul 30, 2009 at 11:57 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Try this, plot(1:5,1:5, t='p', pch=paste(1:5)) baptiste 2009/7/30 amna khan amnakhan...@gmail.com: Dear Sir I want to write the numbers 1,2,3,on a scatter plot instead of points, like 1 corresponding to first point on plot, 2 corresponding second point etc. Help in this regard. Regards -- AMINA SHAHZADI Department of Statistics GC University Lahore, Pakistan. [[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. -- AMINA SHAHZADI Department of Statistics GC University Lahore, Pakistan. -- _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Tests for Two Independent Samples
On 31-Jul-09 13:38:10, tedzzx wrote: Dear R users, I have got two samples: sample A with observation of 223: sample A has five categories: 1,2,3,4,5 (I use the numer 1,2,3,4,5 to define the five differen categories) there are 5 observations in category 1; 81 observations in category 2;110 observations in category 3; 27 observations in category 4; 0 observations in category 5; To present the sample in R: a-rep(1:5, c(5,81,110,27,0)) sample B with observation of 504: sample B also has the same five categories: 1,2,3,4,5 there are 6 observations in category 1; 127 observations in category 2;297 observations in category 3; 72 observations in category 4; 2 observations in category 5; To present the sample in R: b-rep(1:5, c(6,127,297,72,2)) I want to test weather these two samples have significant difference in distribution ( or Tests for Two Independent Samples). I find a webside in: http://faculty.chass.ncsu.edu/garson/PA765/mann.htm This page shows four nonparametric tests. Bust I can only find the test Kolmogorov-Smirnov Z Test. res-ks.test(a,b) Can any one tell me which package has the other 3 tests? or Is there any other test for my question? Thanks advance Ted If your 1,2,3,4,5 are simply nominal codes for the categories, then you may be satisfied with a Fisher test or simply a chi-squared test (using simulated P-values in view of the low frequencies in some cells). Taking your data: A-c(5,81,110,27,0) B-c(6,127,297,72,2) M-cbind(A,B) D-colSums(M) P-M%*%(diag(1/D)) P #[,1][,2] # [1,] 0.02242152 0.011904762 # [2,] 0.36322870 0.251984127 ## So the main differences between # [3,] 0.49327354 0.589285714 ## A and B are in these two categories # [4,] 0.12107623 0.142857143 # [5,] 0. 0.003968254 fisher.test(M,simulate.p.value = TRUE,B=10) # Fisher's Exact Test for Count Data with simulated p-value # (based on 1e+05 replicates) # data: M # p-value = 0.01594 chisq.test(M,simulate.p.value=TRUE,B=10) # Pearson's Chi-squared test with simulated p-value # (based on 1e+05 replicates) # data: M # X-squared = 11.7862, df = NA, p-value = 0.01501 So the P-values are similar in both tests. (Another) Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 31-Jul-09 Time: 17:53:58 -- 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] Fill dataframe from a table according to a criteria
Your posting arrives as plain text so it is impossible to see what you had highlighed in red. Also it is very difficult to see what is in that data.frame. Could you either reduce the data.frame to make minimal, self-contained, reproducible code. A good approach might be to use dput to create a handy form of the data.frame that a reader can easily use. See ?dput --- On Fri, 7/31/09, Meenu Sahi meenus...@gmail.com wrote: From: Meenu Sahi meenus...@gmail.com Subject: [R] Fill dataframe from a table according to a criteria To: R r-help@r-project.org Received: Friday, July 31, 2009, 12:13 PM Deare R users I am new to R. What I want to do is explained below;- I have table called States.Prob which is given below Prob of States Changes State1 State2 State3 State4 A Pa1 Pa2 Pa3 Pa4 B Pb1 Pb2 Pb3 Pb4 C Pc1 Pc2 Pc3 Pc4 D Pd1 Pd2 Pd3 Pd4 and I have a dataframe called mydata which is given below where I want to fill in the last four columns of probabilities taken from States.Prob according to the change and state in mydata4:- PxMid EU0006MIndex.x DMSW1Curncy.x DMSW2Curncy.x DMSW3Curncy.x 1 01/01/2003 2.80113 2.7070 2.8920 3.1720 2 01/01/2007 3.85350 4.0760 4.1250 4.1230 3 01/02/2002 3.41563 3.6385 4.0810 4.3587 4 01/02/2006 2.7 2.9545 3.1672 3.2792 5 01/05/2002 3.49863 3.7940 4.2300 4.4920 6 01/05/2006 3.03588 3.3254 3.5950 3.7380 DMSW4Curncy.x DMSW5Curncy.x DMSW6Curncy.x DMSW7Curncy.x DMSW8Curncy.x 1 3.4360 3.6640 3.8640 4.0360 4.1790 2 4.1230 4.1250 4.1350 4.1460 4.1620 3 4.5487 4.6988 4.8313 4.9338 5.0138 4 3.3627 3.4342 3.4899 3.5437 3.5941 5 4.7650 4.8675 5.0550 5.1600 5.2400 6 3.8290 3.9050 3.9690 4.0240 4.0750 Change State PState1 PState2 PState3 PState4 1 B State1 Pb1 2 A State4 Pa4 3 B State2 Pb2 4 C State3 Pc3 5 D State1 Pd1 6 A State3 Pa3 What I want to do is highlighted in Red. How can I do this easily? Many thanks for your time. kind regards Meenu [[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. __ Looking for the perfect gift? Give the gift of Flickr! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question regarding sqldf
Your sql statement is using a variable in the having clause that is not in the group by clause. Given that group by is supposed to produce a single output per group we see that this construct is problematic since what should happen in the case that there are two equal maximum values in the same group? Its possible that some databases can support that anyways but I don't think sqlite does. Write your query like this: sqldf(select * from testframe a where a.bext = + (select max(bext) from testframe where a.sdate = sdate)) sdate bext otherstuff stuff 1 day1 94.10626 47.20670 15.340856 2 day2 89.34949 55.36058 19.572773 3 day3 95.72650 52.16694 17.632534 4 day4 95.49586 47.28667 12.676297 5 day5 99.43271 48.98959 3.013745 On Thu, Jul 30, 2009 at 5:30 PM, rizzo.mich...@epamail.epa.gov wrote: Here is a test data frame: testframe-data.frame(sdate=rep(paste (day,1:5,sep=),each=5),bext=runif(25,1,100),otherstuff=runif (25,45,60),stuff=runif(25,3,25)) testframe sdate bext otherstuff stuff 1 day1 37.863859 49.19816 10.036211 2 day1 58.557049 59.23145 21.793954 3 day1 70.345462 48.82313 24.630742 4 day1 1.245913 57.70718 14.131270 5 day1 40.170634 50.38963 21.420328 6 day2 36.126846 51.97043 22.815169 7 day2 95.801896 53.30061 13.540535 8 day2 19.959486 50.46775 9.403084 9 day2 5.772996 55.14082 17.137113 10 day2 77.956966 51.44969 13.448527 11 day3 6.743810 54.49836 17.650795 12 day3 60.758896 55.35407 5.005359 13 day3 86.924873 57.74122 8.691572 14 day3 91.933544 48.17538 8.559737 15 day3 23.627126 59.28906 4.766172 16 day4 76.200158 55.78072 19.493428 17 day4 67.809049 51.06784 7.116428 18 day4 70.309643 54.38067 10.736461 19 day4 91.152166 58.39768 23.199943 20 day4 30.358417 54.16645 24.153823 21 day5 64.064953 58.31813 19.856882 22 day5 49.220106 48.49721 16.615940 23 day5 21.554696 47.03421 3.585458 24 day5 30.227874 55.51724 14.435731 25 day5 51.518716 54.31445 20.837326 If I run the following sqldf statement: maxdays-sqldf(select distinct * from testframe group by sdate having bext=max(bext)) I get: maxdays data frame with 0 columns and 0 rows I want to get the entire observation for each day where bext is the maximum for the day. | | From: | | | |milton ruser milton.ru...@gmail.com | | | | To: | | | |Michael Rizzo/RTP/USEPA/u...@epa | | | | Cc: | | | |r-help@r-project.org | | | | Date: | | | |07/30/2009 03:03 PM | | | | Subject: | | | |Re: [R] Question regarding sqldf | | Hi Rizzi, how about a reproducible example/data.frame? :-) milton On Thu, Jul 30, 2009 at 1:46 PM, rizzo.mich...@epamail.epa.gov wrote: Hello, I am having a problem using sqldf. I'm trying to choose a
Re: [R] function problem
I am sorry I should have stated the whole problem: I appreciate all the help I have received from this list and also not being flamed because I am new to R. Many of my problems are in automation so far. I am trying to create multiple objects that are outputs of functions. Here are the tasks: aGAM-somers2(Pred_pres_a_indpdt[,3,,],population[,23]) aGBM-somers2(Pred_pres_a_indpdt[,4,,],population[,23]) cGLM-somers2(Pred_pres_a_indpdt[,5,,],population[,23]) cRF-somers2(Pred_pres_a_indpdt[,8,,],population[,23]) bGAM-somers2(Pred_pres_b_indpdt[,3,,],population[,24]) bGBM-somers2(Pred_pres_b_indpdt[,4,,],population[,24]) bGLM-somers2(Pred_pres_b_indpdt[,5,,],population[,24]) bRF-somers2(Pred_pres_b_indpdt[,8,,],population[,24]) ...and so on through the letter f. so the variables (x,y,z in this example) are as follows: xGAM-somers2(Pred_pres_x_indpdt[,y,,],population[,z]) the GAM, GBM, GLM, and RF are stored in a column y in Pred_pres_x_indpdt. x is denoting a species, which corresponds to column z in population, so a:f == 23:28 ~~~ This may be pushing it, but it would be great if I could get all of these in a matrix of dim[1,96] Here is what I have so far: x - c(a,b,c,d,e,f) nums - c(23:28) rank-function(x){ for(y in nums){ xGAM-somers2(Pred_pres_x_indpdt[,3,,],population[,y]) xGBM-somers2(Pred_pres_x_indpdt[,4,,],population[,y]) xGLM-somers2(Pred_pres_x_indpdt[,5,,],population[,y]) xRF-somers2(Pred_pres_x_indpdt[,8,,],population[,y]) rank(x) }} #for each species, there is 16 columns of output, so a total of 96 columns is needed x_matrix-matrix(c(xGAM[1:2],Evaluation.results.TSS[[1]][1,3:4],xGBM[1:2],Evaluation.results.TSS[[1]][2,3:4], xGLM[1:2],Evaluation.results.TSS[[1]][3,3:4],xRF[1:2],Evaluation.results.TSS[[1]][4,3:4]), nrow=1,ncol=16, dimnames=list(c(), c(x_gam_AUC, x_gam_Dxy,x_gam_TSS,x_gam_Cutoff,x_gbm_AUC, x_gbm_Dxy,x_gbm_TSS,x_gbm_Cutoff, x_glm_AUC, x_glm_Dxy,x_glm_TSS,x_glm_Cutoff,x_rf_AUC, x_rf_Dxy,x_rf_TSS,x_rf_Cutoff))) Thanks again for helping me out Steve Lianoglou-6 wrote: Hi, On Jul 31, 2009, at 12:25 PM, RR! wrote: I have a series of columns that need to be evaluated in various tables. I need to apply a function in the following manner somers2(name1,name2). name1 is a vector of x inputs for the function which correspond to a vector of y inputs in name2. y-rep(c(3,4,5,8),6) z-rep(c(23,24,25,26,27,28),4) name1-sprintf(Pred_pres_%s_indpdt[,%s,,],x,y) name2-sprintf(population[,%s],z) rank-function(i,j){ for(i in name1){ for(j in name2){ somers2(i,j) }}} You're missing a value for x, so I'm finding it hard to understand what you're trying to do, exactly. From your double for loop, it seems like you just want to compute the function over all vals in X, and each x against all Y. Does this help? R x - LETTERS[1:3] R y - LETTERS[10:15] R all.vals - expand.grid(x,y, stringsAsFactors=F) R all.vals[1:3,] Var1 Var2 1AJ 2BJ 3CJ R ans - lapply(seq(nrow(all.vals)), function(i) paste(all.vals[i,1], all.vals[i,2], sep='(*)')) R ans[1:3] [[1]] [1] A(*)J [[2]] [1] B(*)J [[3]] [1] C(*)J -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/function-problem-tp24759253p24759625.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] xyplot with 2 panels and 2 different x-scales
Hi All, I have this data: type-c(country,country,country,world,world,world) place-c(A,B,C,A,B,C) rank-c(1,3,5,512,420,320) df1-data.frame(type,place,rank) and need to produce an xyplot with 2 panels, where the x-values are labelled: xyplot(place~rank|type, data=df1, panel= function(x, y, ..., subscripts) { panel.xyplot(x,y,..., subscripts) require(grid) panel.grid(h = -1,v = 0, lty=dotted) grid.text(unit(x,native), unit(y,native), label=x, just=center) }) Now as you can see, the range of data is very different for the 2 panels. I'd like to have the x-scales be different in each panel to better visualize this data. http://www.nabble.com/file/p24760060/example1.png -- View this message in context: http://www.nabble.com/xyplot-with-2-panels-and-2-different-x-scales-tp24760060p24760060.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] merging two data frame with colomns of different length
Dear all, I am trying to merge two data frames based on a common column but for this common column both data frame do not have the same length and associated information. I checked previous exemples in the list but was not able to apply them in my case... Is someone know how to do that? Below is my code with the expected result: # data frame 1 Id1 - c(1,1,1,2,2,2,3,3,3) Habit1 - c('a','a','a','b','b','b','d','d','d') Id01 - paste(Id1, Habit1,sep=.) data1 - data.frame(Id01) # data frame 2 Id2 - c(1,2,3,3) Habit2 - c('a','b','d','d') Id02 - paste(Id2, Habit2,sep=.) Area - c(10,2,3,5) data2 - data.frame(cbind(Id02, Area)) # result that I would like Area2 - c(10, 0, 0, 2, 0, 0, 3, 5, 0) result - data.frame(cbind(Id01, Area2)) Thank's -- Julien Beguin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] xyplot with 2 panels and 2 different x-scales
I used the scales relation to obtain different x-scales for each panel. However, there's a gap between the 2 panels. Any ideas on how I could remove it? xyplot(place~rank|type, data=df1, scales=(relation=free), panel= function(x, y, ..., subscripts) { panel.xyplot(x,y,..., subscripts) require(grid) panel.grid(h = -1,v = 0, lty=dotted) grid.text(unit(x,native), unit(y,native), label=x, just=center) }) http://www.nabble.com/file/p24760249/example2.png taz9 wrote: Hi All, I have this data: type-c(country,country,country,world,world,world) place-c(A,B,C,A,B,C) rank-c(1,3,5,512,420,320) df1-data.frame(type,place,rank) and need to produce an xyplot with 2 panels, where the x-values are labelled: xyplot(place~rank|type, data=df1, panel= function(x, y, ..., subscripts) { panel.xyplot(x,y,..., subscripts) require(grid) panel.grid(h = -1,v = 0, lty=dotted) grid.text(unit(x,native), unit(y,native), label=x, just=center) }) Now as you can see, the range of data is very different for the 2 panels. I'd like to have the x-scales be different in each panel to better visualize this data. http://www.nabble.com/file/p24760060/example1.png -- View this message in context: http://www.nabble.com/xyplot-with-2-panels-and-2-different-x-scales-tp24760060p24760249.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] about BRugs package
Hi all, There seems a problem when I was installing this package. This question has been frequently asked but I didn't find any clue to solve it from previous answers and comments. And please forgive me if my question has been really answered before! My system is windows xp and R is 2.7x, when I hit in R install.packages(BRugs) the following warnings are output: Warning in install.packages(BRugs) : argument 'lib' is missing: using '/u/s/h/shang/R/x86_64-unknown-linux-gnu-library/2.8' Warning message: In install.packages(BRugs) : package 'BRugs' is not available And I use require(BRugs) to call it in R, it seems R doesn't find it. Any comments on it will be appreciated! Thanks to all! Zuofeng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] merging two data frame with colomns of different length
I forgot to mention that I tried with merge and join (package analogue) without success... Julien Selon Julien Beguin julien.begui...@ulaval.ca, 31.07.2009: Dear all, I am trying to merge two data frames based on a common column but for this common column both data frame do not have the same length and associated information. I checked previous exemples in the list but was not able to apply them in my case... Is someone know how to do that? Below is my code with the expected result: # data frame 1 Id1 - c(1,1,1,2,2,2,3,3,3) Habit1 - c('a','a','a','b','b','b','d','d','d') Id01 - paste(Id1, Habit1,sep=.) data1 - data.frame(Id01) # data frame 2 Id2 - c(1,2,3,3) Habit2 - c('a','b','d','d') Id02 - paste(Id2, Habit2,sep=.) Area - c(10,2,3,5) data2 - data.frame(cbind(Id02, Area)) # result that I would like Area2 - c(10, 0, 0, 2, 0, 0, 3, 5, 0) result - data.frame(cbind(Id01, Area2)) Thank's -- Julien Beguin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Julien Beguin Etudiant au doctorat Faculté de Foresterie et de Géomatique Université Laval, local 2113 2405 rue de la Terrasse, G1V 0A6 Québec (Qc) Tel: (418) 656-2131 poste 2620 http://www.cen.ulaval.ca/anticosti/jbeguin.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] about BRugs package
Zuofeng Shang wrote: Hi all, There seems a problem when I was installing this package. This question has been frequently asked but I didn't find any clue to solve it from previous answers and comments. And please forgive me if my question has been really answered before! My system is windows xp and R is 2.7x, when I hit in R install.packages(BRugs) the following warnings are output: Warning in install.packages(BRugs) : argument 'lib' is missing: using '/u/s/h/shang/R/x86_64-unknown-linux-gnu-library/2.8' This path is completely unregular if you are on Windows. Is this cygwin? BRugs won't work under Linux environments. Best wishes, Uwe Ligges Warning message: In install.packages(BRugs) : package 'BRugs' is not available And I use require(BRugs) to call it in R, it seems R doesn't find it. Any comments on it will be appreciated! Thanks to all! Zuofeng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] x and y Error Bars
Hi All, I have a question about plotting a one-to-one line and x-and-y error bars on a scatterplot for my data. I just can't seem to work it out! I have data from an experiment with 7 different treatment levels with 3 replicates, that is set-out as follows: Treatment LevelReplicateReponse-weightCovariate-weight 110.9450.232 120.3450.213 130.9450.341 210.9250.122 220.1150.110 231.20 0.27 ... and so on. for the 7 different treatment levels (21 rows altogether) I need to plot the means of each different treatment level on a scatterplot (Response-weight on y-axis and Covariate-weight on x-axis). I then need a one-to-one line added to the plot and x and y error bars. I have read the code for x-and-y error bars in Crawley's R book where he creates a function to apply the error bars - unfortunately, I can not understand how to adapt it to my dataset so I'm hoping someone would advise me of the simplest way to do this. So my questions are: 1) How do I plot x-and-y error bars to my scatterplot of the above data? 2) How do I add a one-to-one line? Thank you - please let me know if I should provide anymore information. 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] xyplot with 2 panels and 2 different x-scales
Hi, you want only the x scale to be free, xyplot(place~rank|type, data=df1, panel= function(x, y, ..., subscripts) { panel.xyplot(x,y,..., subscripts) require(grid) panel.grid(h = -1,v = 0, lty=dotted) grid.text(unit(x,native), unit(y,native), label=x, just=center) }, scales = list(x=list(relation=free))) HTH, baptiste 2009/7/31 taz9 alienz...@gmail.com: I used the scales relation to obtain different x-scales for each panel. However, there's a gap between the 2 panels. Any ideas on how I could remove it? xyplot(place~rank|type, data=df1, scales=(relation=free), panel= function(x, y, ..., subscripts) { panel.xyplot(x,y,..., subscripts) require(grid) panel.grid(h = -1,v = 0, lty=dotted) grid.text(unit(x,native), unit(y,native), label=x, just=center) }) http://www.nabble.com/file/p24760249/example2.png taz9 wrote: Hi All, I have this data: type-c(country,country,country,world,world,world) place-c(A,B,C,A,B,C) rank-c(1,3,5,512,420,320) df1-data.frame(type,place,rank) and need to produce an xyplot with 2 panels, where the x-values are labelled: xyplot(place~rank|type, data=df1, panel= function(x, y, ..., subscripts) { panel.xyplot(x,y,..., subscripts) require(grid) panel.grid(h = -1,v = 0, lty=dotted) grid.text(unit(x,native), unit(y,native), label=x, just=center) }) Now as you can see, the range of data is very different for the 2 panels. I'd like to have the x-scales be different in each panel to better visualize this data. http://www.nabble.com/file/p24760060/example1.png -- View this message in context: http://www.nabble.com/xyplot-with-2-panels-and-2-different-x-scales-tp24760060p24760249.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. -- _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Displaying function arguments using a Windows R console
I am relatively new to R, and would appreciate any suggestions you may have. I noticed on a Mac the functions' arguments are listed at the bottom of the R console. Is it possible to add such a feature to a Windows R console? I have Windows XP if that helps. I know function arguments can be found using args(...), but I was wanting to have something more automatic, like what I saw on the Mac computer. I went into GUI preferences, but was not sure what to do. I noticed for graphics, the playwith package can be usedI was wondering if there was something similar to this for the arguments of functions in R. Thank you, Laura __ [[elided Yahoo spam]] [[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] Creating a column based on data in another column
hello all, I have a data frame and I want to create a column which assigns a letter based upon the value in another column. The data column has velocities ranging from 0 to 1000. So for example, for velocities between 0 and 300 I'd like to assign the letter A in the new column, for 300-600, B and so on and so forth. How would I do this? Thank you very much! Mehdi Khan [[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] x and y Error Bars
Sarah B wrote: Hi All, I have a question about plotting a one-to-one line and x-and-y error bars on a scatterplot for my data. I just can't seem to work it out! I have data from an experiment with 7 different treatment levels with 3 replicates, that is set-out as follows: Treatment LevelReplicateReponse-weightCovariate-weight 110.945 0.232 120.345 0.213 130.945 0.341 210.925 0.122 220.115 0.110 231.20 0.27 ... and so on. for the 7 different treatment levels (21 rows altogether) I need to plot the means of each different treatment level on a scatterplot (Response-weight on y-axis and Covariate-weight on x-axis). I then need a one-to-one line added to the plot and x and y error bars. I have read the code for x-and-y error bars in Crawley's R book where he creates a function to apply the error bars - unfortunately, I can not understand how to adapt it to my dataset so I'm hoping someone would advise me of the simplest way to do this. So my questions are: 1) How do I plot x-and-y error bars to my scatterplot of the above data? 2) How do I add a one-to-one line? You can use something like attach(mydata) y.means = tapply(response,list(treatment),mean) y.sd = tapply(response,list(treatment),sd) y.se = y.sd/sqrt(3) ## since you know the numbers per treatment x.means = tapply(covariate,list(treatment),mean) ## etc. library(plotrix) plotCI(x.means,y.means,2*y.se) plotCI(x.means,y.means,2*x.se,add=TRUE,err=x) abline(a=0,b=1) ## 1 to 1 line -- View this message in context: http://www.nabble.com/x-and-y-Error-Bars-tp24760985p24761648.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] Creating a column based on data in another column
Dear Medhi, Take a look at ?cut or ?recode (in the car package). HTH, Jorge On Fri, Jul 31, 2009 at 3:04 PM, Mehdi Khan wrote: hello all, I have a data frame and I want to create a column which assigns a letter based upon the value in another column. The data column has velocities ranging from 0 to 1000. So for example, for velocities between 0 and 300 I'd like to assign the letter A in the new column, for 300-600, B and so on and so forth. How would I do this? Thank you very much! Mehdi Khan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Getting file name from pdf device?
Rainer M Krug-6 wrote: Hi IU would like to modify the dev.off function, so that it automatically compresses the created pdf. I am thinking of doing the following in the modified dev.off: 1) Get the filename of the pdf device 2) close the device by calling the original dev.off() 3) compress the pdf file with a system call of pdftk. If you are the one who initiated the pdf device shouldn't you know the name of the file? in that case just do something like: my.dev.off - function (file, which = dev.cur()) { if (which == 1) stop(cannot shut down device 1 (the null device)) .Internal(dev.off(as.integer(which))) #system call (or something similar) system(paste('pdftk',file)) dev.cur() } fn - 'myplot.pdf' pdf(fn) #plot stuff my.dev.off(fn) -Cameron -- View this message in context: http://www.nabble.com/Getting-file-name-from-pdf-device--tp24755915p24761759.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] Creating a column based on data in another column
have a look at ?cut(); for instance, x - sample(1000, 20, TRUE) x cut(x, c(0, 300, 600, 1000), c(A, B, C)) I hope it helps. Best, Dimitris Mehdi Khan wrote: hello all, I have a data frame and I want to create a column which assigns a letter based upon the value in another column. The data column has velocities ranging from 0 to 1000. So for example, for velocities between 0 and 300 I'd like to assign the letter A in the new column, for 300-600, B and so on and so forth. How would I do this? Thank you very much! Mehdi Khan [[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. -- 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] Creating a column based on data in another column
Try this: cut(sample(0:1000, 100), breaks = c(0, 300, 600, 900, 1000), labels = c('A', 'B', 'C', 'D')) On Fri, Jul 31, 2009 at 4:04 PM, Mehdi Khan mwk...@ucdavis.edu wrote: hello all, I have a data frame and I want to create a column which assigns a letter based upon the value in another column. The data column has velocities ranging from 0 to 1000. So for example, for velocities between 0 and 300 I'd like to assign the letter A in the new column, for 300-600, B and so on and so forth. How would I do this? Thank you very much! Mehdi Khan [[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] automation question
I have columns in two tables that need to be compared in order to get a statistic. The function calculating the statistic is somers2. Here are the two columns I must calculate, row by row. name1 name2 1 Pred_pres_a_indpdt[,3,,] population[,23] 2 Pred_pres_b_indpdt[,3,,] population[,24] 3 Pred_pres_c_indpdt[,3,,] population[,25] 4 Pred_pres_d_indpdt[,3,,] population[,26] 5 Pred_pres_e_indpdt[,3,,] population[,27] 6 Pred_pres_f_indpdt[,3,,] population[,28] 7 Pred_pres_a_indpdt[,4,,] population[,23] 8 Pred_pres_b_indpdt[,4,,] population[,24] 9 Pred_pres_c_indpdt[,4,,] population[,25] 10 Pred_pres_d_indpdt[,4,,] population[,26] 11 Pred_pres_e_indpdt[,4,,] population[,27] 12 Pred_pres_f_indpdt[,4,,] population[,28] 13 Pred_pres_a_indpdt[,5,,] population[,23] 14 Pred_pres_b_indpdt[,5,,] population[,24] 15 Pred_pres_c_indpdt[,5,,] population[,25] 16 Pred_pres_d_indpdt[,5,,] population[,26] 17 Pred_pres_e_indpdt[,5,,] population[,27] 18 Pred_pres_f_indpdt[,5,,] population[,28] 19 Pred_pres_a_indpdt[,8,,] population[,23] 20 Pred_pres_b_indpdt[,8,,] population[,24] 21 Pred_pres_c_indpdt[,8,,] population[,25] 22 Pred_pres_d_indpdt[,8,,] population[,26] 23 Pred_pres_e_indpdt[,8,,] population[,27] 24 Pred_pres_f_indpdt[,8,,] population[,28] the somers2 function works like this: somers2(x, y) for example: somers2(Pred_pres_a_indpdt[,3,,], population[,23]) so somers2 is calculated for each row, with column 1 as x, column 2 as y. Is there anyway to automate this? -R -- View this message in context: http://www.nabble.com/automation-question-tp24761918p24761918.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] merging two data frame with colomns of different length
Salut Julien, t1 - table(data1$Id01) t2 - table(data2$Id02) # compute difference between the two tables diff - t1-t2 # create your data frame from data2 res - data2 names(res)[1] - Id01 lsAdd - rep(attributes(diff)$dimnames[[1]],diff) defVal - NA rbind(res,data.frame(Id01 =lsAdd, Area=defVal)) Julien Beguin wrote: Dear all, I am trying to merge two data frames based on a common column but for this common column both data frame do not have the same length and associated information. I checked previous exemples in the list but was not able to apply them in my case... Is someone know how to do that? Below is my code with the expected result: # data frame 1 Id1 - c(1,1,1,2,2,2,3,3,3) Habit1 - c('a','a','a','b','b','b','d','d','d') Id01 - paste(Id1, Habit1,sep=.) data1 - data.frame(Id01) # data frame 2 Id2 - c(1,2,3,3) Habit2 - c('a','b','d','d') Id02 - paste(Id2, Habit2,sep=.) Area - c(10,2,3,5) data2 - data.frame(cbind(Id02, Area)) # result that I would like Area2 - c(10, 0, 0, 2, 0, 0, 3, 5, 0) result - data.frame(cbind(Id01, Area2)) Thank's -- Julien Beguin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/merging-two-data-frame-with-colomns-of-different-length-tp24760153p24761975.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] merging two data frame with colomns of different length
Try this: merge(transform(data1, .Id01 = ave(as.character(Id01), Id01, FUN=seq)), transform(data2, .Id02 = ave(as.character(Id02), Id02, FUN=seq)), by.x = c('Id01', '.Id01'), by.y = c('Id02', '.Id02'), all = TRUE) On Fri, Jul 31, 2009 at 3:05 PM, Julien Beguin julien.begui...@ulaval.cawrote: I forgot to mention that I tried with merge and join (package analogue) without success... Julien Selon Julien Beguin julien.begui...@ulaval.ca, 31.07.2009: Dear all, I am trying to merge two data frames based on a common column but for this common column both data frame do not have the same length and associated information. I checked previous exemples in the list but was not able to apply them in my case... Is someone know how to do that? Below is my code with the expected result: # data frame 1 Id1 - c(1,1,1,2,2,2,3,3,3) Habit1 - c('a','a','a','b','b','b','d','d','d') Id01 - paste(Id1, Habit1,sep=.) data1 - data.frame(Id01) # data frame 2 Id2 - c(1,2,3,3) Habit2 - c('a','b','d','d') Id02 - paste(Id2, Habit2,sep=.) Area - c(10,2,3,5) data2 - data.frame(cbind(Id02, Area)) # result that I would like Area2 - c(10, 0, 0, 2, 0, 0, 3, 5, 0) result - data.frame(cbind(Id01, Area2)) Thank's -- Julien Beguin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Julien Beguin Etudiant au doctorat Faculté de Foresterie et de Géomatique Université Laval, local 2113 2405 rue de la Terrasse, G1V 0A6 Québec (Qc) Tel: (418) 656-2131 poste 2620 http://www.cen.ulaval.ca/anticosti/jbeguin.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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] scale subset of data
Hi, This should be an easy one, but I have some trouble formatting the data right I'm trying to replace the column of a subset of a dataframe with the scaled data for that column of the subset subset(rawdata, code== foo, select = a) - scale( subset(rawdata, code== foo, select = a) ) It returns: could not find function subset- The scale command works individually and the subset command works individually. Can someone help me format this command line correctly? Thanks, -N [[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] automation question
look at the apply family of functions and look at the MARGIN argument. On Fri, Jul 31, 2009 at 2:30 PM, RR!cwal...@usgs.gov wrote: I have columns in two tables that need to be compared in order to get a statistic. The function calculating the statistic is somers2. Here are the two columns I must calculate, row by row. name1 name2 1 Pred_pres_a_indpdt[,3,,] population[,23] 2 Pred_pres_b_indpdt[,3,,] population[,24] 3 Pred_pres_c_indpdt[,3,,] population[,25] 4 Pred_pres_d_indpdt[,3,,] population[,26] 5 Pred_pres_e_indpdt[,3,,] population[,27] 6 Pred_pres_f_indpdt[,3,,] population[,28] 7 Pred_pres_a_indpdt[,4,,] population[,23] 8 Pred_pres_b_indpdt[,4,,] population[,24] 9 Pred_pres_c_indpdt[,4,,] population[,25] 10 Pred_pres_d_indpdt[,4,,] population[,26] 11 Pred_pres_e_indpdt[,4,,] population[,27] 12 Pred_pres_f_indpdt[,4,,] population[,28] 13 Pred_pres_a_indpdt[,5,,] population[,23] 14 Pred_pres_b_indpdt[,5,,] population[,24] 15 Pred_pres_c_indpdt[,5,,] population[,25] 16 Pred_pres_d_indpdt[,5,,] population[,26] 17 Pred_pres_e_indpdt[,5,,] population[,27] 18 Pred_pres_f_indpdt[,5,,] population[,28] 19 Pred_pres_a_indpdt[,8,,] population[,23] 20 Pred_pres_b_indpdt[,8,,] population[,24] 21 Pred_pres_c_indpdt[,8,,] population[,25] 22 Pred_pres_d_indpdt[,8,,] population[,26] 23 Pred_pres_e_indpdt[,8,,] population[,27] 24 Pred_pres_f_indpdt[,8,,] population[,28] the somers2 function works like this: somers2(x, y) for example: somers2(Pred_pres_a_indpdt[,3,,], population[,23]) so somers2 is calculated for each row, with column 1 as x, column 2 as y. Is there anyway to automate this? -R -- View this message in context: http://www.nabble.com/automation-question-tp24761918p24761918.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 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] scale subset of data
Hi, On Jul 31, 2009, at 4:13 PM, Noah Silverman wrote: Hi, This should be an easy one, but I have some trouble formatting the data right I'm trying to replace the column of a subset of a dataframe with the scaled data for that column of the subset subset(rawdata, code== foo, select = a) - scale( subset(rawdata, code== foo, select = a) ) It returns: could not find function subset- The scale command works individually and the subset command works individually. Can someone help me format this command line correctly? How about: rawdata[rawdata$code=='foo', 'a'] - scale(rawdata[rawdata $code=='foo', 'a']) -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.