Reputation: 198
I want to plot a scatter plot with only specific labels that meet my criteria
I have a dataframe df that looks like
In.Deg `Out.Deg Name
34 38 ABC
56 45 Dummy
53 54 Another_Dummy
I only want values which meet the criteria ( In.Deg > 50 & Out.Deg>50) to be labeled in the plot.
I want only want Another_Dummy to be displayed . I do not want the other names to be displayed as labels while plotting.
Appreciate the help
Upvotes: 1
Views: 7130
Reputation: 99331
## read in your data
d <- read.table(header = TRUE, text = "In.Deg Out.Deg Name
34 38 ABC
56 45 Dummy
53 54 Another_Dummy ")
## subset and plot with label
s <- subset(d, In.Deg > 50 & Out.Deg > 50)
with(d, plot(In.Deg, Out.Deg))
text(s[,1:2], labels = s[,3], pos = 1)
Upvotes: 4