Plotting with ggplot2: “Error: Discrete value supplied to continuous scale” on categorical y-axis

As mentioned in the comments, there cannot be a continuous scale on variable of the factor type. You could change the factor to numeric as follows, just after you define the meltDF variable. meltDF$variable=as.numeric(levels(meltDF$variable))[meltDF$variable] Then, execute the ggplot command ggplot(meltDF[meltDF$value == 1,]) + geom_point(aes(x = MW, y = variable)) + scale_x_continuous(limits=c(0, 1200), breaks=c(0, 400, 800, … Read more

Colouring plot by factor in R

data<-iris plot(data$Sepal.Length, data$Sepal.Width, col=data$Species) legend(7,4.3,unique(data$Species),col=1:length(data$Species),pch=1) should do it for you. But I prefer ggplot2 and would suggest that for better graphics in R.

Coerce multiple columns to factors at once

Choose some columns to coerce to factors: cols <- c(“A”, “C”, “D”, “H”) Use lapply() to coerce and replace the chosen columns: data[cols] <- lapply(data[cols], factor) ## as.factor() could also be used Check the result: sapply(data, class) # A B C D E F G # “factor” “integer” “factor” “factor” “integer” “integer” “integer” # H … Read more