plotting in different shapes using pch argument

0 votes
How can we assign a particular shape to data points  (using the pch argument to plot()) based on a column in my data frame that has the categorical data? Will using as.factor() to group data and then using pch help ?
Jun 2, 2022 in Data Science by avinash
• 1,840 points
438 views

1 answer to this question.

0 votes
plot(Sepal.Length ~ Petal.Length,
      xlab = "Petal Length (cm)",
      ylab = "Sepal Length (cm)",
      pch = c(16, 17, 18)[as.numeric(Species)],  # different 'pch' types 
      main = "Anderson Iris Dataset",
      col = c("red", "green","blue")[as.numeric(Species)],
      data = iris)

Discover the world of data with our Data Science Course and embark on a transformative journey towards analytical excellence.

answered Jun 23, 2022 by Sohail
• 3,040 points

Related Questions In Data Science

0 votes
0 answers

Stepwise AIC using forward selection in R

In R, I'm attempting to perform a ...READ MORE

Jun 24, 2022 in Data Science by Sohail
• 3,040 points
398 views
0 votes
1 answer

Plot a legend outside of the plotting area in base graphics?

It appears that you are experiencing some ...READ MORE

answered Sep 8, 2023 in Data Science by anonymous
• 1,380 points
409 views
0 votes
0 answers

Understanding of minbucket function in CART model using R

Let's say that the training data is ...READ MORE

Jul 20, 2022 in Data Science by avinash
• 1,840 points
490 views
0 votes
1 answer

Converting xlsx to xls using Microsoft Office Compitablity Pack's excelcnv

Simply rearranging the positions of the parameters ...READ MORE

answered Mar 25, 2022 in Data Science by gaurav
• 23,260 points
1,187 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
974 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
1,061 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
5,812 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
993 views
0 votes
1 answer

Add two lines on graph using abline in R

I am using "y 0+x" to fit ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
551 views
0 votes
1 answer

How to implement Knn-algorithm without using k-nn function in r?

I created an example that demonstrates the ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
407 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP