Posts

Data.Frames in R

Errors: > Names <- c("Jeb", "Donald", "Ted" "Marco", "Carly", "Hillary", "Berine") Error: unexpected string constant in "Names <- c("Jeb", "Donald", "Ted" "Marco"" > Names <- c("Jeb", "Donald", "Ted", "Marco", "Carly", "Hillary", "Berine") > ABC <- c(4, 62, 51, 21, 2, 14, 15) > CBS <- c(12, 75, 43, 19, 1, 21, 19) Error: object 'name' not found > df <- data.frame(Names, ABC, CBS) > df Names ABC CBS 1 Jeb 4 12 2 Donald 62 75 3 Ted 51 43 4 Marco 21 19 5 Carly 2 1 6 Hillary 14 21 7 Berine 15 19 Good Program: > Names <- c("Jeb", "Donald", "Ted", "Marco", "Carly", "Hillary", "Berine") > ABC <- c(4, 62, 51, 21, 2, 14, 15) > CBS <- c(12, 75, ...

River Nile Func & basic graphs

Image
 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="...

More means using R :)

  x <-c(1,3,5,6) > x [1] 1 3 5 6 > mean(x) [1] 3.75 >

Module 2 assignment

module2mymeanRW @@ -0,0 +1,27 @@ Task: Your assignment, evaluate the following function call myMean. The data for this function called assignment. assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) >myMean <- function(assignment2) { return(sum(assignment)/length(someData)) } Ans: The “assignment2” returned the following: [1] 16 18 14 22 27 17 19 17 17 22 20 22 The “myMean” returned the following: Error in myMean(assignment2) : object ‘assignment’ not found The function myMean does not work the way it was supposed to work because objects “assignment” and “someData” are not defined. If they were both replaced with predefined object “assignment2”, the function “myMean” would return the expected mean value of the given data set. The corrected program would be: >assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) >myMean <- function(assignment2) { return(sum(assignment2)/length(assignment2)) } >myMean(assignment2) This program will return: ...