$ head dl.csv time,code,count 6:59,200,31 7:00,200,1841 7:00,502,3644 7:01,200,369 > x<-read.csv("dl.csv") > library(dplyr) > library(tidyverse) > ggplot(x,aes(time,count,color=code))+geom_point()+scale_x_discrete(breaks = levels(x$time)[c(T, rep(F, 5))])+theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
R – graph by month
> options(scipen=5) > jan20<-x[grepl("2023-01",x$date) & x$enabled > 0 & x$ignore==0,] > barplot(tapply(jan20$users,jan20$date,sum)/1000,las=2,main="Jan 2023 - by month",col=rainbow(10),cex.names=0.8)
R – Read in CSV
> setwd("/Users/mark/Documents/Stats") > x<-read.csv("sites.csv",sep="\t",stringsAsFactors = F) > summary(x$url) Length Class Mode 983002 character character > summary(x$score) Min. 1st Qu. Median Mean 3rd Qu. Max. NA's -3.000 -2.000 -1.000 1.977 -1.000 25.000 1
R – Package List
How to list all packages that have been imported into current session
> (.packages())
Example output
> (.packages()) [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7] "base"
To see if a package is installed:
> x<-grep("tidyverse",installed.packages()) > installed.packages()[x]
Install a number of packages as below:
> install.packages(c("nycflights13", "gapminder", "Lahman"))