Re: [R] r function definition
Are you using windows? If you are you may want to try to run your R code from a batch file: REM on Microsoft Windows (adjust the path to R.exe as needed) C:\Program Files\R\R-2.13.2\bin\x64\R.exe CMD BATCH C:\Users\Frank\Documents\R\Projects\Heinrich\Heinrich.txt C:\Users\Frank\Documents\R\Projects\Heinrich\Heinrich.out PAUSE Where ...Heinrich.txt is the following R code in a text file: pdf(Heinrich.pdf) ## load Pearson package library(PearsonDS) ## calculate probability density function Fig. 1 x - seq(0.0, +20.0, length=100) hx- dpearsonIV(x,m=2.25,nu=5,location=17,scale=2) k-0.0206631 plot(x, hx , type=l, lwd=2, tck=1, xlab=x value, ylab=Density, main=J. Heinrich Fig. 1) ## calculate probability density function Fig 2 hx- dpearsonIV(x,m=0.75,nu=1.0,location=15,scale=0.5) k-0.218991 plot(x, hx , type=l, lwd=2, tck=1, xlab=x value, ylab=Density, main=J. Heinrich Fig. 2) quit() and Heinrich.out will contain the output of the results of the commands. Look at Heinrich.out for results and errors. Then correct the text file and rerun. GL Frank Chicago Date: Mon, 3 Dec 2012 12:30:31 -0800 From: q...@hotmail.com To: r-help@r-project.org Subject: [R] r function definition I am a very new R user. I am trying to write functons and debug functions. One problem for me is that I need to alwasy copy the whole function body and resubmit to R console every time I changed even one line of the function. Because I have long algorithm function, copying and pasting is very tedious for me. I assume if I save the function files, R should be able to just use the new function body since it is a scripting language. Can somebody let me know his best practice of using R function? -- View this message in context: http://r.789695.n4.nabble.com/r-function-definition-tp4651943.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] QQplot
Have you tried fitting your data to the Pearson family of distributions? In particular the Pearson Type IV has parameters to fit skewed and kurtotic distributions. The Pearson library is described here: http://cran.r-project.org/web/packages/PearsonDS/PearsonDS.pdf The Type IV is described here: http://www-cdf.fnal.gov/physics/statistics/notes/cdf6820_pearson4.pdf GL, Frank Chicago Date: Thu, 29 Nov 2012 07:03:28 -0800 From: michaelverbi...@msn.com To: r-help@r-project.org Subject: [R] QQplot Hi! http://r.789695.n4.nabble.com/file/n4651293/qq.png We are stuck with a problem considering the qqplot of a dataset. We are trying to discover what kind of distribution this is. We already tried to normal, exponential or the logaritmical distribution but none of those are able to solve our problem. Is there someone able to tell us what kind deformation we should try? (I'm sorry for the horrible English but I'm not a native speaker) Thanks! Nathan -- View this message in context: http://r.789695.n4.nabble.com/QQplot-tp4651293.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] Create BATCH file
C:\Program Files\R\R-2.15.1\bin\x64\R.exe CMD BATCH C:\Users\Frank\Documents\R\Projects\Current_Yield\Divs.txt C:\Users\Frank\Documents\R\Projects\Current_Yield\Divs.out Divs.txt contains my R code and the output goes to Divs.out. I always check Divs.out first. If you want to write objects to divs.out, I seem to need to use the print command, not just have the object name: ndivs-nrow(Divs) print(ndivs) Divs_Per_Year-4 print(Divs_Per_Year) Let me know if you have any questions. Thanks, Frank Date: Wed, 21 Nov 2012 02:58:53 -0800 From: antony.akk...@ge.com To: r-help@r-project.org Subject: [R] Create BATCH file Hi, I have a .R file written many functions into that. My requirement what is, i need to create a batch file for this. No idea, how to create it. Tried it many other ways, but no result !. Could anyone please help me out ? Thanks. Antony. -- View this message in context: http://r.789695.n4.nabble.com/Create-BATCH-file-tp4650277.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] about lm
dat=read.csv(c:\\ven.csv,header=TRUE,sep=;); attach(attach(dat)) dat lm.1-lm(ve~ su) summary(lm.1) GL Frank Date: Fri, 16 Nov 2012 20:42:39 +0100 From: soniaam...@gmail.com To: r-help@r-project.org Subject: [R] about lm Dear friends, I have a csv file entitled ven.csv located in C:\\, this file contains only two columns:ve and su I have written the following lines: data=read.csv(c:\\ven.csv,header=TRUE,sep=;); lm(ve~ su) I have obtained the following message: Error in eval(expr, envir, enclos) : object 've' does not exist. What's the problem? thank you for your help in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] about lm
attach(attach(dat)) should be attach(dat) Is attach() broken? I've been using attach() successfully for months. I was surprised that header=TRUE did not map the headers to the data. But since attach() worked, I've never asked for an enhancement to the various read functions. Thanks, Frank CC: soniaam...@gmail.com; r-help@r-project.org From: dwinsem...@comcast.net To: chicagobrownb...@hotmail.com Subject: Re: [R] about lm Date: Sat, 17 Nov 2012 08:31:01 -0800 On Nov 17, 2012, at 4:29 AM, FJ M wrote: dat=read.csv(c:\\ven.csv,header=TRUE,sep=;); attach(attach(dat)) It is generally less error prone to avoid attach (even once). dat lm.1-lm(ve~ su) And instead use: lm.1-lm(ve~ su, data=dat) summary(lm.1) GL Frank Date: Fri, 16 Nov 2012 20:42:39 +0100 From: soniaam...@gmail.com To: r-help@r-project.org Subject: [R] about lm Dear friends, I have a csv file entitled ven.csv located in C:\\, this file contains only two columns:ve and su I have written the following lines: data=read.csv(c:\\ven.csv,header=TRUE,sep=;); lm(ve~ su) I have obtained the following message: Error in eval(expr, envir, enclos) : object 've' does not exist. What's the problem? thank you for your help in advance [[alternative HTML version deleted]] When you do get around to reading the Posting Guide, please note the section where the request to NOT post in HTML is made. 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 Alameda, CA, USA [[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] Moving a file from one location to another
Thanks for this timely post for me. I'm missing something in cat to get file.rename to work for me. cat puts a NULL at the end of a string. Error: downloading MSFT .trying URL 'http://chart.yahoo.com/table.csv?s=MSFTa=1b=19c=2003d=9e=17f=2012g=dq=qy=0z=MSFTx=.csv' Content type 'text/csv' length unknown opened URL downloaded 119 Kbdone. MSFT _Divs.csvNULL Error in file.rename(Stock_Divs.csv, file_name) : invalid 'to' argument Execution halted Code: library(quantmod)## ## Merge Date OHLC with dividend on ex-dividend date ## ticker-c(MSFT,KMI) Divs_Per_Year-4for (i in 1:2) { Divs-getDividends(ticker[i]) Stock-getSymbols.yahoo(ticker[i], from = start(Divs), src = yahoo, verbose=TRUE, auto.assign=FALSE) Stock_Divs-merge(Stock,Divs,fill=0.0) write.zoo(Stock_Divs, file = Stock_Divs.csv, append = FALSE, quote = TRUE, sep = ,) file_name- cat(ticker[i],_Divs.csv) print(file_name) print file.rename(Stock_Divs.csv,file_name) } Best, FrankChicago From: michael.weyla...@gmail.com Date: Wed, 17 Oct 2012 13:47:27 +0100 To: ruipbarra...@sapo.pt CC: r-help@r-project.org; antony.akk...@ge.com Subject: Re: [R] Moving a file from one location to another On Wed, Oct 17, 2012 at 12:53 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, On Windows this should be the old DOS command RENAME (or REN) and apparently the R function ?file.rename carries it's name. I wasn't aware of the file.*() functions -- I'll of course retract my statement that this has to be OS direct via system(). Thanks for that Rui! Cheers, 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. [[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] Graphs using R
To start: pdf(Auto_Analysis.pdf) from the R console type: ? hist For the histogram help page. If you show the R code for your data, I'll generate the actual code for the histogram. Thanks. From: nethal.j...@sydney.edu.au To: r-help@r-project.org Date: Mon, 8 Oct 2012 08:26:59 + Subject: [R] Graphs using R Dear, I have a table with four columns similar to the following: Factory Name Production typeMonthsFreq Factory 1 Car type 1 Jan.0 Factory 1 Car type 2 Feb. 1 Factory 2Car type 3 May 3 I need help in producing graphs; 1. I need to graph the production of the factories per month in Stacked columns 2. I need to graph the each of the production type by factory and month. Regards N.Jajo [[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] Batch Mode for Windows
I have a batch file to run R commands in a text file and an output file that I use. C:\Program Files\R\R-2.13.2\bin\x64\R.exe CMD BATCH C:\Users\Frank\Documents\R\Scripts\TLT_2012.txt C:\Users\Frank\Documents\R\Scripts\TLT_2012.out PAUSE I worked in an environment that you had to fully specify a path, hence C:\Program Files\R\R-2.13.2\bin\x64\R.exe which I continue as a personal best practices. TLT_2012.txt starts with colors - c(red, blue, darkgreen, gold, black) labels - c(8/11/2011,11/3/2011, 2/28/2012, 5/9/2012) pdf(C:\\Users\\Frank\\Documents\\R\\Scripts\\TLT_2012.pdf) . . . TLT_2012.out contains the R output and in particular the errors and warnings. I always consult the .out file first since I usually have errors :). Best, Frank Chicago, IL Date: Fri, 10 Aug 2012 13:59:34 -0700 From: sx...@mtlakes.org To: r-help@r-project.org Subject: [R] Batch Mode for Windows Hi, I have researched batch mode for windows and could not find anything that worked. I know the code should be $ R CMD BATCH inputfile.R outputfile.Rout or R inputfile.R outputfile.Rout I tried these without success. I need detailed, step by step instructions on how to do this. I have tried typing C:\R\bin\x64\Rgui.exe before it, but this just opens R. When I tried to do this, it said that $, R, etc. are not recognizable commands. In other instances it said that the arguments R, CMD, and BATCH were ignored. What specifically should I do to make this work? I thought I was supposed to change the directory to the folder where my input file was stored, but this did not work either. -- View this message in context: http://r.789695.n4.nabble.com/Batch-Mode-for-Windows-tp4639977.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Accessing more than two coefficients in a plot
I needed to create my own forecast from the square root, linear and quadratic coefficients and then the abline() plot worked fine. # Forecast l using non-linear regression coeffs - unweighted lm2.bforecast- numeric(n) for (i in 1:n) { lm2.bforecast[i] - lm2.b$coeff[(Intercept)]+lm2.b$coeff[VV1_2]*VV1_2[i]+lm2.b$coeff[VV1_22]*VV1_22[i]+lm2.b$coeff[VV1_212]*VV1_212[i] } lm2.bforecastline-lm(lm2.bforecast ~ VV1_2, method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE) # unweighted, non-linear regression forecast plot(VV1_2, Lambda1_2, ylim=yrange, tck=1, main=Verizon V(1) Parameters (V, V^2 V^0.5) Unweighted, xlab=VV1_2, ylab=Lambda1_2 Beta1_2,pch=19,col=red) {points(VV1_2, lm2.lforecast, pch=19, col=brown) abline(lm2.lforecastline, col=brown, lty=longdash, lwd=2) ... Date: Sun, 25 Mar 2012 15:36:20 -0700 Subject: Re: [R] Accessing more than two coefficients in a plot From: gunter.ber...@gene.com To: chicagobrownb...@hotmail.com CC: r-help@r-project.org Well, as a line in the plane is determined by 2 coefficients only, I'd guess that trying to find an R function that plots a line defined by 4 coefficients has about the same chance of success as finding a unicorn with 3 horns. You do understand that your linear model defines a hyperplane in your three covariates, do you not? Or do I misunderstand what you have requested? Cheers, Bert On Sun, Mar 25, 2012 at 2:32 PM, FJ M chicagobrownb...@hotmail.com wrote: I've successfully plotted (in the plot and abline code below) a simple regression of Lambda1_2 on VV1_2. I then successfully regressed Lambda1_2 on VV1_2, VV1_22 and VV1_212 producing lm2.l. When I go to plot lm2.l using abline I get the warning: 1: In abline(lm2.l, col = brown, lty = dotted, lwd = 2) : only using the first two of 4 regression coefficients Is there another function like abline that will produce a line using the constant and three coefficients from the lm2.l regression? lm.l - lm(Lambda1_2 ~ VV1_2, method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE) # unweighted regression lm2.l - lm(Lambda1_2 ~ VV1_2 + VV1_22 + VV1_212, method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE) # unweighted regression plot(VV1_2, Lambda1_2, ylim=yrange, tck=1, main=V(1) Parameters (V, V^2 V^0.5), xlab=VV1_2, ylab=Lambda Beta1_2,pch=19,col=red) {abline(lm2.l, col=brown, lty=dotted, lwd=2) abline(wlm2.l, col=gold,lty=longdash, lwd=2) points(VV1_2, Beta1_2, pch=19, col=blue) abline(lm2.b, col=black,lty=dotted, lwd=2) abline(wlm2.b, col=blue, lty=longdash, lwd=2) legend(topright, inset=.05, title=Parameters, labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Integrate(dnorm) with different mean and standard deviation help
It would be a useful additon to the help page to add integrate(dnorm, lower = -1.96, upper = 1.96, mean = 2, sd = 1) as an example. Thanks, Frank Chicago Date: Mon, 23 Jul 2012 19:54:45 -0700 From: ehl...@ucalgary.ca To: kri...@ymail.com CC: chicagobrownb...@hotmail.com; r-help@r-project.org Subject: Re: [R] Integrate(dnorm) with different mean and standard deviation help On 2012-07-23 19:48, Pascal Oettli wrote: Hello, Maybe the following could help: f - function(x) dnorm(x, mean=2, sd=1) integrate(f, -1.96, 1.96) 0.4840091 with absolute error 1.4e-12 Or you could note the '...' argument indicated on the help page: integrate(dnorm, lower = -1.96, upper = 1.96, mean = 2, sd = 1) Peter Ehlers HTH Regards. Le 24/07/2012 11:23, FJ M a écrit : I'm trying to provide different parameters to the integrate function for various probability functions. I'm using dnorm as the simplest example here. For instance integrate(dnorm, -1.96, 1.96) produces the correct answer for a normal distribution with mean 0 and standard deviation 1. I've tried two ways to use mean=2.0 and standard deviation 1, but with no luck. The examples follow. integrate(dnorm, -1.96, 1.96) 0.9500042 with absolute error 1e-11 mean = 2.0 sd = 1.0 integrate(dnorm, -1.96, 1.96) 0.9500042 with absolute error 1e-11 integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96) Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing Calls: integrate - match.fun - dnorm Execution halted How do I change the built in mean=0 and standard deviation=1 for dnorm using integrate? Thanks, Frank Chicago, IL [[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. [[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] Integrate(dnorm) with different mean and standard deviation help
I'm trying to provide different parameters to the integrate function for various probability functions. I'm using dnorm as the simplest example here. For instance integrate(dnorm, -1.96, 1.96) produces the correct answer for a normal distribution with mean 0 and standard deviation 1. I've tried two ways to use mean=2.0 and standard deviation 1, but with no luck. The examples follow. integrate(dnorm, -1.96, 1.96) 0.9500042 with absolute error 1e-11 mean = 2.0 sd = 1.0 integrate(dnorm, -1.96, 1.96) 0.9500042 with absolute error 1e-11 integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96) Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing Calls: integrate - match.fun - dnorm Execution halted How do I change the built in mean=0 and standard deviation=1 for dnorm using integrate? Thanks, Frank Chicago, IL [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] HELP me please with import of csv to R
Try putting the data into some kind of object. I'm not sure what R does with the data from read.csv. I always 1) read the data into an object 2) print the data out 3) attach the data so that the headers become objects that contain the data 4) and yes, print the data out using ls 5) check the output file just in case one of 1-4 throw an error. v_data - read.table(C:\\Users\\Frank\\Options\\CBOE\\VZ\\2012\\VZ_2012_03_Summary_V0_R.TXT,header=T) v_data attach(v_data) ls(v_data) GL Frank Chicago, IL Date: Tue, 10 Jul 2012 09:48:04 -0700 From: farad...@gmail.com To: r-help@r-project.org Subject: [R] HELP me please with import of csv to R Hey, I am having problems with importing a csv file to R. I could read the file by typing: read.csv(file=/Users/kama/Desktop/skatter.csv, header=TRUE, sep=;) However, i can not analyze the skatter - for ex, when i type: skatter = read.csv(skatter.csv) i get this message: Error in file(file, rt) : cannot open the connection In addition: Warning message: In file(file, rt) : What i need is to import this file and analyze it using for example histogram. I have Mac(update) and the file is saved in csv file... and I'm quite new user of R. Thank you very much! -- View this message in context: http://r.789695.n4.nabble.com/HELP-me-please-with-import-of-csv-to-R-tp4636019.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MS-DOS script R
I have the following in a batch file TLT.BAT: C:\Program Files\R\R-2.13.2\bin\x64\R.exe CMD BATCH C:\Users\Frank\Documents\R\Scripts\TLT_2012.txt C:\Users\Frank\Documents\R\Scripts\TLT_2012.out PAUSE The TLT_2012.txt has my R code in it. The TLT_2012.out has the output from R. Look to TLT_2012.out for problems with your batch file. Frank Chicago, IL Date: Wed, 4 Jul 2012 05:44:01 -0700 From: cindy.dolom...@insa-lyon.fr To: r-help@r-project.org Subject: [R] MS-DOS script R Hi, I would like to run R with a script from MS-DOS. R is in My Documents and my script too. How to do? -- View this message in context: http://r.789695.n4.nabble.com/MS-DOS-script-R-tp4635398.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] qplot and colors (Please Help)
colors - c(red, blue, darkgreen, gold, black) labels - c(3/02/2012,12/30/2011,4/20/2012) In plot I use { plot(x, hx1 , type=l, lwd=2, tck=1, col=colors[1], ylim=c(0, maxhx), xlab=x value, ylab=Density, main=AAPL) . . . labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors) } It looks like qplot uses colour=colors to pickup colors. At the R console type colors() For a list of color names and numbers. Hope this helps. Frank Chicago, IL Date: Wed, 27 Jun 2012 09:07:53 -0700 From: david_ly...@yahoo.com To: r-help@r-project.org Subject: [R] qplot and colors (Please Help) Please help: I am using qplot as below and want to specify a different color scheme for race but dont know how, can someone show me. Thanks in advance Code and input file below: library(ggplot2) library(gridExtra) d-read.table(results, header=TRUE, fill=TRUE) plot2-qplot(X,Y,data=d,color=race,facets=TYPE~., xlab=X, ylab=Y) + theme_bw() grid.arrange(plot2,ncol=1) dev.off() cat results snip X Y ID raceTYPE 0.0350 0.02001XNA 0.0280 0.02512XNA 0.0258 0.01753YNA /snip __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Accessing more than two coefficients in a plot
I've successfully plotted (in the plot and abline code below) a simple regression of Lambda1_2 on VV1_2. I then successfully regressed Lambda1_2 on VV1_2, VV1_22 and VV1_212 producing lm2.l. When I go to plot lm2.l using abline I get the warning: 1: In abline(lm2.l, col = brown, lty = dotted, lwd = 2) : only using the first two of 4 regression coefficients Is there another function like abline that will produce a line using the constant and three coefficients from the lm2.l regression? lm.l - lm(Lambda1_2 ~ VV1_2, method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE) # unweighted regression lm2.l - lm(Lambda1_2 ~ VV1_2 + VV1_22 + VV1_212, method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE) # unweighted regression plot(VV1_2, Lambda1_2, ylim=yrange, tck=1, main=V(1) Parameters (V, V^2 V^0.5), xlab=VV1_2, ylab=Lambda Beta1_2,pch=19,col=red) {abline(lm2.l, col=brown, lty=dotted, lwd=2) abline(wlm2.l, col=gold,lty=longdash, lwd=2) points(VV1_2, Beta1_2, pch=19, col=blue) abline(lm2.b, col=black,lty=dotted, lwd=2) abline(wlm2.b, col=blue, lty=longdash, lwd=2) legend(topright, inset=.05, title=Parameters, labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] where I can find more color names or color definition?
Load package fBasics library(fBasics) colors() should give you what you want. Also helpful are colorTable() colorLocator() Which I found by searching for colors from the R console help menu. Date: Wed, 14 Mar 2012 22:55:39 +0800 From: totang...@gmail.com To: r-help@r-project.org Subject: [R] where I can find more color names or color definition? hi everyone . Now I want to draw several lines in one frame.And it seems needs more colors except for blue red,black .Where can i found these color name or define some new color ?thank you . -- TANG Jie Email: totang...@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Automating R script with Windows 7
I created a txt file with R commands in it and then a batch file to process the txt file. The batch file could be scheduled. The batch file is: REM on Microsoft Windows (adjust the path to R.exe as needed) C:\Program Files\R\R-2.13.2\bin\x64\R.exe CMD BATCH C:\Users\Frank\Documents\R\Scripts\Multi_Graph.txt C:\Users\Frank\Documents\R\Scripts\Multi_Graph.out PAUSE The text file is: x - seq(-4, 4, length=100) hx - dnorm(x) degf - c(1, 3, 8, 30) colors - c(red, blue, darkgreen, gold, black) labels - c(df=1, df=3, df=8, df=30, normal) pdf(C:\\Users\\Frank\\Documents\\R\\Scripts\\Norm_Graph.pdf) plot(x, hx, type=l, lty=2, xlab=x value, ylab=Density, main=Comparison of t Distributions) for (i in 1:4){ lines(x, dt(x,degf[i]), lwd=2, col=colors[i]) } legend(topright, inset=.05, title=Distributions, labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors) This produces a nice plot. Frank Date: Mon, 5 Mar 2012 08:55:44 -0800 From: vincentdelua...@gmail.com To: r-help@r-project.org Subject: [R] Automating R script with Windows 7Hi R-users, I am trying to automate the daily running of a simple R script from Windows 7. From previous posts, I understand that this needs to be done with the task scheduler. I can schedule my laptop to automatically open R at a certain time, but not to execute a script. Secondary question: how do I save a list of R commands so that they get executed once the file is open? Right now, I save my code in a notepad doc and paste over in R, but there has to be another way. I have tried saving my code as .r file using the editor and open the file with R later but this does not seem to execute the code. I very much appreciate the help. Vincent Deluard, CFA-- View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with! -Windows-7-tp4446693p4446693.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] Telling plot() the max y value to expect when plotting one distribution and then using lines() to add more distributions
I am plotting three Pearson Type IV distributions. It looks like I have to plot the distribution with the highest value of y and then use lines() to add the two distributions that are shorter / have lower max values of y. The following code figures out which distribution has the max y value, plots it first and then uses lines for the other two distributions with a series of three if statements. This works. I run R from a batch file that reads the following in a text file. I want to graph dozens of distributions and I am looking for a more elegant way to do this. New to R, experienced C programmer, thanks in advance. Frank colors - c(red, blue, darkgreen, gold, black) labels - c(1, 2,3) pdf(C:\\Users\\Frank\\Documents\\R\\Scripts\\pt4_Graph.pdf) ## load Pearson package library(PearsonDS) ##range for x axis no_of_increments- 100 x - seq(-0.06, +0.06, length=no_of_increments) ##parameters for the plots of three distributions mx- c(1.95, 18.35,1.93) nux- c(0.08,-1.02,0.25) locationx- c(0.0048,-0.00254,0.00189) scalex- c(0.0115,0.082187,0.026675) ## calculate probability density function hx1- dpearsonIV(x,m=mx[1],nu=nux[1],location=locationx[1],scale=scalex[1]) hx2- dpearsonIV(x,m=mx[2],nu=nux[2],location=locationx[2],scale=scalex[2]) hx3- dpearsonIV(x,m=mx[3],nu=nux[3],location=locationx[3],scale=scalex[3]) ##calculate max of each distribtion maxhx1- max(hx1) maxhx2- max(hx2) maxhx3- max(hx3) maxhx- max(hx1,hx2,hx3) maxhx1 maxhx2 maxhx3 maxhx if (maxhx1==maxhx) {plot(x, hx1 , type=l, lwd=2, col=colors[1], xlab=x value, ylab=Density, main=pt4) for (i in 2:3){ lines(x, dpearsonIV(x,m=mx[i],nu=nux[i],location=locationx[i],scale=scalex[i]), lwd=2, col=colors[i])} legend(topright, inset=.05, title=Distributions, labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors) grid() } if (maxhx2==maxhx) {plot(x, hx2 , type=l, lwd=2, xlab=x value, ylab=Density, main=SPX, col=colors[2]) { lines(x, dpearsonIV(x,m=mx[1],nu=nux[1],location=locationx[1],scale=scalex[1]), lwd=2, col=colors[1]) lines(x, dpearsonIV(x,m=mx[3],nu=nux[3],location=locationx[3],scale=scalex[3]), lwd=2, col=colors[3]) legend(topright, inset=.05, title=Distributions, labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors) grid() } if (maxhx3==maxhx) {plot(x, hx3 , type=l, lwd=2, col=colors[3], xlab=x value, ylab=Density, main=SPX) for (i in 1:2){ lines(x, dpearsonIV(x,m=mx[i],nu=nux[i],location=locationx[i],scale=scalex[i]), lwd=2, col=colors[i])} legend(topright, inset=.05, title=Distributions, labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors) grid() } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.