Question

In: Finance

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?

Solutions

Expert Solution

The basic syntax for creating scatterplot in R is −

plot(x, y, main, xlab, ylab, xlim, ylim, axes)

Following is the description of the parameters used −

  • x is the data set whose values are the horizontal coordinates.

  • y is the data set whose values are the vertical coordinates.

  • main is the tile of the graph.

  • xlab is the label in the horizontal axis.

  • ylab is the label in the vertical axis.

  • xlim is the limits of the values of x used for plotting.

  • ylim is the limits of the values of y used for plotting.

  • axes indicates whether both axes should be drawn on the plot.

EXAMPLE

We use the data set "mtcars" available in the R environment to create a basic scatterplot. Let's use the columns "wt" and "mpg" in mtcars. The below script will create a scatterplot graph for the relation between wt(weight) and mpg(miles per gallon).

# Get the input values.
input <- mtcars[,c('wt','mpg')]

# Give the chart file a name.
png(file = "scatterplot.png")

# Plot the chart for cars with weight between 2.5 to 5 and mileage between 15 and 30.
plot(x = input$wt,y = input$mpg,
   xlab = "Weight",
   ylab = "Milage",
   xlim = c(2.5,5),
   ylim = c(15,30),              
   main = "Weight vs Milage"
)

Related Solutions

Does anyone know the code to use in R programming to create a box plot?
Does anyone know the code to use in R programming to create a box plot?
Does anyone know how to import data from Microsoft Excel code to use in R programming...
Does anyone know how to import data from Microsoft Excel code to use in R programming ?
There are four numeric columns in R programming language's iris data set. Create a scatter plot...
There are four numeric columns in R programming language's iris data set. Create a scatter plot between the four numeric columns using R programming language and give answers to the following parts. Calculate the correlation between each pair of the four numeric columns in iris. Which pair of variables has the strongest linear relationship? Interpret their ??. Which pair of variables has the weakest linear relationship? Interpret their ??. Which pair(s) of variables can you conclude have a population correlation...
In R programming produce a scatter plot in which you plot the actual used car prices...
In R programming produce a scatter plot in which you plot the actual used car prices (y axis) against the predicted used car prices. Plot a dotted line showing where the points would be if the predicted values equalled the actual values. Give your plot an appropriate title. # YOUR CODE HERE
Use R programming to resolve this; can you please provide details on the code? A) Create...
Use R programming to resolve this; can you please provide details on the code? A) Create a dataframe – comparativeGenomeSize with the following vectors: > organism<-c("Human","Mouse","Fruit Fly", "Roundworm","Yeast") > genomeSizeBP<-c(3000000000,3000000000,135600000,97000000,12100000) > estGeneCount<-c(30000,30000,13061,19099,6034) B) Print the organism and estGeneCount for Human and fruitfly.(1) C) Add a column to this data frame calculating base pairs per gene. To do this, write a function “genedensity” that takes as arguments the genomesizeBP and estimatedGeneCount information, and calculates from this the estimated bp per gene....
Create a scatter plot. What does it indicate? What is the regression equation? Is the equation...
Create a scatter plot. What does it indicate? What is the regression equation? Is the equation significant? How do you know? What is the estimate for Period 13? What is the r2 and what does it signify? Period Sales 1 12 2 13 3 12 4 14 5 13 6 15 7 16 8 14 9 17 10 15 11 17 12 18
Hey anyone good with R studio? How do you create a square shape with R code...
Hey anyone good with R studio? How do you create a square shape with R code by using plot() and lines() please show your code !
Does anyone know to create a model of a ball and urn model of an American...
Does anyone know to create a model of a ball and urn model of an American Roulette Wheel? Please provide a detailed model with an explanation of how you came to the conclusion you did. And if possible, provide an example of using the model to solve a problem. Thank you!
Does anyone know how to do it on EXCEL? Does anyone know how to do it...
Does anyone know how to do it on EXCEL? Does anyone know how to do it on EXCEL? Does anyone know how to do it on EXCEL? Does anyone know how to do it on EXCEL? Anyone know how to do it on EXCEL? The Statistical Abstract of the United States published by the U.S. Census Bureau reports that the average annual consumption of fresh fruit per person is 99.9 pounds. The standard deviation of fresh fruit consumption is about...
(Use R Programming to Code) Use the Monte Carol simulation to estimate the probability that all...
(Use R Programming to Code) Use the Monte Carol simulation to estimate the probability that all six faces appear exactly once in six tosses of fair dice.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT