Subsetting Data

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

ProgrammingQuizW1_data_csvfile_last2rows_error2

Then, finally, this worked!

ProgrammingQuizW1_data_csvfile_last2rows_WORKS

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)]
$foo
[1] 1 2 3 4

$baz
[1] "hello"

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

[1] http://stackoverflow.com/questions/13817174/how-can-i-extract-non-consecutive-rows-from-a-data-set-in-r?rq=1

This also seems to work:

ProgrammingQuizW1_data_subset

Advertisements

About Lisa Cohen

PhD student at UC Davis.
This entry was posted in Coursera, R. Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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