ggplot2 Error in R – Don’t know how to automatically pick scale for object of type function (2 Examples)

This article explains how to deal with the ggplot2 error “Don’t know how to automatically pick scale for object type” in R.

Setting up the Examples

set.seed(65932)                                # Creating example data in R
my_df <- data.frame(Sample = rnorm(100))
head(my_df)
#       Sample
# 1  0.1140494
# 2 -0.4302736
# 3  1.7413250
# 4  1.4110479
# 5 -0.9949425
# 6  0.1164342
install.packages("ggplot2")                    # Install ggplot2 package
library("ggplot2")                             # Load ggplot2 package

Example 1: Replicating the Error Message – automatically pick scale for object of type function

ggplot(my_df, aes(x = 1:100, y = sample)) +    # y = sample (lower case s)
  geom_point()
# Don't know how to automatically pick scale for object of type function. Defaulting to continuous.
# Error: Aesthetics must be valid data columns. Problematic aesthetic(s): y = sample. 
# Did you mistype the name of a data column or forget to add after_stat()?
# Run `rlang::last_error()` to see where the error occurred.

Example 2: Solving the Error Message – automatically pick scale for object of type function

ggplot(my_df, aes(x = 1:100, y = Sample)) +    # y = Sample (upper case S)
  geom_point()

r graph figure 1 ggplot2 error r don't know automatically pick scale for object type function

Related Articles

Please find some related R programming tutorials on topics such as coding errors, lists, and data objects below:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top