Skip to content

Instantly share code, notes, and snippets.

@thmcmahon
Created July 15, 2015 23:53
Show Gist options
  • Save thmcmahon/4120d679935c90e84944 to your computer and use it in GitHub Desktop.
Save thmcmahon/4120d679935c90e84944 to your computer and use it in GitHub Desktop.
library(dplyr)
data(iris)
str(iris['Sepal.Length'])
'data.frame': 150 obs. of 1 variable:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
str(iris[,'Sepal.Length'])
num [1:150] 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
iris <- tbl_df(iris)
str(iris[,'Sepal.Length'])
Classes ‘tbl_df’ and 'data.frame': 150 obs. of 1 variable:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
@thmcmahon
Copy link
Author

The behaviour of subsetting in the matrix fashion changes depending on whether the data frame is a tbl_df or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment