Data Programming

Homework 2

Author

Emilija Petrovska

Published

April 24, 2024

library(lubridate)
library(quarto)
library(readxl)
data<-read.csv("msft.csv")
data$Date<-dmy(data$Date)

1.Display dataframe as a tibble

library(tibble)
as.tibble(data)
# 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
  1. How long has the data been collected?
data$Date<-as.Date(data$Date)
duration <- difftime(max(data$Date, na.rm = TRUE), min(data$Date, na.rm = TRUE),units = "days")
print(duration)
Time difference of 3529 days
  1. Among the highest rated apps return the 10 apps (rows) with the highest amount of reviews. Display only the first 3 columns.
hrapps<-data[order(-data$Rating, -data$No.of.people.Rated),]
hrapps[1:10, 1:3]
                                  Name Rating No.of.people.Rated
1884                               ILN      5                999
320                           TookBook      5                998
3407 Contemplatio - Rosary with images      5                998
3242                  Five Good Things      5                996
2663                    Magenta Health      5                993
1470                       BIOSToolKit      5                989
253                            Ask Sai      5                988
2039               Parents Worship Day      5                988
5306                         Littledot      5                987
4654                       See Tow Bus      5                986

4.Show the number of apps created per month.

month(data$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.Sort the rows of the dataframe from the least wordy to most wordy app name. Display the first 15.

library(dplyr)
data |>
  arrange(nchar(data$Name)) |>
  head(15)
     Name Rating No.of.people.Rated                Category       Date Price
1             NA                948                               <NA>      
2    词轩    5.0                439                   Books 2016-04-01  Free
3      T3    4.0                970                   Books 2014-03-10  Free
4    旺信    2.5                902                  Social 2016-03-01  Free
5     TPi    5.0                100                Business 2017-02-03  Free
6     QMR    5.0                505         Developer Tools 2017-01-14  Free
7     RXT    3.5                820         Developer Tools 2015-09-22  Free
8     ICQ    3.5                733                  Social 2012-10-12  Free
9     ILN    5.0                999                  Social 2019-12-05  Free
10    Tok    3.5                833                  Social 2017-04-03  Free
11    RTI    4.5                565 Government and Politics 2013-12-19  Free
12 趣历史    4.5                511               Lifestyle 2015-10-04  Free
13    N10    3.5                451               Lifestyle 2015-01-30  Free
14 慢慢买    5.0                346               Lifestyle 2016-03-18  Free
15    SHX    5.0                660               Lifestyle 2019-06-17  Free