Data Programming

Homework 2

Author

Mirko Dugajlic

Published

April 21, 2024

Libraries

library(tibble)
library(tidyverse) 
library(dplyr)

Solutions

read.csv("files/msft.csv") -> df1
df1$Date <- dmy(df1$Date)

#1
as.tibble(df1)
# A tibble: 5,322 × 6
   Name                      Rating No.of.people.Rated Category Date       Price
   <chr>                      <dbl>              <int> <chr>    <date>     <chr>
 1 Dynamic Reader               3.5                268 Books    2014-01-07 Free 
 2 Chemistry, Organic Chemi…    3                  627 Books    2014-01-08 Free 
 3 BookViewer                   3.5                593 Books    2016-02-29 Free 
 4 Brick Instructions           3.5                684 Books    2018-01-30 Free 
 5 Introduction to Python P…    2                  634 Books    2018-01-30 Free 
 6 Gurbani Reader               4.5                399 Books    2017-01-18 Free 
 7 NFO Viewer                   4.5                566 Books    2012-11-13 Free 
 8 Text to Speech TTS           3                  175 Books    2013-10-17 Free 
 9 ACK Comics                   4                  460 Books    2012-12-20 Free 
10 Learn Biology and Human …    3.5                363 Books    2013-11-25 Free 
# ℹ 5,312 more rows
#2
oldest <- min(df1$Date, na.rm = T)
newest <- max(df1$Date, na.rm = T)
difftime(newest, oldest, units = "days")
Time difference of 3529 days
#3
as.tibble(df1[order(df1$Rating, df1$No.of.people.Rated,  decreasing = T),1:3])
# A tibble: 5,322 × 3
   Name                              Rating No.of.people.Rated
   <chr>                              <dbl>              <int>
 1 ILN                                    5                999
 2 TookBook                               5                998
 3 Contemplatio - Rosary with images      5                998
 4 Five Good Things                       5                996
 5 Magenta Health                         5                993
 6 BIOSToolKit                            5                989
 7 Ask Sai                                5                988
 8 Parents Worship Day                    5                988
 9 Littledot                              5                987
10 See Tow Bus                            5                986
# ℹ 5,312 more rows
#4
month(df1$Date) %>%
  unlist() %>%
  factor() %>%
  summary
   1    2    3    4    5    6    7    8    9   10   11   12 NA's 
 559  480  479  381  456  381  422  450  395  512  423  383    1 
#5 
(df1[order(nchar(df1$Name)), ])[1:15, ]
       Name Rating No.of.people.Rated                Category       Date Price
5322            NA                948                               <NA>      
592    词轩    5.0                439                   Books 2016-04-01  Free
626      T3    4.0                970                   Books 2014-03-10  Free
1829   旺信    2.5                902                  Social 2016-03-01  Free
1265    TPi    5.0                100                Business 2017-02-03  Free
1690    QMR    5.0                505         Developer Tools 2017-01-14  Free
1715    RXT    3.5                820         Developer Tools 2015-09-22  Free
1848    ICQ    3.5                733                  Social 2012-10-12  Free
1884    ILN    5.0                999                  Social 2019-12-05  Free
2024    Tok    3.5                833                  Social 2017-04-03  Free
2234    RTI    4.5                565 Government and Politics 2013-12-19  Free
3366 趣历史    4.5                511               Lifestyle 2015-10-04  Free
3384    N10    3.5                451               Lifestyle 2015-01-30  Free
3476 慢慢买    5.0                346               Lifestyle 2016-03-18  Free
3540    SHX    5.0                660               Lifestyle 2019-06-17  Free