Analyse persons online in a moodle. Analyse at your own risk. Only for testing.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

35 lines
1.0 KiB

setwd("mywd")
library(tidyverse)
library(ggplot2)
library(viridis)
library(hrbrthemes)
# Generate timecodes
times=seq(
from=as.POSIXct("24|00:01","%d|%H:%M", tz="UTC"), #setup time scanned here
to=as.POSIXct("24|23:59", "%d|%H:%M", tz="UTC"),
by="1 min"
)
names = list.files(paste0(getwd(), "/data")) # Load names from directory
df <- data.frame(times) #Generate dataframe
for(i in names){
print(i)
studentfile = scan(file = paste0(getwd(),"/data/", i))
df[i]= studentfile #Load each file content into the column
}
onlineData=df%>% # make wide list to long list
rownames_to_column()%>%
gather(colname, value, -rowname) #as.character(df[,1])
data <- onlineData[-c(1:1439),] #cut times column #setup amount of data here
# finally plot the heatmap
p <- ggplot(data, aes(x=rowname, y=colname, fill=factor(value)))+geom_tile() + scale_fill_manual(values = c("white", "black"))
p +labs(title="mytitle",
x ="myxaxis", y = "myyaxis", fill="Status") + theme_ipsum() +
theme(axis.text.x=element_text(angle=90))