Question

In: Statistics and Probability

Coding in R Im trying to plot a histogram in R, and i know the basic...

Coding in R

Im trying to plot a histogram in R, and i know the basic code for that, however, the code requires 2 plots coming from the same data set. for example, the voltage of an old process vs. a new process. is there any ways to seperate the 2 processes out from the data set to make 2 relative frequencyt histograms?

Solutions

Expert Solution

The best way I know of solving the problem is using the 'ggplot2' package in R.

'ggplot2' is considered as a fine tool to make plots, as you can easily add new features to your plots, and reading and understanding them is easy.

If you have never used ggplot2 before you will have to run the following commands to be able to use it on your system:

install.packages("ggplot2")

library(ggplot2)

Assuming that you have a variable which can separate old processes from the new processes, you can use the following code to make 2 relative frequency histograms from the same data set.

(If you do not have a variable which tells if it is a new process or an old process, you can create the variable.)

NOTE: In the following code, the piece of code in bold is where you have to enter your code.

ggplot(input1, aes(input2, group = input3 )) +
geom_histogram(aes(y = ..prop..),position="identity", stat="count") +
scale_y_continuous(labels=scales::percent) +
ylab("Relative Frequencies") +
facet_grid(~input3 ) +
labs(title="Input2 by input3 (Relative Frequencies)" )

Input1: Name of the dataset

Input2: 'x' variable

Input3: The variable which separates old processes from new processes. (This must be a factor or a character type variable)

I hope I have understood your question and have answered your question. If there is anything else you might want me to add, please let me know in the comments section and I will do it.


Related Solutions

USE R CODING! Pleaseee I need the code With R coding Obs: it supposed to use...
USE R CODING! Pleaseee I need the code With R coding Obs: it supposed to use probability density function like X ~ Binomial( n ,p ) dbinom(X=?, n, prob) pbinom(X=?, n, prob) rbinmo(幾個符合二項分配的X, n, prob) X~Poisson (lamda) dpois(X=?, lamda) ppois (X=?, lamda) rpois (X, lamda) **Suppose the random variable X obeys the binomial allocation B (n=100, p=0.1) (a) Use X as the binomial allocation to calculate P(12≤X≤14) (b) In practice, when np ≥ 5 and n(1-p) ≥ 5, X will...
6. Histograms: a) How is the histogram related to the frequency plot? i. When does a...
6. Histograms: a) How is the histogram related to the frequency plot? i. When does a histogram look exactly like a frequency plot? b) What visual information do you get from a histogram? c) How can you tell what interval contains the most data points? d) What is the relation between histograms and the cumulative distribution function? e) ​The probability of winning at American roulette is 1/38 . What is your expected number of wheel spins to get your first...
We are using SPSS 24 IBM software to analyze, format and plot the Histogram but i...
We are using SPSS 24 IBM software to analyze, format and plot the Histogram but i need to see how the data is represented, used and Graphed on a histograph: 1.] Suppose you were to roll 2 dice of 6 sides each, and take the total. The values range from 2 - 12, and there are 36 possible combinations of the two dice. a.] (40 pts) Create a histogram that shows the theoretical distribution of the dice rolls. Figure out...
I get an error when im trying to run this java program, I would appreciate if...
I get an error when im trying to run this java program, I would appreciate if someone helped me asap, I will make sure to leave a good review. thank you in advance! java class Node public class Node { private char item; private Node next; Object getNext; public Node(){    item = ' '; next = null; } public Node(char newItem) { setItem(newItem); next = null; } public Node(char newItem, Node newNext){ setItem(newItem); setNext(newNext); } public void setItem(char newItem){...
Please attach R code: Use library(nycflights13) a. plot histogram for distance where carrier is "FL". Print...
Please attach R code: Use library(nycflights13) a. plot histogram for distance where carrier is "FL". Print graph(s). b. plot Two box plots side by side for distance where carrier are "FL" and “US”. Print graph(s). c. plot two histograms and two box plots in one graph where carrier are "FL" and “US”, equal scale for each box plot pair. Print graph(s).
/* I been trying to solve this problem . this is my own coding /here is...
/* I been trying to solve this problem . this is my own coding /here is the HW INSTRUCTION Let the user to try of maximum 8 times to find the random number For every try display if the user find or not the number and the number of tries At the end of each game display to the user the number of tries to find the number Allow the user to play a maximum of 4 times, by asking...
I am trying to plot a difficult function in MATLAB, however I need to understand the...
I am trying to plot a difficult function in MATLAB, however I need to understand the basics first. I am trying to plot n=0 for x=0:0.01:2pi n=n+1 y(n)=sin(x) end I beleive what this says, is that I want to plot sin(x) over a full period hence from o to 2pi, and I beleive the 0.01 is the incremenation along the x-axis. I am not sure what my n is doing Could smeone please graph this for me with the MATLAB...
v Create a graph (either a histogram, box plot or stem and leaf plot … pick...
v Create a graph (either a histogram, box plot or stem and leaf plot … pick just one). Your graph could have either 5, 6 or 7 classes, depending on how you set it up. Create a table and list the class boundaries and the frequency in each class. You must explain to me in detail if you used fewer than 5 classes or more than 7 classes.
In R, if I have a plot of LIFE against BIRTH and I want to specifically...
In R, if I have a plot of LIFE against BIRTH and I want to specifically mark the point corresponding to STATE "AK" as red colour(the rest of the points as black color), what R command should we use? "STATE" "MALE" "BIRTH" "DIVO" "BEDS" "EDUC" "INCO" "LIFE" AK 119.1 24.8 5.6 603.3 14.1 4638 69.31 AL 93.3 19.4 4.4 840.9 7.8 2892 69.05 AR 94.1 18.5 4.8 569.6 6.7 2791 70.66 AZ 96.8 21.2 7.2 536.0 12.6 3614 70.55 CA...
Does anyone know the code to use in R programming to create a scatter plot?
Does anyone know the code to use in R programming to create a scatter plot?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT