I have a scatterplot using this data.frame
:
set.seed(1)
df <- data.frame(a=sample(1:10,10), b = sample(1:10,10),ID = sample(letters[1:10]))
I only want to label the points of ID [1:5]
.
I tried the code below but it still labelled all of them
plot(a~b,data = df)
with(df,text(a~b, labels = ID [1:5]))
I think you just need to subset df in your with()
, try
set.seed(1)
df <- data.frame(a=sample(1:10,10), b = sample(1:10,10),ID = sample(letters[1:10]))
plot(a~b,data = df)
with(df[1:5,], text(a~b, labels = ID [1:5]))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.