Re: [R] Axes value format

2012-05-10 Thread Vihan Pandey
On 08/05/2012, David Winsemius dwinsem...@comcast.net wrote:

 On May 8, 2012, at 2:23 PM, Vihan Pandey wrote:

 On 8 May 2012 19:47, John Kane jrkrid...@inbox.com wrote:
 Quite likely, but we need to know what you are doing and what
 graphics package you are using.

 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 Frightfully sorry about that. I'm using R on a Mac, and its a simple
 plot using plot() which is taking values from a CSV file, let me
 illustrate for one dataset :

 See if this is helpful. Untested,  since you still do not have a
 reproducible example for us to work with.

 x - c(12345, 1234567, 123)
 paste( round( x/c(1, 1000, 100)[findInterval(x,
 c(1,1000,100)) ], 2),
  c(,K,M)[findInterval(x, c(1,1000,100)) ]  )

 [1] 12.35 K 1.23 M 123 

Thanks, xaxt, yaxt in plot() did the job. Sorry for not posting a
reproducible example I just needed a quick fix which I was sure would
be a simple option in plot() or elsewhere.

Thanks and Cheers!

- vihan


 --
 David.


 ==
 #!/usr/bin/Rscript

 out_file = foobar.pdf
 pdf(out_file, height=8.5, width=11)

 my_values - read.csv(foo.csv,head=TRUE,sep=,)

 plot(my_values$num_sims,
  my_values$exec_time,
  xlab=Number of Simulations,
  ylab=Execution Time(in milliseconds),
  col=red,
  main=Execution Time for Simulations)

 lines(my_values$num_sims,my_values$exec_time,col=red)

 my_values2 - read.csv(bar.csv,head=TRUE,sep=,)

 lines(my_values2$num_sims,my_values2$exec_time,col=blue)
 points(my_values2$num_sims,my_values2$exec_time,col=blue)


 legend(topright,
  lty=c(1,1),
c(foo,bar),
col=c(red,blue)
);

 dev.off()

 print(paste(Plot was saved in:, getwd()))
 ==

 foo.csv and bar.csv have values like:

 num_sims,exec_time
 100,44556
 200,89112
 300,133668

 etc.

 Please let me know if you require any additional information.

 Cheers!

 - vihan


 John Kane
 Kingston ON Canada


 -Original Message-
 From: vihanpan...@gmail.com
 Sent: Tue, 8 May 2012 19:29:45 +0200
 To: r-help@r-project.org
 Subject: [R] Axes value format

 Hi all,

 I have some graphs where the values on the X and Y axes are by
 default
 in exponent form like 2e+05 or 1.0e+07. Is it possible to make
 them in
 a more readable form like 10M for 1.0e+07 or 200K for 2e+05?

 Thanks and Regards,

 - vihan

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 
 FREE ONLINE PHOTOSHARING - Share your photos online with your
 friends and family!
 Visit http://www.inbox.com/photosharing to find out more!



 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Axes value format

2012-05-10 Thread Vihan Pandey
On 08/05/2012, John Kane jrkrid...@inbox.com wrote:
 Actually I meant a working example and some data (See ?dput for a handy way
 to supply data)

 It is also a good idea to include the information from sessionInfo()


  I think David W has a good approach.

 Otherwise you might just want to write the axis yourself.

 =
 x  - c(100, 200, 300)
 y  - c( 44556, 89112, 133668)

 nms  - c(1M, 2M, 3M)

 plot(x,y, xaxt=n)
 axis(1, x, labels=nms)
 

Sorry for not posting a working example and some data, I just wanted a
quick fix and didn't know people would work so much for my query few
mailing lists do so :-) Thanks though, your xaxt option did the trick.

I will learn from this and read up on dput and sessioninfo()

Thanks and Cheers!

- vihan




 John Kane
 Kingston ON Canada


 -Original Message-
 From: vihanpan...@gmail.com
 Sent: Tue, 8 May 2012 20:23:21 +0200
 To: jrkrid...@inbox.com
 Subject: Re: [R] Axes value format

 On 8 May 2012 19:47, John Kane jrkrid...@inbox.com wrote:
 Quite likely, but we need to know what you are doing and what graphics
 package you are using.

 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 Frightfully sorry about that. I'm using R on a Mac, and its a simple
 plot using plot() which is taking values from a CSV file, let me
 illustrate for one dataset :

 ==
 #!/usr/bin/Rscript

 out_file = foobar.pdf
 pdf(out_file, height=8.5, width=11)

 my_values - read.csv(foo.csv,head=TRUE,sep=,)

 plot(my_values$num_sims,
  my_values$exec_time,
  xlab=Number of Simulations,
  ylab=Execution Time(in milliseconds),
  col=red,
  main=Execution Time for Simulations)

 lines(my_values$num_sims,my_values$exec_time,col=red)

 my_values2 - read.csv(bar.csv,head=TRUE,sep=,)

 lines(my_values2$num_sims,my_values2$exec_time,col=blue)
 points(my_values2$num_sims,my_values2$exec_time,col=blue)


 legend(topright,
  lty=c(1,1),
c(foo,bar),
col=c(red,blue)
);

 dev.off()

 print(paste(Plot was saved in:, getwd()))
 ==

 foo.csv and bar.csv have values like:

 num_sims,exec_time
 100,44556
 200,89112
 300,133668

 etc.

 Please let me know if you require any additional information.

 Cheers!

 - vihan


 John Kane
 Kingston ON Canada


 -Original Message-
 From: vihanpan...@gmail.com
 Sent: Tue, 8 May 2012 19:29:45 +0200
 To: r-help@r-project.org
 Subject: [R] Axes value format

 Hi all,

 I have some graphs where the values on the X and Y axes are by default
 in exponent form like 2e+05 or 1.0e+07. Is it possible to make them in
 a more readable form like 10M for 1.0e+07 or 200K for 2e+05?

 Thanks and Regards,

 - vihan

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 
 FREE ONLINE PHOTOSHARING - Share your photos online with your friends
 and family!
 Visit http://www.inbox.com/photosharing to find out more!



 
 GET FREE SMILEYS FOR YOUR IM  EMAIL - Learn more at
 http://www.inbox.com/smileys
 Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and
 most webmails




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Axes value format

2012-05-10 Thread Vihan Pandey
On 08/05/2012, arun smartpink...@yahoo.com wrote:
 Hi Vihan,

 The link below might be helpful.


 (http://stackoverflow.com/questions/3415097/controlling-number-formatting-at-axis-of-r-plots)

Thanks, the xaxt parameter in plot() solved the problem.

Thanks and Cheers!

- vihan


 A.K.







 - Original Message -
 From: Vihan Pandey vihanpan...@gmail.com
 To: r-help r-help@r-project.org
 Cc:
 Sent: Tuesday, May 8, 2012 1:29 PM
 Subject: [R] Axes value format

 Hi all,

 I have some graphs where the values on the X and Y axes are by default
 in exponent form like 2e+05 or 1.0e+07. Is it possible to make them in
 a more readable form like 10M for 1.0e+07 or 200K for 2e+05?

 Thanks and Regards,

 - vihan

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Axes value format

2012-05-08 Thread Vihan Pandey
Hi all,

I have some graphs where the values on the X and Y axes are by default
in exponent form like 2e+05 or 1.0e+07. Is it possible to make them in
a more readable form like 10M for 1.0e+07 or 200K for 2e+05?

Thanks and Regards,

- vihan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Axes value format

2012-05-08 Thread Vihan Pandey
On 8 May 2012 19:47, John Kane jrkrid...@inbox.com wrote:
 Quite likely, but we need to know what you are doing and what graphics 
 package you are using.

 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

Frightfully sorry about that. I'm using R on a Mac, and its a simple
plot using plot() which is taking values from a CSV file, let me
illustrate for one dataset :

==
#!/usr/bin/Rscript

out_file = foobar.pdf
pdf(out_file, height=8.5, width=11)

my_values - read.csv(foo.csv,head=TRUE,sep=,)

plot(my_values$num_sims,
my_values$exec_time,
xlab=Number of Simulations,
ylab=Execution Time(in milliseconds),
col=red,
main=Execution Time for Simulations)

lines(my_values$num_sims,my_values$exec_time,col=red)

my_values2 - read.csv(bar.csv,head=TRUE,sep=,)

lines(my_values2$num_sims,my_values2$exec_time,col=blue)
points(my_values2$num_sims,my_values2$exec_time,col=blue)


legend(topright,
lty=c(1,1),
  c(foo,bar),
  col=c(red,blue)
  );

dev.off()

print(paste(Plot was saved in:, getwd()))
==

foo.csv and bar.csv have values like:

num_sims,exec_time
100,44556
200,89112
300,133668

etc.

Please let me know if you require any additional information.

Cheers!

- vihan


 John Kane
 Kingston ON Canada


 -Original Message-
 From: vihanpan...@gmail.com
 Sent: Tue, 8 May 2012 19:29:45 +0200
 To: r-help@r-project.org
 Subject: [R] Axes value format

 Hi all,

 I have some graphs where the values on the X and Y axes are by default
 in exponent form like 2e+05 or 1.0e+07. Is it possible to make them in
 a more readable form like 10M for 1.0e+07 or 200K for 2e+05?

 Thanks and Regards,

 - vihan

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 
 FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
 family!
 Visit http://www.inbox.com/photosharing to find out more!



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] histogram break width

2012-03-29 Thread Vihan Pandey
Hi all,

I am generating histograms with the following R script :

#!/usr/bin/Rscript

out_file = histo.png
png(out_file)

scan(values.csv) - myvalues
hist(myvalues, breaks = 50)

dev.off()

print(paste(Plot was saved in:, getwd()))


I want the histogram to have a larger number of breaks, but a smaller
break width, the idea is to make it appear smoother like a filled
curve. If I keep increasing breaks it starts looking messy. Any
suggestions?

Thanks!

- vihan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] getting multiple plots on a single plot

2012-03-22 Thread Vihan Pandey
Hi all,

I have the following R script :


#!/usr/bin/Rscript

out_file = hybrid.pdf
pdf(out_file, height=8.5, width=11)

myvalues_1M - read.csv(hybrid_sims_1M.csv,head=TRUE,sep=,)
plot(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,xlab=Number
of Simulations per Thread,ylab=Time per 1 million Simulations(in
milliseconds),col=red,main=For 1 million simulations)
lines(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,col=red)

myvalues_5M - read.csv(hybrid_sims_5M.csv,head=TRUE,sep=,)
plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab=Number
of Simulations per Thread,ylab=Time per 1 million Simulations(in
milliseconds),col=blue,main=For 5 million simulations)
lines(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,col=blue)

myvalues_10M - read.csv(hybrid_sims_10M.csv,head=TRUE,sep=,)
plot(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,xlab=Number
of Simulations per Thread,ylab=Time per 1 million Simulations(in
milliseconds),col=green,main=For 10 million simulations)
lines(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,col=green)

dev.off()

print(paste(Plot was saved in:, getwd()))



This generates a 3 page pdf file with a plot on each page. They look like this :

http://s17.postimage.org/ud9ej1cnj/alpha1.png
http://s13.postimage.org/7q3snqsrr/alpha2.png
http://s14.postimage.org/sf374f12p/alpha3.png

I want to plot all the 3 in one graph, in one page with the respective
colours - red, blue, and green. Any ideas on how?

Thanks,

- vihan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] getting multiple plots on a single plot

2012-03-22 Thread Vihan Pandey
On 22 March 2012 20:23, R. Michael Weylandt michael.weyla...@gmail.com wrote:
 Don't use plot three times -- it opens a new page when pdf() is your
 current device. Do the first with plot -- then use lines() online from
 there to the end.

Thanks a million that did the job! :-)

Cheers!

- vihan


 Michael

 On Thu, Mar 22, 2012 at 3:18 PM, Vihan Pandey vihanpan...@gmail.com wrote:
 Hi all,

 I have the following R script :


 #!/usr/bin/Rscript

 out_file = hybrid.pdf
 pdf(out_file, height=8.5, width=11)

 myvalues_1M - read.csv(hybrid_sims_1M.csv,head=TRUE,sep=,)
 plot(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,xlab=Number
 of Simulations per Thread,ylab=Time per 1 million Simulations(in
 milliseconds),col=red,main=For 1 million simulations)
 lines(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,col=red)

 myvalues_5M - read.csv(hybrid_sims_5M.csv,head=TRUE,sep=,)
 plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab=Number
 of Simulations per Thread,ylab=Time per 1 million Simulations(in
 milliseconds),col=blue,main=For 5 million simulations)
 lines(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,col=blue)

 myvalues_10M - read.csv(hybrid_sims_10M.csv,head=TRUE,sep=,)
 plot(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,xlab=Number
 of Simulations per Thread,ylab=Time per 1 million Simulations(in
 milliseconds),col=green,main=For 10 million simulations)
 lines(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,col=green)

 dev.off()

 print(paste(Plot was saved in:, getwd()))



 This generates a 3 page pdf file with a plot on each page. They look like 
 this :

 http://s17.postimage.org/ud9ej1cnj/alpha1.png
 http://s13.postimage.org/7q3snqsrr/alpha2.png
 http://s14.postimage.org/sf374f12p/alpha3.png

 I want to plot all the 3 in one graph, in one page with the respective
 colours - red, blue, and green. Any ideas on how?

 Thanks,

 - vihan

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] getting multiple plots on a single plot

2012-03-22 Thread Vihan Pandey
On 22 March 2012 20:54, Chris Snook snoo...@bellsouth.net wrote:
 vihan,

 you jsut need to add the following statement in the subsequent plot
 commands:

 add = TRUE

 so that your second and later plot commands look similar to:

 plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab=Number
 of Simulations per Thread,ylab=Time per 1 million Simulations(in
 milliseconds),col=blue,main=For 5 million simulations, add = TRUE)

Thanks, but that still does keeps it on different pages and generates warnings :

Warning messages:
1: In plot.window(...) : add is not a graphical parameter
2: In plot.xy(xy, type, ...) : add is not a graphical parameter
3: In axis(side = side, at = at, labels = labels, ...) :
  add is not a graphical parameter
4: In axis(side = side, at = at, labels = labels, ...) :
  add is not a graphical parameter
5: In box(...) : add is not a graphical parameter
6: In title(...) : add is not a graphical parameter

Cheers!

- vihan


 HTH

 Chris
 On 03/22/2012 03:18 PM, Vihan Pandey wrote:
 Hi all,

 I have the following R script :


 #!/usr/bin/Rscript

 out_file = hybrid.pdf
 pdf(out_file, height=8.5, width=11)

 myvalues_1M - read.csv(hybrid_sims_1M.csv,head=TRUE,sep=,)
 plot(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,xlab=Number
 of Simulations per Thread,ylab=Time per 1 million Simulations(in
 milliseconds),col=red,main=For 1 million simulations)
 lines(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,col=red)

 myvalues_5M - read.csv(hybrid_sims_5M.csv,head=TRUE,sep=,)
 plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab=Number
 of Simulations per Thread,ylab=Time per 1 million Simulations(in
 milliseconds),col=blue,main=For 5 million simulations)
 lines(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,col=blue)

 myvalues_10M - read.csv(hybrid_sims_10M.csv,head=TRUE,sep=,)
 plot(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,xlab=Number
 of Simulations per Thread,ylab=Time per 1 million Simulations(in
 milliseconds),col=green,main=For 10 million simulations)
 lines(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,col=green)

 dev.off()

 print(paste(Plot was saved in:, getwd()))



 This generates a 3 page pdf file with a plot on each page. They look like 
 this :

 http://s17.postimage.org/ud9ej1cnj/alpha1.png
 http://s13.postimage.org/7q3snqsrr/alpha2.png
 http://s14.postimage.org/sf374f12p/alpha3.png

 I want to plot all the 3 in one graph, in one page with the respective
 colours - red, blue, and green. Any ideas on how?

 Thanks,

 - vihan

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] getting multiple plots on a single plot

2012-03-22 Thread Vihan Pandey
On 22 March 2012 21:06, David Winsemius dwinsem...@comcast.net wrote:

 On Mar 22, 2012, at 3:18 PM, Vihan Pandey wrote:

 Hi all,

 I have the following R script :


 #!/usr/bin/Rscript

 out_file = hybrid.pdf
 pdf(out_file, height=8.5, width=11)


 At this point (assuming that you want three separate plots on the same page
 which is unclear but you do use different titles and ylabs, so I think this
 is implied) you would either be using layout()

 ?layout

  or par() with arguments mfrow, mfcol, or mfg.

 ?par

Thanks David, I'm a newbie at R and am not familiar with par() and
layout(), I will check them out!

Cheers!

- vihan



 myvalues_1M - read.csv(hybrid_sims_1M.csv,head=TRUE,sep=,)
 plot(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,xlab=Number
 of Simulations per Thread,ylab=Time per 1 million Simulations(in
 milliseconds),col=red,main=For 1 million simulations)
 lines(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,col=red)


 If on the other hand you want one plot frame with overlaid point/lines/etc,
 then you should be determining your x and y limits before any plots and
 putting in the same limits for each plot Adding all your labels on the first
 plot and using:

 par(new=TRUE) # which seems completely backward to me.

 # I say again ...
 ? par



 myvalues_5M - read.csv(hybrid_sims_5M.csv,head=TRUE,sep=,)
 plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab=Number
 of Simulations per Thread,ylab=Time per 1 million Simulations(in
 milliseconds),col=blue,main=For 5 million simulations)
 lines(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,col=blue)

 myvalues_10M - read.csv(hybrid_sims_10M.csv,head=TRUE,sep=,)

 plot(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,xlab=Number
 of Simulations per Thread,ylab=Time per 1 million Simulations(in
 milliseconds),col=green,main=For 10 million simulations)

 lines(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,col=green)

 dev.off()

 print(paste(Plot was saved in:, getwd()))



 This generates a 3 page pdf file with a plot on each page. They look like
 this :

 http://s17.postimage.org/ud9ej1cnj/alpha1.png
 http://s13.postimage.org/7q3snqsrr/alpha2.png
 http://s14.postimage.org/sf374f12p/alpha3.png

 I want to plot all the 3 in one graph, in one page with the respective
 colours - red, blue, and green. Any ideas on how?

 Thanks,

 - vihan

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 David Winsemius, MD
 West Hartford, CT


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] fitting a histogram to a Gaussian curve

2012-03-19 Thread Vihan Pandey
Hello,

I am trying to fit my histogram to a smooth Gaussian curve(the data
closely resembles one except a few bars).

This is my code :

#!/usr/bin/Rscript

out_file = irc_20M_opencl_test.png
png(out_file)

scan(my.csv) - myvals

hist(myvals, breaks = 50, main = My Distribution,xlab = My Values)

pdens - density(myvals, na.rm=T)
plot(pdens, col=black, lwd=3, xlab=My values, main=Default KDE)

dev.off()

print(paste(Plot was saved in:, getwd()))

the problem here is that I a jagged distribution, you can see the result :

http://s15.postimage.org/9ucmkx3bf/foobar.png

this is the original histogram :

http://s12.postimage.org/e0lfp7d5p/foobar2.png

any ideas on how I can smoothen it to a Gaussian curve?

Thanks,

- vihan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] fitting a histogram to a Gaussian curve

2012-03-19 Thread Vihan Pandey
I see, that could be an option, however isn't there a fitting function
which would do that on given data?

On 19 March 2012 19:49, R. Michael Weylandt michael.weyla...@gmail.com wrote:
 If I understand you correctly, a univariate Gaussian distribution is
 uniquely determined by its first two moments so you can just fit those
 directly (using sample mean for population mean and sample variance
 with Besel's correction for population variance) and get the best
 Gaussian (in a ML sense).

 E.g.,

 x - rnorm(500, 3, 2)

 hist(x, freq = FALSE)
 lines(seq(min(x), max(x), length.out = 300) - y, dnorm(y, mean(x),
 sd(x)), col = 2)

 Hope this helps,
 Michael

 On Mon, Mar 19, 2012 at 12:47 PM, Vihan Pandey vihanpan...@gmail.com wrote:
 Hello,

 I am trying to fit my histogram to a smooth Gaussian curve(the data
 closely resembles one except a few bars).

 This is my code :

 #!/usr/bin/Rscript

 out_file = irc_20M_opencl_test.png
 png(out_file)

 scan(my.csv) - myvals

 hist(myvals, breaks = 50, main = My Distribution,xlab = My Values)

 pdens - density(myvals, na.rm=T)
 plot(pdens, col=black, lwd=3, xlab=My values, main=Default KDE)

 dev.off()

 print(paste(Plot was saved in:, getwd()))

 the problem here is that I a jagged distribution, you can see the result :

 http://s15.postimage.org/9ucmkx3bf/foobar.png

 this is the original histogram :

 http://s12.postimage.org/e0lfp7d5p/foobar2.png

 any ideas on how I can smoothen it to a Gaussian curve?

 Thanks,

 - vihan

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] fitting a histogram to a Gaussian curve

2012-03-19 Thread Vihan Pandey
I'll check it out, thanks a million Micheal!

On 19 March 2012 19:59, R. Michael Weylandt michael.weyla...@gmail.com wrote:
 Take a look at fitdistr in the MASS package.

 fitdistr(x, normal)

 I don't think you need to supply start values for the normal since its
 loglikelihood function is nicely behaved. You may need to for harder
 distributions.

 Michael

 On Mon, Mar 19, 2012 at 2:54 PM, Vihan Pandey vihanpan...@gmail.com wrote:
 I see, that could be an option, however isn't there a fitting function
 which would do that on given data?

 On 19 March 2012 19:49, R. Michael Weylandt michael.weyla...@gmail.com 
 wrote:
 If I understand you correctly, a univariate Gaussian distribution is
 uniquely determined by its first two moments so you can just fit those
 directly (using sample mean for population mean and sample variance
 with Besel's correction for population variance) and get the best
 Gaussian (in a ML sense).

 E.g.,

 x - rnorm(500, 3, 2)

 hist(x, freq = FALSE)
 lines(seq(min(x), max(x), length.out = 300) - y, dnorm(y, mean(x),
 sd(x)), col = 2)

 Hope this helps,
 Michael

 On Mon, Mar 19, 2012 at 12:47 PM, Vihan Pandey vihanpan...@gmail.com 
 wrote:
 Hello,

 I am trying to fit my histogram to a smooth Gaussian curve(the data
 closely resembles one except a few bars).

 This is my code :

 #!/usr/bin/Rscript

 out_file = irc_20M_opencl_test.png
 png(out_file)

 scan(my.csv) - myvals

 hist(myvals, breaks = 50, main = My Distribution,xlab = My Values)

 pdens - density(myvals, na.rm=T)
 plot(pdens, col=black, lwd=3, xlab=My values, main=Default KDE)

 dev.off()

 print(paste(Plot was saved in:, getwd()))

 the problem here is that I a jagged distribution, you can see the result :

 http://s15.postimage.org/9ucmkx3bf/foobar.png

 this is the original histogram :

 http://s12.postimage.org/e0lfp7d5p/foobar2.png

 any ideas on how I can smoothen it to a Gaussian curve?

 Thanks,

 - vihan

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Doing Mathematica Quantile[] function in R

2012-03-07 Thread Vihan Pandey
Hi all,

I am an R newbie trying to do some calculations I do in Mathematica in
R on a GNU/Linux system.

The main thing I am interested in doing is taking a 0.999 quantile on
a data set in a file who's data is normally distributed, say foo.csv.

e.g in Mathematica if I have something like this :

a=Import[foo.csv]
b=Transpose[a][[1]]
Quantile[b,0.999]

In R I can load all the data into b with :

scan(foo.csv) - b

now, I can't find a function anywhere which would calculate the
Quantile on the dataset in b.

Any advice?

Also, I am guessing Mathematica does a lot of special things to ensure
a very accurate Quantile value, so if anyone has any ideas on
incorporating those as well, it would be great.

Thanks and Regards,

- vihan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] scripting qqplot and qqnorm

2011-07-25 Thread Vihan Pandey
Hi all,

I am an R newbie, and I have a question about scripting. I have the
following lines which I want to put int\
o a script which I can call from the shell of a Mac/Linux machine :

myrns - read.csv(file=/Users/vihan/test.csv,sep=,header=FALSE)
qqnorm(myrns)
qqline(myrns)

This works fine on an interactive R session.

However, as I understand the basic framework of an R script for
executing on the shell to get a pdf output it is something like :

#!/usr/bin/Rscript

… list inputs…

pdf(plotexample.pdf, width=7, height=9)

plot(...)

dev.off()

print(paste(Plot was saved in:, getwd()))


therefore, I do :


#!/usr/bin/Rscript

myrns - read.csv(file=/Users/vihan/test.csv,sep=,header=FALSE)
qqnorm(myrns)

dev.off()

print(paste(Plot was saved in:, getwd()))

but it does not work, the pdf generated is something my pdf viewer
cannot understand, plot(qqnorm(myrns)) and plot(qqline(myrns)) don't
work either.

Any ideas on what I'm doing wrong?

Moreover, would it be possible to have both qqline(myrns) and
qqnorm(myrns) on the same pdf?

Cheers!

- vihan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.