README.md

title: "README.md" author: "Mark Cherrie" date: "18/09/2019" output: html_document

uvR

The aim of the uvR package is to help researchers use and analyse UVR data in their studies. The package is in beta and currently only works with mac OS.

This work was supported by Health Data Research UK, an initiative funded by UK Research and Innovation, Department of Health and Social Care (England) and devolved administrations, and leading medical research charities. This work is part of HDR UK Scotland

Instructions for use

```{r install, include=F} devtools::install_github("markocherrie/uvR")


* Load the package
```{r load, include=F}
library(uvR)

* Convert that data to something usable
```{r convert, include=F}
uvR::JAXA_convert()

* Visualise the raster
```{r rstviz, include=F}
rst<-raster(list.files("raster/", full.names = T)[1])
plot(rst)

* Visualise the output

```{r summaryvisualise, include=F}
multmerge = function(mypath){
  filenames=list.files(path=mypath, full.names=TRUE)
  datalist = lapply(filenames, function(x){read.csv(file=x,header=T)})
  Reduce(function(x,y) {merge(x,y)}, datalist)
}
# from: https://www.r-bloggers.com/merging-multiple-data-files-into-one-data-frame/

mergedf = multmerge("extract/")

mergedf<-reshape(mergedf, varying=c(3:4), direction="long", idvar="NAME", sep="", timevar="date")
mergedf$date<-as.Date(substr(mergedf$date, 8,15), format="%Y%m%d")

library(ggplot2)
## simple line chart in ggplot
p<-ggplot(data=mergedf, aes(x=date, y=MYD, group=NAME, color=NAME)) +
  geom_line() +
  geom_point() +
  labs(title="Mean daily UVB for Local Authorities in Scotland", x="Date" ,y="UVB (W/m2)") 
p


markocherrie/uvR documentation built on Nov. 4, 2019, 5:25 p.m.