[1] "Hello" "345"
[1] "character"
Length Class Mode
2 character character
[1] 51 100 511 5100 51000
[1] "numeric"
library(dplyr)
# Creating data frame and assigning it to a object named "data"
data <- data.frame(
ID = 1:5,
Name = c("Alice", "Bob", "Charlie", "David", "Eve"),
Age = c(25, 30, 22, 35, 28),
City = c("NY", "LA", "Chicago", "LA", "Boston"),
Score = c(85, 92, 78, 88, 95)
)
print(data) ID Name Age City Score
1 1 Alice 25 NY 85
2 2 Bob 30 LA 92
3 3 Charlie 22 Chicago 78
4 4 David 35 LA 88
5 5 Eve 28 Boston 95
ID Name Age City Score
1 1 Alice 25 NY 85
2 2 Bob 30 LA 92
3 3 Charlie 22 Chicago 78
4 4 David 35 LA 88
5 5 Eve 28 Boston 95
ID Name Age City Score
Min. :1 Length:5 Min. :22 Length:5 Min. :78.0
1st Qu.:2 Class :character 1st Qu.:25 Class :character 1st Qu.:85.0
Median :3 Mode :character Median :28 Mode :character Median :88.0
Mean :3 Mean :28 Mean :87.6
3rd Qu.:4 3rd Qu.:30 3rd Qu.:92.0
Max. :5 Max. :35 Max. :95.0
[1] 28
# A tibble: 53,940 × 10
carat cut color clarity depth table price x y z
<dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl>
1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43
2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31
3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31
4 0.29 Premium I VS2 62.4 58 334 4.2 4.23 2.63
5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75
6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48
7 0.24 Very Good I VVS1 62.3 57 336 3.95 3.98 2.47
8 0.26 Very Good H SI1 61.9 55 337 4.07 4.11 2.53
9 0.22 Fair E VS2 65.1 61 337 3.87 3.78 2.49
10 0.23 Very Good H VS1 59.4 61 338 4 4.05 2.39
# ℹ 53,930 more rows
# A tibble: 6 × 10
carat cut color clarity depth table price x y z
<dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl>
1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43
2 0.23 Ideal J VS1 62.8 56 340 3.93 3.9 2.46
3 0.31 Ideal J SI2 62.2 54 344 4.35 4.37 2.71
4 0.3 Ideal I SI2 62 54 348 4.31 4.34 2.68
5 0.33 Ideal I SI2 61.8 55 403 4.49 4.51 2.78
6 0.33 Ideal I SI2 61.2 56 403 4.49 4.5 2.75
# A tibble: 1 × 1
AveragePrice
<dbl>
1 3458.
# This is the same thing as doing
new.dataset <- diamonds %>% filter(cut == "Ideal")
mean(new.dataset$price)[1] 3457.542
# A tibble: 5 × 2
cut AveragePrice
<ord> <dbl>
1 Fair 4359.
2 Good 3929.
3 Very Good 3982.
4 Premium 4584.
5 Ideal 3458.