Subsetting Data

In addition to what I tried yesterday, I tried these today, with no luck:


Then, finally, this worked!


A combination of [1] and the lecture notes on subsetting lists and matrices, with syntax:

> x<-list(foo=1:4,bar=0.6,baz="hello")
> x[c(1,3)]
[1] 1 2 3 4

[1] "hello"

> x[[c(1,3)]]
[1] 3


This also seems to work:


About Lisa Johnson

PhD candidate at UC Davis in Molecular, Cellular, and Integrative Physiology
This entry was posted in Coursera, R. Bookmark the permalink.

2 Responses to Subsetting Data

  1. Lisa, 5 years later and I am still using this. Thank you!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s