Publications by MM
Activity 2 - Sample Mean
Short simulation example to show that the sample mean (x bar) is a random variable Setting seed and creating sample Sample 1 set seed, create sample with n=10, mean=20, and sd=2 set.seed(1) sample1= rnorm(n= 10, mean= 20, sd= 2) sample1 ## [1] 18.74709 20.36729 18.32874 23.19056 20.65902 18.35906 20.97486 21.47665 ## [9] 21.15156 19.38922...
544 sym 2 img
Activity 1 - Presidents Data Frame
Presidents presid_name year winner opponent isWinnerTaller difference presid_party Obama 2008 185 175 TRUE 10 Dem … … … … … … … Creating basis for Data Frame Defining Vectors: Presidents’ names, winners’ heights, opponents’ heights presid_name= c("Obama","Bush","Bush","Clinton","Clinton","Bush Father","Reagan","Reagan","...
1498 sym 1 tbl
Activity 3 - Infections
Activity 3 - Infections Importing Data Assign dataset (dataframe) to infections variable without headers being set infections <- read.table("C:/Users/marxm/OneDrive/Documents/ProgrammingForData_R/acti3/data/PopInf.txt",header=FALSE) View dataset #View(infections) Assign dataset to variable with headers being set infections <- read.table("C:/Use...
1244 sym
Activity 4 - Vectorized Operations
Activity 4 - Vectorized Operations Vectori In, Vector Out Comparing the values at each position in each vector -> Bigger, smaller: returns boolean u <- c(5,2,8) v <- c(1,3,9) u>v ## [1] TRUE FALSE FALSE Creating and comparing own vectors: is two bigger than one? one <- c(8561, 9416, 98451) two <-c(2465,98435,32) one < two ## [1] FALSE TRU...
1762 sym
Activity 5 - R SQL
Installing SQL Library #install.packages("sqldf") importing SQL Library library(sqldf) ## Warning: package 'sqldf' was built under R version 4.1.3 ## Loading required package: gsubfn ## Warning: package 'gsubfn' was built under R version 4.1.3 ## Loading required package: proto ## Warning: package 'proto' was built under R version 4.1.3 ## Loadin...
4299 sym R (15813 sym/51 pcs)
Activity 6 - Matrix
Vector Element Names The elements of a vector can optionally be given names. For example, say we have a 50-element vector showing the population of each state in the United States. We could name each element according to its state name, such as “Montana” and “New Jersey”. This in turn might lead to naming points in plots, and so on. x...
13129 sym
Activity 7 - Three Dimensional
At the beginning of the chapter, I said that a matrix is just a vector but with two additional attributes: the number of rows and the number of columns. Here, we’ll take a closer look at the vector nature of matrices. Consider this example: z <- matrix(10:17,nrow=4) z [,1] [,2] [1,] 10 14 [2,] 11 15 [3,] 12 16 [4,] 13...
11769 sym
Activity 8 - Lists
Class Activity 8 - Lists In contrast to a vector, in which all elements must be of the same mode, R’s list structure can combine objects of different types. Creating Lists Technically, a list is a vector. Ordinary vectors—those of the type we’ve been using so far in this book—are termed atomic vectors, since their components cannot be...
6852 sym
Activity 9 - DataFrames
Activity 9: Dataframes On an intuitive level, a data frame is like a matrix, with a two-dimensional rows-and columns structure. However, it differs from a matrix in that each column may have a different mode. For instance, one column may consist of numbers, and another column might have character strings. In this sense, just as lists are the...
12985 sym Python (1029 sym/30 pcs)
Activity 10 - Frames
Factors In-class activity 10 Factors form the basis for many of R’s powerful operations, including many of those performed on tabular data. The motivation for factors comes from the notion of nominal, or categorical, variables in statistics. These values are nonnumerical in nature, corresponding to categories such as Democrat, Republican, ...
17825 sym