- Bağlantıyı al
- X
- E-posta
- Diğer Uygulamalar
- Bağlantıyı al
- X
- E-posta
- Diğer Uygulamalar
Basic multiple scatterplots with regression lines
#Kütüphaneler
library(ggplot2)
library(reshape2)
#SpesifikDeğişken
CPI <- allgroups$CPI
#allgroups data.frame'i CPI değişkeniyle birlikte 13 değişkeni barındırıyor
#Burada 12 değişkeni CPI'ya karşı çizdiriyoruz.
foo2 <- melt(allgroups, "CPI")
ggplot(foo2, aes(CPI, value )) +
geom_point() +
geom_smooth(method=lm) +
facet_wrap(~ variable, ncol = 3)
Burada bir sıkıntı doğmaktadır. Çünkü her değişken (y ekseni) sınırlandırılmadığı takdirde
CPI ilişkileri belirsizleşecektir.
library(ggplot2)
library(reshape2)
CPI <- allgroups$CPI
group1 <- allgroups$Group1
group2 <- allgroups$Group2
group3 <- allgroups$Group3
group4 <- allgroups$Group4
group5 <- allgroups$Group5
group6 <- allgroups$Group6
group7 <- allgroups$Group7
group8 <- allgroups$Group8
group9 <- allgroups$Group9
group10 <- allgroups$Group10
group11 <- allgroups$Group11
group12 <- allgroups$Group12
p1 <-ggplot(allgroups, aes(x=CPI, y=group1)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p2 <-ggplot(allgroups, aes(x=CPI, y=group2)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p3 <-ggplot(allgroups, aes(x=CPI, y=group3)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p4 <-ggplot(allgroups, aes(x=CPI, y=group4)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p5 <-ggplot(allgroups, aes(x=CPI, y=group5)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p6 <-ggplot(allgroups, aes(x=CPI, y=group6)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p7 <-ggplot(allgroups, aes(x=CPI, y=group7)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p8 <-ggplot(allgroups, aes(x=CPI, y=group8)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p9 <-ggplot(allgroups, aes(x=CPI, y=group9)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p10 <-ggplot(allgroups, aes(x=CPI, y=group10)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p11 <-ggplot(allgroups, aes(x=CPI, y=group11)) +
geom_point(shape=1) +
geom_smooth(method=lm)
p12 <-ggplot(allgroups, aes(x=CPI, y=group12)) +
geom_point(shape=1) +
geom_smooth(method=lm)
multiplot(p1, p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12, cols=3)
......................................................................................................................................
multiplot.R bunu directory'e kaydedin.
multiplot <- function(..., plotlist = NULL, file, cols = 1, layout = NULL) {
require(grid)
plots <- c(list(...), plotlist)
numPlots = length(plots)
if (is.null(layout)) {
layout <- matrix(seq(1, cols * ceiling(numPlots/cols)),
ncol = cols, nrow = ceiling(numPlots/cols))
}
if (numPlots == 1) {
print(plots[[1]])
} else {
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout))))
for (i in 1:numPlots) {
matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE))
print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row,
layout.pos.col = matchidx$col))
}
}
}
Dr. Engin YILMAZ
29/11/2017
ANKARA
- Bağlantıyı al
- X
- E-posta
- Diğer Uygulamalar
Yorumlar
Yorum Gönder