Tuesday, March 5, 2024

LIS 4317 Visual Analytics - Module 9 Assignment

In this week of Visual Analytics, we are asked to create a multi-variate visualization graph with a dataset of our choice.

In this case, I decided to work with a dataset called nyc_squirrels.csv and basically it contains very detailed observations from squirrel watching in New York City's Central Park. From what they were doing, what sound they made, to even the exact geo coordinates of where the squirrel watching event occurred, it is all noted down in the data. 

Link to where I found the data: NYC Squirrels Data

From this data, I decided that I wanted to better understand the spatial distribution of squirrel sightings and see if there is any difference in sightings that occurred in the AM or PM.

To begin my analysis, I did make a point to clean my data containing entries with NA values and deleted variables that were not conducive to the analysis.

With the data ready, I used the ggplot2 package in R to graph the points:

Here is the visual: 

As you can see, when the geo coordinate points are plotted, it actually makes a rough outline of Central Park. The big empty gap you are seeing represents Jacqueline Kennedy Onassis Reservoir so it makes sense that there were not any squirrels spotted there. For the most part, I do not see any particular difference in squirrel sightings in the AM versus PM but there does appear to be more squirrel sightings at night than during the day.

For fun, let's see what this plot looks like in Tableau with a map underneath the points:

See the map up close here: NYC Squirrel Sightings

Wrapping up, visualizing multi-variables can be very helpful when it comes to understanding the subtle relationships between them. It is definitely interesting to be able to compare AM sightings to PM sightings and where they occurred in Central Park and allows for one to better understand the dataset.

As for applying the 5 principles of design, alignment is used for the axis labels, legend, and title for better readability. With repetition, shape style, color, font size, and type are kept consistently. To highlight the difference between day and night, I opted to use cool colors most often associated with the night for PM and warm colors for AM which checks off the contrast requirement. Moving on to proximity, visual elements like the legend are clearly placed together to promote connection. Lastly, with balance, I must admit that the Tableau visual is not as balanced as the previous ggplot visual. It has very small legend which makes it have uneven weight. To prevent this, I should think about adding more data elements to make the visual more balanced.

~ Katie

Thursday, February 29, 2024

LIS 4317 Visual Analytics - Module 8 Assignment

In this week in Visual Analytics, we are asked to generate a visual from the mtcars dataset that is either based on correlation and regression analysis.

In this case, I will be conducting correlation analysis on the variables number of cylinders (cyl) and horsepower (hp). That is, I want to know if these variables have a positive correlation or negative correlation relationship.

Let's begin by plotting the relationship via ggplot2 in a scatterplot. I will also draw in a line of best fit using the lm argument.

Here's my code:

The resulting output:

Interestingly, there appears to be a rather strong positive correlation between the number of cylinders and horsepower. Perhaps, this is alluding to cars that have a greater number of cylinders have a higher horsepower. Let's take a look at the correlation coefficient.

With a value of .832, that's a pretty high correlation value!

Lastly, let's finish up by creating a linear regression model of these variables:

Looking at the significance codes, cyl is highly significant at the (***) mark at 0.001. However, the model can only capture about 68% of the variability so it is a moderately strong correlation.

Reflecting on the design remarks of Few from the textbook, my visual does follow a few of his best practices. To begin, I do feature some grid lines for greater readability of graph and one can easily determine the points and where they fall in terms of cyl and hp. However, I do see how grid lines can be helpful if multiple scatter plots are used in the analysis. In addition, my visual also has a line of best fit so that we easily see the correlation's linear shape and positive slope.

I appreciate Few's recommendations when it comes to visualizing correlations between variables. Although my visual does not include all his suggestions and I know that they will be helpful for other datasets.

~ Katie


LIS4370 R Programming - Module 8 Assignment

For this week's assignment in R Programming, we are to do the following:

Step 1: Import txt file in R. This file is called Assignment 6 Dataset.txt

Step 2: Use ddply from the plyr package to generate mean of Age and Grade variables split by Sex variable, this will be saved to new variable, Grade.Average

Step 3: Create a new txt file containing new variable Grade.Average. This new txt file will be called Sorted.Average

Step 4: Separate values in Sorted.Average by comma using sep argument, and save it back to Sorted.Average

Step 5: Using the original txt file, filter the names in the list that contain the letter (i). Then, save the result to a new file called DataSubset with the values separated by comma.

Let's take a look at our new files:

Sorted.Average:

DataSubset:

As you can see by the resulting output, the values are separated by commas and the variables are differentiated as they are surrounded by double quotes. 

See the code on GitHub: Module 8 Code

~ Katie

Thursday, February 22, 2024

LIS 4317 Visual Analytics - Module 7 Assignment

For this week's assignment, we are tasked with creating visual analytics based on distribution analysis. I will be working with the mtcars dataset to understand the distribution of horsepower (hp).

A quick note, I generated a couple visuals of the horsepower (hp) distribution:

Scatter plot:

Boxplot:

Line Graph:

Histogram:

Reflecting on Few's recommendations in testing and best practices when it comes to conducting distribution analysis, each of my graphs have strengths and weaknesses. To begin, Few notes that there are three main characteristics when it comes to describing distributions. These are...

Spread: A simple measure of dispersion, or how spread out the values are and it essentially is the full range of values from highest to lowest.

Center: An estimate of the middle of a set of values and it is often demonstrated by either the mean or median.

Shape: Where the values are located throughout the spread. 

For the most part, my visuals do a good job of showing spread except for maybe the boxplot as it simplifies the values that are shown on the y-axis tick marks but the full spread is still albeit it is slightly downplayed. As for center, visuals 1, 3, and 4 provides horsepower's mean and median and where it lies in correspondence to the chart. The second visual, the boxplot, only provides the median. Moving on to shape, one can note that visuals 1, 3, and 4 appear slightly skewed to the right. In the histogram, one can also see a brief gap near the 300 tick mark and an outlier when hp equals 325. 

As for whether these visuals correspond to Few's distribution analysis best practices, I believe my visuals do a fairly good job when it comes to interval consistency but fails when it comes to outlier resistance. As one can tell from the visuals, there is a clear outlier where hp equals 325. The mean calculation can be heavily affected by outliers and as a result, can be shifted in the direction of that outlier and we can clearly see that happening here. Therefore, it might be a good idea to remove that outlier from the dataset before conducting visual analysis. 

All in all, Few's recommendations are incredibly helpful when it comes to deciphering data when it is visualized.

~ Katie

Wednesday, February 21, 2024

LIS 4370 R Programming - Module 7 Assignment

For this week's assignment, I will start out by examining the iris dataset and then transition to my own dataset when it comes to creating two examples of S3 and S4.

Question 1: Determine if a generic function can be applied to your dataset

To begin, I used the following functions on the iris dataset and came up with the following output:

Based on this output, I can confirm that a generic function can be applied to my chosen dataset.

Question 2: How do you tell what OO system (S3 vs. S4) an object is associated with?

In the library, pryr, one can use the function otype() to determine which OO system object is associated with.

In this case, the iris dataset is associated with S3.

Question 3: How do you determine what the base type of an object is?

Using the typeof() function can help in determining an object's base type. Continuing with the iris dataset, we can check the object type of each of the variables within the dataset:

Question 4: What is an generic function?

A generic function can be defined as a function that performs a common task like printing (print()) or even plotting (plot()). Furthermore, they can be thought as extended function objects because they contain information that is used in creating and dispatching for the function.

Question 5: What are the main differences between S3 and S4?

To put it simply, S3 is considered more convenient while S4 is more safe. Additionally, S3 classes are very straightforward to implement as it only uses the first argument to dispatch but it can allow for mistakes to slip through like misspelled values and missing values and will not alert the programmer of the potential issues. On the other hand, S4 classes and methods are way more formal and more closely related to object-oriented concepts and unlike S3, S4 will complain about such misspellings and other issues to alert the programmer that the current code does need to be fixed.

Question 6: Create two examples of S3 and S4. (Code will be linked to GitHub)

S3 Code:

Output:

S4: Code:

Output:

After conducting this brief code experiment, I must admit that I greatly prefer the form of S4 over S3 just for its ease of creating instances of the class. 

Link to GitHub Code: Module 7 Code

~ Katie

Thursday, February 15, 2024

LIS 4370 R Programming - Module 6 Assignment

 In this week in LIS 4370, we are asked to answer the following questions using R.

Question 1:

Consider A <- matrix(c(2, 0, 1, 3), ncol = 2) and B <- matrix(c(5, 2, 4, -1), ncol = 2)

a) Find A + B

b) Find A - B

Output:

Question 2:

Use the diag() function to to build a matrix of size 4 with the following values in the diagonal: 4, 1, 2, 3

Output:

Question 3:

Generate the following matrix:

Hint: Use the diag() command to build it.

Solution and Output:

Here's the link to the full code on GitHub: Module 6 Code

~ Katie

LIS 4317 Visual Analytics - Module 6 Assignment

For this week, we were tasked with creating a simple data visualization using R. I decided to work with the mtcars dataset which comes as a prebuilt dataset in R and lists various cars from the 1974 Motor Trends US magazine.

There are many variables to look at but I wanted to examine all the average miles per gallon (mpg) for each of the cars listed.

To do so, I used ggplot2 and came up with the following:


(Click on the image to make it bigger)

Reflecting on Few and Yau's discussions on conducting basic visualizations, my visualization somewhat follows the various design principles they introduced. Such as, selecting the right type of graph that best visualizes the data in a meaningful way. As Few mentions in page 37 of the textbook, not all graphs can effectively show the data. With this many car names, a pie chart would not be suitable in order to tell the differences between mpg. 

If I were to revise this visualization, I would attempt to create space between each bar to better make out which car belongs to which bar. It is a bit condensed and spacing is needed. Next, the color scheme is pretty but can get quite hard to see when it comes to reading colored bars between the colors orange, green, blue, and pink. 

~ Katie 


LIS 4370 R Programming - sentimentTextAnalyzer2 Final Project

For this class's major final project, I set out to make the process of analyzing textual files and URL links for sentiment insights much...