{"id":19261938,"url":"https://github.com/hacksu/r-lesson","last_synced_at":"2026-02-28T02:34:45.697Z","repository":{"id":126540083,"uuid":"216055170","full_name":"hacksu/r-lesson","owner":"hacksu","description":null,"archived":false,"fork":false,"pushed_at":"2020-06-08T17:56:58.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"draft","last_synced_at":"2025-10-14T07:27:47.897Z","etag":null,"topics":["advanced","lesson"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hacksu.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-18T15:31:36.000Z","updated_at":"2020-06-08T17:57:00.000Z","dependencies_parsed_at":"2023-06-17T04:30:22.342Z","dependency_job_id":null,"html_url":"https://github.com/hacksu/r-lesson","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hacksu/r-lesson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2Fr-lesson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2Fr-lesson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2Fr-lesson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2Fr-lesson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacksu","download_url":"https://codeload.github.com/hacksu/r-lesson/tar.gz/refs/heads/draft","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2Fr-lesson/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29923408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"online","status_checked_at":"2026-02-28T02:00:07.010Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advanced","lesson"],"created_at":"2024-11-09T19:29:07.818Z","updated_at":"2026-02-28T02:34:45.668Z","avatar_url":"https://github.com/hacksu.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"Taught 10/22.  \nNotes if taught again:  \n-Downloads and loading a data set took awhile. \n-Challenges were too challenging. \n\n1. Download R Studio.\nhttps://rstudio.com/products/rstudio/download/\n  \n2. What is R?\n  - Open source language used a lot in stats and for graphing data\n  - Derived from S\n  - Data manipulation language\n\nBut what do I use it for? \n- Stats\n- Deep Learning\n- connect APIs\n- build and host interactive web apps\n- big data processing with Apache Spark\n- more, more, more\n\n3. Clone this github to get the CSV files.\n\n4. Connect repository to R Studio. File \u003e New Project \u003e Existing Directory\n\n\nMoving on...\nBasic data types in R:\n  char, numeric, integer, logical, complex\n\nSmallest data set you can create is a vector.\n\u003e c(1,2,3)\n\nIn R, you can do math with with vectors without needing a for loop\n\u003e 2 * c(1,2,3)\n\n\n  \n  ------------IMPORTING CUSTOM DATASETS \u0026 DOING BASIC VISUALIZATIONS---------\n  Let’s learn how to import our own dataset and create some basic visualizations with it. Grab “apps.csv” from GitHub.\nImport KHE CSV\nGo to files tab \u003e apps.csv \u003e import dataset\nMake sure the box contains a grid of the data \"school\", \"shirt\", \"demo\", etc.; if not, cancel and click 'import dataset' again\nPress import\n\nDataset should be visible for you to browse. Double-check environment tab on right for variable name. \n\nLet’s see what our column names are. \n\u003e\tcolnames(apps)\n\nAsk if this returned column names.\n\nIf not, it looks like we are not totally done importing the data. Let’s fix this. \n\u003e\tread.csv(“apps.csv”)\nCall for the column names again and we’ll be able to see them.\n\u003e\tcolnames(apps)\n\nIf you have a long filename, we could store the data source in our own variable. We’re using “\u003c-” which is an assignment operator.\n\u003e\tt\u003c- read.csv(“apps.csv”)\n\nThere is some n/a data entries. We want to clean these out.  \n\u003e\tapps=na.omit(apps)\n\n\nNext, let’s get the number of t-shirts by size.\n\u003e\ttable(apps$shirt)\n\nLet’s put this into a bar-chart.  \n\u003e\tbarplot(table(apps$shirt))\n\nBut I find blue boring so let’s change into a color. \n\u003e\tbarplot(table(apps$shirt), col=\"purple\")\n\nI want to find out the age of attendees and this would be best represented by a boxplot.\n\u003e\tboxplot(apps$age)\n\nCHALLENGE 1: FIGURE OUT HOW TO MAKE IT A BOXPLOT WHERE THE OUTLIERS ARE A TRIANGLE SHAPE AND MAKE THE MIDDLE LINE BLUE\n\u003e\tboxplot(apps$age, medcol=\"blue\",bg=\"red\",outpch=6)  \n\nLet's make a line chart of when accounts were created:\n  plot(table(apps$created), line=\"l\")\n  \nIt should show the dates out of order on the x-axis. We can convert these string values into a date by saving it as a new local global value.\n\nUse this to convert into dates\n \u003e\tdates \u003c- as.Date(apps$created, \"%m/%d/%Y\")\n\nIF THERE’S TIME, FIGURE OUT HOW TO MAKE THESE DATES NEW TO OLD\n  \nNow call to see the new graph:\n\u003e\tplot(table(dates), type=\"l\")\n  \n--------------------------R STUDIO DATA SETS \u0026 SOME STATS---------------------------------\nMoving on to some other R capabilities...  \nLet's say you want to easily import a given data set. R Studio has many data sets sitting in a package that downloads with the software.\n\u003e\tdata()              and press enter\n\nA list of available datasets will show up. Enter the name inside that parenthesis.\nCall dataset by given name. Let's use:\n\u003e\tmtcars\n\nName Descriptions:\nmpg: Miles/(US) gallon\ncyl: Number of cylinders\ndisp: Displacement (cu.in.)\nhp: Gross horsepower\ndrat: Rear axle ratio\nwt: Weight (1000 lbs)\nqsec: 1/4 mile time\nvs: V/S\nam: Transmission (0 = automatic, 1 = manual)\ngear: Number of forward gears\ncarb: Number of carburetors\nhttp://www.sthda.com/english/wiki/r-built-in-data-sets\n\nLet’s plot this.\n \u003e\tplot(mtcars)\n\nThere's a lot of data here. Maybe we're only interested in a few columns. \n\u003e\tplot(mtcars[c(1,3,8)])\n\nI’d like to know the average mpg. \n\u003e\tmean(mtcars$mpg)\n\nCHALLENGE 2: FIND THE FIVE NUMBER SUMMARY USED IN STATS ON JUST MTCARS MPG\n\u003e \tsummary(mtcars$mpg)\n\nCHALLENGE 3: CREATE A LINEAR REGRESSION LINE USING MPG AND CYL, THEN PLOT IT. \nChallenge to find linear relationship or something.  \n\u003e plot(lm(mtcars$mpg~mtcars$cyl, data=mtcars))\n\n--------------------------------------------HEATMAP----------------------------------------------------------\nNext, let’s create a heatmap using gradebook.csv file. Import gradebook dataset. \nPut the dataset in a var. I’m going to also save the dataset into something easier to work with.\n\u003e\t grades \u003c- gradebook\n\nLet’s have it print out the student ID instead of the row number, but we’re going to save that in a new var\n\u003e \trow.names(grades) \u003c- grades$`Student ID`\n\nCHALLENGE 4: FIGURE OUT HOW TO INPUT THE DATA IN NAMES INTO A MATRIX. \n\u003e\tg_matrix \u003c- data.matrix(grades)\n\nCreate the heatmap\n\u003e\theatmap(g_matrix, Rowv=NA, Colv=NA, col = cm.colors(256), scale=\"column\", margins=c(5,10))\n\n\n--------------------------------------------------------------------------------------------------------------------\nHelpful shortcuts:\nclear - ctrl-l or Option + Command + L\n\nFind installed libraries\ninstalled.packages(lib.loc = NULL, priority = NULL,\n                   noCache = FALSE, fields = NULL,\n                   subarch = .Platform$r_arch,)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacksu%2Fr-lesson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacksu%2Fr-lesson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacksu%2Fr-lesson/lists"}