Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot
Many, many thanks, Alexander! This is precisely what I wanted to achieve! Cheers, -Original Message- From: Alexander Ilich To: bfalevl...@gmail.com ; r-sig-geo@r-project.org ; rain1...@aim.com Sent: Thu, Oct 13, 2022 3:04 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot #yiv5944274138 P {margin-top:0;margin-bottom:0;}The best way would probably be that you could create a new column indicating which subset each row is in and then set that to the color aesthetic in the aes call. Alternatively, you could call geom_density multiple times and overwrite the data argument and change the color. For exampleGEV$set<- NA #initialize new column as NA's# Now create code to fill in the set column appropriately (e.g. as "set1", "set2", "set3", etc)ggplot(data=GEV[c(1:4, 17:21, 30:34),], aes(x=RL45, color=set)) + geom_density() + xlab("One-day max (mm/day)") + ggtitle("Global one-day max Return Level (RCP 4.5)") + xlim(300, 450) OR ggplot() + geom_density(data=GEV[1:4,], mapping = aes(x=RL45), color="midnightblue") + geom_density(data=GEV[17:21,], mapping = aes(x=RL45), color="green")+ geom_density(data=GEV[30:34,], mapping = aes(x=RL45), color="red")+ xlab("One-day max (mm/day)") + ggtitle("Global one-day max Return Level (RCP 4.5)") + xlim(300, 450) From: rain1...@aim.com Sent: Thursday, October 13, 2022 2:21 PM To: Alexander Ilich ; bfalevl...@gmail.com ; r-sig-geo@r-project.org Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot Finally, let's say that I wanted to add several lines/curves on the same plot using different subsets, how would we do this? I tried the following: newplot1 <- ggplot(data=GEV[17:21,], aes(x=RL45)) + geom_density(color="midnightblue") + xlab("One-day max (mm/day)") + ggtitle("Global one-day max Return Level (RCP 4.5)") + xlim(300, 450) + (data=GEV[1:5,], aes(x=RL45)) + geom_density(color="blue") I receive this error in the process: Error: unexpected ',' in "newplot1 <- ggplot(data=GEV[17:21,], aes(x=RL45)) + geom_density(color="midnightblue") + xlab("One-day max (mm/day)") + ggtitle("Global one-day max Return Level (RCP 4.5)") + xlim(300, 450) + (d" Here, I am identifying two different subsets to create two different lines on the same plot, but for some reason, this strange error occurs. Unless, there is a way to specify all of the subsets desired earlier in the command? Thanks, -Original Message- From: Alexander Ilich To: bfalevl...@gmail.com ; r-sig-geo@r-project.org ; rain1...@aim.com Sent: Thu, Oct 13, 2022 2:07 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot Make sure to include the comma after the numbers so that you're selecting rows x through y and all columns. For example, GEV[17:21,] not GEV[17:21]From: R-sig-Geo on behalf of rain1290--- via R-sig-Geo Sent: Thursday, October 13, 2022 1:08 PM To: bfalevl...@gmail.com ; r-sig-geo@r-project.org Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot That you so much! Yes, this stopped the error from appearing. >From what I see, though, when I attempt to change the subset from [1:4] to, >say, [17:21] or [30:34], I end up with the exact same plots. Why could that >be? The idea would be to make different curves on the same plot by changing >the subset. -Original Message- From: Bede-Fazekas Ákos To: r-sig-geo@r-project.org Sent: Thu, Oct 13, 2022 12:37 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot Hello, try 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) HTH, Ákos --- Ákos Bede-Fazekas Centre for Ecological Research, Hungary 2022.10.13. 18:27 keltezéssel, rain1290--- via R-sig-Geo írta: > 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 >
Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot
The best way would probably be that you could create a new column indicating which subset each row is in and then set that to the color aesthetic in the aes call. Alternatively, you could call geom_density multiple times and overwrite the data argument and change the color. For example GEV$set<- NA #initialize new column as NA's # Now create code to fill in the set column appropriately (e.g. as "set1", "set2", "set3", etc) ggplot(data=GEV[c(1:4, 17:21, 30:34),], aes(x=RL45, color=set)) + geom_density() + xlab("One-day max (mm/day)") + ggtitle("Global one-day max Return Level (RCP 4.5)") + xlim(300, 450) OR ggplot() + geom_density(data=GEV[1:4,], mapping = aes(x=RL45), color="midnightblue") + geom_density(data=GEV[17:21,], mapping = aes(x=RL45), color="green")+ geom_density(data=GEV[30:34,], mapping = aes(x=RL45), color="red")+ xlab("One-day max (mm/day)") + ggtitle("Global one-day max Return Level (RCP 4.5)") + xlim(300, 450) From: rain1...@aim.com Sent: Thursday, October 13, 2022 2:21 PM To: Alexander Ilich ; bfalevl...@gmail.com ; r-sig-geo@r-project.org Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot Finally, let's say that I wanted to add several lines/curves on the same plot using different subsets, how would we do this? I tried the following: newplot1 <- ggplot(data=GEV[17:21,], aes(x=RL45)) + geom_density(color="midnightblue") + xlab("One-day max (mm/day)") + ggtitle("Global one-day max Return Level (RCP 4.5)") + xlim(300, 450) + (data=GEV[1:5,], aes(x=RL45)) + geom_density(color="blue") I receive this error in the process: Error: unexpected ',' in "newplot1 <- ggplot(data=GEV[17:21,], aes(x=RL45)) + geom_density(color="midnightblue") + xlab("One-day max (mm/day)") + ggtitle("Global one-day max Return Level (RCP 4.5)") + xlim(300, 450) + (d" Here, I am identifying two different subsets to create two different lines on the same plot, but for some reason, this strange error occurs. Unless, there is a way to specify all of the subsets desired earlier in the command? Thanks, -Original Message- From: Alexander Ilich To: bfalevl...@gmail.com ; r-sig-geo@r-project.org ; rain1...@aim.com Sent: Thu, Oct 13, 2022 2:07 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot Make sure to include the comma after the numbers so that you're selecting rows x through y and all columns. For example, GEV[17:21,] not GEV[17:21] From: R-sig-Geo on behalf of rain1290--- via R-sig-Geo Sent: Thursday, October 13, 2022 1:08 PM To: bfalevl...@gmail.com ; r-sig-geo@r-project.org Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot That you so much! Yes, this stopped the error from appearing. >From what I see, though, when I attempt to change the subset from [1:4] to, >say, [17:21] or [30:34], I end up with the exact same plots. Why could that >be? The idea would be to make different curves on the same plot by changing >the subset. -Original Message- From: Bede-Fazekas �kos To: r-sig-geo@r-project.org Sent: Thu, Oct 13, 2022 12:37 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot Hello, try 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) HTH, �kos --- �kos Bede-Fazekas Centre for Ecological Research, Hungary 2022.10.13. 18:27 keltez�ssel, rain1290--- via R-sig-Geo �rta: > 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 >
Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot
Finally, let's say that I wanted to add several lines/curves on the same plot using different subsets, how would we do this? I tried the following: newplot1 <- ggplot(data=GEV[17:21,], aes(x=RL45)) + geom_density(color="midnightblue") + xlab("One-day max (mm/day)") + ggtitle("Global one-day max Return Level (RCP 4.5)") + xlim(300, 450) + (data=GEV[1:5,], aes(x=RL45)) + geom_density(color="blue") I receive this error in the process: Error: unexpected ',' in "newplot1 <- ggplot(data=GEV[17:21,], aes(x=RL45)) + geom_density(color="midnightblue") + xlab("One-day max (mm/day)") + ggtitle("Global one-day max Return Level (RCP 4.5)") + xlim(300, 450) + (d" Here, I am identifying two different subsets to create two different lines on the same plot, but for some reason, this strange error occurs. Unless, there is a way to specify all of the subsets desired earlier in the command? Thanks, -Original Message- From: Alexander Ilich To: bfalevl...@gmail.com ; r-sig-geo@r-project.org ; rain1...@aim.com Sent: Thu, Oct 13, 2022 2:07 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot #yiv2227645102 P {margin-top:0;margin-bottom:0;}Make sure to include the comma after the numbers so that you're selecting rows x through y and all columns. For example, GEV[17:21,] not GEV[17:21]From: R-sig-Geo on behalf of rain1290--- via R-sig-Geo Sent: Thursday, October 13, 2022 1:08 PM To: bfalevl...@gmail.com ; r-sig-geo@r-project.org Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot That you so much! Yes, this stopped the error from appearing. >From what I see, though, when I attempt to change the subset from [1:4] to, >say, [17:21] or [30:34], I end up with the exact same plots. Why could that >be? The idea would be to make different curves on the same plot by changing >the subset. -Original Message- From: Bede-Fazekas Ákos To: r-sig-geo@r-project.org Sent: Thu, Oct 13, 2022 12:37 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot Hello, try 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) HTH, Ákos --- Ákos Bede-Fazekas Centre for Ecological Research, Hungary 2022.10.13. 18:27 keltezéssel, rain1290--- via R-sig-Geo írta: > 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-geodata=05%7C01%7Cailich%40usf.edu%7Cf3a66d57d850475703de08daad3da230%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012777488310075%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=QWh37WcKos58sGkwE6aiccdKPcjlWdcEPBNJ%2FxJDneo%3Dreserved=0 ___ 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-geodata=05%7C01%7Cailich%40usf.edu%7Cf3a66d57d850475703de08daad3da230%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012777488466291%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=1jk%2BDyj%2BgAML1JoeJIcsL%2BdwIeBE4eG%2BeR1AU1u5LMM%3Dreserved=0 [[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-geodata=05%7C01%7Cailich%40usf.edu%7Cf3a66d57d850475703de08daad3da230%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012777488466291%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=1jk%2BDyj%2BgAML1JoeJIcsL%2BdwIeBE4eG%2BeR1AU1u5LMM%3Dreserved=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
Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot
That was precisely the problem! Thank you so much! -Original Message- From: Alexander Ilich To: bfalevl...@gmail.com ; r-sig-geo@r-project.org ; rain1...@aim.com Sent: Thu, Oct 13, 2022 2:07 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot #yiv4975106143 P {margin-top:0;margin-bottom:0;}Make sure to include the comma after the numbers so that you're selecting rows x through y and all columns. For example, GEV[17:21,] not GEV[17:21]From: R-sig-Geo on behalf of rain1290--- via R-sig-Geo Sent: Thursday, October 13, 2022 1:08 PM To: bfalevl...@gmail.com ; r-sig-geo@r-project.org Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot That you so much! Yes, this stopped the error from appearing. >From what I see, though, when I attempt to change the subset from [1:4] to, >say, [17:21] or [30:34], I end up with the exact same plots. Why could that >be? The idea would be to make different curves on the same plot by changing >the subset. -Original Message- From: Bede-Fazekas Ákos To: r-sig-geo@r-project.org Sent: Thu, Oct 13, 2022 12:37 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot Hello, try 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) HTH, Ákos --- Ákos Bede-Fazekas Centre for Ecological Research, Hungary 2022.10.13. 18:27 keltezéssel, rain1290--- via R-sig-Geo írta: > 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-geodata=05%7C01%7Cailich%40usf.edu%7Cf3a66d57d850475703de08daad3da230%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012777488310075%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=QWh37WcKos58sGkwE6aiccdKPcjlWdcEPBNJ%2FxJDneo%3Dreserved=0 ___ 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-geodata=05%7C01%7Cailich%40usf.edu%7Cf3a66d57d850475703de08daad3da230%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012777488466291%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=1jk%2BDyj%2BgAML1JoeJIcsL%2BdwIeBE4eG%2BeR1AU1u5LMM%3Dreserved=0 [[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-geodata=05%7C01%7Cailich%40usf.edu%7Cf3a66d57d850475703de08daad3da230%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012777488466291%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=1jk%2BDyj%2BgAML1JoeJIcsL%2BdwIeBE4eG%2BeR1AU1u5LMM%3Dreserved=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
Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot
Make sure to include the comma after the numbers so that you're selecting rows x through y and all columns. For example, GEV[17:21,] not GEV[17:21] From: R-sig-Geo on behalf of rain1290--- via R-sig-Geo Sent: Thursday, October 13, 2022 1:08 PM To: bfalevl...@gmail.com ; r-sig-geo@r-project.org Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot That you so much! Yes, this stopped the error from appearing. >From what I see, though, when I attempt to change the subset from [1:4] to, >say, [17:21] or [30:34], I end up with the exact same plots. Why could that >be? The idea would be to make different curves on the same plot by changing >the subset. -Original Message- From: Bede-Fazekas �kos To: r-sig-geo@r-project.org Sent: Thu, Oct 13, 2022 12:37 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot Hello, try 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) HTH, �kos --- �kos Bede-Fazekas Centre for Ecological Research, Hungary 2022.10.13. 18:27 keltez�ssel, rain1290--- via R-sig-Geo �rta: > 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-geodata=05%7C01%7Cailich%40usf.edu%7Cf3a66d57d850475703de08daad3da230%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012777488310075%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=QWh37WcKos58sGkwE6aiccdKPcjlWdcEPBNJ%2FxJDneo%3Dreserved=0 ___ 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-geodata=05%7C01%7Cailich%40usf.edu%7Cf3a66d57d850475703de08daad3da230%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012777488466291%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=1jk%2BDyj%2BgAML1JoeJIcsL%2BdwIeBE4eG%2BeR1AU1u5LMM%3Dreserved=0 [[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-geodata=05%7C01%7Cailich%40usf.edu%7Cf3a66d57d850475703de08daad3da230%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012777488466291%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=1jk%2BDyj%2BgAML1JoeJIcsL%2BdwIeBE4eG%2BeR1AU1u5LMM%3Dreserved=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
Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot
That you so much! Yes, this stopped the error from appearing. >From what I see, though, when I attempt to change the subset from [1:4] to, >say, [17:21] or [30:34], I end up with the exact same plots. Why could that >be? The idea would be to make different curves on the same plot by changing >the subset. -Original Message- From: Bede-Fazekas Ákos To: r-sig-geo@r-project.org Sent: Thu, Oct 13, 2022 12:37 pm Subject: Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot Hello, try 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) HTH, Ákos --- Ákos Bede-Fazekas Centre for Ecological Research, Hungary 2022.10.13. 18:27 keltezéssel, rain1290--- via R-sig-Geo írta: > 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://stat.ethz.ch/mailman/listinfo/r-sig-geo ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot
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 on behalf of rain1290--- via R-sig-Geo Sent: Thursday, October 13, 2022 12:27 PM To: 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-geodata=05%7C01%7Cailich%40usf.edu%7Cb1a922b685464ea1578208daad37e286%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012752802904543%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=6dbwE4NOy9SeJBqLd52kIv07d1FlRt4Ehj7r4g4R598%3Dreserved=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
Re: [R-sig-Geo] Selecting a range of values in a specific column for R ggplot
Hello, try 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) HTH, Ákos --- Ákos Bede-Fazekas Centre for Ecological Research, Hungary 2022.10.13. 18:27 keltezéssel, rain1290--- via R-sig-Geo írta: 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://stat.ethz.ch/mailman/listinfo/r-sig-geo ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo