From 23d0ffe55df84983d297ee04e9bf47428ed32549 Mon Sep 17 00:00:00 2001 From: Johanna1403 Date: Fri, 26 Nov 2021 16:18:55 -0500 Subject: [PATCH] Final code with the txt data file for the first task added. --- EstonianCoronaData.txt | 640 +++++++++++++++++++++++++++++++++++++++++ Exercise10.R | 59 ++++ 2 files changed, 699 insertions(+) create mode 100644 EstonianCoronaData.txt create mode 100644 Exercise10.R diff --git a/EstonianCoronaData.txt b/EstonianCoronaData.txt new file mode 100644 index 0000000..d2cb195 --- /dev/null +++ b/EstonianCoronaData.txt @@ -0,0 +1,640 @@ +"days","last14cases" +"1",1,1 +"2",2,1 +"3",3,1 +"4",4,1 +"5",5,1 +"6",6,2 +"7",7,2 +"8",8,3 +"9",9,10 +"10",10,10 +"11",11,10 +"12",12,10 +"13",13,13 +"14",14,15 +"15",15,17 +"16",16,57 +"17",17,100 +"18",18,123 +"19",19,198 +"20",20,222 +"21",21,244 +"22",22,271 +"23",23,292 +"24",24,305 +"25",25,346 +"26",26,359 +"27",27,380 +"28",28,453 +"29",29,505 +"30",30,502 +"31",31,523 +"32",32,540 +"33",33,497 +"34",34,503 +"35",35,538 +"36",36,588 +"37",37,653 +"38",38,714 +"39",39,736 +"40",40,734 +"41",41,752 +"42",42,713 +"43",43,681 +"44",44,695 +"45",45,677 +"46",46,642 +"47",47,627 +"48",48,641 +"49",49,611 +"50",50,567 +"51",51,499 +"52",52,478 +"53",53,431 +"54",54,427 +"55",55,402 +"56",56,373 +"57",57,383 +"58",58,347 +"59",59,330 +"60",60,334 +"61",61,321 +"62",62,286 +"63",63,268 +"64",64,257 +"65",65,237 +"66",66,189 +"67",67,174 +"68",68,170 +"69",69,161 +"70",70,156 +"71",71,130 +"72",72,120 +"73",73,99 +"74",74,96 +"75",75,94 +"76",76,89 +"77",77,85 +"78",78,69 +"79",79,72 +"80",80,71 +"81",81,74 +"82",82,80 +"83",83,79 +"84",84,80 +"85",85,79 +"86",86,81 +"87",87,87 +"88",88,83 +"89",89,82 +"90",90,87 +"91",91,88 +"92",92,92 +"93",93,92 +"94",94,94 +"95",95,94 +"96",96,86 +"97",97,79 +"98",98,86 +"99",99,90 +"100",100,103 +"101",101,110 +"102",102,115 +"103",103,115 +"104",104,112 +"105",105,117 +"106",106,113 +"107",107,111 +"108",108,109 +"109",109,105 +"110",110,104 +"111",111,104 +"112",112,96 +"113",113,87 +"114",114,70 +"115",115,51 +"116",116,44 +"117",117,43 +"118",118,37 +"119",119,27 +"120",120,21 +"121",121,17 +"122",122,13 +"123",123,14 +"124",124,14 +"125",125,16 +"126",126,14 +"127",127,14 +"128",128,12 +"129",129,12 +"130",130,12 +"131",131,13 +"132",132,13 +"133",133,20 +"134",134,27 +"135",135,27 +"136",136,28 +"137",137,27 +"138",138,27 +"139",139,26 +"140",140,27 +"141",141,26 +"142",142,29 +"143",143,28 +"144",144,28 +"145",145,27 +"146",146,27 +"147",147,22 +"148",148,16 +"149",149,15 +"150",150,17 +"151",151,18 +"152",152,18 +"153",153,21 +"154",154,24 +"155",155,33 +"156",156,42 +"157",157,49 +"158",158,56 +"159",159,57 +"160",160,67 +"161",161,86 +"162",162,95 +"163",163,103 +"164",164,114 +"165",165,117 +"166",166,123 +"167",167,128 +"168",168,131 +"169",169,122 +"170",170,112 +"171",171,111 +"172",172,110 +"173",173,111 +"174",174,108 +"175",175,93 +"176",176,102 +"177",177,110 +"178",178,117 +"179",179,120 +"180",180,117 +"181",181,127 +"182",182,137 +"183",183,151 +"184",184,166 +"185",185,179 +"186",186,183 +"187",187,183 +"188",188,195 +"189",189,208 +"190",190,214 +"191",191,213 +"192",192,227 +"193",193,245 +"194",194,258 +"195",195,271 +"196",196,276 +"197",197,277 +"198",198,291 +"199",199,294 +"200",200,305 +"201",201,325 +"202",202,329 +"203",203,343 +"204",204,338 +"205",205,358 +"206",206,384 +"207",207,408 +"208",208,409 +"209",209,412 +"210",210,447 +"211",211,476 +"212",212,485 +"213",213,509 +"214",214,523 +"215",215,568 +"216",216,592 +"217",217,614 +"218",218,673 +"219",219,694 +"220",220,702 +"221",221,682 +"222",222,675 +"223",223,682 +"224",224,650 +"225",225,682 +"226",226,690 +"227",227,680 +"228",228,664 +"229",229,615 +"230",230,591 +"231",231,575 +"232",232,528 +"233",233,508 +"234",234,475 +"235",235,472 +"236",236,469 +"237",237,469 +"238",238,489 +"239",239,488 +"240",240,492 +"241",241,507 +"242",242,546 +"243",243,545 +"244",244,558 +"245",245,644 +"246",246,690 +"247",247,748 +"248",248,845 +"249",249,900 +"250",250,955 +"251",251,993 +"252",252,1156 +"253",253,1212 +"254",254,1400 +"255",255,1576 +"256",256,1711 +"257",257,1819 +"258",258,1910 +"259",259,1916 +"260",260,2212 +"261",261,2375 +"262",262,2506 +"263",263,2649 +"264",264,2798 +"265",265,2904 +"266",266,2967 +"267",267,3247 +"268",268,3365 +"269",269,3438 +"270",270,3594 +"271",271,3701 +"272",272,3777 +"273",273,4027 +"274",274,4065 +"275",275,4173 +"276",276,4284 +"277",277,4415 +"278",278,4460 +"279",279,4463 +"280",280,4716 +"281",281,4755 +"282",282,4866 +"283",283,5125 +"284",284,5256 +"285",285,5271 +"286",286,5353 +"287",287,5516 +"288",288,5647 +"289",289,5640 +"290",290,6024 +"291",291,6010 +"292",292,6084 +"293",293,6192 +"294",294,6257 +"295",295,6540 +"296",296,6726 +"297",297,6730 +"298",298,6830 +"299",299,6867 +"300",300,7145 +"301",301,7264 +"302",302,7416 +"303",303,7631 +"304",304,7317 +"305",305,7340 +"306",306,7427 +"307",307,7606 +"308",308,7982 +"309",309,7981 +"310",310,7742 +"311",311,7557 +"312",312,7319 +"313",313,7426 +"314",314,7292 +"315",315,7348 +"316",316,7737 +"317",317,7948 +"318",318,8056 +"319",319,8116 +"320",320,7988 +"321",321,7848 +"322",322,7737 +"323",323,7636 +"324",324,7672 +"325",325,7910 +"326",326,7955 +"327",327,7829 +"328",328,7997 +"329",329,7890 +"330",330,7473 +"331",331,7184 +"332",332,7113 +"333",333,7220 +"334",334,7189 +"335",335,7210 +"336",336,6995 +"337",337,7053 +"338",338,7287 +"339",339,7071 +"340",340,7151 +"341",341,7253 +"342",342,7059 +"343",343,7134 +"344",344,7136 +"345",345,7232 +"346",346,7337 +"347",347,7227 +"348",348,7309 +"349",349,7494 +"350",350,7653 +"351",351,7640 +"352",352,7665 +"353",353,8022 +"354",354,8223 +"355",355,8271 +"356",356,8483 +"357",357,8605 +"358",358,8930 +"359",359,9290 +"360",360,9490 +"361",361,9652 +"362",362,10140 +"363",363,10559 +"364",364,10828 +"365",365,11303 +"366",366,11794 +"367",367,12606 +"368",368,13138 +"369",369,13749 +"370",370,14243 +"371",371,14890 +"372",372,15313 +"373",373,15894 +"374",374,16646 +"375",375,17383 +"376",376,17733 +"377",377,18077 +"378",378,18494 +"379",379,19299 +"380",380,19454 +"381",381,19471 +"382",382,19203 +"383",383,19458 +"384",384,19810 +"385",385,20136 +"386",386,20415 +"387",387,20632 +"388",388,20341 +"389",389,20396 +"390",390,20211 +"391",391,19969 +"392",392,20038 +"393",393,19510 +"394",394,19303 +"395",395,18866 +"396",396,18826 +"397",397,18129 +"398",398,17869 +"399",399,17100 +"400",400,16517 +"401",401,15678 +"402",402,14954 +"403",403,14068 +"404",404,13470 +"405",405,13327 +"406",406,12767 +"407",407,12109 +"408",408,11640 +"409",409,11137 +"410",410,10695 +"411",411,10386 +"412",412,9831 +"413",413,9374 +"414",414,8839 +"415",415,8415 +"416",416,8231 +"417",417,8288 +"418",418,8127 +"419",419,7748 +"420",420,7237 +"421",421,6912 +"422",422,6628 +"423",423,6371 +"424",424,6137 +"425",425,6027 +"426",426,5856 +"427",427,5702 +"428",428,5550 +"429",429,5428 +"430",430,5501 +"431",431,5127 +"432",432,5071 +"433",433,4929 +"434",434,4877 +"435",435,4798 +"436",436,4783 +"437",437,4741 +"438",438,4682 +"439",439,4716 +"440",440,4596 +"441",441,4564 +"442",442,4437 +"443",443,4350 +"444",444,4217 +"445",445,4176 +"446",446,4151 +"447",447,4047 +"448",448,3873 +"449",449,3745 +"450",450,3588 +"451",451,3420 +"452",452,3366 +"453",453,3244 +"454",454,3048 +"455",455,2861 +"456",456,2705 +"457",457,2567 +"458",458,2414 +"459",459,2344 +"460",460,2250 +"461",461,2085 +"462",462,1959 +"463",463,1826 +"464",464,1696 +"465",465,1579 +"466",466,1527 +"467",467,1487 +"468",468,1412 +"469",469,1296 +"470",470,1206 +"471",471,1120 +"472",472,1046 +"473",473,1022 +"474",474,991 +"475",475,921 +"476",476,850 +"477",477,785 +"478",478,743 +"479",479,710 +"480",480,684 +"481",481,658 +"482",482,610 +"483",483,566 +"484",484,530 +"485",485,486 +"486",486,467 +"487",487,457 +"488",488,444 +"489",489,430 +"490",490,407 +"491",491,388 +"492",492,372 +"493",493,381 +"494",494,383 +"495",495,391 +"496",496,404 +"497",497,422 +"498",498,462 +"499",499,491 +"500",500,521 +"501",501,519 +"502",502,525 +"503",503,533 +"504",504,553 +"505",505,596 +"506",506,620 +"507",507,645 +"508",508,659 +"509",509,674 +"510",510,705 +"511",511,760 +"512",512,823 +"513",513,868 +"514",514,910 +"515",515,976 +"516",516,1021 +"517",517,1159 +"518",518,1274 +"519",519,1432 +"520",520,1549 +"521",521,1732 +"522",522,1818 +"523",523,1870 +"524",524,2010 +"525",525,2145 +"526",526,2281 +"527",527,2436 +"528",528,2575 +"529",529,2610 +"530",530,2690 +"531",531,2784 +"532",532,2956 +"533",533,3108 +"534",534,3212 +"535",535,3255 +"536",536,3331 +"537",537,3408 +"538",538,3544 +"539",539,3599 +"540",540,3698 +"541",541,3787 +"542",542,3763 +"543",543,3738 +"544",544,3910 +"545",545,3998 +"546",546,4091 +"547",547,4121 +"548",548,4189 +"549",549,4223 +"550",550,4350 +"551",551,4442 +"552",552,4443 +"553",553,4564 +"554",554,4681 +"555",555,4699 +"556",556,4831 +"557",557,4985 +"558",558,4879 +"559",559,4895 +"560",560,4945 +"561",561,5008 +"562",562,5197 +"563",563,5366 +"564",564,5365 +"565",565,5378 +"566",566,5492 +"567",567,5609 +"568",568,5646 +"569",569,5832 +"570",570,5870 +"571",571,6077 +"572",572,6231 +"573",573,6304 +"574",574,6505 +"575",575,6627 +"576",576,6633 +"577",577,6783 +"578",578,6918 +"579",579,7040 +"580",580,7362 +"581",581,7581 +"582",582,7862 +"583",583,8061 +"584",584,8410 +"585",585,8573 +"586",586,8746 +"587",587,9178 +"588",588,9537 +"589",589,9897 +"590",590,10305 +"591",591,10728 +"592",592,11078 +"593",593,11410 +"594",594,11875 +"595",595,12356 +"596",596,12624 +"597",597,13170 +"598",598,13668 +"599",599,14160 +"600",600,14441 +"601",601,14646 +"602",602,14943 +"603",603,15501 +"604",604,15869 +"605",605,16445 +"606",606,17415 +"607",607,17974 +"608",608,17903 +"609",609,18702 +"610",610,19637 +"611",611,20037 +"612",612,20691 +"613",613,21449 +"614",614,22039 +"615",615,22510 +"616",616,23473 +"617",617,23913 +"618",618,24025 +"619",619,23907 +"620",620,23070 +"621",621,22577 +"622",622,22473 +"623",623,21806 +"624",624,20993 +"625",625,20355 +"626",626,19456 +"627",627,18142 +"628",628,17243 +"629",629,16540 +"630",630,15255 +"631",631,14181 +"632",632,13462 +"633",633,12402 +"634",634,12292 +"635",635,11906 +"636",636,11643 +"637",637,10941 +"638",638,10379 +"639",639,9976 diff --git a/Exercise10.R b/Exercise10.R new file mode 100644 index 0000000..5874c24 --- /dev/null +++ b/Exercise10.R @@ -0,0 +1,59 @@ +# Exercise 10 + +# task 1 + +setwd("/Users/johi/Desktop/Courses/Biocomputing/Biocomp_tutorial12") + +# opening the initial data of Estonian corona statistics +data <- read.table(file = "opendata_covid19_tests_total.csv", header = T, sep = ",", stringsAsFactors = FALSE) +head(data) + +# creating a new dataframe that contains 2 columns (days from the first Covid positive test and TotalCasesLast14D - the sum of positive cases last 14 days) +days = seq(1, dim(data)[1], 1) +last14cases = data$TotalCasesLast14D + +coronaData = data.frame(days, last14cases) + +#writing a new txt file fir the new dataframe +write.table(coronaData, file = "EstonianCoronaData.txt", sep = ",", col.names = TRUE) + +data <- read.table(file = "EstonianCoronaData.txt", header = T, sep = ",", stringsAsFactors = FALSE) + +# importing the ggplot library +library(ggplot2) + +# plotting the data with trend line (polynomial trend line) +ggplot(data = data,aes(x = days, y = last14cases)) + + geom_point() + + stat_smooth() + + xlab("Day from the start") + + ylab("Total cases last 14 days") + + theme_classic() + + +# task 2 + +data <- read.table(file = "data.txt", header = T, sep = ",", stringsAsFactors = FALSE) +tail(data) + +# bar plot of the means of the four populations +ggplot(data, aes(x = region, y = observations)) + + stat_summary(fun = mean, geom = "bar") + + xlab("Region") + + ylab("Observations") + + theme_classic() + +# scatterplot +ggplot(data = data,aes(x = region, y = observations)) + + geom_point() + + geom_jitter() + xlab("Region") + + ylab("Observations") + + theme_classic() + + +# Although they are spread very differently, the means are basically the same. +# Therefore, there is no difference in the bar plot but when it comes to the scatterplot we can see the difference between the regional observations. +# Scatterplot shows the variance while the bar plot doesn't. + +