Monday, January 30, 2023

 Hello Class,

In this assignment we were to calculate the mean of two polls for several candidates.  To do this (you may find my code here: https://github.com/Wellis11/assignment3 , I combined two concatenated lists of poll values into a data frame.  I then found the mean of each row of values (ABC and NBC polls).  I wanted to organize this by candidate, so I combined this new list of means with the list of candidate names into a new data frame.

I imagine there is a more efficient way of doing this.  I would liked to have found a way to create just a single data frame and calculate the mean of numerical components of rows and present the results headed by the candidate names.

Below is my code and output.

>Name = c("Jeb", "Donald", "Ted", "Marco", "Carly", "Hillary", "Bernie")

>ABC_political = c(4, 62, 51, 21, 2, 14, 15)

>NBC_political = c(12, 75, 43, 19, 1, 21, 19)

>first.df = data.frame(ABC_political, NBC_political)

>first.df

>pollmean=(rowMeans(first.df))

>pollmean

>second.df = data.frame(Name, pollmean)

>second.df


Monday, January 23, 2023

 In Assignment 2, we were presented with the prompt:

assignment2 <- c(161814222717191717222022)
>
myMean <- function(assignment2) { return(sum(assignment2)/length(assignment2)) }
> YOUR turn...


In analyzing this R code, after reading the article "Writing Functions Using R" it was apparent that the intended purpose of the function "myMean" was to return the mean value of the sequence "assignment2" by dividing the sum of the sequence by the length of the sequence.  As written, the code did nothing.  The expression was correctly formatted, but I needed to replace line 3 (>YOUR turn...) to get the code to return a value.  I chose to enter 

"> myMean(assignment2)" 

to apply the function to the object "assignment2".  When I did so, R returned [1] 19.25, which is the mean of the sequence.  It worked!


I am having a terrible time understanding how to link RStudio to GitHub.  I'm also uncertain if I should be using the Project window or the console window in RStudio to create and test my code.  It seems as though the project window is necessary for versioning.  If that is the case, why would I use the console window?  I'll figure this out eventually.


Saturday, January 14, 2023

 I have a new Git Hub repository:

R_Prog_Course_Wellis