Posts

Showing posts from January, 2021

Intro to data.frame

Image
This week we will begin to familiarize ourselves with Data Frames. We are given mock data representing the polls for the 2016 U.S Presidential Election by ABC and CBS. Here are the information given to us exactly as it was presented: > Name <- c("Jeb", “Donald”, "Ted”, “Marco” “Carly”, “Hillary”, “Berine”) > ABC political poll results <- c(4, 62,51, 21, 2, 14, 15) > CBS political poll results <- c(12, 75, 43, 19, 1, 21, 19) Our goal here is to take what we have learned about Data Frames and try to organize our data in R with what we've learned so far. Github link:  https://github.com/Ant-nguyen/Intro_r_2021/blob/main/Module%203.R Let's begin! First we assign the different candidates to vector named 'Name'.* >Name <-c("Jeb","Donald","Ted","Marco","Carly", "Hillary", "Bernie") *Note: That in order to do this we couldn't simply copy and paste the line that was p...

myMean assignment

Image
For our first R assignment we will be working with how user created functions work by testing a user created function myMean. Here is a GitHub link of all the testing I did based on the history of commands I ran on RStudio:   https://github.com/Ant-nguyen/Intro_r_2021/blob/main/myMean/.Rhistory Let's begin! We are given a set of data and a user created function: assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) myMean <- function(assignment2) { return(sum(assignment)/length(someData)) } To test this we open up RStudio and copy and paste the provided data and function. So far so good, we do not get any error and RStudio assigns the argument and function accordingly: (Line 1 &2 in the Rhistory on GitHub) Now we test our function (Line 3). We get an error:  Error in myMean(assignment2 = assignment2) :    object 'assignment' not found Looking at our function it seems that R does not know what assignment is since nothing was assigned to it! So we ...

GitHub repository

Here is my GitHub repository for my R-2021 class: https://github.com/Ant-nguyen/Intro_r_2021 Here I will upload projects and assignments I'm working on. Excited to learn R! -Ant