The aesthetic is looking for the name of the variable, so try subsetting the 
dataframe in the data portion instead.

newplot <- ggplot(data = GEV[1:4,], aes(x = RL45)) + geom_density(color = 
"midnightblue") + xlab("Location (mm/day") + ggtitle("Global Location under 
RCP4.5") + xlim(300, 350)
________________________________
From: R-sig-Geo <r-sig-geo-boun...@r-project.org> on behalf of rain1290--- via 
R-sig-Geo <r-sig-geo@r-project.org>
Sent: Thursday, October 13, 2022 12:27 PM
To: r-sig-geo@r-project.org <r-sig-geo@r-project.org>
Subject: [R-sig-Geo] Selecting a range of values in a specific column for R 
ggplot

I am trying to select a range of values (i.e. the first 4 values) in a specific 
column from a table. The column is called "RL45". I tried the following code to 
create a plot in ggplot:
newplot <- ggplot(data = GEV, aes(x = RL45[1:4])) + geom_density(color = 
"midnightblue") + xlab("Location (mm/day") + ggtitle("Global Location under 
RCP4.5") + xlim(300, 350)

This results in this strange error:

Error: Aesthetics must be either length 1 or the same as the data (34): x

This is odd, as I selected the first 4 values in that "RL45" column.
Any thoughts would be greatly appreciated!
Thank you,
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&amp;data=05%7C01%7Cailich%40usf.edu%7Cb1a922b685464ea1578208daad37e286%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012752802904543%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=6dbwE4NOy9SeJBqLd52kIv07d1FlRt4Ehj7r4g4R598%3D&amp;reserved=0
[EXTERNAL EMAIL] DO NOT CLICK links or attachments unless you recognize the 
sender and know the content is safe.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to