Data Extraction

This entry is to record how to extract data


Extract column from data.frame

A <- head(iris[1])
> B <- head(iris[[1]])

A
Sepal.Length
1 5.1
2 4.9
3 4.7
4 4.6
5 5.0
6 5.4
> B
[1] 5.1 4.9 4.7 4.6 5.0 5.4
>

str(A)
‘data.frame’: 6 obs. of 1 variable:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4
> str(B)
num [1:6] 5.1 4.9 4.7 4.6 5 5.4
>

A extract it to data.frame

B extract the column into numeric


Advertisements

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