plotting in different shapes using pch= argument

If I am using R to plot. How can I assign a particular shape to data points belonging to one category (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 ?

Answers


You mean something like this...?

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)

Which produces:


Need Your Help

Parameters for states without URLs in ui-router for AngularJS

angularjs angular-ui-router

I am using ui-router to represent states in my AngularJS app. In it I'd like to change the state without changing the URL (basically a "detail view" is updated but this should not affect the URL).

Can I modify the default Check-in Action in TFS 2010?

tfs2010 workitem checkin

When you associate a changeset with a workitem TFS defaults to resolving the workitem. I want to default to associating it.