[R] Odp: how to calculate the product of every two elements in two vectors
Hi r-help-boun...@r-project.org napsal dne 23.07.2010 17:11:43: Thanks in advance! A=c(1, 2,3) B=c (9, 10, 11, 12) I want to get C=c(1*9, 1*10, 1*11, 1*12, ., 3*9, 3*10, 3*11, 3*12)? C is still a vector with 12 elements Is there a way to do that? Maybe as.vector(t(outer(A,B))) Regards Petr -- View this message in context: http://r.789695.n4.nabble.com/how-to-calculate- the-product-of-every-two-elements-in-two-vectors-tp2300299p2300299.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Odp: Help me with prediction in linear model
Hi r-help-boun...@r-project.org napsal dne 24.07.2010 11:48:11: Thanks Murphy and pikal, I need another help,for fitting first fourier transformation ,i used following thing .Please advise on this beer_monthl has 400+ records EXample: head(beer_monthly) beer 1 93.2 2 96.0 3 95.2 4 77.1 5 70.9 6 64.8 time-seq(1956,1995.2,length=length(beer_monthly)) Even this is not working time-seq(1956,1995.2,length=length(beer_monthly)) Error in seq.default(1956, 1995.2, length = length(beer_monthly)) : object 'beer_monthly' not found sin.t-sin(2*pi*time) cos.t-cos(2*pi*time) beer_fit_fourier=lm(beer_monthly[,1]~poly(time,2)+sin.t+cos.t) #this is not working gives me result without error beer_fit_fourier=lm(beer_monthly[,1]~time+time2+sin.t+cos.t) #it is working #prediction is not workinng tpred_four - data.frame(time = seq(1995, 1998, length = 20)) predict(beer_fit_fourier, newdata = tpred_four) You'd rather read some documentation about lm and predict. You do not have variables sin.t and cos.t in your newdata. Please do read docs, posting guide and provide reproducible example. Is there any way to fit first fourier frequency , Please assist. Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/Help-me-with- prediction-in-linear-model-tp2297313p2300991.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package for rank ordered logit
zachmohr wrote: You may want to try a multinomial logit, mlogit{mlogit}. Hope this helps. Please do not guess (Tal too) if you don't know the answer, you'll be Googled forever... The question is about something like Stata's rologit, which is a rather different beast. -pd On Fri, Jul 16, 2010 at 11:42 AM, Suresh Singh-2 [via R] ml-node+2291644-2038081369-246...@n4.nabble.comml-node%2b2291644-2038081369-246...@n4.nabble.com wrote: My understanding is that polr will do ordered logit but I am not sure if it is also suited for rank ordered logit (or is there no such distinction) I am thinking of following two situations 1. there is an ordered response (say small,medium,large coffee) and each individual selects one of these options. the order is predetermined i.e we know which one is small, medium or large and interested in knowing which option is selected. in this case each choice is independent because different individuals choose them 2. an individual ranks some or all the options (say three different types of coffee). We do not know apriori what the order is beforehand - these ranks are dependent because the same individual selects them I am calling the 1st situation - ordered logit and 2nd situation - rank ordered logit. Are these equivalent situations and is polr suited for both? Suresh On Fri, Jul 16, 2010 at 11:41 AM, Tal Galili [hidden email]http://user/SendEmail.jtp?type=nodenode=2291644i=0 wrote: Did you try: library(MASS) ?polr ? Contact Details:--- Contact me: [hidden email]http://user/SendEmail.jtp?type=nodenode=2291644i=1| 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Fri, Jul 16, 2010 at 6:15 PM, Suresh Singh [hidden email]http://user/SendEmail.jtp?type=nodenode=2291644i=2 wrote: Is there a package in R that can run rank-ordered logit? Thanks, Suresh __ [hidden email] http://user/SendEmail.jtp?type=nodenode=2291644i=3mailing list https://stat.ethz.ch/mailman/listinfo/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]] __ [hidden email] http://user/SendEmail.jtp?type=nodenode=2291644i=4mailing list https://stat.ethz.ch/mailman/listinfo/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 message @ http://r.789695.n4.nabble.com/package-for-rank-ordered-logit-tp2291526p2291644.html To unsubscribe from R, click here (link removed) ==. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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] Question regarding panel data diagnostic
Dear Lexi, Thanks a lot for your prompt answers, The issue i'm confronted to is the following: i have a panel data N=17 T=5 (annual observations) and wanted to check for stationarity to avoid a spurious regression, but the question is do i' have the right do do so??? it's statistically correct? if no is there any alternative method to verify if our regression is correct? Thanks again Ama == Dear Ama, I copy my reply to the list, in case someone needs it. Spurious regression occurs when correlation between time series variables results from their common trends - the variables tend to move together over some cycle. However, it may difficult to decipher whether or not the variables in your model have significant trends; also trends differ (see Enders 1995 Time Series Econometrics). So to deal with this, you must perform formal integration tests. If the variables have unit root (ie, non-stationary) then you cannot model the variables in their levels. You must transform them by appropriate differencing. Then you can model using a dynamic model or error-correction model (ecm) (if the variables are cointegrated). Use of ecm makes sense only if the time span of your data is long enough - it is a long run concept. Long enough depends on the phenomenon under study. If theory suggests that equilibrium could occur within the time span of your data (17 years in your case - this is long enough in most cases), then concepts of cointegration and ecm are relevant. Hope this helps. Lexi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Setlhare Lekgatlhamang Sent: Saturday, July 24, 2010 1:01 PM To: amatoallah ouchen; r-help@r-project.org Subject: Re: [R] Question regarding panel data diagnostic Let me correct an omission in my response below. The last sentence should read But if the data are 10 quarterly or monthly values, these techniques are not relevant. Cheers Lexi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Setlhare Lekgatlhamang Sent: Saturday, July 24, 2010 12:54 PM To: amatoallah ouchen; r-help@r-project.org Subject: Re: [R] Question regarding panel data diagnostic My thought is this: It depends on what you have in the panel. Are your data cross-section data observed over ten years for, say, 3 countries (or regions within the same country)? If so, yes you can perform integration properties (what people usually call unit root test) and then test for cointegration. But if the data are quarterly or monthly, these techniques are not relevant. Hope this helps. Lexi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of amatoallah ouchen Sent: Friday, July 23, 2010 12:18 AM To: r-help@r-project.org Subject: [R] Question regarding panel data diagnostic Good day R-listers, I'm currently working on a panel data analysis (N=17, T=5), in order to check for the spurious regression problem, i have to test for stationarity but i've read somewhere that i needn't to test for it as my T10 , what do you think? if yes is there any other test i have to perform in such case (a kind of cointegration test for small T?) Any hint would be highly appreciated. Ama. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. DISCLAIMER:\ Sample Disclaimer added in a VBScript.\\ .{{dropped:15}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Creating a map .
Hello. I would try to explain what I would like to implement so to suggest me what to try out. I would like to create an area of X*X km that would be used to Simulate an area map (eg. city's area, suburban area). -X would be a parameter so I do not want it to be fixed -In this map I would like to place users (people), thus I do not know in advance if in one place there would be one,two, or more users.. -I would also like to not have fixed resolution in my map and specify it as a parameter during run-time. In my X*X area I would like sometimes to have resolution of 1Km and others resolution of 10 meters. As resolution increases (1 km-100m-10m) less users would be found in the same place. -In every place I would like to specify some parameters (eg. number of users, characteristics of users, energy consumption per user). I do not know in advance how much data I would need per user. Ofc 10 parameters per place might be ok but a not fixed approach is better. My first thoughts were to use an array and actually define an array of X*X dimension where X is defined at run time as parameter. The problem with this approach is that I do not have variable resolution in this area as I have the constant number of X*X places only. Also one more problem is that the cels of the array (where cell is used to simulate place) can not be used to story many parameters but only a single numerical value). What do you suggest me to try looking at and what made up your decision? I would like to thank everyone that reached to this point reading all my big text. Best Regards Alex. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 panel data diagnostic
Oops, I misread your email in respect of the number of years you have for your data. Anyways, my comments still hold. Lexi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Setlhare Lekgatlhamang Sent: Monday, July 26, 2010 8:59 AM To: amatoallah ouchen; r-help@r-project.org Subject: Re: [R] Question regarding panel data diagnostic Dear Lexi, Thanks a lot for your prompt answers, The issue i'm confronted to is the following: i have a panel data N=17 T=5 (annual observations) and wanted to check for stationarity to avoid a spurious regression, but the question is do i' have the right do do so??? it's statistically correct? if no is there any alternative method to verify if our regression is correct? Thanks again Ama == Dear Ama, I copy my reply to the list, in case someone needs it. Spurious regression occurs when correlation between time series variables results from their common trends - the variables tend to move together over some cycle. However, it may difficult to decipher whether or not the variables in your model have significant trends; also trends differ (see Enders 1995 Time Series Econometrics). So to deal with this, you must perform formal integration tests. If the variables have unit root (ie, non-stationary) then you cannot model the variables in their levels. You must transform them by appropriate differencing. Then you can model using a dynamic model or error-correction model (ecm) (if the variables are cointegrated). Use of ecm makes sense only if the time span of your data is long enough - it is a long run concept. Long enough depends on the phenomenon under study. If theory suggests that equilibrium could occur within the time span of your data (17 years in your case - this is long enough in most cases), then concepts of cointegration and ecm are relevant. Hope this helps. Lexi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Setlhare Lekgatlhamang Sent: Saturday, July 24, 2010 1:01 PM To: amatoallah ouchen; r-help@r-project.org Subject: Re: [R] Question regarding panel data diagnostic Let me correct an omission in my response below. The last sentence should read But if the data are 10 quarterly or monthly values, these techniques are not relevant. Cheers Lexi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Setlhare Lekgatlhamang Sent: Saturday, July 24, 2010 12:54 PM To: amatoallah ouchen; r-help@r-project.org Subject: Re: [R] Question regarding panel data diagnostic My thought is this: It depends on what you have in the panel. Are your data cross-section data observed over ten years for, say, 3 countries (or regions within the same country)? If so, yes you can perform integration properties (what people usually call unit root test) and then test for cointegration. But if the data are quarterly or monthly, these techniques are not relevant. Hope this helps. Lexi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of amatoallah ouchen Sent: Friday, July 23, 2010 12:18 AM To: r-help@r-project.org Subject: [R] Question regarding panel data diagnostic Good day R-listers, I'm currently working on a panel data analysis (N=17, T=5), in order to check for the spurious regression problem, i have to test for stationarity but i've read somewhere that i needn't to test for it as my T10 , what do you think? if yes is there any other test i have to perform in such case (a kind of cointegration test for small T?) Any hint would be highly appreciated. Ama. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. DISCLAIMER:\ Sample Disclaimer added in a VBScript.\\\ {{dropped:15}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SQL/R
see the manual from package sqldf: http://cran.r-project.org/web/packages/sqldf/sqldf.pdf Bart -- View this message in context: http://r.789695.n4.nabble.com/SQL-R-tp2298545p2301975.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] data arranged by p-values
Have a look at ?cumsum. Apply that on a true/false vector (p-value 0.05) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics 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 jd6688 Verzonden: maandag 26 juli 2010 7:07 Aan: r-help@r-project.org Onderwerp: [R] data arranged by p-values Idcat1locationitem_values p-values sequence a111 1 3002737 0.196504377 0.011 a112 1 3017821 0.196504377 0.052 a113 1 3027730 0.196504377 0.023 a114 1 3036220 0.196504377 0.044 a115 1 3053984 0.196504377 0.035 a116 1 3063892 0.196504377 0.076 a117 1 3076333 0.196504377 0.087 a118 1 3090500 0.196504377 0.028 a119 1 3103304 0.196504377 0.039 a120 1 3119350 0.196504377 0.0510 a121 1 3129884 0.196504377 0.0111 a122 1 3154598 0.196504377 0.0312 a123 1 3170910 0.196504377 0.0513 a124 1 3180712 0.196504377 0.0614 a125 1 3186519 0.196504377 0.0715 a126 1 3192256 0.196504377 0.0916 a127 1 3198441 0.196504377 0.0117 a128 1 3205784 0.196504377 0.0218 a129 1 3210685 0.196504377 0.0319 a130 1 3218542 0.196504377 0.0420 a131 1 3234318 0.196504377 0.0521 a132 1 3239972 0.196504377 0.0922 a133 1 3245663 0.196504377 0.0523 a134 1 3257997 0.196504377 0.0224 a135 1 3273226 0.196504377 0.0326 a136 1 3285404 0.196504377 0.0427 a137 1 3290332 0.196504377 0.0528 a138 1 3300679 0.196504377 0.0329 a139 1 3310164 0.196504377 0.0930 first of all, please pay attention to the P -values, all the rows with the p-value 0.05 will be considered as one region until the p-value 0.05 identified. for instance: REGION 1 is the rows from id a111 to id A115 . REGION 2 is the rows from id a118 to a123, etc. what i am going to accomplish is to pick the start and end location, and the peak value from the item_values for each region. option 1: loop through each row until the p-value0.05 identified then start_location=the first location value end_location=the location value before the p0.05 peak_value of the item_values=the maximum one option 2 create a sequence number for each row; subset the raw dataframe by p0.05; the p-value regions will be identified by the gapped sequence number. for instance from sequence 1 to 5 will be considering one region. Id cat1locationitem_values p-values sequence a111 1 3002737 0.196504377 0.011 a112 1 3017821 0.196504377 0.052 a113 1 3027730 0.196504377 0.023 a114 1 3036220 0.196504377 0.044 a115 1 3053984 0.196504377 0.035 a118 1 3090500 0.196504377 0.028 a119 1 3103304 0.196504377 0.039 I need your recommendation on the different approach to implement this? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/data-arranged-by-p-values-tp2301 909p2301909.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. Druk dit bericht a.u.b. niet onnodig af. Please do not print this message unnecessarily. 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
Re: [R] vectorisation?
have a look at function rollapply() from package zoo. I hope it helps. Best, Dimitris On 7/26/2010 8:28 AM, Raghu wrote: Hi I have 3500 rows of data (say a single column) in a vector. If I want to compare every ith element with the simple average of the previous (i-5) elements, then I could write something like this: for(i in 6:NROW(data)){ if(data[i] = mean(data[(i-5):i]) (counter[i]=1)} } Is it possible to replicate the above faster in R? -- 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] After writing data in MMF using SEXP structure, can i reference in R?
Hi all, After writing data in MMF(Memory Map File) using SEXP structure, can i reference in R? If input data is larger than 2GB, Can i reference MMF Data in R? my work environment : R version : 2.11.1 OS : WinXP Pro sp3 Thanks and best regards. Park, Young-Ju from Korea. [1][rKWLzcpt.zNp8gmPEwGJCA00] [...@from=dllmainrcpt=r%2Dhelp%40r%2Dproject%2Eorgmsgid=%3C20100726173212%2EH M%2E0bk%40dllmain%2Ewwl737%2Ehanmail%2Enet%3E] References 1. mailto:dllm...@hanmail.net __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] vectorisation?
Hi I have 3500 rows of data (say a single column) in a vector. If I want to compare every ith element with the simple average of the previous (i-5) elements, then I could write something like this: for(i in 6:NROW(data)){ if(data[i] = mean(data[(i-5):i]) (counter[i]=1)} } Is it possible to replicate the above faster in R? -- 'Raghu' [[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] Creating a map .
raster package may be what you're looking for. -- View this message in context: http://r.789695.n4.nabble.com/Creating-a-map-tp2301972p2302053.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] Mask grid in R
raster package can do that. see ?polygonsToRaster and the vignettes of the same package. -- View this message in context: http://r.789695.n4.nabble.com/Mask-grid-in-R-tp2301703p2302057.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] decision tree with weighted inputs
Hi, In the R-Help history there have been similar questions to yours. As a starting point you can check this: http://tolstoy.newcastle.edu.au/R/e2/help/07/01/9138.html Regrads, Carlos. On Thu, Jul 22, 2010 at 6:37 PM, David Shin ds...@jumptrading.com wrote: I'd like to train a decision tree on a set of weighted data points. I looked into the rpart package, which builds trees but doesn't seem to offer the capability of weighting inputs. (There is a weights parameter, but it seems to correspond to output classes rather than to input points). I'm making do for now by preprocessing my input data by adding multiple instances of each data point corresponding to its weight before feeding to rpart. But I worry this tricks the cross-validation phase of the rpart building process into thinking a model generalizes better than it really does. This is because a heavily-weighted point can be included in both the training and testing set of a cross validation split. Is there a better way to achieve my goal? Note: This email is for the confidential use of the named addressee(s) only and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you are hereby notified that any review, dissemination or copying of this email is strictly prohibited, and to please notify the sender immediately and destroy this email and any attachments. Email transmission cannot be guaranteed to be secure or error-free. Jump Trading, therefore, does not make any guarantees as to the completeness or accuracy of this email or any attachments. This email is for informational purposes only and does not constitute a recommendation, offer, request or solicitation of any kind to buy, sell, subscribe, redeem or perform any type of transaction of a financial product. [[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] Marginal effects from interaction regression model
On Jul 25, 2010, at 11:47 PM, Guillem R. wrote: As far as I know, the predict command gives the predicted values (and intervals) of y, but what I'm looking for is the conditional effects (betas) of x on y conditional on values of z. If you want the betas, then simply print the object. Don't for get the default parameterization is for treatment effects. I'm trying to produce a plot similar to the first shown in this link: http://homepages.nyu.edu/~mrg217/interaction.html#code If you want to provide an example ...and a more complete description of the desire output, I sure someone here can finish the job of showing you how setting up a call to predict will get you to that goal. -- David. Thanks again David Winsemius wrote: On Jul 25, 2010, at 10:24 PM, Guillem R. wrote: Dear all, I'd like to plot the marginal effect of a variable in a multiplicative interaction regression, that is, the effect of a variable conditional on the values of another variable. As an illustration, given model lm1 lm1 - lm(y ~ x*z) ? predict Perhaps: predict(lm1, newdata=data.frame(x=1:10, z=5), interval=confidence) I'd like to get the effects of x on y conditional on the values of z, with the corresponding confidence intervals if possible. Does anyone know of any package or simple way to do this? Thanks -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://r.789695.n4.nabble.com/Marginal-effects-from-interaction-regression-model-tp2301858p2301884.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Manage several graphical devices in interactive mode
Thanks Duncan and Ted, That will be tremendously helpful to me. In combination with the width/height and xpos/ypos arguments, I think I'll be able to create this matrix of devices I am looking for. Thanks again Sebastien On Sun, Jul 25, 2010 at 12:07 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 25/07/2010 10:03 AM, (Ted Harding) wrote: On 25-Jul-10 13:22:11, Sébastien Bihorel wrote: Dear R-users, Does anybody know a good way to create and use several graphical devices at the same time in interactive mode? Ideally, I'd like to open 2 to 3 devices and assign names to them. This way, I could make any addition/modification/update to a particular device using its name. I did not see anything like a name argument in ?X11. Is there an alternative? Thanks in advance for your feeback. Sebastien You can certainly do this by hand. The basic R terminal is device number 1. If you do X11() (or invoke it implicitly by using a 'plot' command) this will be device number 2. With just this one open, any 'plot' (or plot-related) commands will re-use it. However, having opened device #2, you can do X11() again and get a second graphics device which will be number 3. And so on, for as many additional devices as you like. By default, the device that the results of any 'plot' command are sent to will be the most recently opened one. However, you can select the device using the command dev.set(n) where n ( = 2,3,... ) is the device you want to use. The device which is active will be shown by the word (ACTIVE) attached to its display. All other devices will show (inactive). You could name your devices by indexing a vector (2:n) by names. Try the following, Starting with no graphics devices open: X11() # dev 2 X11() # dev 3 X11() # dev 4 ## This one is currently active That's the right idea, but I wouldn't count on the numbers coming out 2, 3, 4: what if another device was already opened? Better to use dev.cur() just after you open a new device to find out what its number was. So do something like X11() plotA - dev.cur() X11() plotB - dev.cur() X11() plotC - dev.cur() dev.set(plotA) # first one is active etc. Duncan Murdoch ## Arange these so that you can see all their top bars devN - c(plotA=2,plotB=3,plotC=4) dev.set(devN[plotA]) # dev 2 is active dev.set(devN[plotC]) # dev 4 is active dev.set(devN[plotB]) # dev 3 is active dev.set(devN[plotA]) # dev 2 is active dev.set(devN[plotC]) # dev 4 is active Hoping this helps, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 25-Jul-10 Time: 15:03:14 -- 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. [[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] Plot of a subset of a data.frame()
Hello, my data.frame is sort of a collection of process values, i.e. huge run-chart. It consists of a time-stamp in the first column (date as string), factors in the following columns (used for subset-filtering), and some process-data columns. Hereafter, two examples are listed, showing the problems that occour during print: At first the example, that works fine: ~~ a = c(1:10) # create a vector of integers b = rep(c(a,b),5) # create a vector of chars, used # as factor-levels d = rnorm(10) # some random numbers e = data.frame(a,b,d) # connect to a data.frame e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) # plot first data-subset points(d~a, e.2, pch=4, col=3) # plot the 2nd one ~~ all looks fine in theses plots. However, changing the content of vector a to a set of strings the following happens: ~~ a = c(a,b,c,d,e,f,g,h,i,j) e = data.frame(a,b,d) # re-build data.frame e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) points(d~a, e.2, pch=4, col=3) ~~ The plot-command produces horizontal lines instead of dots. This seems to happen when the x-axis contains strings rather than numbers. is there a way out? Best regards, /Steffen -- Steffen Uhlig, PhD Mechatronik und Sensortechnik HTW des Saarlandes Goebenstraße 40 66117 Saarbrücken Tel.: +49 (0) 681 58 67 274 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 a vignette?
I am trying to find a simple R guide that explain what a vignette is but so far I didnt make any progress. I tried to search inside R's built in help.start() but it only returns results how to see vignettes. So could you please tell me what a vignette is and if you can also could you give some simple guide that I can always use to read about these things? Best Regards Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot of a subset of a data.frame()
Hello, It is completely normal. I advise you to read the manual An introduction to R on the CRAN website. For example you can find (part 12.1.1) : 12.1.1 The |plot()| function One of the most frequently used plotting functions in R is the |plot()| function. This is a /generic/ function: the type of plot produced is dependent on the type or /class/ of the first argument. |plot(|x|, |y|)| |plot(|xy|)| If x and y are vectors, |plot(|x|, |y|)| produces a scatterplot of y against x. The same effect can be produced by supplying one argument (second form) as either a list containing two elements x and y or a two-column matrix. |plot(|x|)| If x is a time series, this produces a time-series plot. If x is a numeric vector, it produces a plot of the values in the vector against their index in the vector. If x is a complex vector, it produces a plot of imaginary versus real parts of the vector elements. |plot(|f|)| |plot(|f|, |y|)| f is a factor object, y is a numeric vector. The first form generates a bar plot of f; the second form produces boxplots of y for each level of f. |plot(|df|)| |plot(~ |expr|)| |plot(|y| ~ |expr|)| df is a data frame, y is any object, expr is a list of object names separated by `|+|' (e.g., |a + b + c|). The first two forms produce distributional plots of the variables in a data frame (first form) or of a number of named objects (second form). The third form plots y against every object named in expr. Alain On 26-Jul-10 13:38, Steffen Uhlig wrote: Hello, my data.frame is sort of a collection of process values, i.e. huge run-chart. It consists of a time-stamp in the first column (date as string), factors in the following columns (used for subset-filtering), and some process-data columns. Hereafter, two examples are listed, showing the problems that occour during print: At first the example, that works fine: ~~ a = c(1:10) # create a vector of integers b = rep(c(a,b),5)# create a vector of chars, used # as factor-levels d = rnorm(10)# some random numbers e = data.frame(a,b,d)# connect to a data.frame e.1 = subset(e, b==a)# create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) # plot first data-subset points(d~a, e.2, pch=4, col=3) # plot the 2nd one ~~ all looks fine in theses plots. However, changing the content of vector a to a set of strings the following happens: ~~ a = c(a,b,c,d,e,f,g,h,i,j) e = data.frame(a,b,d) # re-build data.frame e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) points(d~a, e.2, pch=4, col=3) ~~ The plot-command produces horizontal lines instead of dots. This seems to happen when the x-axis contains strings rather than numbers. is there a way out? Best regards, /Steffen -- Alain Guillet Statistician and Computer Scientist SMCS - IMMAQ - Université catholique de Louvain Bureau c.316 Voie du Roman Pays, 20 B-1348 Louvain-la-Neuve Belgium tel: +32 10 47 30 50 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: Plot of a subset of a data.frame()
Hi r-help-boun...@r-project.org napsal dne 26.07.2010 13:38:44: Hello, my data.frame is sort of a collection of process values, i.e. huge run-chart. It consists of a time-stamp in the first column (date as string), factors in the following columns (used for subset-filtering), and some process-data columns. Hereafter, two examples are listed, showing the problems that occour during print: At first the example, that works fine: ~~ a = c(1:10) # create a vector of integers b = rep(c(a,b),5) # create a vector of chars, used # as factor-levels d = rnorm(10) # some random numbers e = data.frame(a,b,d) # connect to a data.frame e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) # plot first data-subset Rather strange plot call. I usually call plot(a, d, pch=as.numeric(as.factor(b))+2, col=as.numeric(as.factor(b))+1) as you could have problem when some point in second subset is outside a range of first subset. points(d~a, e.2, pch=4, col=3) # plot the 2nd one ~~ all looks fine in theses plots. However, changing the content of vector a to a set of strings the following happens: ~~ a = c(a,b,c,d,e,f,g,h,i,j) e = data.frame(a,b,d) # re-build data.frame e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) points(d~a, e.2, pch=4, col=3) ~~ The plot-command produces horizontal lines instead of dots. This seems to happen when the x-axis contains strings rather than numbers. is there a way out? You actually called boxplots hence lines and labels under x axis. The way out depends on how do you want everything to be plotted. If a vector was a factor you could use conversion to numeric representation by a.n-as.numeric(a) and plot d against a.n with axis labels from a. Try to go through plot, plot.default, boxplot, factor help pages Regards Petr Best regards, /Steffen -- Steffen Uhlig, PhD Mechatronik und Sensortechnik HTW des Saarlandes Goebenstraße 40 66117 Saarbrücken Tel.: +49 (0) 681 58 67 274 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Plot of a subset of a data.frame()
You could have a look at the ggplot2 package to make such plots. The code for the plots is more readable than with base plots. a = c(1:10) # create a vector of integers b = rep(c(a,b),5) # create a vector of chars, used # as factor-levels d = rnorm(10) # some random numbers e = data.frame(a,b,d) library(ggplot2) ggplot(e, aes(x = a, y = d, colour = b, shape = b)) + geom_point() a = c(a,b,c,d,e,f,g,h,i,j) e = data.frame(a,b,d) # re-build data.frame ggplot(e, aes(x = a, y = d, colour = b, shape = b)) + geom_point() HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics 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 Steffen Uhlig Verzonden: maandag 26 juli 2010 13:39 Aan: r-help@r-project.org Onderwerp: [R] Plot of a subset of a data.frame() Hello, my data.frame is sort of a collection of process values, i.e. huge run-chart. It consists of a time-stamp in the first column (date as string), factors in the following columns (used for subset-filtering), and some process-data columns. Hereafter, two examples are listed, showing the problems that occour during print: At first the example, that works fine: ~~ a = c(1:10) # create a vector of integers b = rep(c(a,b),5) # create a vector of chars, used # as factor-levels d = rnorm(10) # some random numbers e = data.frame(a,b,d) # connect to a data.frame e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) # plot first data-subset points(d~a, e.2, pch=4, col=3) # plot the 2nd one ~~ all looks fine in theses plots. However, changing the content of vector a to a set of strings the following happens: ~~ a = c(a,b,c,d,e,f,g,h,i,j) e = data.frame(a,b,d) # re-build data.frame e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) points(d~a, e.2, pch=4, col=3) ~~ The plot-command produces horizontal lines instead of dots. This seems to happen when the x-axis contains strings rather than numbers. is there a way out? Best regards, /Steffen -- Steffen Uhlig, PhD Mechatronik und Sensortechnik HTW des Saarlandes Goebenstraße 40 66117 Saarbrücken Tel.: +49 (0) 681 58 67 274 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Druk dit bericht a.u.b. niet onnodig af. Please do not print this message unnecessarily. 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] Plot of a subset of a data.frame()
On Jul 26, 2010, at 7:38 AM, Steffen Uhlig wrote: Hello, my data.frame is sort of a collection of process values, i.e. huge run-chart. It consists of a time-stamp in the first column (date as string), factors in the following columns (used for subset- filtering), and some process-data columns. Hereafter, two examples are listed, showing the problems that occour during print: At first the example, that works fine: ~~ a = c(1:10) # create a vector of integers b = rep(c(a,b),5) # create a vector of chars, used # as factor-levels d = rnorm(10) # some random numbers e = data.frame(a,b,d) # connect to a data.frame You've gotten several answers, but none have addressed an aspect of R behavior that took me longer to appreciate than it perhaps should have. The b column inside the e data.frame is now a factor column. I mention that because you later referred to it as a string which it is not. It is an integer with an associated indexed level character vector. Many of the functions that you might think would work on strings will give either errors or unexpected results when applied to factors. e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) # plot first data-subset points(d~a, e.2, pch=4, col=3) # plot the 2nd one ~~ all looks fine in theses plots. However, changing the content of vector a to a set of strings the following happens: ~~ a = c(a,b,c,d,e,f,g,h,i,j) e = data.frame(a,b,d) # re-build data.frame e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) points(d~a, e.2, pch=4, col=3) ~~ The plot-command produces horizontal lines instead of dots. This seems to happen when the x-axis contains strings rather than numbers. is there a way out? Best regards, /Steffen -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] vectorisation?
Many thanks Dimitris. On Mon, Jul 26, 2010 at 9:13 AM, Dimitris Rizopoulos d.rizopou...@erasmusmc.nl wrote: have a look at function rollapply() from package zoo. I hope it helps. Best, Dimitris On 7/26/2010 8:28 AM, Raghu wrote: Hi I have 3500 rows of data (say a single column) in a vector. If I want to compare every ith element with the simple average of the previous (i-5) elements, then I could write something like this: for(i in 6:NROW(data)){ if(data[i] = mean(data[(i-5):i]) (counter[i]=1)} } Is it possible to replicate the above faster in R? -- 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 -- 'Raghu' [[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] glm - prediction of a factor with several levels
Thanks a lot for your anwers. To Ben Bolker : I am trying to perform an ordinal logistic regression to predict an Y 3-class variable, having observed 3 continous predictors V1, V2, V3. With random data my code would be something like : # simulate 10 observations of 3 independant N(0,1) predictors X=rmvnorm(10,rep(0,3)) # variable to predict Y=c(1,1,1,2,2,2,3,3,3,3) # create data frame A=as.data.frame(cbind(X,Y)) # turn Y into class variable A$Y=as.factor(A$Y) # perform logisitic regression glm(Y~V1+V2+V3,A,family=binomial) As only one intercept is returned, it seems indeed that a 2-class model has been performed instead, as said by zachmor. Although I solved my problem by using polr instead of glm, I'd like to understand what glm does in such a case since it gave me better well-classification rates with the predict function. Thanks a lot again ! -- View this message in context: http://r.789695.n4.nabble.com/glm-prediction-of-a-factor-with-several-levels-tp2300793p2302078.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] Outlier detection in bimodal distribution
Hi, I was looking for a package that would help with outlier detection for bimodal distributions. I have tried 'outliers' and 'extremevalues' packages, but am not sure if they are ok for bimodal distribution. Any help would be highly appreciated! thanks, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] what is a vignette?
vignette is an R jargon for documentation. try ?vignette. Not all packages come with vignettes. You may want to install a package and go to the installed directory to see if any examples are given for the same. HTH Raghu On Mon, Jul 26, 2010 at 12:56 PM, alaios [via R] ml-node+2302242-1733300369-309...@n4.nabble.comml-node%2b2302242-1733300369-309...@n4.nabble.com wrote: I am trying to find a simple R guide that explain what a vignette is but so far I didnt make any progress. I tried to search inside R's built in help.start() but it only returns results how to see vignettes. So could you please tell me what a vignette is and if you can also could you give some simple guide that I can always use to read about these things? Best Regards Alex __ [hidden email] http://user/SendEmail.jtp?type=nodenode=2302242i=0mailing list https://stat.ethz.ch/mailman/listinfo/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 message @ http://r.789695.n4.nabble.com/what-is-a-vignette-tp2302242p2302242.html To start a new topic under R help, email ml-node+789696-608741344-309...@n4.nabble.comml-node%2b789696-608741344-309...@n4.nabble.com To unsubscribe from R help, click here (link removed) . -- 'Raghu' -- View this message in context: http://r.789695.n4.nabble.com/what-is-a-vignette-tp2302242p2302258.html Sent from the R help mailing list archive at Nabble.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] Marginal effects from interaction regression model
The plots you are looking for are called 'effect plots'. See the effects package by John Fox. Guillem R. wrote: As far as I know, the predict command gives the predicted values (and intervals) of y, but what I'm looking for is the conditional effects (betas) of x on y conditional on values of z. I'm trying to produce a plot similar to the first shown in this link: http://homepages.nyu.edu/~mrg217/interaction.html#code Thanks again David Winsemius wrote: On Jul 25, 2010, at 10:24 PM, Guillem R. wrote: Dear all, I'd like to plot the marginal effect of a variable in a multiplicative interaction regression, that is, the effect of a variable conditional on the values of another variable. As an illustration, given model lm1 lm1 - lm(y ~ x*z) ? predict Perhaps: predict(lm1, newdata=data.frame(x=1:10, z=5), interval=confidence) I'd like to get the effects of x on y conditional on the values of z, with the corresponding confidence intervals if possible. Does anyone know of any package or simple way to do this? Thanks -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] what is a vignette?
Alex, Vignettes are optional supplemental documentation. That is, they are in addition to the required boilerplate documentation for R functions and datasets. Vignettes are written in the spirit of sharing knowledge, and assisting new users in learning the purpose and use of a package. Maybe the best place to start is simply to read one, or a few. The `zoo` package has a few, for example here: http://cran.r-project.org/web/packages/zoo/index.html The technical details of vignettes, and how to write one are contained in the `Writing R Extensions` manual: http://cran.r-project.org/manuals.html -Matt On Mon, 2010-07-26 at 07:55 -0400, Alaios wrote: I am trying to find a simple R guide that explain what a vignette is but so far I didnt make any progress. I tried to search inside R's built in help.start() but it only returns results how to see vignettes. So could you please tell me what a vignette is and if you can also could you give some simple guide that I can always use to read about these things? Best Regards Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Matthew S. Shotwell Graduate Student Division of Biostatistics and Epidemiology Medical University of South Carolina __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] glm - prediction of a factor with several levels
On Jul 26, 2010, at 4:18 AM, blackscorpio wrote: Thanks a lot for your anwers. To Ben Bolker : I am trying to perform an ordinal logistic regression to predict an Y 3-class variable, having observed 3 continous predictors V1, V2, V3. With random data my code would be something like : # simulate 10 observations of 3 independant N(0,1) predictors X=rmvnorm(10,rep(0,3)) # variable to predict Y=c(1,1,1,2,2,2,3,3,3,3) # create data frame A=as.data.frame(cbind(X,Y)) # turn Y into class variable A$Y=as.factor(A$Y) # perform logisitic regression glm(Y~V1+V2+V3,A,family=binomial) As only one intercept is returned, it seems indeed that a 2-class model has been performed instead, as said by zachmor. Although I solved my problem by using polr instead of glm, I'd like to understand what glm does in such a case since it gave me better well-classification rates with the predict function. Thanks a lot again ! From the Details section of ?glm: For binomial and quasibinomial families the response can also be specified as a factor (when the first level denotes failure and all others success) ... So 1 is a failure and c(2, 3) denote success, thus a two level response. BTW, if you are going to use a function (eg. rmvnorm()) from an external package, be sure to include the relevant library() call in your example code so folks don't need to guess which CRAN package(s) may be required to run 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] does package QuantPsych function lm.beta can handle resultsof a regression with weights?
The original function was created for a simple example. It never was written to address weighted regression. A quick fix will work for you situation. ### The original is: lm.beta - function (MOD) { b - summary(MOD)$coef[-1, 1] sx - sd(MOD$model[-1]) sy - sd(MOD$model[1]) beta - b * sx/sy return(beta) } A newer modification: lm.betaW - function (MOD) { b - summary(MOD)$coef[-1, 1] sx - sd(MOD$model[-1][1]) sy - sd(MOD$model[1]) beta - b * sx/sy return(beta) } The above should do the trick. TF -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri Liakhovitski Sent: Thursday, July 22, 2010 12:35 PM To: r-help@r-project.org Subject: [R] does package QuantPsych function lm.beta can handle resultsof a regression with weights? Hello, and sorry for not providing an example. I run a regular linear regression (using lm) and use weights with it (weights = ...). I use QuantPsych package, its function lm.beta to extract standardized regression weights from my lm regression object. When I don't use weights, everything is fine. But when I do use weights, I get an error that refers to lm.beta code: In b * sx : longer object length is not a multiple of shorter object length This happens because there is an extra column in the object: regr$model that lm.beta is using to get at the betas. Is there some other package that just gives me the standardized regression weights - even if I used weights for regression? Thank you! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] what is a vignette?
A good article is: http://www.statistik.lmu.de/~leisch/Sweave/Sweave-Rnews-2003-2.pdf Max On Mon, Jul 26, 2010 at 9:18 AM, Matt Shotwell shotw...@musc.edu wrote: Alex, Vignettes are optional supplemental documentation. That is, they are in addition to the required boilerplate documentation for R functions and datasets. Vignettes are written in the spirit of sharing knowledge, and assisting new users in learning the purpose and use of a package. Maybe the best place to start is simply to read one, or a few. The `zoo` package has a few, for example here: http://cran.r-project.org/web/packages/zoo/index.html The technical details of vignettes, and how to write one are contained in the `Writing R Extensions` manual: http://cran.r-project.org/manuals.html -Matt On Mon, 2010-07-26 at 07:55 -0400, Alaios wrote: I am trying to find a simple R guide that explain what a vignette is but so far I didnt make any progress. I tried to search inside R's built in help.start() but it only returns results how to see vignettes. So could you please tell me what a vignette is and if you can also could you give some simple guide that I can always use to read about these things? Best Regards Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Matthew S. Shotwell Graduate Student Division of Biostatistics and Epidemiology Medical University of South Carolina __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Concatenate a mix of numbers and letters to create a vector name
Dear all, I am trying to create a vector name, for example tmax.195012 from tmax., 1950 and 12. Obviously I don't wish to simply type it because the 3 name components are changing in each iteration within a loop. Is there any way of concatenating those 3 components (which are a mixture of numbers and letters)? Thanks for reading, Panos - Dr Panos Hadjinicolaou Energy Environment Water Research Center (EEWRC) The Cyprus Institute -- [[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] Concatenate a mix of numbers and letters to create a vector name
have a look at function paste(), i.e., ?paste I hope it helps. Best, Dimitris On 7/26/2010 3:44 PM, Panos Hadjinicolaou wrote: Dear all, I am trying to create a vector name, for example tmax.195012 from tmax., 1950 and 12. Obviously I don't wish to simply type it because the 3 name components are changing in each iteration within a loop. Is there any way of concatenating those 3 components (which are a mixture of numbers and letters)? Thanks for reading, Panos - Dr Panos Hadjinicolaou Energy Environment Water Research Center (EEWRC) The Cyprus Institute -- [[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.
[R] = vs - operator
Hello I notice that in Linux the = operator works like the - operator So a=3 is similar to a-3. Could you please verify me that is correct? I would like to use = operator. Do you think that might be a problem in the future? Best Regards Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] search and replace in a list of strings
Hi everybody, I have a 4*4 matrix WD of wind data of the following form: WD $date [1] 07.07.2010 07.07.2010 07.07.2010 07.07.2010 $time [1] 00:00:00 00:10:00 00:20:00 00:30:00 $CH1Avg [1] 3.02 3.04 2.94 2.71 I would like to transform the date and time strings in usable numbers for plotting : - Transform 07.07.2010 in 07*24 + 07*31*24 for example - Transform the string of type 12:15:20 in a number equals to 12+15/60+20/3600 I would hence need a function able to look for defined patterns in a list, like aa:bb:cc and evaluate aa+bb/60+cc/3600. Anyone has a idea? Thanks a lot! Cheers Olivier Coupiac [[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] Smalltalk with R
Dear all, i´m search for informations referring to R and Seaside respectively VisualWorks or other cross-platforms for the implementation of Smalltalk. Do you know a interface or a bridge,which enables work with such a R-Smalltalk connection? Best Regards Nero -- View this message in context: http://r.789695.n4.nabble.com/Smalltalk-with-R-tp2302344p2302344.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] search and replace in a list of strings
The most usable form is to convert it to POSIXct since most of the plotting routines know how to handle date/time. You could do: myDate - as.POSIXct(paste(WD$date, WD$time), format='%m.%d.%Y %H:%M:%S') e.g., as.POSIXct('07.07.2010 12:34:15', format='%m.%d.%Y %H:%M:%S') [1] 2010-07-07 12:34:15 EDT On Mon, Jul 26, 2010 at 9:07 AM, Olivier Coupiac olivier.coup...@renerco.com wrote: Hi everybody, I have a 4*4 matrix WD of wind data of the following form: WD $date [1] 07.07.2010 07.07.2010 07.07.2010 07.07.2010 $time [1] 00:00:00 00:10:00 00:20:00 00:30:00 $CH1Avg [1] 3.02 3.04 2.94 2.71 I would like to transform the date and time strings in usable numbers for plotting : - Transform 07.07.2010 in 07*24 + 07*31*24 for example - Transform the string of type 12:15:20 in a number equals to 12+15/60+20/3600 I would hence need a function able to look for defined patterns in a list, like aa:bb:cc and evaluate aa+bb/60+cc/3600. Anyone has a idea? Thanks a lot! Cheers Olivier Coupiac [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] = vs - operator
Check the mail archieve on this; there has been a long discussion. To avoid trouble in the future, use - as the assignment operator. On Mon, Jul 26, 2010 at 9:51 AM, Alaios ala...@yahoo.com wrote: Hello I notice that in Linux the = operator works like the - operator So a=3 is similar to a-3. Could you please verify me that is correct? I would like to use = operator. Do you think that might be a problem in the future? Best Regards Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] = vs - operator
Hi, Just as an example, here are three threads that discuss it. http://www.mail-archive.com/r-help@r-project.org/msg16881.html http://r.789695.n4.nabble.com/advice-opinion-on-vs-in-teaching-R-td1014502.html#a1014502 http://www.mail-archive.com/r-help@r-project.org/msg100034.html Cheers, Josh On Mon, Jul 26, 2010 at 6:51 AM, Alaios ala...@yahoo.com wrote: Hello I notice that in Linux the = operator works like the - operator So a=3 is similar to a-3. Could you please verify me that is correct? I would like to use = operator. Do you think that might be a problem in the future? Best Regards Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Optimization problem with nonlinear constraint
Dear all, I'm looking for a way to solve a simple optimization problem with a nonlinear constraint. An example would be max x s.t. y = x * T ^(x-1) where y and T are known values. optim() and constrOptim() do only allow for box or linear constraints, so I did not succedd here. I also found hints to donlp2 but this does not seem to be available anymore. Any hints are welcome, Uli -- Uli Kleinwechter Agricultural and Food Policy Group (420a) University of Hohenheim D-70593 Stuttgart E-mail: u.kleinwech...@uni-hohenheim.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Concatenate a mix of numbers and letters to create a vector name
Thanks for the reply. Indeed the paste function results in concatenation: paste(c(tmax., 1950, 12), collapse=) [1] tmax.195012 but I am looking for a way to subsequently get rid of the - - in order to use tmax.195012 as an object (e.g. to define a vector with that name). Any ideas? Thanks, Panos _ From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl] To: Panos Hadjinicolaou [mailto:p.hadjinicol...@cyi.ac.cy] Cc: r-help@r-project.org Sent: Mon, 26 Jul 2010 16:48:31 +0300 Subject: Re: [R] Concatenate a mix of numbers and letters to create a vector name have a look at function paste(), i.e., ?paste I hope it helps. Best, Dimitris On 7/26/2010 3:44 PM, Panos Hadjinicolaou wrote: Dear all, I am trying to create a vector name, for example tmax.195012 from tmax., 1950 and 12. Obviously I don't wish to simply type it because the 3 name components are changing in each iteration within a loop. Is there any way of concatenating those 3 components (which are a mixture of numbers and letters)? Thanks for reading, Panos - Dr Panos Hadjinicolaou Energy Environment Water Research Center (EEWRC) The Cyprus Institute -- [[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 [[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] Concatenate a mix of numbers and letters to create a vector name
have a look at assign() -- Best, Dimitris On 7/26/2010 4:23 PM, Panos Hadjinicolaou wrote: Thanks for the reply. Indeed the paste function results in concatenation: paste(c(tmax., 1950, 12), collapse=) [1] tmax.195012 but I am looking for a way to subsequently get rid of the - - in order to use tmax.195012 as an object (e.g. to define a vector with that name). Any ideas? Thanks, Panos _ From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl] To: Panos Hadjinicolaou [mailto:p.hadjinicol...@cyi.ac.cy] Cc: r-help@r-project.org Sent: Mon, 26 Jul 2010 16:48:31 +0300 Subject: Re: [R] Concatenate a mix of numbers and letters to create a vector name have a look at function paste(), i.e., ?paste I hope it helps. Best, Dimitris On 7/26/2010 3:44 PM, Panos Hadjinicolaou wrote: Dear all, I am trying to create a vector name, for example tmax.195012 from tmax., 1950 and 12. Obviously I don't wish to simply type it because the 3 name components are changing in each iteration within a loop. Is there any way of concatenating those 3 components (which are a mixture of numbers and letters)? Thanks for reading, Panos - Dr Panos Hadjinicolaou Energy Environment Water Research Center (EEWRC) The Cyprus Institute -- [[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 [[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] Concatenate a mix of numbers and letters to create a vector name
Hi, assign(paste(c(tmax., 1950, 12), collapse=) ,1:10) does what you want. Alain On 26-Jul-10 16:23, Panos Hadjinicolaou wrote: Thanks for the reply. Indeed the paste function results in concatenation: paste(c(tmax., 1950, 12), collapse=) [1] tmax.195012 but I am looking for a way to subsequently get rid of the - - in order to use tmax.195012 as an object (e.g. to define a vector with that name). Any ideas? Thanks, Panos _ From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl] To: Panos Hadjinicolaou [mailto:p.hadjinicol...@cyi.ac.cy] Cc: r-help@r-project.org Sent: Mon, 26 Jul 2010 16:48:31 +0300 Subject: Re: [R] Concatenate a mix of numbers and letters to create a vector name have a look at function paste(), i.e., ?paste I hope it helps. Best, Dimitris On 7/26/2010 3:44 PM, Panos Hadjinicolaou wrote: Dear all, I am trying to create a vector name, for example tmax.195012 from tmax., 1950 and 12. Obviously I don't wish to simply type it because the 3 name components are changing in each iteration within a loop. Is there any way of concatenating those 3 components (which are a mixture of numbers and letters)? Thanks for reading, Panos - Dr Panos Hadjinicolaou Energy Environment Water Research Center (EEWRC) The Cyprus Institute -- [[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 [[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. -- Alain Guillet Statistician and Computer Scientist SMCS - IMMAQ - Université catholique de Louvain Bureau c.316 Voie du Roman Pays, 20 B-1348 Louvain-la-Neuve Belgium tel: +32 10 47 30 50 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] List to data frame
Hi, Any ideas on how to efficiently convert list(c(1,2,3),c(4,5,6)) to data.frame(OriginalListIndex=c(1,1,1,2,2,2),Item=c(1,2,3,4,5,6)) Thanks for any hints, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 using grid.layout in Sweave
Hi! I am troubled by Sweave which I want to use in order to plot graphics which I build up successively by the use of grid.layout. Here is the code: fig=TRUE,label=evolDist,height=6in,width=3in,pdf=FALSE= ## combined plot via grid viewports grid.newpage() pushViewport(viewport(layout=grid.layout(2,1))) vlay - function(x,y) viewport(layout.pos.row=x, layout.pos.col=y) print(pl$gscoreDist, vp=vlay(1,1)) print(pl$acceptDist, vp=vlay(2,1)) dev.off() @ The error is the following from Sweave: Error in grid.newpage() : Non-finite location and/or size for viewport In addition: There were 24 warnings (use warnings() to see them) Error in driver$runcode(drobj, chunk, chunkopts) : Error in grid.newpage() : Non-finite location and/or size for viewport Calls: Sweave - Anonymous Execution halted Any hints? Of course, I can always wrap the code into a fig=FALSE, and pdf()-call, but that is not how sweave is meant to be used, as I got it. Many thanks in advance, Sebastian Weber [[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] List to data frame
Try this: stack(data.frame(list('A' = c(1,2,3), 'B' = c(4,5,6 On Mon, Jul 26, 2010 at 11:46 AM, Johannes Graumann johannes_graum...@web.de wrote: Hi, Any ideas on how to efficiently convert list(c(1,2,3),c(4,5,6)) to data.frame(OriginalListIndex=c(1,1,1,2,2,2),Item=c(1,2,3,4,5,6)) Thanks for any hints, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Plot of a subset of a data.frame()
Dear David, Petr, and Alain, thank you very much for your fast responses. It's a typical handbook-not-read-error at my side. I will dig deeper into the plot-functions and the assignment of data. I was not aware of that the vector a is handled as a vector of factors with 10 levels. Thanks for your suggestions and hints! Best regards, /steffen Am 26.07.2010 14:30, schrieb David Winsemius: On Jul 26, 2010, at 7:38 AM, Steffen Uhlig wrote: Hello, my data.frame is sort of a collection of process values, i.e. huge run-chart. It consists of a time-stamp in the first column (date as string), factors in the following columns (used for subset-filtering), and some process-data columns. Hereafter, two examples are listed, showing the problems that occour during print: At first the example, that works fine: ~~ a = c(1:10) # create a vector of integers b = rep(c(a,b),5) # create a vector of chars, used # as factor-levels d = rnorm(10) # some random numbers e = data.frame(a,b,d) # connect to a data.frame You've gotten several answers, but none have addressed an aspect of R behavior that took me longer to appreciate than it perhaps should have. The b column inside the e data.frame is now a factor column. I mention that because you later referred to it as a string which it is not. It is an integer with an associated indexed level character vector. Many of the functions that you might think would work on strings will give either errors or unexpected results when applied to factors. e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) # plot first data-subset points(d~a, e.2, pch=4, col=3) # plot the 2nd one ~~ all looks fine in theses plots. However, changing the content of vector a to a set of strings the following happens: ~~ a = c(a,b,c,d,e,f,g,h,i,j) e = data.frame(a,b,d) # re-build data.frame e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) points(d~a, e.2, pch=4, col=3) ~~ The plot-command produces horizontal lines instead of dots. This seems to happen when the x-axis contains strings rather than numbers. is there a way out? Best regards, /Steffen -- Steffen Uhlig, PhD Mechatronik und Sensortechnik HTW des Saarlandes Goebenstraße 40 66117 Saarbrücken Tel.: +49 (0) 681 58 67 274 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] search and replace in a list of strings
It works, thanks a lot! Cheers -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: Monday, July 26, 2010 4:04 PM To: Olivier Coupiac Cc: r-help@r-project.org Subject: Re: [R] search and replace in a list of strings The most usable form is to convert it to POSIXct since most of the plotting routines know how to handle date/time. You could do: myDate - as.POSIXct(paste(WD$date, WD$time), format='%m.%d.%Y %H:%M:%S') e.g., as.POSIXct('07.07.2010 12:34:15', format='%m.%d.%Y %H:%M:%S') [1] 2010-07-07 12:34:15 EDT On Mon, Jul 26, 2010 at 9:07 AM, Olivier Coupiac olivier.coup...@renerco.com wrote: Hi everybody, I have a 4*4 matrix WD of wind data of the following form: WD $date [1] 07.07.2010 07.07.2010 07.07.2010 07.07.2010 $time [1] 00:00:00 00:10:00 00:20:00 00:30:00 $CH1Avg [1] 3.02 3.04 2.94 2.71 I would like to transform the date and time strings in usable numbers for plotting : - Transform 07.07.2010 in 07*24 + 07*31*24 for example - Transform the string of type 12:15:20 in a number equals to 12+15/60+20/3600 I would hence need a function able to look for defined patterns in a list, like aa:bb:cc and evaluate aa+bb/60+cc/3600. Anyone has a idea? Thanks a lot! Cheers Olivier Coupiac [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] hatching posibility in Panel.Polygon
Thank you very much for your quick help. In fact, I was trying to show confidence intervals from two different methods (for various groups in panels) that had some overlaps and some exclusive areas. And using fill hides the area of the one underneath. Hatching may have been very good for this and that is why I was trying to figure out a way for doing it. Since the option is not there right now, I will use lines' to show the comparison and be content with that for the time being! Once again, thank you very much for your help. HC -- View this message in context: http://r.789695.n4.nabble.com/hatching-posibility-in-Panel-Polygon-tp2301863p2302461.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] List to data frame
Hi, Here is another option if you already have a list you want to convert. This will handle different elements of the list being different lengths. #Using your example data mydata - list(c(1,2,3),c(4,5,6)) data.frame( OriginalListIndex = rep(x = seq_along(mydata), times = unlist(lapply(mydata, length))), Item = unlist(mydata) ) #Just to demonstrate that this method works generally mydata - list(c(1,2,3), c(7,6), c(3,4,5,6,7,8,9)) data.frame( OriginalListIndex = rep(x = seq_along(mydata), times = unlist(lapply(mydata, length))), Item = unlist(mydata) ) HTH, Josh On Mon, Jul 26, 2010 at 7:46 AM, Johannes Graumann johannes_graum...@web.de wrote: Hi, Any ideas on how to efficiently convert list(c(1,2,3),c(4,5,6)) to data.frame(OriginalListIndex=c(1,1,1,2,2,2),Item=c(1,2,3,4,5,6)) Thanks for any hints, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Trouble using grid.layout in Sweave
I just run the code below with sweave and works fine It looks like you might be missing the sequence of vplay fig.R,echo=F,fig=T= library(ggplot2) vplay- function(x, y) viewport(layout.pos.row=x, layout.pos.col=y) grid.newpage() p - ggplot(diamonds, aes(x=carat, y=..density..)) + geom_histogram(binwidth=0.2) p - p + facet_grid(. ~ cut) pushViewport(viewport(layout=grid.layout(3,3))) print(p, vp=vplay(1,1)) print(p, vp=vplayt(2:3,2:3)) print(p, vp=vplay(1, 2:3)) print(p, vp=vplay(2:3, 1)) @ Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA - Original Message From: Sebastian Weber sebastian.we...@physik.tu-darmstadt.de To: r-help@r-project.org Sent: Mon, July 26, 2010 7:51:06 AM Subject: [R] Trouble using grid.layout in Sweave Hi! I am troubled by Sweave which I want to use in order to plot graphics which I build up successively by the use of grid.layout. Here is the code: fig=TRUE,label=evolDist,height=6in,width=3in,pdf=FALSE= ## combined plot via grid viewports grid.newpage() pushViewport(viewport(layout=grid.layout(2,1))) vlay - function(x,y) viewport(layout.pos.row=x, layout.pos.col=y) print(pl$gscoreDist, vp=vlay(1,1)) print(pl$acceptDist, vp=vlay(2,1)) dev.off() @ The error is the following from Sweave: Error in grid.newpage() : Non-finite location and/or size for viewport In addition: There were 24 warnings (use warnings() to see them) Error in driver$runcode(drobj, chunk, chunkopts) : Error in grid.newpage() : Non-finite location and/or size for viewport Calls: Sweave - Anonymous Execution halted Any hints? Of course, I can always wrap the code into a fig=FALSE, and pdf()-call, but that is not how sweave is meant to be used, as I got it. Many thanks in advance, Sebastian Weber [[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] How to generate a sequence of dates without hardcoding the year
Thanks Jim and Enrique, that should work since I am only trying to show the month along my X axis it regardless of what year it is. Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA - Original Message From: jim holtman jholt...@gmail.com To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: r-h...@stat.math.ethz.ch Sent: Sat, July 24, 2010 4:02:57 PM Subject: Re: [R] How to generate a sequence of dates without hardcoding the year Is this what you want if you want to assume that the date without a year is this year: seq(as.Date(7-1,%m-%d),by=week, length=52) [1] 2010-07-01 2010-07-08 2010-07-15 2010-07-22 2010-07-29 2010-08-05 2010-08-12 2010-08-19 [9] 2010-08-26 2010-09-02 2010-09-09 2010-09-16 2010-09-23 2010-09-30 2010-10-07 2010-10-14 [17] 2010-10-21 2010-10-28 2010-11-04 2010-11-11 2010-11-18 2010-11-25 2010-12-02 2010-12-09 [25] 2010-12-16 2010-12-23 2010-12-30 2011-01-06 2011-01-13 2011-01-20 2011-01-27 2011-02-03 [33] 2011-02-10 2011-02-17 2011-02-24 2011-03-03 2011-03-10 2011-03-17 2011-03-24 2011-03-31 [41] 2011-04-07 2011-04-14 2011-04-21 2011-04-28 2011-05-05 2011-05-12 2011-05-19 2011-05-26 [49] 2011-06-02 2011-06-09 2011-06-16 2011-06-23 On Sat, Jul 24, 2010 at 5:07 PM, Felipe Carrillo mazatlanmex...@yahoo.com wrote: Hi: I have a dataframe named 'spring' and I am trying to add a new variable named 'IdDate' This line of code works fine: spring$idDate - seq(as.Date(2008-07-01),as.Date(2009-06-30),by=week) But I don't want to hardcode the year because it will be used again the following year Is it possible to just generate dates with the month and day? I tried the code below: seq(as.Date(7-1,%B%d),as.Date(6-30,%B%d),by=week) and got this error message: Error in seq.int(0, to - from, by) : 'to' must be finite Thanks for any pointers Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Optimization problem with nonlinear constraint
Hi Uli, I am not sure if this is the problem that you really want to solve. The answer is the solution to the equation y = x * T^(x-1), provided a solution exists. There is no optimization involved here. What is the real problem that you are trying to solve? If you want to solve a more meaningful constrained optimization problem, you may want to try the abalama package which I just put on CRAN. It can optimize smooth nonlinear functions subject to linear and nonlinear equality and inequality constraints. http://cran.r-project.org/web/packages/alabama/index.html Let me know if you run into any problems using it. Best, Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Uli Kleinwechter Sent: Monday, July 26, 2010 10:16 AM To: r-help@r-project.org Subject: [R] Optimization problem with nonlinear constraint Dear all, I'm looking for a way to solve a simple optimization problem with a nonlinear constraint. An example would be max x s.t. y = x * T ^(x-1) where y and T are known values. optim() and constrOptim() do only allow for box or linear constraints, so I did not succedd here. I also found hints to donlp2 but this does not seem to be available anymore. Any hints are welcome, Uli -- Uli Kleinwechter Agricultural and Food Policy Group (420a) University of Hohenheim D-70593 Stuttgart E-mail: u.kleinwech...@uni-hohenheim.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] merge table rows (\multirow)
You can also automate it with this: do.multirow-function(df, which=1:ncol(df)){ for(c in which){ runs - rle(as.character(df[,c])) if(all(runs$lengths1)){ tmp - rep(, nrow(df)) tmp[c(1, 1+head(cumsum(runs$lengths),- 1))] - paste(\\multirow{,runs$lengths,}{*}{,df[c(1, 1+head(cumsum(runs$lengths),-1)),c],},sep=) df[,c] - tmp } } return(df) } This will replace the which-columns of data.frame df that have only repeated entries with the appropriate \multirow commands. You then have to use print.xtable with sth like print(xtable(do.multirow(df)), sanitize.text.function = function(x){ return(x) } ) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] UseR! 2010 - my impressions
Dear Ravi - I echo everything you wrote, useR2010 was an amazing experience (for me, and for many others with whom I have spoken about it). Many thanks should go to the wonderful people who put their efforts into making this conference a reality (and Kate is certainly one of them). Thank you for expressing feelings I had using your own words. Best, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Sat, Jul 24, 2010 at 2:50 AM, Ravi Varadhan rvarad...@jhmi.edu wrote: Dear UseRs!, Everything about UseR! 2010 was terrific! I really mean everything - the tutorials, invited talks, kaleidoscope sessions, focus sessions, breakfast, snacks, lunch, conference dinner, shuttle services, and the participants. The organization was fabulous. NIST were gracious hosts, and provided top notch facilities. The rousing speech by Antonio Possolo, who is the chief of Statistical Engineering Division at NIST, set the tempo for the entire conference. Excellent invited lectures by Luke Tierney, Frank Harrell, Mark Handcock, Diethelm Wurtz, Uwe Ligges, and Fritz Leisch. All the sessions that I attended had many interesting ideas and useful contributions. During the whole time that I was there, I could not help but get the feeling that I am a part of something great. Before I end, let me add a few words about a special person. This conference would not have been as great as it was without the tireless efforts of Kate Mullen. The great thing about Kate is that she did so much without ever hogging the limelight. Thank you, Kate and thank you NIST! I cannot wait for UseR!2011! Best, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] OOP module
Hello, Does anybody know if the OOP module (Chambers Temple Lang) is going to replace the the S4 (and the S3) class system? http://www.omegahat.org/OOP/oop.pdf Cheers!! Albert-Jan ~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~ [[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] gapped sequence data summary
Id cat1 location item_values p-values sequence a111 1 3002737 100 0.01 1 a112 1 3017821 102 0.05 2 a113 2 3027730 103 0.02 3 a114 2 3036220 104 0.04 4 a115 1 3053984 105 0.03 5 a118 1 3090500 106 0.02 8 a119 1 3103304 107 0.03 9 a120 2 3090500 106 0.02 10 a121 2 3103304 107 0.03 11 what I am trying to accomplish is: for sequence 1:5 cat1start of the location end of the location, peak value of the item_values 1 30027373053984 105 2 30277303036220104 for sequence 8:11 cat1start of the location end of the location, peak value of the item_values 1 3090500 3103304 107 2 3090500 3103304 107 and so on... I have been trying to find a way to accomplish this, however, I didn't find one that worked as expected. would you shed some light on this? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/gapped-sequence-data-summary-tp2302552p2302552.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] List to data frame
Thanks a lot! This solves my problem! Joh On Monday 26 July 2010 17:06:37 Joshua Wiley wrote: Hi, Here is another option if you already have a list you want to convert. This will handle different elements of the list being different lengths. #Using your example data mydata - list(c(1,2,3),c(4,5,6)) data.frame( OriginalListIndex = rep(x = seq_along(mydata), times = unlist(lapply(mydata, length))), Item = unlist(mydata) ) #Just to demonstrate that this method works generally mydata - list(c(1,2,3), c(7,6), c(3,4,5,6,7,8,9)) data.frame( OriginalListIndex = rep(x = seq_along(mydata), times = unlist(lapply(mydata, length))), Item = unlist(mydata) ) HTH, Josh On Mon, Jul 26, 2010 at 7:46 AM, Johannes Graumann johannes_graum...@web.de wrote: Hi, Any ideas on how to efficiently convert list(c(1,2,3),c(4,5,6)) to data.frame(OriginalListIndex=c(1,1,1,2,2,2),Item=c(1,2,3,4,5,6)) Thanks for any hints, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Cluster analysis
Hi all, I have no idea if this question is to easy to be answered, but I´m starting with R. So, here we go. I have a large dataset with a lot of steps a judicial case. A sample is attached. I´d like to do a cluster analysis to try to understand with one is the most usual path followed by this legal cases. After that, I´d like to plot a cluster tree. In the attached sample, the column: - id_processo is the primary key of a legal case; - number is the step number in the legal case; - andamento is the description of the legal case step. I have no idea on how to do it using R. Can someone help me? Thanks in advanced -- *Pablo de Camargo Cerdeira* pa...@fgv.br pablo.cerde...@gmail.com +55 (21) 3799-6065 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gapped sequence data summary
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of jd6688 Sent: Monday, July 26, 2010 9:23 AM To: r-help@r-project.org Subject: [R] gapped sequence data summary Id cat1 location item_values p-values sequence a111 1 3002737 100 0.01 1 a112 1 3017821 102 0.05 2 a113 2 3027730 103 0.02 3 a114 2 3036220 104 0.04 4 a115 1 3053984 105 0.03 5 a118 1 3090500 106 0.02 8 a119 1 3103304 107 0.03 9 a120 2 3090500 106 0.02 10 a121 2 3103304 107 0.03 11 what I am trying to accomplish is: for sequence 1:5 cat1start of the location end of the location, peak value of the item_values 1 30027373053984 105 2 30277303036220 104 for sequence 8:11 cat1start of the location end of the location, peak value of the item_values 1 3090500 3103304 107 2 3090500 3103304 107 and so on... To find which rows are the first and last row of a run of numbers that differs by 1 you can use the functions first - function(x)c(TRUE, diff(x)!=1) last - function(x)c(diff(x)!=1, TRUE) on 'sequence'. You can assign a group identifier to each run with runNumber - cumsum(c(TRUE, diff(sequence))) and use aggregate() or one of the functions in the plyr package to apply a summary function to each group. If there might be NA's in the sequence variable you will have to modify these a bit. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com I have been trying to find a way to accomplish this, however, I didn't find one that worked as expected. would you shed some light on this? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/gapped-sequence-data-summary-tp2 302552p2302552.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Trouble using grid.layout in Sweave
Hi! I moved the definition of the vlay function before the grid.newpage call, and now it works! This is weird, I don't get it what was wrong in the first place, if someone can enlighten me, I would feel better. Sebastian To make it clear, this works: evolDist,fig=TRUE= vlay - function(x,y) viewport(layout.pos.row=x, layout.pos.col=y) ## combined plot via grid viewports grid.newpage() pushViewport(viewport(layout=grid.layout(2,1))) print(pl$gscoreDist, vp=vlay(1,1)) print(pl$acceptDist, vp=vlay(2,1)) @ On Mon, Jul 26, 2010 at 5:32 PM, Felipe Carrillo mazatlanmex...@yahoo.comwrote: I just run the code below with sweave and works fine It looks like you might be missing the sequence of vplay fig.R,echo=F,fig=T= library(ggplot2) vplay- function(x, y) viewport(layout.pos.row=x, layout.pos.col=y) grid.newpage() p - ggplot(diamonds, aes(x=carat, y=..density..)) + geom_histogram(binwidth=0.2) p - p + facet_grid(. ~ cut) pushViewport(viewport(layout=grid.layout(3,3))) print(p, vp=vplay(1,1)) print(p, vp=vplayt(2:3,2:3)) print(p, vp=vplay(1, 2:3)) print(p, vp=vplay(2:3, 1)) @ Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA - Original Message From: Sebastian Weber sebastian.we...@physik.tu-darmstadt.de To: r-help@r-project.org Sent: Mon, July 26, 2010 7:51:06 AM Subject: [R] Trouble using grid.layout in Sweave Hi! I am troubled by Sweave which I want to use in order to plot graphics which I build up successively by the use of grid.layout. Here is the code: fig=TRUE,label=evolDist,height=6in,width=3in,pdf=FALSE= ## combined plot via grid viewports grid.newpage() pushViewport(viewport(layout=grid.layout(2,1))) vlay - function(x,y) viewport(layout.pos.row=x, layout.pos.col=y) print(pl$gscoreDist, vp=vlay(1,1)) print(pl$acceptDist, vp=vlay(2,1)) dev.off() @ The error is the following from Sweave: Error in grid.newpage() : Non-finite location and/or size for viewport In addition: There were 24 warnings (use warnings() to see them) Error in driver$runcode(drobj, chunk, chunkopts) : Error in grid.newpage() : Non-finite location and/or size for viewport Calls: Sweave - Anonymous Execution halted Any hints? Of course, I can always wrap the code into a fig=FALSE, and pdf()-call, but that is not how sweave is meant to be used, as I got it. Many thanks in advance, Sebastian Weber [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] the real dimnames
Hi, R seems to have a feature that isn't used much, which I don't really now how to call. But, the dimnames function, can in addition to giving names to rows/columns/dim 3 rows/dim 4 rows... can also give labels to the dimensions themselves. Thus, I can do: A = matrix(1:9,3,3) dimnames(A) = list(from=c(), to=c() ) and now, printing a prints these dimension labels nicely: A to from [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 I don't know exactly what these labels are called, but they can be handy sometimes. For example, they could be handy when using aperm. Instead of writing aperm(A, c(2,1) ) It would be nice to be able to write: aperm(A, c(from,to) ) This way, I don't have to remember what is the order of the dims of A. It is easy to extend the functionality of aperm, so that the above code works: --- my.aperm=function( A, d , ...) { n=names(dimnames(A)) if( is.null(n) ) { return( aperm(A,d, ...)) } dimnum = seq(along=n) names(dimnum) = n return( aperm(A, dimnum[d], ... )) } -- It seems some functions support these dim labels (print, for example), and some don't (for example, matrix multiplication doesn't, aperm doesn't, apply doesn't). Another cool way to use these, would be labeled arguments in array subsetting: a[to=1:2,from=2:3] to from [,1] [,2] [1,]47 [2,]58 a[from=1:2,to=2:3] to from [,1] [,2] [1,]47 [2,]58 No, doesn't seem to work. My questions are: 1. Do these have names, so that I can search the documentation for them? 2. How are they usually used? thanks, Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] zoo objects and c
Dear R People: I would like to combine a zoo object with some observations at the end. Here is the set up: xgh 2010-06-15 2010-06-16 2010-06-17 2010-06-18 2010-06-19 2010-06-20 2010-06-21 5 6 1 5 0 0 13 2010-06-22 2010-06-23 2010-06-24 2010-06-25 2010-06-26 2010-06-27 2010-06-28 9 6 4 6 0 0 9 2010-06-29 2010-06-30 2010-07-01 2010-07-02 2010-07-03 2010-07-04 2010-07-05 15 10 5 6 0 0 0 2010-07-06 2010-07-07 2010-07-08 2010-07-09 2010-07-10 12 8 3 6 0 xs [1] 2010-06-15 2010-06-16 2010-06-17 2010-06-18 2010-06-19 [6] 2010-06-20 2010-06-21 2010-06-22 2010-06-23 2010-06-24 [11] 2010-06-25 2010-06-26 2010-06-27 2010-06-28 2010-06-29 [16] 2010-06-30 2010-07-01 2010-07-02 2010-07-03 2010-07-04 [21] 2010-07-05 2010-07-06 2010-07-07 2010-07-08 2010-07-09 [26] 2010-07-10 2010-07-11 2010-07-12 2010-07-13 2010-07-14 [31] 2010-07-15 zoo(c(xgh,-0.7,3.6,3.7,3.4,3.2),order=xs) Error in rbind.zoo(...) : indexes overlap What am I doing wrong, please? I'm sure that it's something simple. Thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.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] Outlier detection in bimodal distribution
I doubt that there are any. For a bimodal distrbution, I think one would have to specify in detail the nature of the distribution and then define what one means by an outlier (a slippery, sinister notion, at best and a flimsy cloak for skulduggery at worst) . As has been said her frquently before -- what is the scientific context? What is the scientific question? I suspect you need to seek the help of a local statistician before you sweep possibly important data under the outlier rug. Bert Gunter Genentech Nonclinical Biostatistics On Mon, Jul 26, 2010 at 5:40 AM, Tim Smith tim_smith_...@yahoo.com wrote: Hi, I was looking for a package that would help with outlier detection for bimodal distributions. I have tried 'outliers' and 'extremevalues' packages, but am not sure if they are ok for bimodal distribution. Any help would be highly appreciated! thanks, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] zoo objects and c
On Mon, Jul 26, 2010 at 2:17 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Dear R People: I would like to combine a zoo object with some observations at the end. Here is the set up: xgh 2010-06-15 2010-06-16 2010-06-17 2010-06-18 2010-06-19 2010-06-20 2010-06-21 5 6 1 5 0 0 13 2010-06-22 2010-06-23 2010-06-24 2010-06-25 2010-06-26 2010-06-27 2010-06-28 9 6 4 6 0 0 9 2010-06-29 2010-06-30 2010-07-01 2010-07-02 2010-07-03 2010-07-04 2010-07-05 15 10 5 6 0 0 0 2010-07-06 2010-07-07 2010-07-08 2010-07-09 2010-07-10 12 8 3 6 0 xs [1] 2010-06-15 2010-06-16 2010-06-17 2010-06-18 2010-06-19 [6] 2010-06-20 2010-06-21 2010-06-22 2010-06-23 2010-06-24 [11] 2010-06-25 2010-06-26 2010-06-27 2010-06-28 2010-06-29 [16] 2010-06-30 2010-07-01 2010-07-02 2010-07-03 2010-07-04 [21] 2010-07-05 2010-07-06 2010-07-07 2010-07-08 2010-07-09 [26] 2010-07-10 2010-07-11 2010-07-12 2010-07-13 2010-07-14 [31] 2010-07-15 zoo(c(xgh,-0.7,3.6,3.7,3.4,3.2),order=xs) Error in rbind.zoo(...) : indexes overlap What am I doing wrong, please? I'm sure that it's something simple. please use dput when posting to r-help: dput(xgh) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] zoo objects and c
Whoops...sorry about that. Here we go: dput(xgh) structure(c(5, 6, 1, 5, 0, 0, 13, 9, 6, 4, 6, 0, 0, 9, 15, 10, 5, 6, 0, 0, 0, 12, 8, 3, 6, 0), index = structure(c(14775, 14776, 14777, 14778, 14779, 14780, 14781, 14782, 14783, 14784, 14785, 14786, 14787, 14788, 14789, 14790, 14791, 14792, 14793, 14794, 14795, 14796, 14797, 14798, 14799, 14800), class = Date), class = zoo) dput(xs) structure(c(14775, 14776, 14777, 14778, 14779, 14780, 14781, 14782, 14783, 14784, 14785, 14786, 14787, 14788, 14789, 14790, 14791, 14792, 14793, 14794, 14795, 14796, 14797, 14798, 14799, 14800, 14801, 14802, 14803, 14804, 14805), class = Date) zoo(c(xgh,-0.7,3.6,3.7,3.4,3.2),order=xs) Error in rbind.zoo(...) : indexes overlap I just tried this: zoo(c(as.numeric(xgh),-0.7,3.6,3.7,3.4,3.2),order=xs) and it does work. However, I'm not sure if that's the right way to go. Thanks, Erin On Mon, Jul 26, 2010 at 1:20 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Mon, Jul 26, 2010 at 2:17 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Dear R People: I would like to combine a zoo object with some observations at the end. Here is the set up: xgh 2010-06-15 2010-06-16 2010-06-17 2010-06-18 2010-06-19 2010-06-20 2010-06-21 5 6 1 5 0 0 13 2010-06-22 2010-06-23 2010-06-24 2010-06-25 2010-06-26 2010-06-27 2010-06-28 9 6 4 6 0 0 9 2010-06-29 2010-06-30 2010-07-01 2010-07-02 2010-07-03 2010-07-04 2010-07-05 15 10 5 6 0 0 0 2010-07-06 2010-07-07 2010-07-08 2010-07-09 2010-07-10 12 8 3 6 0 xs [1] 2010-06-15 2010-06-16 2010-06-17 2010-06-18 2010-06-19 [6] 2010-06-20 2010-06-21 2010-06-22 2010-06-23 2010-06-24 [11] 2010-06-25 2010-06-26 2010-06-27 2010-06-28 2010-06-29 [16] 2010-06-30 2010-07-01 2010-07-02 2010-07-03 2010-07-04 [21] 2010-07-05 2010-07-06 2010-07-07 2010-07-08 2010-07-09 [26] 2010-07-10 2010-07-11 2010-07-12 2010-07-13 2010-07-14 [31] 2010-07-15 zoo(c(xgh,-0.7,3.6,3.7,3.4,3.2),order=xs) Error in rbind.zoo(...) : indexes overlap What am I doing wrong, please? I'm sure that it's something simple. please use dput when posting to r-help: dput(xgh) -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.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] using string variable as order() function argument
Hello, In my script I would like to use a loop, which sorts the dataframe according to different columns, pointed by the string variable. id col1 col2 col3 1 1004 8 2 1112 2 3 1208 3 4 1305 5 Usually the order() function can be used like this: sorted = mytable[order(column3) , ] which results in properly sorted table: id col1 col2 col3 2 1112 2 3 1208 3 4 1305 5 1 1004 8 But when trying to use a string variable instead of column3 name: columnname = column3 sorted = mytable[order(columnname) , ] this command is not properly evaluated and the effect is somewhat strange. Would you suggest some solution? Thanks a lot! Mirek __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using string variable as order() function argument
On 26/07/2010 2:56 PM, mirek wrote: Hello, In my script I would like to use a loop, which sorts the dataframe according to different columns, pointed by the string variable. id col1 col2 col3 1 1004 8 2 1112 2 3 1208 3 4 1305 5 Usually the order() function can be used like this: sorted = mytable[order(column3) , ] which results in properly sorted table: id col1 col2 col3 2 1112 2 3 1208 3 4 1305 5 1 1004 8 But when trying to use a string variable instead of column3 name: columnname = column3 sorted = mytable[order(columnname) , ] this command is not properly evaluated and the effect is somewhat strange. The argument to order() should be a vector whose sort order is to be returned. So you just need to extract one column from the dataframe, e.g. column - mytable[, columnname] sorted - mytable[order(column) , ] Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] zoo objects and c
On Mon, Jul 26, 2010 at 2:24 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Whoops...sorry about that. Here we go: dput(xgh) structure(c(5, 6, 1, 5, 0, 0, 13, 9, 6, 4, 6, 0, 0, 9, 15, 10, 5, 6, 0, 0, 0, 12, 8, 3, 6, 0), index = structure(c(14775, 14776, 14777, 14778, 14779, 14780, 14781, 14782, 14783, 14784, 14785, 14786, 14787, 14788, 14789, 14790, 14791, 14792, 14793, 14794, 14795, 14796, 14797, 14798, 14799, 14800), class = Date), class = zoo) dput(xs) structure(c(14775, 14776, 14777, 14778, 14779, 14780, 14781, 14782, 14783, 14784, 14785, 14786, 14787, 14788, 14789, 14790, 14791, 14792, 14793, 14794, 14795, 14796, 14797, 14798, 14799, 14800, 14801, 14802, 14803, 14804, 14805), class = Date) zoo(c(xgh,-0.7,3.6,3.7,3.4,3.2),order=xs) Error in rbind.zoo(...) : indexes overlap I just tried this: zoo(c(as.numeric(xgh),-0.7,3.6,3.7,3.4,3.2),order=xs) and it does work. However, I'm not sure if that's the right way to go. It should be written like this: zoo(c(coredata(xgh), -0.7, 3.6, 3.7, 3.4, 3.2), xs) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] HowTo get callback on destroy of grDevices::windows()
I'm build with the usage of the tcltk/tcltk2 package a gui which is started with rscript.exe. At this gui the user is able to open and close plot windows. Now I'm looking for a way that a r function is called when a grDevices::windows window is closed. Is there a way to attach a callback function or so, which would be triggert if the user click at close of the grDevices::window? My workarround is to check continues the open windows with the tcl command after, but it's no good workarround. thanks roland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Time-dependent covarites in survreg function
Dear all, I'm doing a survival analysis with time-dependent covariates. Until now, I have used a simple Cox model for this, specifically the coxph function from the survival library. Now, I would like to try out an accelerated failure time model with a parametric specification as implemented for example in the survreg function. Two questions: First, can survreg handle time-dependent covariates? The description for this function does not make reference to them. And second, in case survreg cannot deal with time-dependent covariates, is there a similar function in some other package that can? Thanks very much, Michael [[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] HowTo get callback on destroy of grDevices::windows()
On 26/07/2010 3:09 PM, rrich...@fh-lausitz.de wrote: I'm build with the usage of the tcltk/tcltk2 package a gui which is started with rscript.exe. At this gui the user is able to open and close plot windows. Now I'm looking for a way that a r function is called when a grDevices::windows window is closed. Is there a way to attach a callback function or so, which would be triggert if the user click at close of the grDevices::window? I don't know if that's possible, but you'll be more likely to get a definitive answer on the R-devel list. Duncan Murdoch My workarround is to check continues the open windows with the tcl command after, but it's no good workarround. thanks roland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] the real dimnames
On 26/07/10 19:01, Michael Lachmann wrote: Hi, R seems to have a feature that isn't used much, which I don't really now how to call. But, the dimnames function, can in addition to giving names to rows/columns/dim 3 rows/dim 4 rows... can also give labels to the dimensions themselves. Thus, I can do: A = matrix(1:9,3,3) dimnames(A) = list(from=c(), to=c() ) If you just want to set the names of the dimnames, just do names(dimnames(A)) - c(from, to) Remember that dimnames is a list and all lists have names. Allan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] HowTo get callback on destroy of grDevices::windows()
okay, thanks I will try the R-devel list :) BR Roland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sample size calculation for non-normal population with unknown mean and SD
Basically, we have a population of 4,392 documents and we want to find out the number of patents per document. We don’t want to go through all 4,392 documents, but want a reliable sample size from which to draw inferences. I feel like this count data will not follow a normal distribution, but more like a Poisson (skewed right.) The problem is we don’t have much similar data to this data set, so mean and standard deviation are unknown. Is there any way to derive a sample size based off the confidence interval, margin of error, and population size for what I assume to be a non-normal population? Any help would be greatly appreciated. -- View this message in context: http://r.789695.n4.nabble.com/Sample-size-calculation-for-non-normal-population-with-unknown-mean-and-SD-tp2302833p2302833.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] Sample size calculation for non-normal population with unknown mean and SD
The obvious: Take a small sample, say 25-50. Get an estimate of your distribution from that. Then use this to determine how many more (if any) additional samples you need for desired precision. This latter can probably easily be done via simulation/bootstrap if you don't want to specify a parametric form. My guess is that your distribution is right-skew but not Poisson -- probably more like a truncated Poisson. But of course I have no idea what sorts of documents you've got, so how would I know? Bert Gunter Genentech Nonclinical Biostatistics On Mon, Jul 26, 2010 at 1:28 PM, Majonu mnu...@andrew.cmu.edu wrote: Basically, we have a population of 4,392 documents and we want to find out the number of patents per document. We don’t want to go through all 4,392 documents, but want a reliable sample size from which to draw inferences. I feel like this count data will not follow a normal distribution, but more like a Poisson (skewed right.) The problem is we don’t have much similar data to this data set, so mean and standard deviation are unknown. Is there any way to derive a sample size based off the confidence interval, margin of error, and population size for what I assume to be a non-normal population? Any help would be greatly appreciated. -- View this message in context: http://r.789695.n4.nabble.com/Sample-size-calculation-for-non-normal-population-with-unknown-mean-and-SD-tp2302833p2302833.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] problem with building package on CRAN
Dear friends, I have just gotten a strange error message back from Uwe saying that the most recent version of psych failed to pass R CMD check for Windows. The error message was less than helpful, in that it seems to have failed when trying to include the Rcpp library, which I do not directly call. (see below) * using log directory 'd:/Rcompile/CRANpkg/local/2.11/psych.Rcheck' * using R version 2.11.1 (2010-05-31) * using session charset: ISO8859-1 * checking for file 'psych/DESCRIPTION' ... OK * this is package 'psych' version '1.0-90' * checking package name space information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking whether package 'psych' can be installed ... ERROR Installation failed. The installation logfile: -Id:/Rcompile/CRANpkg/lib/2.11/Rcpp/include I do have several suggested packages (polycor, GPArotation, MASS, graph, Rgraphviz, mvtnorm, Rcsdp), but none of these are actually required. My examples all ask if the suggested packages are available and then do not call them if they are not. Any suggestions on what to do would be appreciated. Thanks. Bill -- William Revelle http://personality-project.org/revelle.html Professor http://personality-project.org Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern University http://www.northwestern.edu/ Use R for psychology http://personality-project.org/r It is 6 minutes to midnight http://www.thebulletin.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] using string variable as order() function argument
Hello, In my script I would like to use a loop, which sorts the dataframe according to different columns, pointed by the string variable. id col1 col2 col3 1 1004 8 2 1112 2 3 1208 3 4 1305 5 Usually the order() function can be used like this: sorted = mytable**[order(column3) , ] which results in properly sorted table: ** id col1 col2 col3 2 1112 2 3 1208 3 4 1305 5 1 1004 8 **But when trying to use a string variable instead of column3 name: columnname = column3 **sorted = mytable**[order(columnname) , ]** this command is not properly evaluated and the effect is somewhat strange. Would you suggest some solution? Thanks a lot! Mirek __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] easy debugging
I am new to R. Used to use FORTRAN. R is so different from FORTRAN. The following codes would work in FOTRAN. I am trying to put an upper limit at 120. If the score is 120, it is assigned 120. Or else, keep the original values. version 1: equated-11 result-11 equated-c(111.0,112.06, 112.9, 113.8, 115.0, 116.2, 117.0, 118.0, 120.5, 120.5, 120.5) for (i in 1:11){ if (equated 120) result[i]-120 if (equated 120) result[i]-equated[i] result-result result } result version2: if (equated 120) result-120 if (equated 120) result-equated If any of you can help, I would appreciate that. G [[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] Model Fit Statistics in a Logit Model
I'm running a logistic regression model in R. I've used both the Zelig and Car packages. However, I'm wondering if there is a simple way to get the model fit statistics for the model. (pseudo R-square, chi-square, log liklihood,etc) Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] easy debugging
Is this what you want: equated-c(111.0,112.06, 112.9, 113.8, 115.0, 116.2, 117.0, 118.0, 120.5, + 120.5, 120.5) equated[equated 120] - 120 equated [1] 111.00 112.06 112.90 113.80 115.00 116.20 117.00 118.00 120.00 120.00 120.00 You should read up on 'indexing' in the R Intro paper. On Mon, Jul 26, 2010 at 1:26 PM, ying_chen wang gracedrop.w...@gmail.com wrote: I am new to R. Used to use FORTRAN. R is so different from FORTRAN. The following codes would work in FOTRAN. I am trying to put an upper limit at 120. If the score is 120, it is assigned 120. Or else, keep the original values. version 1: equated-11 result-11 equated-c(111.0,112.06, 112.9, 113.8, 115.0, 116.2, 117.0, 118.0, 120.5, 120.5, 120.5) for (i in 1:11){ if (equated 120) result[i]-120 if (equated 120) result[i]-equated[i] result-result result } result version2: if (equated 120) result-120 if (equated 120) result-equated If any of you can help, I would appreciate that. G [[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] Bug on r-bc?
Dear All, The following code should return 1, but it returns 0: source(http://r-bc.googlecode.com/svn/trunk/R/bc.R;) bc(9 % 2) Do you confirm this bug? Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using string variable as order() function argument
Hi, Is this what you want? ## mytable - read.table(textConnection( id col1 col2 col3 1004 8 1112 2 1208 3 1305 5 ), header = TRUE) mytable columnname - col3 mytable[order(mytable[, columnname]), ] ### Josh On Mon, Jul 26, 2010 at 11:54 AM, mirek wyczesany miroslaw.wyczes...@uj.edu.pl wrote: Hello, In my script I would like to use a loop, which sorts the dataframe according to different columns, pointed by the string variable. id col1 col2 col3 1 10 0 4 8 2 11 1 2 2 3 12 0 8 3 4 13 0 5 5 Usually the order() function can be used like this: sorted = mytable**[order(column3) , ] which results in properly sorted table: ** id col1 col2 col3 2 11 1 2 2 3 12 0 8 3 4 13 0 5 5 1 10 0 4 8 **But when trying to use a string variable instead of column3 name: columnname = column3 **sorted = mytable**[order(columnname) , ]** this command is not properly evaluated and the effect is somewhat strange. Would you suggest some solution? Thanks a lot! Mirek __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to generate a random data from a empirical distribition
hi, this is more a statistical question than a R question. but I do want to know how to implement this in R. I have 10,000 data points. Is there any way to generate a empirical probablity distribution from it (the problem is that I do not know what exactly this distribution follows, normal, beta?). My ultimate goal is to generate addition 20,000 data point from this empirical distribution created from the existing 10,000 data points. thank you all in advance. -- View this message in context: http://r.789695.n4.nabble.com/how-to-generate-a-random-data-from-a-empirical-distribition-tp2302716p2302716.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] Your message to R-help awaits moderator approval
verry sorry for posting the mwssage below from wrong email account. please reject it. sorry for the inconvenience... mirek On 07/26/2010 08:54 PM, r-help-boun...@r-project.org wrote: Your mail to 'R-help' with the subject using string variable as order() function argument Is being held until the list moderator can review it for approval. The reason it is being held: Post by non-member to a members-only list Either the message will get posted to the list, or you will receive notification of the moderator's decision. If you would like to cancel this posting, please visit the following URL: https://stat.ethz.ch/mailman/confirm/r-help/a091c4c24fa7c13e6e67722b19bbc43a0badf79f -- Mirek Wyczesany Jagiellonian University Psychophysiology Lab Kraków, PL __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Accessing single element of data.frame
Hi I am new to R. I am having this problem t1 - read.csv(myfile.csv) t2 - data.frame(t1) which have 10 row and 10 columns t2[1,1] does not give the first element but it gives the levels, how can I fix it. I will be thankful to community. -- View this message in context: http://r.789695.n4.nabble.com/Accessing-single-element-of-data-frame-tp2302770p2302770.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] easy debugging
On Mon, Jul 26, 2010 at 2:06 PM, ying_chen wang gracedrop.w...@gmail.com wrote: Thanks, it works. I found out the solution a moment ago. The 2nd one works. But, the weird thing is that if I use 'x', it works. If I use 'equated', it didn't work. Not sure why. What is 'x' ? Thanks again. G On Mon, Jul 26, 2010 at 5:04 PM, Joshua Wiley jwiley.ps...@gmail.com wrote: What about these two options? #One way ifelse(equated 120, 120, equated) #Another way equated[equated 120] - 120 HTH, Josh On Mon, Jul 26, 2010 at 10:26 AM, ying_chen wang gracedrop.w...@gmail.com wrote: I am new to R. Used to use FORTRAN. R is so different from FORTRAN. The following codes would work in FOTRAN. I am trying to put an upper limit at 120. If the score is 120, it is assigned 120. Or else, keep the original values. version 1: equated-11 result-11 equated-c(111.0,112.06, 112.9, 113.8, 115.0, 116.2, 117.0, 118.0, 120.5, 120.5, 120.5) for (i in 1:11){ if (equated 120) result[i]-120 if (equated 120) result[i]-equated[i] result-result result } result version2: if (equated 120) result-120 if (equated 120) result-equated If any of you can help, I would appreciate that. G [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] easy debugging
What about these two options? #One way ifelse(equated 120, 120, equated) #Another way equated[equated 120] - 120 HTH, Josh On Mon, Jul 26, 2010 at 10:26 AM, ying_chen wang gracedrop.w...@gmail.com wrote: I am new to R. Used to use FORTRAN. R is so different from FORTRAN. The following codes would work in FOTRAN. I am trying to put an upper limit at 120. If the score is 120, it is assigned 120. Or else, keep the original values. version 1: equated-11 result-11 equated-c(111.0,112.06, 112.9, 113.8, 115.0, 116.2, 117.0, 118.0, 120.5, 120.5, 120.5) for (i in 1:11){ if (equated 120) result[i]-120 if (equated 120) result[i]-equated[i] result-result result } result version2: if (equated 120) result-120 if (equated 120) result-equated If any of you can help, I would appreciate that. G [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using string variable as order() function argument
Try this: mytable id col1 col2 col3 1 10048 2 11122 3 12083 4 13055 colName - 'col3' mytable[order(mytable[[colName]]),] id col1 col2 col3 2 11122 3 12083 4 13055 1 10048 colName - 'id' mytable[order(mytable[[colName]]),] id col1 col2 col3 1 10048 2 11122 3 12083 4 13055 On Mon, Jul 26, 2010 at 2:54 PM, mirek wyczesany miroslaw.wyczes...@uj.edu.pl wrote: Hello, In my script I would like to use a loop, which sorts the dataframe according to different columns, pointed by the string variable. id col1 col2 col3 1 10 0 4 8 2 11 1 2 2 3 12 0 8 3 4 13 0 5 5 Usually the order() function can be used like this: sorted = mytable**[order(column3) , ] which results in properly sorted table: ** id col1 col2 col3 2 11 1 2 2 3 12 0 8 3 4 13 0 5 5 1 10 0 4 8 **But when trying to use a string variable instead of column3 name: columnname = column3 **sorted = mytable**[order(columnname) , ]** this command is not properly evaluated and the effect is somewhat strange. Would you suggest some solution? Thanks a lot! Mirek __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with building package on CRAN
Hello, (ccing Rcpp-devel too because this is relevant) This comes up every now and again on packages that are completely unrelated to Rcpp. We don't know yet why or what to do to fix the issue. I believe (but this might not be the case) that this is due to packages that do use Rcpp and fail to follow our guidelines and documentation and emails about using LinkingTo to pull in header files. See http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2010-July/000898.html I'm really sorry you are caught in the middle of this, there is probably nothing wrong with your package, it just happens sort of randomly. I believe the chances of this happening would be lower if package developers (of package using Rcpp) would be so kind and follow our guidelines, but we can only offer to write the guidelines, we cannot force them to read or apply them. Romain Le 26/07/10 22:43, William Revelle a écrit : Dear friends, I have just gotten a strange error message back from Uwe saying that the most recent version of psych failed to pass R CMD check for Windows. The error message was less than helpful, in that it seems to have failed when trying to include the Rcpp library, which I do not directly call. (see below) * using log directory 'd:/Rcompile/CRANpkg/local/2.11/psych.Rcheck' * using R version 2.11.1 (2010-05-31) * using session charset: ISO8859-1 * checking for file 'psych/DESCRIPTION' ... OK * this is package 'psych' version '1.0-90' * checking package name space information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking whether package 'psych' can be installed ... ERROR Installation failed. The installation logfile: -Id:/Rcompile/CRANpkg/lib/2.11/Rcpp/include I do have several suggested packages (polycor, GPArotation, MASS, graph, Rgraphviz, mvtnorm, Rcsdp), but none of these are actually required. My examples all ask if the suggested packages are available and then do not call them if they are not. Any suggestions on what to do would be appreciated. Thanks. Bill -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/bc8jNi : Rcpp 0.8.4 |- http://bit.ly/dz0RlX : bibtex 0.2-1 `- http://bit.ly/a5CK2h : Les estivales 2010 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] O/T good c/c++ code for LU decomposition
Dear R People: Could someone recommend a good c/c++ code (or Fortran) for LU decomposition, please? Sorry to bother about this. I'm trying to do some non-R work that requires a matrix inversion. Thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] version 2.0-0 of the car package
Dear all, Sandy Weisberg and I would like to announce version 2.0-0 of the car package, now on CRAN. We've released this major revision of the package in anticipation of the publication of An R Companion to Applied Regression, Second Edition (Sage, in press), co-authored by us, which should be available before the end of the year. The new version of the car package has a number of new functions and data sets, along with many changes to old functions, including a change in naming conventions, using camel-case rather than period-separated names: for example, av.plots() is now avPlots(). For the time-being, old function names, such as av.plots(), are available as deprecated aliases. A few functions from the alr3 package have also been rewritten, renamed, and are now part of car. The alr3 package will be updated later in the year. Regards, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Accessing single element of data.frame
The solution to (most R problems) is as follows: 1.if asking for help include reproducible examples including parts of your data otherwise we can just guess what kind of data you have. 2. In general, refer to the help pages of the functions you use ( help(read.csv),help(data.frame) ) ( i have to confess that a similar problem puzzled me for quite a while, so here comes suggestion 3: 3. As a start, have a look what kind of data you have: class(t1) class(t2) class(t2[2,]) I would guess that t2 is a factor and not a vector and that the problem lies in read.csv converting whatever data you have to factors. See ?read.csv and the stringsAsFactors argument of that call. Adjusting its values might fix your problem. If not, go back to advice 1 ;-) HTH Jannis vacas schrieb: Hi I am new to R. I am having this problem t1 - read.csv(myfile.csv) t2 - data.frame(t1) which have 10 row and 10 columns t2[1,1] does not give the first element but it gives the levels, how can I fix it. I will be thankful to community. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] latent class analysis with mixed variable types
Donald, Mixed types are handled in flexmix and in depmixS4, not sure about ordinal in flexmix (depmixS4 does not handle ordinal but does handle multinomial, constraints may be an option to deal with ordinal); both have glm distributions, ie gaussian, binary and many others. Best, Ingmar On Sat, Jul 24, 2010 at 3:52 AM, Donald Braman donald.bra...@gmail.comwrote: As an alternative to Latent GOLD, I'm wondering if anyone knows of and R package that can manage Latent Class Analysis with mixed variable types (continuous, ordinal, and nominal/binary). [[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] O/T good c/c++ code for LU decomposition
Hi, Armadillo (http://arma.sourceforge.net/docs.html) has LU. Here is an example adapted from armadillo's documentation using Rcpp/RcppArmadillo and inline: require( inline ) require( RcppArmadillo ) fx - cxxfunction( signature( A_ = matrix), ' using namespace arma ; mat A = asmat(A_); mat L; mat U; mat P; lu(L, U, P, A); mat B = trans(P)*L*U; return List::create( _[L] = L, _[U] = U, _[P] = P, _[A] = A, _[B] = B ) ; ', plugin = RcppArmadillo ) fx( matrix( runif(100), 10, 10) ) Romain Le 26/07/10 23:46, Erin Hodgess a écrit : Dear R People: Could someone recommend a good c/c++ code (or Fortran) for LU decomposition, please? Sorry to bother about this. I'm trying to do some non-R work that requires a matrix inversion. Thanks, Erin -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/bc8jNi : Rcpp 0.8.4 |- http://bit.ly/dz0RlX : bibtex 0.2-1 `- http://bit.ly/a5CK2h : Les estivales 2010 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Switch Enter and Return in R.app?
Hi all, I googled this but no luck. I am using R.app 2.10.1 on Mac OSX 10.4. Here's the problem: When I type at the R.app command line and hit the carriage return Enter (right pinky, Return on some keyboards), it just adds a blank line. To actually get the command to execute, I have to go all the way over to the number-keypad and hit Enter there. Surely there must be a way to get R.app to synonymize these two keys? All that moving over to the number pad is driving me nuts. Thanks so much!! Apologies if it is something obvious which I missed!! Nick -- Nicholas J. Matzke Ph.D. Candidate, Graduate Student Researcher Huelsenbeck Lab Center for Theoretical Evolutionary Genomics 4151 VLSB (Valley Life Sciences Building) Department of Integrative Biology University of California, Berkeley Graduate Student Instructor, IB200A Principles of Phylogenetics: Systematics http://ib.berkeley.edu/courses/ib200a/index.shtml Lab websites: http://ib.berkeley.edu/people/lab_detail.php?lab=54 http://fisher.berkeley.edu/cteg/hlab.html Dept. personal page: http://ib.berkeley.edu/people/students/person_detail.php?person=370 Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html Lab phone: 510-643-6299 Dept. fax: 510-643-6264 Cell phone: 510-301-0179 Email: mat...@berkeley.edu Mailing address: Department of Integrative Biology 3060 VLSB #3140 Berkeley, CA 94720-3140 - [W]hen people thought the earth was flat, they were wrong. When people thought the earth was spherical, they were wrong. But if you think that thinking the earth is spherical is just as wrong as thinking the earth is flat, then your view is wronger than both of them put together. Isaac Asimov (1989). The Relativity of Wrong. The Skeptical Inquirer, 14(1), 35-44. Fall 1989. http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug on r-bc?
Paul Smith phhs80 at gmail.com writes: Dear All, The following code should return 1, but it returns 0: source(http://r-bc.googlecode.com/svn/trunk/R/bc.R;) bc(9 % 2) Do you confirm this bug? It's not a bug in r-bc, it's a misfeature (?) in bc. It has to do with the 'scale' parameter in bc (which gets set to 100 explicitly by r-bc, but would be set to 20 in any case by the use of the '-l' option to bc) http://superuser.com/questions/31445/gnu-bc-modulo-with-scale-other-than-0 http://en.wikipedia.org/wiki/Bc_programming_language http://www.linuxquestions.org/questions/programming-9/bc-using-l-messes-up-modulus-331003/ a workaround; source(http://r-bc.googlecode.com/svn/trunk/R/bc.R;) bc(scale=0; 9%2) [1] 1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug on r-bc?
On Mon, Jul 26, 2010 at 1:44 PM, Paul Smith phh...@gmail.com wrote: Dear All, The following code should return 1, but it returns 0: source(http://r-bc.googlecode.com/svn/trunk/R/bc.R;) bc(9 % 2) See FAQ 2 on the r-bc package home page: http://r-bc.googlecode.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] Plot of a subset of a data.frame()
On Jul 26, 2010, at 10:56 AM, Steffen Uhlig wrote: Dear David, Petr, and Alain, thank you very much for your fast responses. It's a typical handbook-not-read-error at my side. I will dig deeper into the plot-functions and the assignment of data. I was not aware of that the vector a is handled as a vector of factors with 10 levels. Thanks for your suggestions and hints! You can prevent that behavior and instead get a character vector ... at least from functions that return such ... by using stringsAsFactors = FALSE within the data.frame call. You also have the option of setting that globally which at least one well known institution has adopted as the default policy for its work. ?data.frame ?options -- David Best regards, /steffen Am 26.07.2010 14:30, schrieb David Winsemius: On Jul 26, 2010, at 7:38 AM, Steffen Uhlig wrote: Hello, my data.frame is sort of a collection of process values, i.e. huge run-chart. It consists of a time-stamp in the first column (date as string), factors in the following columns (used for subset- filtering), and some process-data columns. Hereafter, two examples are listed, showing the problems that occour during print: At first the example, that works fine: ~~ a = c(1:10) # create a vector of integers b = rep(c(a,b),5) # create a vector of chars, used # as factor-levels d = rnorm(10) # some random numbers e = data.frame(a,b,d) # connect to a data.frame You've gotten several answers, but none have addressed an aspect of R behavior that took me longer to appreciate than it perhaps should have. The b column inside the e data.frame is now a factor column. I mention that because you later referred to it as a string which it is not. It is an integer with an associated indexed level character vector. Many of the functions that you might think would work on strings will give either errors or unexpected results when applied to factors. e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) # plot first data-subset points(d~a, e.2, pch=4, col=3) # plot the 2nd one ~~ all looks fine in theses plots. However, changing the content of vector a to a set of strings the following happens: ~~ a = c(a,b,c,d,e,f,g,h,i,j) e = data.frame(a,b,d) # re-build data.frame e.1 = subset(e, b==a) # create two subsets e.2 = subset(e, b==b) plot(d~a, e.1, pch=3, col=2) points(d~a, e.2, pch=4, col=3) ~~ The plot-command produces horizontal lines instead of dots. This seems to happen when the x-axis contains strings rather than numbers. is there a way out? Best regards, /Steffen -- Steffen Uhlig, PhD Mechatronik und Sensortechnik HTW des Saarlandes Goebenstraße 40 66117 Saarbrücken Tel.: +49 (0) 681 58 67 274 David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to generate a random data from a empirical distribition
On Jul 26, 2010, at 2:36 PM, xin wei wrote: hi, this is more a statistical question than a R question. but I do want to know how to implement this in R. I have 10,000 data points. Is there any way to generate a empirical probablity distribution from it (the problem is that I do not know what exactly this distribution follows, normal, beta?). ?ecdf My ultimate goal is to generate addition 20,000 data point from this empirical distribution created from the existing 10,000 data points. thank you all in advance. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.