using a variable with scatter plt

Trying to learn how to plot using this data set
1 cp_cust tngpp 4/22/2020 1.02
2 cp_geam tngpp 4/22/2020 1.33
3 cp_wip tngpp 4/22/2020 5.25
4 cp_xla_ods tncpp 4/22/2020 1.09
5 hvr_job_c002 tntap 4/22/2020 1.04
6 khw_fin_c4 tngpp 4/22/2020 5.94

this works fine
main = "Latency Times",
xlab = "ytd",
ylab = "Time")

now trying to add variable to only plot data based on a specific loc_name such as

with 'data$LOC_NAME==("tngpp")',
main="target ~ Latency")

and keep hitting a roadblock .. simply want to only ploy latency_hrs based on a specific loc_name


FYI I am a complete new r user and any help is appreciated

Here are three ways to make a subset of a data frame

data[data$LOC_NAME == "tngpp", ]

subset(data, LOC_NAME == "tngpp"]

filter(data, LOC_NAME == "tngpp")

Personally, I would do the subsetting in a separate step, storing the result in a variable, and plot that.


filter(data, LOC_NAME == "tncpp")
main="target ~ Latency")

works great

add on question ..
subset(data, LOC_NAME == "tngpp")
xlab='Target Volume', ylab = 'Latency in Hrs',
main='Target - Latency')

works too but the plot shows all of the data and not just the subset or filtered data. The correct data entries show in the console but not the plot

sorry for all the newbie questions and hope this is the correct place to ask them

You have to store the result of the subset function in a variable and use that in scatter.smooth.

SubSetOfData <- subset(data, LOC_NAME == "tngpp")
scatter.smooth(x= SubSetOfData$LATENCY_HRS,
xlab='Target Volume', ylab = 'Latency in Hrs',
main='Target - Latency')

The same would apply to the use of the filter() function from dplyr.

thank you :grinning:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.