Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Plotting two plots in a single row using ggplot in R

$
0
0

@NSS wrote:

Hi there,

I encountered a problem today while trying to plot two ggplots side by side.
I tried using the par command but it seemed to work only for base plotting package and not lattice and ggplot.

Here is what I tried.

library(data.table)
setwd("F:\\ML_P\\course 2")
data<-fread("crime rate.csv")
View(data)

par(mfrow=c(2,2))

library(ggplot2)
g1<-ggplot(data,aes(HousePrice,CrimeRate))+geom_point()+geom_smooth(method = "lm")


data1<-subset(data,CrimeRate<200)
g2<-ggplot(data1,aes(HousePrice,CrimeRate))+geom_point()+geom_smooth(method = "lm")+ylim(0,300)

Am I doing anything wrong ? Or is par incompatible with tht lattice and ggplot packages.

Thanks

Neeraj

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles