0

1.Perform the following tasks:
Use the in-built dataset mtcars, by configuring parameters mfrow with 2,2 and generate 4 graphs by using the following parameters and view how the graphs are plotted.

mtcars$mpg vs mtcars$cyl
mtcars$mpg vs mtcars$hp
mtcars$mpg vs mtcars$wt
mtcars$mpg vs mtcars$vs

2.Perform the following tasks:
Use the in-built dataset Orange, and generate a bar chart for the column Tree.
Use the following for the bar chart.

Name of the chart - Trees count
x-axis - Tree Types
y-axis - count
Ensure that the barplot is red in color.

3.Perform the following tasks:
Rotate the bar chart generated in the previous step to horizontal, change both the axes and change the color of the bar chart to green

4.Perform the following tasks:
Create a Stacked bar plot using in-built dataset mtcars and column cyl and gear.

5.Perform the following tasks:
Create a Pie chart for the top 6 entries of the mtcars dataset. Plot the mpg values against the row name(labels) of the dataset.

I tried with this code, but maybe I am not able to understand the question correctly, as in katacoda environment. I am not able to move forward. Code:

data(mtcars)
par(mfrow=c(2,2))
plot(mtcars$mpg,mtcars$cyl)
plot(mtcars$mpg,mtcars$hp)
plot(mtcars$mpg,mtcars$wt)
plot(mtcars$mpg,mtcars$vs)
data(Orange)
plot(Orange$Tree)
count<-table(Orange$Tree)
barplot(count,main="Trees count",xlab="Tree Types",ylab="count",col="Red")
barplot(count,main="Trees count",xlab="count",ylab="Tree Types",col="Green",horiz="TRUE",las=1)
data(mtcars)
plot(mtcars$cyl,mtcars$gear)
data(mtcars)
pie(table(mtcars$mpg[1:6]),labels=row.names(mtcars)[1:6])
LC-datascientist
  • 1,960
  • 1
  • 18
  • 32
  • Please edit the question to clarify where you are encountering a problem and make your question title more specific to that problem. Please remove any task that you already know how to solve (if it doesn't contribute to the problem). We don't know how to help you if the question is too vague. – LC-datascientist Dec 13 '20 at 10:22
  • You can also move the appropriate snippets of code under their associated task for a better clarification on what you were trying to do with them. – LC-datascientist Dec 13 '20 at 10:29
  • Thansk @LC-datascientist I am not sure which part of the code in answer is not right. This entirely is 1 question and I am unable to proceed without passing this question. – Vinay Kiran Dec 13 '20 at 12:52

1 Answers1

0
data(mtcars)
par(mfrow = c(2,2))
plot(mtcars$mpg,mtcars$cyl)
plot(mtcars$mpg,mtcars$hp)
plot(mtcars$mpg,mtcars$wt)
plot(mtcars$mpg,mtcars$vs)
data(Orange)
count<-table(Orange$Tree)
barplot(count, main="Trees count", xlab="Tree Types", ylab="count", col=c("red"))
barplot(count, main="Trees count", xlab="count", ylab="Tree Types", col=c("green"), 
horiz = TRUE)
data(mtcars)
counts <- table(mtcars$cyl, mtcars$gear)
barplot(counts, xlab="cyl", ylab="gear")
pie(table(mtcars$mpg[1:6]),labels=row.names(mtcars)[1:6])
tamtam
  • 3,541
  • 1
  • 7
  • 21
Shiney
  • 16