River Nile Func & basic graphs
Visualization in R
Basic Graphs
Covid-19
Histograms
Apparently the R Libraries has a River Nile function that produces a graph, how ironic?
> print(hn)
$breaks
[1] 400 500 600 700 800 900 1000 1100 1200 1300 1400
$counts
[1] 1 0 5 20 25 19 12 11 6 1
$density
[1] 0.0001 0.0000 0.0005 0.0020 0.0025 0.0019 0.0012 0.0011 0.0006 0.0001
$mids
[1] 450 550 650 750 850 950 1050 1150 1250 1350
$xname
[1] "Nile"
$equidist
[1] TRUE
attr(,"class")
[1] "histogram"
Plots.
> Infected <- c(1, 3, 6, 4, 9)
> Deaths <- c(2, 5, 4, 5, 12)
>
> # Graph cars using a y axis that ranges from 0 to 12
> plot(Infected, type="o", col="blue", ylim=c(0,12))
> lines(Deaths, type="o", pch=20, lty=4, col="red")
> title(main="Covid-19-2023", col.main="C", font.main=6)
> title(main="Covid-19-2023", col.main="Pink", font.main=6)
> title(main="Covid-19-2023", col.main="Red", font.main=6)
> title(main="Covid-19-2023", col.main="#000000", font.main=6)
> Infected <- c(1, 3, 6, 4, 9)
> Deaths <- c(2, 5, 4, 5, 12)
>
> # Graph cars using a y axis that ranges from 0 to 12
> plot(Infected, type="o", col="blue", ylim=c(0,12))
> lines(Deaths, type="o", pch=20, lty=4, col="red")
> title(main="Covid-19-2023", col.main="C", font.main=6)
Error in title(main = "Covid-19-2023", col.main = "C", font.main = 6) :
invalid color name 'C'
> title(main="Covid-19-2023", col.main="Pink", font.main=6)
> title(main="Covid-19-2023", col.main="Red", font.main=6)
> title(main="Covid-19-2023", col.main="#000000", font.main=6)
> legend(1, g_range[2], c("Infected 🚑","Death 🪦"), cex=0.8,
+ col=c("blue","red"), pch=21:22, lty=1:2);
Error: object 'g_range' not found
[WARNING] Deprecated: --self-contained. use --embed-resources --standalone
> # Graph cars using a y axis that ranges from 0 to 12
Warning message:
In doTryCatch(return(expr), name, parentenv, handler) :
could not open file '//Rplot.png/cloud/project'
> plot(Infected, type="o", col="blue", ylim=c(0,12))
> lines(Deaths, type="o", pch=20, lty=4, col="red")
> title(main="Covid-19-2023", col.main="#000000", font.main=6)
> Infected <- c(1, 3, 6, 4, 9)
> Deaths <- c(2, 5, 4, 5, 12)
>
> g_range <- range(0, Infected, Deaths)
>
> # Graph autos using y axis that ranges from 0 to max
> # value in cars or trucks vector. Turn off axes and
> # annotations (axis labels) so we can specify them ourself
> plot(Infected, type="o", col="turquoise3", ylim=g_range,
+ axes=FALSE, ann=FALSE)
> # Make x axis using Jan-Jun labels
> axis(1, at=1:6, lab=c("Jan","Feb","Mar","Apr","May", "Jun"))
> # Make y axis with horizontal labels that display ticks at
> # every 4 marks. 4*0:g_range[2] is equivalent to c(0,4,8,12).
> axis(2, las=1, at=4*0:g_range[2])
> # Create a box around plot
> box()
> lines(Deaths, type="o", pch=20, lty=4, col="#FFA500")
> # Create a title with a red, bold/italic font
> title(main="COVID '23", col.main="#000", font.main=6)
Error in title(main = "COVID '23", col.main = "#000", font.main = 6) :
invalid RGB specification
> # Create a title with a red, bold/italic font
> title(main="COVID '23", col.main="#000000", font.main=6)
> # Label the x and y axes with dark green text
> title(xlab="Time", col.lab=rgb(0,0.5,0))
> title(ylab="Total", col.lab=rgb(0,0.5,0))
> # Create a legend at (1, g_range[2]) that is slightly smaller
> # (cex) and uses the same line colors and points used by
> # the actual plots
> legend(1, g_range[2], c("Infected","Deaths"), cex=0.8,
+ col=c("#40E0D0","orange"), pch=21:22, lty=1:2)
Comments
Post a Comment