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 in Data Science by avinash
• 1,840 points
47 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)
answered Jun 23 by Sohail
• 2,960 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 in Data Science by Sohail
• 2,960 points
24 views
0 votes
0 answers

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

I've only recently started using RStudio to ...READ MORE

Jul 20 in Data Science by avinash
• 1,840 points
20 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 in Data Science by avinash
• 1,840 points
15 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 in Data Science by gaurav
• 18,960 points
170 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
452 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
495 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
4,457 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
515 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 in Data Science by Sohail
• 2,960 points
35 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 in Data Science by Sohail
• 2,960 points
25 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