Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 3 motivating plot #50

Open
jamessv opened this issue Oct 30, 2017 · 1 comment
Open

Chapter 3 motivating plot #50

jamessv opened this issue Oct 30, 2017 · 1 comment

Comments

@jamessv
Copy link

jamessv commented Oct 30, 2017

`> spam.path <- file.path("C:\03-Classification\data", "spam")

spam2.path <- file.path("C:\03-Classification\data", "spam_2")
easyham.path <- file.path("C:\03-Classification\data", "easy_ham")
easyham2.path <- file.path("C:\03-Classification\data", "easy_ham_2")
hardham.path <- file.path("C:\03-Classification\data", "hard_ham")
hardham2.path <- file.path("C:\03-Classification\data", "hard_ham_2")
x <- runif(1000, 0, 40)
y1 <- cbind(runif(100, 0, 10), 1)
y2 <- cbind(runif(800, 10, 30), 2)
y3 <- cbind(runif(100, 30, 40), 1)
val <- data.frame(cbind(x, rbind(y1, y2, y3)),

  •               stringsAsFactors = TRUE)
    

ex1 <- ggplot(val, aes(x, V2)) +

  • geom_jitter(aes(shape = as.factor(V3)),
  •               position = position_jitter(height = 2)) +
    
  • scale_shape_discrete(guide = "none", solid = FALSE) +
  • geom_hline(aes(yintercept = c(10,30)), linetype = 2) +
  • theme_bw() +
  • xlab("X") +
  • ylab("Y")

ggsave(plot = ex1,

  •    filename = file.path("C:\\03-Classification\\images", "00_Ex1.pdf"),
    
  •    height = 10,
    
  •    width = 10)
    

Error in grDevices::pdf(..., version = version) :
cannot open file 'C:\03-Classification\images/00_Ex1.pdf'

ggsave(plot = ex1,

  •    filename = file.path("C:\\03-Classification\\images\\00_Ex1.pdf"),
    
  •    height = 10,
    
  •    width = 10)
    

Error: Aesthetics must be either length 1 or the same as the data (1000): yintercept

getwd()
[1] "C:/Users/mm/Documents"

`

@hao2leaf
Copy link

hao2leaf commented Jul 26, 2019

You can split "geom_hline(aes(yintercept = c(10,30)), linetype = 2) +" into "geom_hline(aes(yintercept = c(10)), linetype = 2) + geom_hline(aes(yintercept = c(30)), linetype = 2) +". This will help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants