[R] Scatterplot of many variables against a single variable
sezenismail at gmail.com
Mon Nov 27 21:18:03 CET 2017
> On 27 Nov 2017, at 11:56, Engin YILMAZ <ispanyolcom at gmail.com> wrote:
> I try to realize one scatter matrix which draws *one single variable to all
> variables* with *regression line* . You can see my eviews version in the
> annex .
> How can I draw this graph with R studio?
A tiny note; You do calculations in R not RSudio. RStudio is a tool (IDE) to use R in an easy way.
The code below shows how to accomplish this task easily by ggplot. It’s adapted from .
# This is your initial data.frame and you want scatterplots of all variables against x1.
foo <- data.frame(x1 = runif(50, 0, 1),
x2 = runif(50, 0, 1),
x3 = runif(50, 0, 1),
x4 = runif(50, 0, 1))
# melt data. This is very handy function from reshape2 library.
foo2 <- melt(foo, "x1”)
# plot points and add lm lines.
ggplot(foo2, aes(value, x1)) +
More information about the R-help