INTRODUCTION: This is an updated and expanded version of the mammals sleep dataset. Updated sleep times and weights were taken from V. M. Savage and G. B. West. A quantitative, theoretical framework for understanding mammalian sleep. Proceedings of the National Academy of Sciences, 104 (3):1051-1056, 2007. Sleep in mammals and non mammals indicates the state when body remain suspended nervous system be inactive,eyes remaining closed for several hours.Mammals sleep have various diversity.Some mammals sleep while standing, some sleep while sitting, some are sleeping upside down.They have different Body Mass Index as per their sleeping behaviour.Sleep sometimes increase metabolism,conserve energy.Different mammals like bats sleep 18-20 hours per day and girafees sleep 3-4 hours per day. Are Brain and Body weight responsible for sleep?

Mammas sleep data frame has 83 rows and 11 variables. 1.name : common name 2.genus: 3.vore: carnivore, omnivore or herbivore? 4.order: 5.conservation: the conservation status of the animal 6.sleep_total: total amount of sleep, in hours 7.sleep_rem: rem sleep, in hours 8.sleep_cycle: length of sleep cycle, in hours 9.awake: amount of time spent awake, in hours 10.brainwt: brain weight in kilograms 11.bodywt: body weight in kilograms

## Loading required package: knitr
## Loading required package: rmarkdown
## Warning: package 'rmarkdown' was built under R version 3.4.4
## Loading required package: ggplot2
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
summary(msleep)
##                         name             genus         vore   
##  African elephant         : 1   Panthera    : 3   carni  :19  
##  African giant pouched rat: 1   Spermophilus: 3   herbi  :32  
##  African striped mouse    : 1   Equus       : 2   insecti: 5  
##  Arctic fox               : 1   Vulpes      : 2   omni   :20  
##  Arctic ground squirrel   : 1   Acinonyx    : 1   NA's   : 7  
##  Asian elephant           : 1   Aotus       : 1               
##  (Other)                  :77   (Other)     :71               
##           order          conservation  sleep_total      sleep_rem    
##  Rodentia    :22   cd          : 2    Min.   : 1.90   Min.   :0.100  
##  Carnivora   :12   domesticated:10    1st Qu.: 7.85   1st Qu.:0.900  
##  Primates    :12   en          : 4    Median :10.10   Median :1.500  
##  Artiodactyla: 6   lc          :27    Mean   :10.43   Mean   :1.875  
##  Soricomorpha: 5   nt          : 4    3rd Qu.:13.75   3rd Qu.:2.400  
##  Cetacea     : 3   vu          : 7    Max.   :19.90   Max.   :6.600  
##  (Other)     :23   NA's        :29                    NA's   :22     
##   sleep_cycle         awake          brainwt            bodywt        
##  Min.   :0.1167   Min.   : 4.10   Min.   :0.00014   Min.   :   0.005  
##  1st Qu.:0.1833   1st Qu.:10.25   1st Qu.:0.00290   1st Qu.:   0.174  
##  Median :0.3333   Median :13.90   Median :0.01240   Median :   1.670  
##  Mean   :0.4396   Mean   :13.57   Mean   :0.28158   Mean   : 166.136  
##  3rd Qu.:0.5792   3rd Qu.:16.15   3rd Qu.:0.12550   3rd Qu.:  41.750  
##  Max.   :1.5000   Max.   :22.10   Max.   :5.71200   Max.   :6654.000  
##  NA's   :51                       NA's   :27
summary(msleep$sleep_total)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.90    7.85   10.10   10.43   13.75   19.90

SELECT FUNCTION

select(msleep,name,vore,sleep_total)
##                              name    vore sleep_total
## 1                         Cheetah   carni        12.1
## 2                      Owl monkey    omni        17.0
## 3                 Mountain beaver   herbi        14.4
## 4      Greater short-tailed shrew    omni        14.9
## 5                             Cow   herbi         4.0
## 6                Three-toed sloth   herbi        14.4
## 7               Northern fur seal   carni         8.7
## 8                    Vesper mouse    <NA>         7.0
## 9                             Dog   carni        10.1
## 10                       Roe deer   herbi         3.0
## 11                           Goat   herbi         5.3
## 12                     Guinea pig   herbi         9.4
## 13                         Grivet    omni        10.0
## 14                     Chinchilla   herbi        12.5
## 15                Star-nosed mole    omni        10.3
## 16      African giant pouched rat    omni         8.3
## 17      Lesser short-tailed shrew    omni         9.1
## 18           Long-nosed armadillo   carni        17.4
## 19                     Tree hyrax   herbi         5.3
## 20         North American Opossum    omni        18.0
## 21                 Asian elephant   herbi         3.9
## 22                  Big brown bat insecti        19.7
## 23                          Horse   herbi         2.9
## 24                         Donkey   herbi         3.1
## 25              European hedgehog    omni        10.1
## 26                   Patas monkey    omni        10.9
## 27      Western american chipmunk   herbi        14.9
## 28                   Domestic cat   carni        12.5
## 29                         Galago    omni         9.8
## 30                        Giraffe   herbi         1.9
## 31                    Pilot whale   carni         2.7
## 32                      Gray seal   carni         6.2
## 33                     Gray hyrax   herbi         6.3
## 34                          Human    omni         8.0
## 35                 Mongoose lemur   herbi         9.5
## 36               African elephant   herbi         3.3
## 37           Thick-tailed opposum   carni        19.4
## 38                        Macaque    omni        10.1
## 39               Mongolian gerbil   herbi        14.2
## 40                 Golden hamster   herbi        14.3
## 41                          Vole    herbi        12.8
## 42                    House mouse   herbi        12.5
## 43               Little brown bat insecti        19.9
## 44           Round-tailed muskrat   herbi        14.6
## 45                     Slow loris   carni        11.0
## 46                           Degu   herbi         7.7
## 47     Northern grasshopper mouse   carni        14.5
## 48                         Rabbit   herbi         8.4
## 49                          Sheep   herbi         3.8
## 50                     Chimpanzee    omni         9.7
## 51                          Tiger   carni        15.8
## 52                         Jaguar   carni        10.4
## 53                           Lion   carni        13.5
## 54                         Baboon    omni         9.4
## 55                Desert hedgehog    <NA>        10.3
## 56                          Potto    omni        11.0
## 57                     Deer mouse    <NA>        11.5
## 58                      Phalanger    <NA>        13.7
## 59                   Caspian seal   carni         3.5
## 60                Common porpoise   carni         5.6
## 61                        Potoroo   herbi        11.1
## 62                Giant armadillo insecti        18.1
## 63                     Rock hyrax    <NA>         5.4
## 64                 Laboratory rat   herbi        13.0
## 65          African striped mouse    omni         8.7
## 66                Squirrel monkey    omni         9.6
## 67          Eastern american mole insecti         8.4
## 68                     Cotton rat   herbi        11.3
## 69                       Mole rat    <NA>        10.6
## 70         Arctic ground squirrel   herbi        16.6
## 71 Thirteen-lined ground squirrel   herbi        13.8
## 72 Golden-mantled ground squirrel   herbi        15.9
## 73                     Musk shrew    <NA>        12.8
## 74                            Pig    omni         9.1
## 75            Short-nosed echidna insecti         8.6
## 76      Eastern american chipmunk   herbi        15.8
## 77                Brazilian tapir   herbi         4.4
## 78                         Tenrec    omni        15.6
## 79                     Tree shrew    omni         8.9
## 80           Bottle-nosed dolphin   carni         5.2
## 81                          Genet   carni         6.3
## 82                     Arctic fox   carni        12.5
## 83                        Red fox   carni         9.8
select(msleep,name:bodywt)
##                              name         genus    vore           order
## 1                         Cheetah      Acinonyx   carni       Carnivora
## 2                      Owl monkey         Aotus    omni        Primates
## 3                 Mountain beaver    Aplodontia   herbi        Rodentia
## 4      Greater short-tailed shrew       Blarina    omni    Soricomorpha
## 5                             Cow           Bos   herbi    Artiodactyla
## 6                Three-toed sloth      Bradypus   herbi          Pilosa
## 7               Northern fur seal   Callorhinus   carni       Carnivora
## 8                    Vesper mouse       Calomys    <NA>        Rodentia
## 9                             Dog         Canis   carni       Carnivora
## 10                       Roe deer     Capreolus   herbi    Artiodactyla
## 11                           Goat         Capri   herbi    Artiodactyla
## 12                     Guinea pig         Cavis   herbi        Rodentia
## 13                         Grivet Cercopithecus    omni        Primates
## 14                     Chinchilla    Chinchilla   herbi        Rodentia
## 15                Star-nosed mole     Condylura    omni    Soricomorpha
## 16      African giant pouched rat    Cricetomys    omni        Rodentia
## 17      Lesser short-tailed shrew     Cryptotis    omni    Soricomorpha
## 18           Long-nosed armadillo       Dasypus   carni       Cingulata
## 19                     Tree hyrax   Dendrohyrax   herbi      Hyracoidea
## 20         North American Opossum     Didelphis    omni Didelphimorphia
## 21                 Asian elephant       Elephas   herbi     Proboscidea
## 22                  Big brown bat     Eptesicus insecti      Chiroptera
## 23                          Horse         Equus   herbi  Perissodactyla
## 24                         Donkey         Equus   herbi  Perissodactyla
## 25              European hedgehog     Erinaceus    omni  Erinaceomorpha
## 26                   Patas monkey  Erythrocebus    omni        Primates
## 27      Western american chipmunk      Eutamias   herbi        Rodentia
## 28                   Domestic cat         Felis   carni       Carnivora
## 29                         Galago        Galago    omni        Primates
## 30                        Giraffe       Giraffa   herbi    Artiodactyla
## 31                    Pilot whale Globicephalus   carni         Cetacea
## 32                      Gray seal  Haliochoerus   carni       Carnivora
## 33                     Gray hyrax   Heterohyrax   herbi      Hyracoidea
## 34                          Human          Homo    omni        Primates
## 35                 Mongoose lemur         Lemur   herbi        Primates
## 36               African elephant     Loxodonta   herbi     Proboscidea
## 37           Thick-tailed opposum    Lutreolina   carni Didelphimorphia
## 38                        Macaque        Macaca    omni        Primates
## 39               Mongolian gerbil      Meriones   herbi        Rodentia
## 40                 Golden hamster  Mesocricetus   herbi        Rodentia
## 41                          Vole       Microtus   herbi        Rodentia
## 42                    House mouse           Mus   herbi        Rodentia
## 43               Little brown bat        Myotis insecti      Chiroptera
## 44           Round-tailed muskrat      Neofiber   herbi        Rodentia
## 45                     Slow loris     Nyctibeus   carni        Primates
## 46                           Degu       Octodon   herbi        Rodentia
## 47     Northern grasshopper mouse     Onychomys   carni        Rodentia
## 48                         Rabbit   Oryctolagus   herbi      Lagomorpha
## 49                          Sheep          Ovis   herbi    Artiodactyla
## 50                     Chimpanzee           Pan    omni        Primates
## 51                          Tiger      Panthera   carni       Carnivora
## 52                         Jaguar      Panthera   carni       Carnivora
## 53                           Lion      Panthera   carni       Carnivora
## 54                         Baboon         Papio    omni        Primates
## 55                Desert hedgehog   Paraechinus    <NA>  Erinaceomorpha
## 56                          Potto  Perodicticus    omni        Primates
## 57                     Deer mouse    Peromyscus    <NA>        Rodentia
## 58                      Phalanger     Phalanger    <NA>   Diprotodontia
## 59                   Caspian seal         Phoca   carni       Carnivora
## 60                Common porpoise      Phocoena   carni         Cetacea
## 61                        Potoroo      Potorous   herbi   Diprotodontia
## 62                Giant armadillo    Priodontes insecti       Cingulata
## 63                     Rock hyrax      Procavia    <NA>      Hyracoidea
## 64                 Laboratory rat        Rattus   herbi        Rodentia
## 65          African striped mouse     Rhabdomys    omni        Rodentia
## 66                Squirrel monkey       Saimiri    omni        Primates
## 67          Eastern american mole      Scalopus insecti    Soricomorpha
## 68                     Cotton rat      Sigmodon   herbi        Rodentia
## 69                       Mole rat        Spalax    <NA>        Rodentia
## 70         Arctic ground squirrel  Spermophilus   herbi        Rodentia
## 71 Thirteen-lined ground squirrel  Spermophilus   herbi        Rodentia
## 72 Golden-mantled ground squirrel  Spermophilus   herbi        Rodentia
## 73                     Musk shrew        Suncus    <NA>    Soricomorpha
## 74                            Pig           Sus    omni    Artiodactyla
## 75            Short-nosed echidna  Tachyglossus insecti     Monotremata
## 76      Eastern american chipmunk        Tamias   herbi        Rodentia
## 77                Brazilian tapir       Tapirus   herbi  Perissodactyla
## 78                         Tenrec        Tenrec    omni    Afrosoricida
## 79                     Tree shrew        Tupaia    omni      Scandentia
## 80           Bottle-nosed dolphin      Tursiops   carni         Cetacea
## 81                          Genet       Genetta   carni       Carnivora
## 82                     Arctic fox        Vulpes   carni       Carnivora
## 83                        Red fox        Vulpes   carni       Carnivora
##    conservation sleep_total sleep_rem sleep_cycle awake brainwt   bodywt
## 1            lc        12.1        NA          NA 11.90      NA   50.000
## 2          <NA>        17.0       1.8          NA  7.00 0.01550    0.480
## 3            nt        14.4       2.4          NA  9.60      NA    1.350
## 4            lc        14.9       2.3   0.1333333  9.10 0.00029    0.019
## 5  domesticated         4.0       0.7   0.6666667 20.00 0.42300  600.000
## 6          <NA>        14.4       2.2   0.7666667  9.60      NA    3.850
## 7            vu         8.7       1.4   0.3833333 15.30      NA   20.490
## 8          <NA>         7.0        NA          NA 17.00      NA    0.045
## 9  domesticated        10.1       2.9   0.3333333 13.90 0.07000   14.000
## 10           lc         3.0        NA          NA 21.00 0.09820   14.800
## 11           lc         5.3       0.6          NA 18.70 0.11500   33.500
## 12 domesticated         9.4       0.8   0.2166667 14.60 0.00550    0.728
## 13           lc        10.0       0.7          NA 14.00      NA    4.750
## 14 domesticated        12.5       1.5   0.1166667 11.50 0.00640    0.420
## 15           lc        10.3       2.2          NA 13.70 0.00100    0.060
## 16         <NA>         8.3       2.0          NA 15.70 0.00660    1.000
## 17           lc         9.1       1.4   0.1500000 14.90 0.00014    0.005
## 18           lc        17.4       3.1   0.3833333  6.60 0.01080    3.500
## 19           lc         5.3       0.5          NA 18.70 0.01230    2.950
## 20           lc        18.0       4.9   0.3333333  6.00 0.00630    1.700
## 21           en         3.9        NA          NA 20.10 4.60300 2547.000
## 22           lc        19.7       3.9   0.1166667  4.30 0.00030    0.023
## 23 domesticated         2.9       0.6   1.0000000 21.10 0.65500  521.000
## 24 domesticated         3.1       0.4          NA 20.90 0.41900  187.000
## 25           lc        10.1       3.5   0.2833333 13.90 0.00350    0.770
## 26           lc        10.9       1.1          NA 13.10 0.11500   10.000
## 27         <NA>        14.9        NA          NA  9.10      NA    0.071
## 28 domesticated        12.5       3.2   0.4166667 11.50 0.02560    3.300
## 29         <NA>         9.8       1.1   0.5500000 14.20 0.00500    0.200
## 30           cd         1.9       0.4          NA 22.10      NA  899.995
## 31           cd         2.7       0.1          NA 21.35      NA  800.000
## 32           lc         6.2       1.5          NA 17.80 0.32500   85.000
## 33           lc         6.3       0.6          NA 17.70 0.01227    2.625
## 34         <NA>         8.0       1.9   1.5000000 16.00 1.32000   62.000
## 35           vu         9.5       0.9          NA 14.50      NA    1.670
## 36           vu         3.3        NA          NA 20.70 5.71200 6654.000
## 37           lc        19.4       6.6          NA  4.60      NA    0.370
## 38         <NA>        10.1       1.2   0.7500000 13.90 0.17900    6.800
## 39           lc        14.2       1.9          NA  9.80      NA    0.053
## 40           en        14.3       3.1   0.2000000  9.70 0.00100    0.120
## 41         <NA>        12.8        NA          NA 11.20      NA    0.035
## 42           nt        12.5       1.4   0.1833333 11.50 0.00040    0.022
## 43         <NA>        19.9       2.0   0.2000000  4.10 0.00025    0.010
## 44           nt        14.6        NA          NA  9.40      NA    0.266
## 45         <NA>        11.0        NA          NA 13.00 0.01250    1.400
## 46           lc         7.7       0.9          NA 16.30      NA    0.210
## 47           lc        14.5        NA          NA  9.50      NA    0.028
## 48 domesticated         8.4       0.9   0.4166667 15.60 0.01210    2.500
## 49 domesticated         3.8       0.6          NA 20.20 0.17500   55.500
## 50         <NA>         9.7       1.4   1.4166667 14.30 0.44000   52.200
## 51           en        15.8        NA          NA  8.20      NA  162.564
## 52           nt        10.4        NA          NA 13.60 0.15700  100.000
## 53           vu        13.5        NA          NA 10.50      NA  161.499
## 54         <NA>         9.4       1.0   0.6666667 14.60 0.18000   25.235
## 55           lc        10.3       2.7          NA 13.70 0.00240    0.550
## 56           lc        11.0        NA          NA 13.00      NA    1.100
## 57         <NA>        11.5        NA          NA 12.50      NA    0.021
## 58         <NA>        13.7       1.8          NA 10.30 0.01140    1.620
## 59           vu         3.5       0.4          NA 20.50      NA   86.000
## 60           vu         5.6        NA          NA 18.45      NA   53.180
## 61         <NA>        11.1       1.5          NA 12.90      NA    1.100
## 62           en        18.1       6.1          NA  5.90 0.08100   60.000
## 63           lc         5.4       0.5          NA 18.60 0.02100    3.600
## 64           lc        13.0       2.4   0.1833333 11.00 0.00190    0.320
## 65         <NA>         8.7        NA          NA 15.30      NA    0.044
## 66         <NA>         9.6       1.4          NA 14.40 0.02000    0.743
## 67           lc         8.4       2.1   0.1666667 15.60 0.00120    0.075
## 68         <NA>        11.3       1.1   0.1500000 12.70 0.00118    0.148
## 69         <NA>        10.6       2.4          NA 13.40 0.00300    0.122
## 70           lc        16.6        NA          NA  7.40 0.00570    0.920
## 71           lc        13.8       3.4   0.2166667 10.20 0.00400    0.101
## 72           lc        15.9       3.0          NA  8.10      NA    0.205
## 73         <NA>        12.8       2.0   0.1833333 11.20 0.00033    0.048
## 74 domesticated         9.1       2.4   0.5000000 14.90 0.18000   86.250
## 75         <NA>         8.6        NA          NA 15.40 0.02500    4.500
## 76         <NA>        15.8        NA          NA  8.20      NA    0.112
## 77           vu         4.4       1.0   0.9000000 19.60 0.16900  207.501
## 78         <NA>        15.6       2.3          NA  8.40 0.00260    0.900
## 79         <NA>         8.9       2.6   0.2333333 15.10 0.00250    0.104
## 80         <NA>         5.2        NA          NA 18.80      NA  173.330
## 81         <NA>         6.3       1.3          NA 17.70 0.01750    2.000
## 82         <NA>        12.5        NA          NA 11.50 0.04450    3.380
## 83         <NA>         9.8       2.4   0.3500000 14.20 0.05040    4.230
max(msleep$bodywt)
## [1] 6654
filter(msleep, vore == "herbi")
##                              name        genus  vore          order
## 1                 Mountain beaver   Aplodontia herbi       Rodentia
## 2                             Cow          Bos herbi   Artiodactyla
## 3                Three-toed sloth     Bradypus herbi         Pilosa
## 4                        Roe deer    Capreolus herbi   Artiodactyla
## 5                            Goat        Capri herbi   Artiodactyla
## 6                      Guinea pig        Cavis herbi       Rodentia
## 7                      Chinchilla   Chinchilla herbi       Rodentia
## 8                      Tree hyrax  Dendrohyrax herbi     Hyracoidea
## 9                  Asian elephant      Elephas herbi    Proboscidea
## 10                          Horse        Equus herbi Perissodactyla
## 11                         Donkey        Equus herbi Perissodactyla
## 12      Western american chipmunk     Eutamias herbi       Rodentia
## 13                        Giraffe      Giraffa herbi   Artiodactyla
## 14                     Gray hyrax  Heterohyrax herbi     Hyracoidea
## 15                 Mongoose lemur        Lemur herbi       Primates
## 16               African elephant    Loxodonta herbi    Proboscidea
## 17               Mongolian gerbil     Meriones herbi       Rodentia
## 18                 Golden hamster Mesocricetus herbi       Rodentia
## 19                          Vole      Microtus herbi       Rodentia
## 20                    House mouse          Mus herbi       Rodentia
## 21           Round-tailed muskrat     Neofiber herbi       Rodentia
## 22                           Degu      Octodon herbi       Rodentia
## 23                         Rabbit  Oryctolagus herbi     Lagomorpha
## 24                          Sheep         Ovis herbi   Artiodactyla
## 25                        Potoroo     Potorous herbi  Diprotodontia
## 26                 Laboratory rat       Rattus herbi       Rodentia
## 27                     Cotton rat     Sigmodon herbi       Rodentia
## 28         Arctic ground squirrel Spermophilus herbi       Rodentia
## 29 Thirteen-lined ground squirrel Spermophilus herbi       Rodentia
## 30 Golden-mantled ground squirrel Spermophilus herbi       Rodentia
## 31      Eastern american chipmunk       Tamias herbi       Rodentia
## 32                Brazilian tapir      Tapirus herbi Perissodactyla
##    conservation sleep_total sleep_rem sleep_cycle awake brainwt   bodywt
## 1            nt        14.4       2.4          NA   9.6      NA    1.350
## 2  domesticated         4.0       0.7   0.6666667  20.0 0.42300  600.000
## 3          <NA>        14.4       2.2   0.7666667   9.6      NA    3.850
## 4            lc         3.0        NA          NA  21.0 0.09820   14.800
## 5            lc         5.3       0.6          NA  18.7 0.11500   33.500
## 6  domesticated         9.4       0.8   0.2166667  14.6 0.00550    0.728
## 7  domesticated        12.5       1.5   0.1166667  11.5 0.00640    0.420
## 8            lc         5.3       0.5          NA  18.7 0.01230    2.950
## 9            en         3.9        NA          NA  20.1 4.60300 2547.000
## 10 domesticated         2.9       0.6   1.0000000  21.1 0.65500  521.000
## 11 domesticated         3.1       0.4          NA  20.9 0.41900  187.000
## 12         <NA>        14.9        NA          NA   9.1      NA    0.071
## 13           cd         1.9       0.4          NA  22.1      NA  899.995
## 14           lc         6.3       0.6          NA  17.7 0.01227    2.625
## 15           vu         9.5       0.9          NA  14.5      NA    1.670
## 16           vu         3.3        NA          NA  20.7 5.71200 6654.000
## 17           lc        14.2       1.9          NA   9.8      NA    0.053
## 18           en        14.3       3.1   0.2000000   9.7 0.00100    0.120
## 19         <NA>        12.8        NA          NA  11.2      NA    0.035
## 20           nt        12.5       1.4   0.1833333  11.5 0.00040    0.022
## 21           nt        14.6        NA          NA   9.4      NA    0.266
## 22           lc         7.7       0.9          NA  16.3      NA    0.210
## 23 domesticated         8.4       0.9   0.4166667  15.6 0.01210    2.500
## 24 domesticated         3.8       0.6          NA  20.2 0.17500   55.500
## 25         <NA>        11.1       1.5          NA  12.9      NA    1.100
## 26           lc        13.0       2.4   0.1833333  11.0 0.00190    0.320
## 27         <NA>        11.3       1.1   0.1500000  12.7 0.00118    0.148
## 28           lc        16.6        NA          NA   7.4 0.00570    0.920
## 29           lc        13.8       3.4   0.2166667  10.2 0.00400    0.101
## 30           lc        15.9       3.0          NA   8.1      NA    0.205
## 31         <NA>        15.8        NA          NA   8.2      NA    0.112
## 32           vu         4.4       1.0   0.9000000  19.6 0.16900  207.501
filter(msleep, sleep_total > 14)
##                              name        genus    vore           order
## 1                      Owl monkey        Aotus    omni        Primates
## 2                 Mountain beaver   Aplodontia   herbi        Rodentia
## 3      Greater short-tailed shrew      Blarina    omni    Soricomorpha
## 4                Three-toed sloth     Bradypus   herbi          Pilosa
## 5            Long-nosed armadillo      Dasypus   carni       Cingulata
## 6          North American Opossum    Didelphis    omni Didelphimorphia
## 7                   Big brown bat    Eptesicus insecti      Chiroptera
## 8       Western american chipmunk     Eutamias   herbi        Rodentia
## 9            Thick-tailed opposum   Lutreolina   carni Didelphimorphia
## 10               Mongolian gerbil     Meriones   herbi        Rodentia
## 11                 Golden hamster Mesocricetus   herbi        Rodentia
## 12               Little brown bat       Myotis insecti      Chiroptera
## 13           Round-tailed muskrat     Neofiber   herbi        Rodentia
## 14     Northern grasshopper mouse    Onychomys   carni        Rodentia
## 15                          Tiger     Panthera   carni       Carnivora
## 16                Giant armadillo   Priodontes insecti       Cingulata
## 17         Arctic ground squirrel Spermophilus   herbi        Rodentia
## 18 Golden-mantled ground squirrel Spermophilus   herbi        Rodentia
## 19      Eastern american chipmunk       Tamias   herbi        Rodentia
## 20                         Tenrec       Tenrec    omni    Afrosoricida
##    conservation sleep_total sleep_rem sleep_cycle awake brainwt  bodywt
## 1          <NA>        17.0       1.8          NA   7.0 0.01550   0.480
## 2            nt        14.4       2.4          NA   9.6      NA   1.350
## 3            lc        14.9       2.3   0.1333333   9.1 0.00029   0.019
## 4          <NA>        14.4       2.2   0.7666667   9.6      NA   3.850
## 5            lc        17.4       3.1   0.3833333   6.6 0.01080   3.500
## 6            lc        18.0       4.9   0.3333333   6.0 0.00630   1.700
## 7            lc        19.7       3.9   0.1166667   4.3 0.00030   0.023
## 8          <NA>        14.9        NA          NA   9.1      NA   0.071
## 9            lc        19.4       6.6          NA   4.6      NA   0.370
## 10           lc        14.2       1.9          NA   9.8      NA   0.053
## 11           en        14.3       3.1   0.2000000   9.7 0.00100   0.120
## 12         <NA>        19.9       2.0   0.2000000   4.1 0.00025   0.010
## 13           nt        14.6        NA          NA   9.4      NA   0.266
## 14           lc        14.5        NA          NA   9.5      NA   0.028
## 15           en        15.8        NA          NA   8.2      NA 162.564
## 16           en        18.1       6.1          NA   5.9 0.08100  60.000
## 17           lc        16.6        NA          NA   7.4 0.00570   0.920
## 18           lc        15.9       3.0          NA   8.1      NA   0.205
## 19         <NA>        15.8        NA          NA   8.2      NA   0.112
## 20         <NA>        15.6       2.3          NA   8.4 0.00260   0.900
filter(msleep, sleep_total > 12, vore == "herbi")
##                              name        genus  vore    order conservation
## 1                 Mountain beaver   Aplodontia herbi Rodentia           nt
## 2                Three-toed sloth     Bradypus herbi   Pilosa         <NA>
## 3                      Chinchilla   Chinchilla herbi Rodentia domesticated
## 4       Western american chipmunk     Eutamias herbi Rodentia         <NA>
## 5                Mongolian gerbil     Meriones herbi Rodentia           lc
## 6                  Golden hamster Mesocricetus herbi Rodentia           en
## 7                           Vole      Microtus herbi Rodentia         <NA>
## 8                     House mouse          Mus herbi Rodentia           nt
## 9            Round-tailed muskrat     Neofiber herbi Rodentia           nt
## 10                 Laboratory rat       Rattus herbi Rodentia           lc
## 11         Arctic ground squirrel Spermophilus herbi Rodentia           lc
## 12 Thirteen-lined ground squirrel Spermophilus herbi Rodentia           lc
## 13 Golden-mantled ground squirrel Spermophilus herbi Rodentia           lc
## 14      Eastern american chipmunk       Tamias herbi Rodentia         <NA>
##    sleep_total sleep_rem sleep_cycle awake brainwt bodywt
## 1         14.4       2.4          NA   9.6      NA  1.350
## 2         14.4       2.2   0.7666667   9.6      NA  3.850
## 3         12.5       1.5   0.1166667  11.5  0.0064  0.420
## 4         14.9        NA          NA   9.1      NA  0.071
## 5         14.2       1.9          NA   9.8      NA  0.053
## 6         14.3       3.1   0.2000000   9.7  0.0010  0.120
## 7         12.8        NA          NA  11.2      NA  0.035
## 8         12.5       1.4   0.1833333  11.5  0.0004  0.022
## 9         14.6        NA          NA   9.4      NA  0.266
## 10        13.0       2.4   0.1833333  11.0  0.0019  0.320
## 11        16.6        NA          NA   7.4  0.0057  0.920
## 12        13.8       3.4   0.2166667  10.2  0.0040  0.101
## 13        15.9       3.0          NA   8.1      NA  0.205
## 14        15.8        NA          NA   8.2      NA  0.112
head(select(msleep,name,sleep_cycle,sleep_total))
##                         name sleep_cycle sleep_total
## 1                    Cheetah          NA        12.1
## 2                 Owl monkey          NA        17.0
## 3            Mountain beaver          NA        14.4
## 4 Greater short-tailed shrew   0.1333333        14.9
## 5                        Cow   0.6666667         4.0
## 6           Three-toed sloth   0.7666667        14.4
msleep %>% arrange(order) %>% head
##       name     genus  vore        order conservation sleep_total sleep_rem
## 1   Tenrec    Tenrec  omni Afrosoricida         <NA>        15.6       2.3
## 2      Cow       Bos herbi Artiodactyla domesticated         4.0       0.7
## 3 Roe deer Capreolus herbi Artiodactyla           lc         3.0        NA
## 4     Goat     Capri herbi Artiodactyla           lc         5.3       0.6
## 5  Giraffe   Giraffa herbi Artiodactyla           cd         1.9       0.4
## 6    Sheep      Ovis herbi Artiodactyla domesticated         3.8       0.6
##   sleep_cycle awake brainwt  bodywt
## 1          NA   8.4  0.0026   0.900
## 2   0.6666667  20.0  0.4230 600.000
## 3          NA  21.0  0.0982  14.800
## 4          NA  18.7  0.1150  33.500
## 5          NA  22.1      NA 899.995
## 6          NA  20.2  0.1750  55.500
msleep %>% arrange(order) %>% tail
##                          name     genus    vore        order conservation
## 78                 Tree shrew    Tupaia    omni   Scandentia         <NA>
## 79 Greater short-tailed shrew   Blarina    omni Soricomorpha           lc
## 80            Star-nosed mole Condylura    omni Soricomorpha           lc
## 81  Lesser short-tailed shrew Cryptotis    omni Soricomorpha           lc
## 82      Eastern american mole  Scalopus insecti Soricomorpha           lc
## 83                 Musk shrew    Suncus    <NA> Soricomorpha         <NA>
##    sleep_total sleep_rem sleep_cycle awake brainwt bodywt
## 78         8.9       2.6   0.2333333  15.1 0.00250  0.104
## 79        14.9       2.3   0.1333333   9.1 0.00029  0.019
## 80        10.3       2.2          NA  13.7 0.00100  0.060
## 81         9.1       1.4   0.1500000  14.9 0.00014  0.005
## 82         8.4       2.1   0.1666667  15.6 0.00120  0.075
## 83        12.8       2.0   0.1833333  11.2 0.00033  0.048
msleep %>% 
  select(name,genus,order,sleep_total) %>%
  arrange(order,sleep_total) %>%
  filter(sleep_total>= 12)
##                              name        genus           order sleep_total
## 1                          Tenrec       Tenrec    Afrosoricida        15.6
## 2                         Cheetah     Acinonyx       Carnivora        12.1
## 3                    Domestic cat        Felis       Carnivora        12.5
## 4                      Arctic fox       Vulpes       Carnivora        12.5
## 5                            Lion     Panthera       Carnivora        13.5
## 6                           Tiger     Panthera       Carnivora        15.8
## 7                   Big brown bat    Eptesicus      Chiroptera        19.7
## 8                Little brown bat       Myotis      Chiroptera        19.9
## 9            Long-nosed armadillo      Dasypus       Cingulata        17.4
## 10                Giant armadillo   Priodontes       Cingulata        18.1
## 11         North American Opossum    Didelphis Didelphimorphia        18.0
## 12           Thick-tailed opposum   Lutreolina Didelphimorphia        19.4
## 13                      Phalanger    Phalanger   Diprotodontia        13.7
## 14               Three-toed sloth     Bradypus          Pilosa        14.4
## 15                     Owl monkey        Aotus        Primates        17.0
## 16                     Chinchilla   Chinchilla        Rodentia        12.5
## 17                    House mouse          Mus        Rodentia        12.5
## 18                          Vole      Microtus        Rodentia        12.8
## 19                 Laboratory rat       Rattus        Rodentia        13.0
## 20 Thirteen-lined ground squirrel Spermophilus        Rodentia        13.8
## 21               Mongolian gerbil     Meriones        Rodentia        14.2
## 22                 Golden hamster Mesocricetus        Rodentia        14.3
## 23                Mountain beaver   Aplodontia        Rodentia        14.4
## 24     Northern grasshopper mouse    Onychomys        Rodentia        14.5
## 25           Round-tailed muskrat     Neofiber        Rodentia        14.6
## 26      Western american chipmunk     Eutamias        Rodentia        14.9
## 27      Eastern american chipmunk       Tamias        Rodentia        15.8
## 28 Golden-mantled ground squirrel Spermophilus        Rodentia        15.9
## 29         Arctic ground squirrel Spermophilus        Rodentia        16.6
## 30                     Musk shrew       Suncus    Soricomorpha        12.8
## 31     Greater short-tailed shrew      Blarina    Soricomorpha        14.9
plot(msleep$bodywt,msleep$brainwt,col = "blue")

plot(sqrt(msleep$bodywt),sqrt(msleep$brainwt),col = "blue")

plot(log10(msleep$brainwt),log10(msleep$brainwt),col = "blue")

#Relationship Between Body weight and total hour of sleep:

ggplot(msleep)+ geom_point(aes(log10(msleep$bodywt),sleep_total))+facet_wrap(~vore)

cor(log10(msleep$bodywt),msleep$sleep_total,use = "complete.obs")
## [1] -0.5686377

The negative correlation is the relationship between two variables in which one variable will increase and other variable will decrease.Here the value of correlation coefficient indicates that the more the mammal weighs, the less likely the total hour of sleep.

Relationship Between Brain weight and total sleep hour:

ggplot(msleep)+ geom_point(aes(log10(msleep$brainwt),sleep_total))+facet_wrap(~vore)
## Warning: Removed 27 rows containing missing values (geom_point).

cor(log10(msleep$brainwt),msleep$sleep_total,use = "complete.obs")
## [1] -0.5944555

It is concluded that Brain weight and total sleep hours closely related to each other.It is difficult to find that which factor really affects the sleep hours of mammals wheather it is brain weight or Body weight,