Your verification ID is: guDlT7MCuIOFFHSbB3jPFN5QLaQ Big Computing: An Example of Plotting a Histogram in base R

Sunday, October 5, 2014

An Example of Plotting a Histogram in base R

Doing plots in R is easy, and there are countless types of graphs you can do in base R, Lattice and other packages like ggplot2. One of the most used plot is a simple Histogram. Histogram ared use to plot the number of times a element in a column has a certain value. It is a great way to first visualise a single column of data. In order to use the histogram plot the values must be numeric.

Lets do a simple plot of data
numbers<-c(1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6)
hist(numbers)
plot of chunk unnamed-chunk-1 Well, that is a little funky. The histgrom is technically correct, but what has happened here is the program determined the breaks which resulted in the integers 1 and 2 being put together in the same bin. The way to fix this is to add the break term to the Histgram Plot.
hist(numbers,breaks=c(0,1,2,3,4,5,6))
plot of chunk unnamed-chunk-2 The issue here is you really need to know what you have. A better method may be to create a lot of bins (here I use the length of the numbers vector).
hist(numbers,breaks=length(numbers))
plot of chunk unnamed-chunk-3
Typically the historgram is used to determine if the data you have visually matches a certian distribution like normal, t, poisson, gamma, etc. In order to do that we need to add another element to the histogram plot and add a plot of the actual curve of the distrbution to our histogram. In the call for the histogram we need to add the term freq=FALSE. This will convert the frequencies of the Histogram from pure counts to ratios that add up to 1. Lets see what this looks like with a sample of 10,000 random normal values
dist=rnorm(10000)
hist(dist,freq=FALSE)
curve(dnorm,add=TRUE)
plot of chunk unnamed-chunk-4
So that is really it from a functionality standpoint. Everything else is really to dress up the plot with colors and labels etc.
hist(dist,breaks=100,freq=FALSE,col="blue",border="dark blue",main="Histogram",xlab="randomly generated normal data")
curve(dnorm,add=TRUE,col="yellow",lwd=4)
plot of chunk unnamed-chunk-5
With these things you should be able to do histograms in R.

2 comments:

  1. تُستخدم عملية البثق على نطاق واسع عندما تكون هناك حاجة إلى التحكم في كثافة الحبيبات، مثل غلايات بخار صناعية، الطافية أو الغارقة. ويتأثر ذلك بعدة عوامل، من بينها تركيبة الخلطة، ومعدل الرطوبة، وظروف الحرارة والضغط، وتصميم القالب، والعمليات اللاحقة للبثق. ولذلك يجب تصميم عملية الإنتاج كمنظومة متكاملة بدل التعامل مع الإكسترودر كمعدة منفصلة.
    يجب أن تتضمن دراسة تحديث خط الأعلاف تقدير استهلاك الطاقة الإضافي الناتج عن تشغيل الإكسترودر والمعدات المرتبطة به. ويشمل ذلك الطاقة الكهربائية والاحتياجات الحرارية والبخار، إضافة إلى استهلاك أنظمة التجفيف والتبريد والنقل. ويساعد حساب تكلفة الطاقة لكل طن منتج في تقييم التأثير الحقيقي للتحديث على تكلفة التصنيع والربحية التشغيلية.

    ReplyDelete
  2. تحتاج المنطقة الموجودة أسفل حوض المطبخ إلى حلول تخزين مناسبة بسبب وجود أنابيب الصرف وتوصيلات المياه التي تقلل من المساحة المتاحة. ويمكن استخدام أدراج أو سلال مصممة إكسسوارات دواليب و غرف الملابس لاستغلال هذه المنطقة دون التأثير في التوصيلات. ويجب اختيار خامات تتحمل ظروف الرطوبة المحتملة، مع ترك مساحات مناسبة حول الأنابيب لتسهيل أعمال الصيانة والوصول إلى التوصيلات عند الحاجة.
    تستخدم سلال الزجاجات في تنظيم زجاجات الزيوت والخل والصلصات وغيرها من العبوات الطويلة، ويمكن تركيبها داخل وحدات ضيقة لا تصلح للأدراج التقليدية. وتوفر بعض التصميمات نظام سحب يساعد على الوصول إلى الزجاجات بسهولة، كما يمكن أن تحتوي على حواجز تمنع سقوط العبوات أثناء الحركة. ويجب اختيار السلة وفق عرض الوحدة وارتفاع العبوات والحمولة المطلوبة.

    ReplyDelete