I'm learning R through the Google Analytics Certification and I get stuck on the summary command in R. I'm using Rstudio for this.
We first load the palmerpenguins package and then have to enter the command summary(penguins). The problem is I keep getting an error message as follow:
> install.packages("palmerpenguins", lib="C:/Program Files/R/R-4.1.2/library")
package ‘palmerpenguins’ successfully unpacked and MD5 sums checked
> summary(penguins)
Error in summary(penguins) : object 'penguins' not found
Thank you in advance for your help!
CodePudding user response:
You can use this code:
install.packages("palmerpenguins")
library(palmerpenguins)
summary(penguins)
Output of summary:
species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g
Adelie :152 Biscoe :168 Min. :32.10 Min. :13.10 Min. :172.0 Min. :2700
Chinstrap: 68 Dream :124 1st Qu.:39.23 1st Qu.:15.60 1st Qu.:190.0 1st Qu.:3550
Gentoo :124 Torgersen: 52 Median :44.45 Median :17.30 Median :197.0 Median :4050
Mean :43.92 Mean :17.15 Mean :200.9 Mean :4202
3rd Qu.:48.50 3rd Qu.:18.70 3rd Qu.:213.0 3rd Qu.:4750
Max. :59.60 Max. :21.50 Max. :231.0 Max. :6300
NA's :2 NA's :2 NA's :2 NA's :2
sex year
female:165 Min. :2007
male :168 1st Qu.:2007
NA's : 11 Median :2008
Mean :2008
3rd Qu.:2009
Max. :2009
CodePudding user response:
You don't have to load the package, base function data
has a package
argument.
data(penguins, package = "palmerpenguins")
summary(penguins)
#> species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex year
#> Adelie :152 Biscoe :168 Min. :32.10 Min. :13.10 Min. :172.0 Min. :2700 female:165 Min. :2007
#> Chinstrap: 68 Dream :124 1st Qu.:39.23 1st Qu.:15.60 1st Qu.:190.0 1st Qu.:3550 male :168 1st Qu.:2007
#> Gentoo :124 Torgersen: 52 Median :44.45 Median :17.30 Median :197.0 Median :4050 NA's : 11 Median :2008
#> Mean :43.92 Mean :17.15 Mean :200.9 Mean :4202 Mean :2008
#> 3rd Qu.:48.50 3rd Qu.:18.70 3rd Qu.:213.0 3rd Qu.:4750 3rd Qu.:2009
#> Max. :59.60 Max. :21.50 Max. :231.0 Max. :6300 Max. :2009
#> NA's :2 NA's :2 NA's :2 NA's :2
Created on 2022-03-06 by the reprex package (v2.0.1)