Description Usage Arguments Details Value Examples
View source: R/AnalysisByCountry2.R
function for country-wise analysis
1 2 3 4 5 6 7 8 9 10 | AnalysisByCountry2(
CountryAbbrev = "USA",
alldata = countrydata,
fval = 0.14,
lwdval1 = 5,
lwdval2 = 3,
cexval = 0.9,
toplot = F,
lowdeaths = 1
)
|
CountryAbbrev |
Country name |
alldata |
data |
fval |
graphical parameter |
lwdval1 |
graphical parameter |
lwdval2 |
graphical parameter |
cexval |
graphical parameter |
toplot |
plot or not |
lowdeaths |
the lowest number for deaths |
Okay
list
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (CountryAbbrev = "USA", alldata = countrydata, fval = 0.14,
lwdval1 = 5, lwdval2 = 3, cexval = 0.9, toplot = F, lowdeaths = 1)
{
countrycodes = alldata$CountryCode
ccode = which(countrycodes == CountryAbbrev)
cdata = alldata$Country_Data[[ccode]]
CountryCode = as.character(cdata$code)
CountryID = as.character(cdata$id)
CountryName = as.character(cdata$name)
CountryPopn = cdata$popn
StartDate = as.character(cdata$dateRep[1])
len = length(cdata$dateRep)
EndDate = as.character(cdata$dateRep[len])
ind = which(cdata$cumdeaths >= lowdeaths)
dateFirstCase = as.character(cdata$dateRep[ind[1]])
dates = as.character(cdata$dateRep[ind])
daynum = cdata$dayNum[ind]
dailycases = cdata$cases[ind]
dailydeaths = cdata$deaths[ind]
cumcases = cdata$cumcases[ind]
cumdeaths = cdata$cumdeaths[ind]
close.screen(all.screens = T)
if (toplot) {
plot(daynum, dailydeaths, type = "l", lwd = lwdval1,
cex = cexval, xlab = "Day Number", ylab = "Daily Deaths")
scan()
plot(daynum, cumdeaths, type = "l", lwd = lwdval1, cex = cexval,
xlab = "Day Number", ylab = "Cumulative Deaths")
}
return(list(CountryCode = CountryCode, CountryID = CountryID,
CountryName = CountryName, Population = CountryPopn,
StartDate = StartDate, dateFirstCase = dateFirstCase,
EndDate = EndDate, DateRep = dates, daynum = daynum,
dailydeaths = dailydeaths, cumdeaths = cumdeaths))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.