Question

In: Computer Science

Let x3 be the following vector: x3 <- c(0, 1, 1, 2, 2, 2, 3, 3,...

Let x3 be the following vector: x3 <- c(0, 1, 1, 2, 2, 2, 3, 3, 4) Imagine what a histogram of x3 would look like. Assume that the histogram has a bin width of 1. How many bars will the histogram have? Where will they appear? How high will each be? When you are done, plot a histogram of x3 with bin width = 1, and see if you are right.

I need code help R programming

Solutions

Expert Solution

Given:

Bin width is 1
Input Data is given x3 <- c(0, 1, 1, 2, 2, 2, 3, 3, 4)

Solution:

There will be 4 bars in the histogram.
Data will be segregated in different bins in the following way.

1st will have these values: 0,1,1
2nd will have these values: 2,2,2
3rd will have the following values: 3,3
4th will have this value: 4

Bin Freq
1st 3
2nd 3
3rd 2
4th 1

R code:

##set working directory where you want to
##save the image file

##setwd()

# Create data for the graph.
x3 <- c(0, 1, 1, 2, 2, 2, 3, 3, 4)

# Give the chart a name##

png(file = "x3_histogram.png")

# Create the histogram.
## Give x axis and y axis a name##
##Give colors to column and border##
## Put limits on x axis and y axis##
## Provide width to each bar using breaks##

hist(x3,xlab = "Weight",col = "blue",border = "red", xlim = c(0,5), ylim = c(0,5),
breaks=5)

# Save the file.
dev.off()

###Output##



Related Solutions

Let C be the following matrix: C=( 1 2 3 -2 0 1 1 -2 -1...
Let C be the following matrix: C=( 1 2 3 -2 0 1 1 -2 -1 3 2 -8 -1 -2 -3 2 ) Give a basis for the row space of Cin the format [1,2,3],[3,4,5], for example.
Let A, B and C be events. Express for k = 0, 1, 2, 3, the...
Let A, B and C be events. Express for k = 0, 1, 2, 3, the probabilities that: a) Exactly k of events A, B and C occur. b) At least k of events A, B and C occur.
Let ?1, ?2, ?3 be 3 independent random variables with uniform distribution on [0, 1]. Let...
Let ?1, ?2, ?3 be 3 independent random variables with uniform distribution on [0, 1]. Let ?? be the ?-th smallest among {?1, ?2, ?3}. Find the variance of ?2, and the covariance between the median ?2 and the sample mean ? = 1 3 (?1 + ?2 + ?3).
Let A =   [  0 2 0 1 0 2 0 1 0 ]  . (a)...
Let A =   [  0 2 0 1 0 2 0 1 0 ]  . (a) Find the eigenvalues of A and bases of the corresponding eigenspaces. (b) Which of the eigenspaces is a line through the origin? Write down two vectors parallel to this line. (c) Find a plane W ⊂ R 3 such that for any w ∈ W one has Aw ∈ W , or explain why such a plain does not exist. (d) Write down explicitly...
(1) (2) (3) DI C DI C DI C $0 $4 $0 $65 $0 $2 10...
(1) (2) (3) DI C DI C DI C $0 $4 $0 $65 $0 $2 10 11 80 125 20 20 20 18 160 185 40 38 30 25 240 245 60 56 40 32 320 305 80 74 50 39 400 365 100 92 Refer to the given consumption schedules. DI signifies disposable income and C represents consumption expenditures. All figures are in billions of dollars. At an income level of $40 billion, the average propensity to consume is...
Let A = 0 2 0 1 0 2 0 1 0 . (a) Find the...
Let A = 0 2 0 1 0 2 0 1 0 . (a) Find the eigenvalues of A and bases of the corresponding eigenspaces. (b) Which of the eigenspaces is a line through the origin? Write down two vectors parallel to this line. (c) Find a plane W ⊂ R 3 such that for any w ∈ W one has Aw ∈ W , or explain why such a plain does not exist. (d) Write down explicitly a diagonalizing...
Let A = 0 2 0 1 0 2 0 1 0 . (a) Find the...
Let A = 0 2 0 1 0 2 0 1 0 . (a) Find the eigenvalues of A and bases of the corresponding eigenspaces. (b) Which of the eigenspaces is a line through the origin? Write down two vectors parallel to this line. (c) Find a plane W ⊂ R 3 such that for any w ∈ W one has Aw ∈ W , or explain why such a plain does not exist. (d) Write down explicitly a diagonalizing...
Let a and b be non-parallel vectors (algebraically a1b2 −a2b1 /= 0). For a vector c...
Let a and b be non-parallel vectors (algebraically a1b2 −a2b1 /= 0). For a vector c there are unique λ, µ real numbers such that c = λ· a+µ·b. proof?
Let f: [0 1] → R be a function of the class c ^ 2 that...
Let f: [0 1] → R be a function of the class c ^ 2 that satisfies the differential equation f '' (x) = e^xf(x) for all x in (0,1). Show that if x0 is in (0,1) then f can not have a positive local maximum at x0 and can not have a negative local minimum at x0. If f (0) = f (1) = 0, prove that f = 0
Let A = 2 0 1 0 2 0 1 0 2 and eigenvalue λ1 =...
Let A = 2 0 1 0 2 0 1 0 2 and eigenvalue λ1 = 3 and associated eigenvector v(1) = (1, 0, 1)t . Find the second dominant eigenvalue λ2 (or the approximation to λ2) by the Wielandt Dflation method
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT