diff --git a/content/_index.md b/content/_index.md index 41bfbb0..bc5211b 100644 --- a/content/_index.md +++ b/content/_index.md @@ -1,4 +1,5 @@ --- title: Brandon Rozek description: "Software Developer, Researcher, and Linux Enthusiast." ---- \ No newline at end of file +--- + diff --git a/content/blog/2015-10-10-javascript-data-types.md b/content/blog/2015-10-10-javascript-data-types.md index a3354f0..ad4d1cd 100644 --- a/content/blog/2015-10-10-javascript-data-types.md +++ b/content/blog/2015-10-10-javascript-data-types.md @@ -20,288 +20,266 @@ tags: ["Web", "JS"] --- Javascript has multiple ways you can store your data. Each of these different ways is called a data type, and they each carry different “methods” which are helpful commands. Today, I’ll show you the different data types and methods that I use and how they’re useful. - - This post is by far not a comprehenive list of all the Data types and their methods. If you want one of those, please check out [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects) and/or [WebPlatform](http://docs.webplatform.org/wiki/javascript/objects){.broken_link}. This is the second lecture of the web development class I’m teaching for the newer folks over at [Math I/O](http://math-io.com). Due to the nature of Math I/O (making math games and all), the next few posts will be Javascript centric. We’re getting ready to build a new game, so I want to prepare them as much as possible. \*Excited\* ^_^ Ilya Kantor does a good job of descibing Javascript data types and their many methods in [Mastering Data Types](http://javascript.info/tutorial/mastering-data-types) which I made the recommended reading for this lecture. -### String {#string} +### String A string is one or more characters. -
var name = "Brandon";
+```javascript
+var name = "Brandon";
+```
You can access a character inside of a string by using [] notation. Inside the [] you put the index of the character you want. An index is the numeral location of the character starting from the left. It is important to note that Javascript starts counting from 0.
-- B - | +| B | r | a | n | d | o | n | +| ---- | ---- | ---- | ---- | ---- | ---- | ---- | +| 0 | 1 | 2 | 3 | 4 | 5 | 6 | -- r - | - -- a - | - -- n - | - -- d - | - -- o - | - -- n - | -
- | - -- 1 - | - -- 2 - | - -- 3 - | - -- 4 - | - -- 5 - | - -- 6 - | -
var firstInitial = "Brandon"[0];
+#### Some useful methods for strings
-Now the value of firstInitial is the letter "B"
.
-
-#### Some useful methods for strings {#some-useful-methods-for-strings}
-
-##### String.prototype.indexOf(); {#string.prototype.indexof();}
+##### `String.prototype.indexOf`
This can be used to find the index of any character(s) in a string. I primarily use it for when I need to check if something exists in a string. Do I have a ‘z’ in my name?
-"Brandon".indexOf('z');
+```javascript
+"Brandon".indexOf('z');
+```
-Nope, so Javascript will return a -1
. How about a ‘d’?
+Nope, so Javascript will return a `-1`. How about a ‘d’?
-"Brandon".indexOf('d');
+```javascript
+"Brandon".indexOf('d');
+```
-Yes, Javascript will return 5
which is the index of the letter ‘d’.
+Yes, Javascript will return `5` which is the index of the letter `‘d’`.
-##### String.prototype.replace(); {#string.prototype.replace();}
+##### `String.prototype.replace`
-The replace method can replace any character(s) with other character(s). For more complex replacing, look into [Regular Expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) and how you can use them in .replace(). Replace the first ‘n’ in my name with an ‘m’.
+The replace method can replace any character(s) with other character(s). For more complex replacing, look into [Regular Expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) and how you can use them in `.replace()`. Replace the first `‘n’` in my name with an `‘m’`.
-
+```javascript
var modifiedName = "Brandon".replace('n', 'm');
-
console.log(modifiedName);
-
+```
-Logs "Bramdon"
.
+Logs `"Bramdon"`.
-##### String.prototype.toUpperCase(); {#string.prototype.touppercase();}
+##### `String.prototype.toUpperCase`
This method returns the string with all the lowercase characters converted to uppercase and can be useful for when you’re checking user input and you don’t want to worry about different cases.
-"Brandon".toUpperCase();
+```javascript
+"Brandon".toUpperCase();
+```
-Returns "BRANDON"
.
+Returns `"BRANDON"`.
-##### String.prototype.toLowerCase(); {#string.prototype.tolowercase();}
+##### `String.prototype.toLowerCase()`
Same as above but instead of converting lowercase to uppercase, it converts uppercase to lowercase.
-"Brandon".toLowerCase();
+```javascript
+"Brandon".toLowerCase();
+```
-Returns "brandon"
.
+Returns `"brandon"`.
-#### A couple useful escape secquences {#a-couple-useful-escape-secquences}
+#### A couple useful escape secquences
- * n
for newline.
- * t
for tab character.
+ * `\n` for newline.
+ * `\t` for tab character.
-You can also use escape sequnces if you want to add “” or ‘’ to your strings.
-
-
-var greeting = "Hello "Brandon"";
+You can also use escape sequnces if you want to add `“”` or `‘’` to your strings.
+```javascript
+var greeting = "Hello \"Brandon\"";
console.log(greeting);
-
+```
-Returns "Hello "Brandon""
.
+Returns `"Hello "Brandon""`.
-### Number {#number}
+### Number
-Any number between -(253 – 1) and (253 – 1).
+Any number between -(2^53 – 1) and (2^53 – 1).
-#### Number Methods {#number-methods}
+#### Number Methods
Number methods are useful when trying to represent complex numbers.
-##### Number.prototype.toExponential(); {#number.prototype.toexponential();}
+##### `Number.prototype.toExponential()`
Returns a string representing a number in exponential notation.
-77.1234.toExponential(2);
+```javascript
+77.1234.toExponential(2);
+```
-Returns "7.71e+1"
.
+Returns `"7.71e+1"`.
-##### Number.prototype.toFixed(); {#number.prototype.tofixed();}
+##### `Number.prototype.toFixed()`
Returns a string representing a number fixed to x amount of decimal places.
-12345.6789.toFixed(1);
+```javascript
+12345.6789.toFixed(1);
+```
-Returns "12345.7"
.
+Returns `"12345.7"`.
-##### Number.prototype.toPrecision(); {#number.prototype.toprecision();}
+##### `Number.prototype.toPrecision();`
Returns a string representing a number using x amount of significant figures.
-5.123456.toPrecision(2);
+```javascript
+5.123456.toPrecision(2);
+```
-Returns "5.1"
.
+Returns `"5.1"`.
-#### Math properties/methods {#math-properties/methods}
+#### Math properties/methods
In Javascript there is a Math object which contains many properties and methods which are useful for mathmatical calculations.
-##### Return Euler’s constant {#return-euler's-constant}
+##### Return Euler’s constant
-Math.E
which returns ~2.718.
+`Math.E` which returns ~2.718.
-##### Return the natural log of x {#return-the-natural-log-of-x}
+##### Return the natural log of x
-Math.log(x)
+```javascript
+Math.log(x)
+```
-##### Rise x to the y power {#rise-x-to-the-y-power}
+##### Rise x to the y power
-Math.pow(x,y)
+```javascript
+Math.pow(x,y)
+```
-##### Return a psuedo random number [0,1) {#return-a-psuedo-random-number-[0,1)}
+##### Return a psuedo random number \[0,1\)
-Math.random()
+```javascript
+Math.random()
+```
-##### Round x to the nearest integer {#round-x-to-the-nearest-integer}
+##### Round x to the nearest integer
-Math.round(x)
+```javascript
+Math.round(x)
+```
-### Boolean {#boolean}
+### Boolean
-Booleans are either true
or false and
are typically used in conditional statements. You can either create them explicitly
-
-var alive = true;
+Booleans are either `true` or `false` and are typically used in conditional statements. You can either create them explicitly
+```javascript
+var alive = true;
+```
or by evaluating a [comparison](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators).
-
+```javascript
var dead = false;
var isAlive = !dead;
-
+```
-isAlive equals true
.
+isAlive equals `true`.
-### Array {#array}
+### Array
An array is a list of items. In Javascript these items can be any data type, even arrays themselves.
-var mixedBag = ['sword', 24, true, [Math.PI, Math.E], 'shield'];
+```javascript
+var mixedBag = ['sword', 24, true, [Math.PI, Math.E], 'shield'];
+```
To access an item in an array use [] notation with an index as mentioned over at strings.
-['sword', 'shield', 'helmet'][1];
+```javascript
+['sword', 'shield', 'helmet'][1];
+```
-Returns 'shield'
. to figure out how many items are in the array.
+Returns `'shield'`. In order to figure out how many items are in the array:
-
+```javascript
var inventory = ['boots', 'gloves', 'pants', 'shirt'];
var inventoryAmt = inventory.length;
-
+```
-inventoryAmt is 4
since there are 4 items in inventory.
+inventoryAmt is `4` since there are 4 items in inventory.
-#### Array Methods {#array-methods}
+#### Array Methods
-##### Array.prototype.push(); {#array.prototype.push();}
+##### `Array.prototype.push()`
Adds whatever is inside the parenthesis to the end of the array. Great for adding items to a list. For example, test scores.
-[100,92,95].push(80);
+```javascript
+[100,92,95].push(80);
+```
-Returns [100,92,95,80]
.
+Returns `[100,92,95,80]`.
-##### Array.prototype.reverse(); {#array.prototype.reverse();}
+##### `Array.prototype.reverse()`
Reverses the order of all the items in the array.
-[1,2,3].reverse();
+```javascript
+[1,2,3].reverse();
+```
-Returns [3,2,1]
.
+Returns `[3,2,1]`.
-##### Array.prototype.concat(); {#array.prototype.concat();}
+##### `Array.prototype.concat()`
-Combines two arrays, putting the items from the array in the parenthesis to the end of the main array. This method is a lot faster than grabbing each item by their index and adding them using the .push() method.
+Combines two arrays, putting the items from the array in the parenthesis to the end of the main array. This method is a lot faster than grabbing each item by their index and adding them using the `.push()` method.
-['a','b','c'].concat([1,2,3]);
+```javascript
+['a','b','c'].concat([1,2,3]);
+```
-Returns ['a','b','c',1,2,3]
.
+Returns `['a','b','c',1,2,3]`.
-##### Array.prototype.join(); {#array.prototype.join();}
+##### `Array.prototype.join()`
Converts the array into a string, with each item seperated by whatever is in the parenthesis. Useful for telling the user the items in their inventory, for example.
-
+```javascript
var inventory = ['books','apples','pencils'];
console.log("You have " + inventory.join(", ") + " in your inventory.");
-
+```
-Logs "You have books, apples, pencils in your inventory."
+Logs `"You have books, apples, pencils in your inventory."`
-##### Array.prototype.indexOf(); {#array.prototype.indexof();}
+##### `Array.prototype.indexOf()`
Similar to String.prototype.indexOf(), it returns the index of the item inside the parenthesis.
-['chicken','pizza','tacos'].indexOf('tacos');
+```javascript
+['chicken','pizza','tacos'].indexOf('tacos');
+```
-Returns 2
.
+Returns `2`.
-### Objects {#objects}
+### Objects
Objects are like arrays, however they’re easier for establishing the relationship between properties and their values. You can store any data type as a property of an object.
-
+```javascript
var player = {};
player.name = "Brandon";
player.health = Number.POSITIVE_INFINITY;
console.log(player.name + " has " + player.health + " health.");
-
+```
-Logs "Brandon has Infinity health"
Yup that sounds about right.
+Logs `"Brandon has Infinity health"`. Yup that sounds about right.
-### Conclusion {#conclusion}
+### Conclusion
-All of the different data types in Javascript are tools for you to get the job done. When assigning a variable, think to yourself which tool you should use. I had fun doing this lecture. We finished earlier than expected, due to my extra preparations. (Still shuddering over my unpreparedness from last week). We had finished so early in fact, that I went ahead and started teaching next week’s material. Do not worry though, my lovely reader’s only get the most structured of lesson materials. So you’ll have to wait until next week to hear more. 🙂
\ No newline at end of file
+All of the different data types in Javascript are tools for you to get the job done. When assigning a variable, think to yourself which tool you should use. I had fun doing this lecture. We finished earlier than expected, due to my extra preparations. (Still shuddering over my unpreparedness from last week). We had finished so early in fact, that I went ahead and started teaching next week's material. Do not worry though, my lovely readers only get the most structured of lesson materials. So you'll have to wait until next week to hear more. 🙂
\ No newline at end of file
diff --git a/content/blog/2015-10-25-functions.md b/content/blog/2015-10-25-functions.md
index ef9934a..ae89eab 100644
--- a/content/blog/2015-10-25-functions.md
+++ b/content/blog/2015-10-25-functions.md
@@ -17,9 +17,7 @@ tags: ["Web", "JS"]
---
Ever had a snippet of code that appears multiple times in different places in your program? Whenever you had to change that snippet, you end up playing this game of search and replace. Functions can help. They exist to abstract your code, making it not only easier to change that little snippet, but to read and debug your code as well.
-
-
-### How to create/execute a function {#how-to-create/execute-a-function}
+### How to create/execute a function
To make a function
@@ -35,7 +33,7 @@ To call the above function to execute
doSomething();
```
-### Arguments {#arguments}
+### Arguments
You can also add in arguments (parameters that go inside the paraenthesis next to the word function) for the functions to use.
@@ -51,13 +49,13 @@ And when you use the `return` keyword, like the function above. You can store th
var total = add(1, 3);
```
-total
here will equal `4`
+`total` here will equal `4`
-### Scope {#scope}
+### Scope
Functions create their own scope, which means that variables created inside the function will only be able available within that function.
-The snippet below will output an error like total is not defined
+The snippet below will output an error like `total is not defined`.
```javascript
var add = function(number1, number2) {
@@ -80,7 +78,7 @@ Below is a correct example of the concept
It’s also important to note that functions can use variables outside of it; granted it resides in the same scope.
-Here is an example of a variable that doesn’t reside in the same scope as the function. (The below code will fail)
+Here is an example of a variable that doesn't reside in the same scope as the function. (The below code will fail)
```javascript
var something = function() {
@@ -104,8 +102,8 @@ Below, is an example of where the variable does reside in the same scope as the
var sum = addX(6);
```
-sum
here will equal 11
+`sum` here will equal `11`
-### Conclusion {#conclusion}
+### Conclusion
As long as you name them appropriately, functions are useful for abstracting your code, making them easier to understand. This concludes another lecture made for the members over at Math I/O. Until next week 🙂
\ No newline at end of file
diff --git a/content/blog/2015-11-14-service-workers.md b/content/blog/2015-11-14-service-workers.md
index 23e296e..d1ad781 100644
--- a/content/blog/2015-11-14-service-workers.md
+++ b/content/blog/2015-11-14-service-workers.md
@@ -62,7 +62,7 @@ var offlineFundamentals = [
```
-Since cache.addAll()
hasn’t been implemented yet in any of the browsers, and the polyfill implementation didn’t work for my needs. I pieced together my own.
+Since `cache.addAll()` hasn’t been implemented yet in any of the browsers, and the polyfill implementation didn’t work for my needs. I pieced together my own.
```javascript
var updateStaticCache = function() {
@@ -85,8 +85,8 @@ var updateStaticCache = function() {
Let’s go through this chunk of code.
- 1. Open the cache called 'v2.0.24:fundamentals'
- 2. Go through all of the offlineFundamental
‘s URLs
+ 1. Open the cache called `'v2.0.24:fundamentals'`
+ 2. Go through all of the `offlineFundamental`‘s URLs
* Does the file I ask for come from the same domain as my site?
* No. Then, make the request ‘no-cors’ (I had difficulty getting my asset files in cors mode. If the cors headers are included in the response, then you can take out this line)
* Fetch the file from the network and then cache it.
@@ -140,7 +140,7 @@ self.addEventListener("activate", function(event) {
The cool thing about service worker’s is that it can handle file requests. We could cache all files requested for offline use, and if a fetch for a resource failed, then the service worker can look for it in the cache or provide an alternative. This is a large section, so I’m going to attempt to break it down as much as I can.
-## Limit the cache {#limit-the-cache}
+## Limit the cache
If the visitor started browsing all of the pages on my site, his or her cache would start to get bloated with files. To not burden my visitors, I decided to only keep the latest 25 pages and latest 10 images in the cache.
@@ -159,7 +159,7 @@ We’ll call it later in the code.
## Fetch from network and cache
-Every time I fetch a file from the network I throw it into a specific cache container. 'pages'
for HTML files, 'images'
for CSS files, and 'assets'
for any other file. This is so I can handle the cache limiting above easier. Defined within the `fetch` event.
+Every time I fetch a file from the network I throw it into a specific cache container: `'pages'` for HTML files, `'images'` for CSS files, and `'assets'` for any other file. This is so I can handle the cache limiting above easier. Defined within the `fetch` event.
```javascript
var fetchFromNetwork = function(response) {
@@ -371,4 +371,4 @@ self.addEventListener("fetch", function(event) {
self.addEventListener("activate", function(event) {
event.waitUntil(clearOldCaches())
});
-```
\ No newline at end of file
+```
diff --git a/content/blog/2015-12-22-playing-with-qr-codes.md b/content/blog/2015-12-22-playing-with-qr-codes.md
index bdd4e6d..f75beca 100644
--- a/content/blog/2015-12-22-playing-with-qr-codes.md
+++ b/content/blog/2015-12-22-playing-with-qr-codes.md
@@ -18,26 +18,21 @@ bridgy_syndication:
https://twitter.com/B_RozekJournal/status/790337750280970241
---
-Looking at Aaron Parecki’s [“Fun with QR Codes”](https://aaronparecki.com/articles/2015/10/05/1/fun-with-qr-codes) inspired me to play with QR Codes myself. Using the tool [QArt Coder](http://research.swtch.com/qr/draw) made by [Russ Cox](https://plus.google.com/116810148281701144465), I made a QR Code with my face in it!
+Looking at Aaron Parecki's [“Fun with QR Codes”](https://aaronparecki.com/articles/2015/10/05/1/fun-with-qr-codes) inspired me to play with QR Codes myself. Using the tool [QArt Coder](http://research.swtch.com/qr/draw) made by [Russ Cox](https://plus.google.com/116810148281701144465), I made a QR Code with my face in it!
-
+
-- Picture by Azad Zahoory -
-
+```javascript
/*
representative-h-card - v0.1.0
Copyright (c) 2015 Brandon Rozek
@@ -60,7 +60,7 @@ var representativeHCard = function(hCards, url) {
hCard.items = [hCards.items[0]];
return hCard
} else {
- for (var i = 0; i < hCards.items.length; i++) {
+ for (var i = 0; i < hCards.items.length; i++) {
if (urlsMatchURL(hCards.items[i], url) && (uidsMatchURL(hCards.items[i], url) || relMeMatchURL(hCards, url))) {
hCard = hCards;
hCard.items = [hCards.items[i]];
@@ -75,7 +75,7 @@ var representativeHCard = function(hCards, url) {
var urlsMatchURL = function(hCard, url) {
var urls = hCard.properties.url;
if (typeof(urls) == "object") {
- for (var i = 0; i < urls.length; i++) {
+ for (var i = 0; i < urls.length; i++) {
if (new URL(urls[i]).toString() == new URL(url).toString()) {
return true;
}
@@ -86,7 +86,7 @@ var urlsMatchURL = function(hCard, url) {
var uidsMatchURL = function(hCard, url) {
var uids = hCard.properties.uid;
if (typeof(uids) == "object") {
- for (var i = 0; i < uids.length; i++) {
+ for (var i = 0; i < uids.length; i++) {
if (new URL(uids[i]).toString() == new URL(url).toString()) {
return true;
}
@@ -97,7 +97,7 @@ var uidsMatchURL = function(hCard, url) {
var relMeMatchURL = function(microformats, url) {
var me = microformats.rels.me;
if (typeof(me) == "object") {
- for (var i = 0; i < me.length; i++) {
+ for (var i = 0; i < me.length; i++) {
if (new URL(me[i]).toString() == new URL(url).toString()) {
return true;
}
@@ -105,9 +105,9 @@ var relMeMatchURL = function(microformats, url) {
}
return false;
}
-
+```
-Next up, is making the vCard. For this, I had to look at the [vCard 4.0 specification](https://tools.ietf.org/html/rfc6350) to figure out what the property names and values are. Then I browsed around different sites (takes you to a random [Indieweb](https://indiewebcamp.com/) site) to figure out which properties are the most common.
+Next up, is making the vCard. For this, I had to look at the [vCard 4.0 specification](https://tools.ietf.org/html/rfc6350) to figure out what the property names and values are. Then I browsed around different [sites](http://indieweb.thatmustbe.us/) (takes you to a random [Indieweb](https://indiewebcamp.com/) site) to figure out which properties are the most common.
The properties I ended up adding to the vCard.
@@ -123,7 +123,7 @@ The properties I ended up adding to the vCard.
As I was browsing around, I noticed that a few people would have empty values for certain properties on their h-card. To avoid having this show up on the vCard, I added a filter that takes out empty strings.
-
+```javascript
/*
vCard-from-h-card - v0.1.0
Copyright (c) 2015 Brandon Rozek
@@ -180,7 +180,7 @@ var makeVCard = function(hCard) {
//Add IMPP (Instant Messaging and Presence Protocol)
if (typeof(impp) == "object") {
impp.removeEmptyStrings();
- for (var i = 0; i < impp.length; i++) {
+ for (var i = 0; i < impp.length; i++) {
vCard += "IMPP;PREF=" + (i + 1) + ": " + impp[i] + "n";
}
}
@@ -189,7 +189,7 @@ var makeVCard = function(hCard) {
var email = hCard.items[0].properties.email;
if (typeof(email) == "object") {
email.removeEmptyStrings();
- for (var i = 0; i < email.length; i++) {
+ for (var i = 0; i < email.length; i++) {
try {
vCard += "EMAIL: " + new URL(email[i]).pathname + "n";
} catch (e) {
@@ -238,10 +238,9 @@ var makeVCard = function(hCard) {
Array.prototype.removeEmptyStrings = function() {
return this.filter(function(i) { return i !== "" })
}
+```
-
-
-Now for the final part, making the userscript. Inspired by [Ryan Barret](https://snarfed.org/) and his userscript [Let’s Talk,](https://github.com/snarfed/misc/blob/master/userscripts/lets_talk.user.js) this userscript brings all of the above modules together. First it grabs the microformats from the page using microformat-shiv.
+Now for the final part, making the userscript. Inspired by [Ryan Barret](https://snarfed.org/) and his userscript [Let's Talk,](https://github.com/snarfed/misc/blob/master/userscripts/lets_talk.user.js) this userscript brings all of the above modules together. First it grabs the microformats from the page using microformat-shiv.
For some reason, when I tried filtering it by ‘h-card’ it froze my computer. So I wrote my own little filter instead.
@@ -249,7 +248,7 @@ After I grab the representative h-card from the page using the little module I w
The link is actually a [data uri](https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs) that has all of the information of the vCard encoded in it. Depending on your browser, once you click the link you might have to hit CTRL-S to save.
-
+```javascript
/*
show-vCard - v0.1.0
Copyright (c) 2015 Brandon Rozek
@@ -257,8 +256,8 @@ The link is actually a [data uri](https://developer.mozilla.org/en-US/docs/Web/H
*/
var filterMicroformats = function(items, filter) {
var newItems = [];
- for (var i = 0; i < items.items.length; i++) {
- for (var k = 0; k < items.items[i].type.length; k++) {
+ for (var i = 0; i < items.items.length; i++) {
+ for (var k = 0; k < items.items[i].type.length; k++) {
if (filter.indexOf(items.items[i].type[k]) != -1) {
newItems.push(items.items[i]);
}
@@ -306,16 +305,16 @@ var render = function() {
document.addEventListener("DOMContentLoaded", function() {
render();
});
-
+```
-Sadly, I have no way of controlling the file name when you save it so you’ll have to manually rename it to something more meaningful than a random string of characters. Also remember to add the extension ‘.vcf’ for it to be recognized by some devices.
+Sadly, I have no way of controlling the file name when you save it so you'll have to manually rename it to something more meaningful than a random string of characters. Also remember to add the extension ‘.vcf’ for it to be recognized by some devices.
### Conclusion
-Fire up your favorite userscript handling tool and add the [script](https://gist.github.com/brandonrozek/e0153b2733e947fa9c87) in! Of course, since it’s pure JavaScript, you can also add it to your own site to serve the same purpose.
+Fire up your favorite userscript handling tool and add the [script](https://gist.github.com/brandonrozek/e0153b2733e947fa9c87) in! Of course, since it's pure JavaScript, you can also add it to your own site to serve the same purpose.
-I ran into a small problem loading a contact onto my Android 5.0.2 phone. Apparently, they don’t support vCard 4.0 yet so I had to go into the file and change the line that says “VERSION 4.0” to “VERSION 3.0” which then allowed me to import the file into my contacts.
+I ran into a small problem loading a contact onto my Android 5.0.2 phone. Apparently, they don't support vCard 4.0 yet so I had to go into the file and change the line that says “VERSION 4.0” to “VERSION 3.0” which then allowed me to import the file into my contacts.
As with all the code I write, feel free to comment/criticize. I love hearing feedback so if you spot anything, [contact me](mailto:brozek@brandonrozek.com) 🙂
-Also posted on [IndieNews](http://news.indiewebcamp.com/en){.u-syndication}
\ No newline at end of file
+Also posted on [IndieNews](http://news.indiewebcamp.com/en){.u-syndication}
diff --git a/content/blog/2017-03-07-uniformity-math-random.md b/content/blog/2017-03-07-uniformity-math-random.md
index bb6bf64..fe4d2a2 100644
--- a/content/blog/2017-03-07-uniformity-math-random.md
+++ b/content/blog/2017-03-07-uniformity-math-random.md
@@ -31,7 +31,7 @@ HA: The random numbers outputted do not follow the uniform distribution
I wrote a small [website](http://share.zeropointshift.com/files/2017/03/random.html) and obtained my data by getting the CSV outputted when I use IE11, Firefox, and Chrome.
-The website works by producing a random number using Math.random()
between 1 and 1000 inclusive and calls the function 1,000,000 times. Storing it’s results in a file
+The website works by producing a random number using `Math.random()` between 1 and 1000 inclusive and calls the function 1,000,000 times. Storing its results in a file
This website produces a file with all the numbers separated by a comma. We want these commas to be replaced by newlines. To do so, we can run a simple command in the terminal
@@ -45,13 +45,13 @@ Here are a copy of my files for [Firefox](https://brandonrozek.com/wp-content/up
## Check Conditions
-Since we’re interested in if the random values occur uniformly, we need to perform a Chi-Square test for Goodness of Fit. With every test comes some assumptions
+Since we're interested in if the random values occur uniformly, we need to perform a Chi-Square test for Goodness of Fit. With every test comes some assumptions
-Counted Data Condition: The data can be converted from quantatative to count data.
+**Counted Data Condition:** The data can be converted from quantatative to count data.
-Independence Assumption: One random value does not affect another.
+**Independence Assumption:** One random value does not affect another.
-Expected Cell Frequency Condition: The expected counts are going to be 10000
+**Expected Cell Frequency Condition:** The expected counts are going to be 10000
Since all of the conditions are met, we can use the Chi-square test of Goodness of Fit
diff --git a/content/blog/2017-05-24-viewing-java-applets.md b/content/blog/2017-05-24-viewing-java-applets.md
index a370290..c41560a 100644
--- a/content/blog/2017-05-24-viewing-java-applets.md
+++ b/content/blog/2017-05-24-viewing-java-applets.md
@@ -18,13 +18,14 @@ tags: ["Java"]
---
When you use an IDE there are many things you can take for granted. A section of an intro level computer science course at my university uses [JGrasp](http://www.jgrasp.org/) to build Java Applets.
-Following around using a normal text editor, I found that I couldn’t just compile and run the code like I have with my java programs in the past. To be able to help around and assist in the course, I need to be able to build and run these applications. The rest of this article describes the process I underwent to be able to use my existing setup to write and build java applets. Of course you can always install JGrasp and have that all built in, but it’s always nice to not have to change your workflow.
-
-
+Following around using a normal text editor, I found that I couldn't just compile and run the code like I have with my java programs in the past. To be able to help around and assist in the course, I need to be able to build and run these applications. The rest of this article describes the process I underwent to be able to use my existing setup to write and build java applets. Of course you can always install JGrasp and have that all built in, but it's always nice to not have to change your workflow.
When I tried following along, I would receive the following error
+```
Main method not found in class HelloWorld, please define main method as...
+```
+
Which makes sense since I have never defined a main method inside my source code. So how do I go about doing this?
@@ -32,20 +33,20 @@ Which makes sense since I have never defined a main method inside my source code
Java Applets are meant to run on web pages, because of this one needs an html file to host the applet. The following code gives you the bare minimum for setting up the html file. I called it `HelloWorld.html`.
-
-<html>
- <head><title>Applet Container<title>
- <body>
- <applet code='HelloWorld.class' width=400 height=400></applet>
- </body>
-</html>
-
+```html
+;
+
+```java
import javax.swing.JApplet;
import java.awt.Graphics;
@@ -54,18 +55,22 @@ public class HelloWorld extends JApplet {
g.drawString("Hello World", 30, 30);
}
}
-
+```
## Running the Applet
Now we need to compile the code
-javac HelloWorld.java
+```bash
+javac HelloWorld.java
+```
Then run the appletviewer
-appletviewer HelloWorld.html
+```bash
+appletviewer HelloWorld.html
+```
## Conclusion
-This tutorial concludes the setup of running a simple Java applet. From here you can look at the different methods in the [Graphics library](https://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html) and play around 😀
\ No newline at end of file
+This tutorial concludes the setup of running a simple Java applet. From here you can look at the different methods in the [Graphics library](https://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html) and play around 😀
diff --git a/content/blog/2017-06-05-java-swing-components.md b/content/blog/2017-06-05-java-swing-components.md
index 665610f..5dbe6c8 100644
--- a/content/blog/2017-06-05-java-swing-components.md
+++ b/content/blog/2017-06-05-java-swing-components.md
@@ -22,41 +22,43 @@ This post, over time, will serve as a reference to myself and others of the diff
Buttons are created using the JButton component. The constructor takes the text placed inside the button.
-
+```java
JButton stopBtn = new JButton("Stop");
-
+```
+
+
-
+```java
Image img = this.getImage(this.getCodeBase(), "smallpanda.jpg");
ImageIcon imgIcon = new ImageIcon(img);
JButton feedBtn = new JButton("Feed", imgIcon);
-
+```
Sometimes, you want to change the location of the text in the button. Like say, we want to place the text in the center horizontally and bottom vertically.
-
+```java
feedBtn.setHorizontalTextPosition(JButton.CENTER);
feedBtn.setVerticalTextPosition(JButton.BOTTOM);
-
+```
-Don’t forget to add your buttons to the screen!
+Don't forget to add your buttons to the screen!
-
+```java
this.add(stopBtn);
this.add(feedBtn);
-
+```
+
+
-
+```java
JLabel nameLabel = new JLabel("Enter in your name: ");
// Create an input and set the width to be 10px wide
@@ -67,28 +69,30 @@ One of the most common forms of input is a text field, usually distinguished wit
this.add(nameLabel);
this.add(nameInput);
-
+```
+
+
-
+```java
JCheckBox pizza = new JCheckBox("Pizza");
JCheckBox noodles = new JCheckBox("Noodles");
JCheckBox rice = new JCheckBox("Rice");
this.add(pizza);
this.add(noodles);
this.add(rice);
-
+```
-
+You can even replace the default look of the checkbox with an image. To do this, you need to make image icons for both when it's checked and when it's unchecked.
+
+```java
Image checkedImage = this.getImage(this.getCodeBase(), "checked.png");
Image uncheckedImage = this.getImage(this.getCodeBase(), "unchecked.png");
@@ -99,32 +103,33 @@ JCheckBox checkbox = new JCheckBox("Check Me", uncheckedIcon);
checkbox.setSelectedIcon(checkedIcon);
this.add(checkbox);
-
+```
+
+
+
-
+```java
JTextArea textarea = new JTextArea(10, 10);
-
+```
-By default, when the someone inputs more text than the size can hold, it will automatically grow with the text inputted. To override this behaviour and instead introuduce scroll bars. One must define a ScrollPane and put the TextArea inside of it by using it as the scroll pane’s argument for its constructor.
+By default, when the someone inputs more text than the size can hold, it will automatically grow with the text inputted. To override this behaviour and instead introuduce scroll bars. One must define a ScrollPane and put the TextArea inside of it by using it as the scroll pane's argument for its constructor.
-
+```java
JScrollPane scrollPane = new JScrollPane(textarea);
-
+```
-
+```java
// Make the radio buttons
JRadioButton radio1 = new JRadioButton("Pies");
JRadioButton radio2 = new JRadioButton("Cakes");
@@ -140,55 +145,56 @@ desserts.add(radio3);
this.add(radio1);
this.add(radio2);
this.add(radio3);
-
+```
+
+
-
+```java
DefaultListModel model = new DefaultListModel();
JList list = new JList(model);
-
+```
To add scrolling capabilities, remember to add it to a scroll pane
-
+```java
JScollPane sp = new JScrollPane(list);
-
+```
You can set the number of items you wish to see in the list. The example below, allows us to see three items in the list.
-
+```java
list.setVisibleRowCount(3);
-
+```
There are a variety of ways to add items to the list. If a number is specified that tells it to place it at the index specified. Starting from the top at zero, to the button.
-
+```java
model.addElement("Apples")
model.addElement("Cherries");
model.addElement("Bananas");
// Adds 'Oranges' to the top
model.add(0, "Oranges");
-
+```
-Sometimes, you want to only let the user select one item. At the end, don’t forget to add the component to the screen!
+Sometimes, you want to only let the user select one item. At the end, don't forget to add the component to the screen!
-
+```java
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.add(sp);
-
+```
-
+```java
JComboBox cb = new JComboBox();
cb.addItem("Select Food Option");
cb.addItem("Pizza");
@@ -197,6 +203,6 @@ cb.addItem("Hot Dog");
cb.addItem("Steak");
// Add it to the screen
this.add(cb);
-
+```
-
+```java
try {
UIManager.setLookAndFeel(UIManager
.getSystemLookAndFeelClassName());
} catch(Exception e) {}
-
+```
Here the application will attempt to look up the system theme and set that as the default styles for the Swing components. If the lookup fails, then it will default back to the metal theme.
@@ -37,6 +37,6 @@ For more information, check out this page from [Oracle](http://docs.oracle.com/j
### Discussion
-If it is so easy to set up applications that look native to each desktop environment, why not have that by default? With the cross platform metal theme, you can ensure that the style of your application is the same across all the operating systems. In this fashion, you don’t need to worry about spacing between components and have full control of the “look and feel” of your application.
+If it is so easy to set up applications that look native to each desktop environment, why not have that by default? With the cross platform metal theme, you can ensure that the style of your application is the same across all the operating systems. In this fashion, you don't need to worry about spacing between components and have full control of the “look and feel” of your application.
-Since I am used to development for the web, I don’t have strong motivation to have an application look the same on all platforms. I prefer the application to match the system theme and look like it was built for the platform that I am on. One loses partial control on the presentation of your application across different desktop environmnets, but with a strong layout, it is possible to make it look organized and integrated.
\ No newline at end of file
+Since I am used to development for the web, I don't have strong motivation to have an application look the same on all platforms. I prefer the application to match the system theme and look like it was built for the platform that I am on. One loses partial control on the presentation of your application across different desktop environmnets, but with a strong layout, it is possible to make it look organized and integrated.
diff --git a/content/blog/2018-01-22-identifying-misspelled-words-dataset-hunspell.md b/content/blog/2018-01-22-identifying-misspelled-words-dataset-hunspell.md
index 5f0ff29..65afd61 100644
--- a/content/blog/2018-01-22-identifying-misspelled-words-dataset-hunspell.md
+++ b/content/blog/2018-01-22-identifying-misspelled-words-dataset-hunspell.md
@@ -14,7 +14,7 @@ mf2_syndication:
- 'a:1:{i:0;s:60:"https://twitter.com/B_RozekJournal/status/955308388384235521";}'
tags: []
---
-This article is based on one written by [Markus Konrad](https://datascience.blog.wzb.eu/author/markus_konrad/) at this link https://datascience.blog.wzb.eu/2016/07/13/autocorrecting-misspelled-words-in-python-using-hunspell/
+This article is based on one written by [Markus Konrad](https://datascience.blog.wzb.eu/author/markus_konrad/) at this link [https://datascience.blog.wzb.eu/2016/07/13/autocorrecting-misspelled-words-in-python-using-hunspell/](https://datascience.blog.wzb.eu/2016/07/13/autocorrecting-misspelled-words-in-python-using-hunspell/).
I assume in this article that you have hunspell and it's integration with python installed. If not, please refer to the article mention above and follow the prerequisite steps.
@@ -24,8 +24,10 @@ This article is inspired from the need to correct misspelled words in the [Dress
Misspelled words are common when dealing with survey data or data where humans type in the responses manually. In the Dress Attributes Dataset this is apparent when looking at the sleeve lengths of the different dresses.
-dresses_data['SleeveLength'].value_counts()
-
from hunspell import HunSpell
-spellchecker = HunSpell('/usr/share/hunspell/en_US.dic', '/usr/share/hunspell/en_US.aff')
-
+```python
+from hunspell import HunSpell
+spellchecker = HunSpell('/usr/share/hunspell/en_US.dic', '/usr/share/hunspell/en_US.aff')
+```
I modified his `correct_words` function so that it only corrects one word and so I can `apply` it along the `SleeveLength` column.
-def correct_word(checker, word, add_to_dict=[]):
+```python
+def correct_word(checker, word, add_to_dict=[]):
"Takes in a hunspell object and a word and corrects the word if needed"
# Add custom words to the dictionary
for w in add_to_dict:
checker.add(w)
corrected = ""
- # Check to see if it's a string
+ # Check to see if it's a string
if isinstance(word, str):
# Check the spelling
ok = checker.spell(word)
@@ -89,15 +93,17 @@ I modified his `correct_words` function so that it only corrects one word and so
## Not a string. Return original
corrected = word
return corrected
-
+```
Now let's apply the function over the `SleeveLength` column of the dataset:
-dresses_data['SleeveLength'] = dresses_data['SleeveLength'].apply(
- lambda x: correct_word(spellchecker, x))
-
+```python
+dresses_data['SleeveLength'] = dresses_data['SleeveLength'].apply(
+ lambda x: correct_word(spellchecker, x)
+)
+```
-Doing so creates the following series:def list_word_suggestions(checker, words, echo = True, add_to_dict=[]):
+```python
+def list_word_suggestions(checker, words, echo = True, add_to_dict=[]):
"Takes in a list of words and returns a dictionary with mispellt words as keys and suggestions as a list. Also prints it out"
# add custom words to the dictionary
for w in add_to_dict:
@@ -141,34 +148,37 @@ Keeping that in mind, I modified the function again to take in a list of the dat
elif echo:
print(word + ": " + "[", ", ".join(repr(i) for i in suggestions[word]), "]")
return suggestions
-
+```
With that, I can use the function on my data. To do so, I convert the pandas values to a list and pass it to the function:
-s = list_word_suggestions(spellchecker, dresses_data['SleeveLength'].values.tolist())
-
+```python
+s = list_word_suggestions(spellchecker, dresses_data['SleeveLength'].values.tolist())
+```
These are the suggestions it produces:
-sleevless: [ 'sleeveless', 'sleepless', 'sleeves', 'sleekness', 'sleeve', 'lossless' ]
-threequarter: [ 'three quarter', 'three-quarter', 'forequarter' ]
-halfsleeve: ['half sleeve', 'half-sleeve', 'sleeveless' ]
+```
+sleevless: [ 'sleeveless', 'sleepless', 'sleeves', 'sleekness', 'sleeve', 'lossless' ]
+threequarter: [ 'three quarter', 'three-quarter', 'forequarter' ]
+halfsleeve: ['half sleeve', 'half-sleeve', 'sleeveless' ]
turndowncollor: No suggestions
-threequater: [ 'forequarter' ]
-capsleeves: [ 'cap sleeves', 'cap-sleeves', 'capsules' ]
-sleeevless: [ 'sleeveless', 'sleepless', 'sleeves', 'sleekness', 'sleeve' ]
-urndowncollor: [ 'landownership' ]
-thressqatar: [ 'throatiness' ]
-sleveless: [ 'sleeveless', 'levelness', 'valveless', 'loveless', 'sleepless' ]
-
+threequater: [ 'forequarter' ]
+capsleeves: [ 'cap sleeves', 'cap-sleeves', 'capsules' ]
+sleeevless: [ 'sleeveless', 'sleepless', 'sleeves', 'sleekness', 'sleeve' ]
+urndowncollor: [ 'landownership' ]
+thressqatar: [ 'throatiness' ]
+sleveless: [ 'sleeveless', 'levelness', 'valveless', 'loveless', 'sleepless' ]
+```
From here, you can analyze the output and do the replacements yourself:
-dresses_data['SleeveLength'].replace('sleevless', 'sleeveless', inplace = True)
-
+```python
+dresses_data['SleeveLength'].replace('sleevless', 'sleeveless', inplace = True)
+```
### What's the Benefit?
This is where you ask "What's the difference if it doesn't automatically fix my data?"
-When you have large datasets, it can be hard to individually identify which items are misspelled. Using this method will allow you to have a list of all the items that are misspelled which can let you deal with it in a systematic way.
\ No newline at end of file
+When you have large datasets, it can be hard to individually identify which items are misspelled. Using this method will allow you to have a list of all the items that are misspelled which can let you deal with it in a systematic way.
diff --git a/content/blog/abstractdef.md b/content/blog/abstractdef.md
index c761611..9683b7d 100644
--- a/content/blog/abstractdef.md
+++ b/content/blog/abstractdef.md
@@ -71,9 +71,9 @@ An ideal $J$ of a commutative ring is said to be a **prime ideal** if for any tw
$$
ab \in J \implies a \in J \text{ or } b \in J
$$
-Theorem: If $J$ is a prime ideal of a community ring with unity $A$, then the quotient ring $A / J$ is an integral domain.
+**Theorem:** If $J$ is a prime ideal of a community ring with unity $A$, then the quotient ring $A / J$ is an integral domain.
An ideal $J$ of $A$ with $J \ne A$ is called a **maximal ideal** if there exists no proper ideal $K$ of $A$ such that $J \subseteq K$ with $J \ne K$.
-Theorem: If $A$ is a commutative ring with unity, then $J$ is a maximal ideal of $A$ iff $A/J$ is a field.
+**Theorem:** If $A$ is a commutative ring with unity, then $J$ is a maximal ideal of $A$ iff $A/J$ is a field.
diff --git a/content/blog/albuquerque.md b/content/blog/albuquerque.md
index d8a288d..167a2de 100644
--- a/content/blog/albuquerque.md
+++ b/content/blog/albuquerque.md
@@ -76,31 +76,31 @@ coefficients of CUST2 and the y-intercept.
##### Checking the Conditions for Inference
Before we conclude with the analysis, we must first check the conditions for inference to see if the technique is appropriate for our data.
-Independence Assumption:
+**Independence Assumption:**
A house’s selling price can depend on another’s so this condition is not met.
-Randomization Condition:
+**Randomization Condition:**
The dataset is comprised of a random sample of records of resale of homes which satisfies the
randomization condition.
-Straight Enough Condition:
+**Straight Enough Condition:**
The scatterplot matrix in Figure 20 shows that for the predictors square footage and tax that the
scatterplot is straight enough and doesn’t have any bends or curves.
-Equal Variance Assumption:
+**Equal Variance Assumption:**
The residual analysis in Figure 21 shows that the outliers are not spread equally on the
scatterplot. Therefore, the equal variance assumption is not met.
-Nearly Normal Condition:
+**Nearly Normal Condition:**
The QQ-Plot in Figure 21 shows that the residuals follow a unimodal and symmetric distribution.
Taking out the outliers in the model also did not introduce any new outliers in the boxplot.
-Missing At Random Condition:
+**Missing At Random Condition:**
7The discussion in the descriptive statistics section about the missing data tells us that the data
is missing evenly with respect to the different variables. Therefore, it is safe to assume that the
data is missing at random
-Multicollinearity Condition:
+**Multicollinearity Condition:**
All of the VIF values are lower than 10, therefore this condition is met.
-The conditions for inference are not fully met due to the equal variance assumption. This means that our model will be more inaccurate for some price range of homes than others. Looking at our residual analysis, it appears that the inaccuracies happen when the price of the home is higher. There weren’t many outliers in the dataset (6 out of 117 or 5%) so removing these outliers makes the model more representative to the majority of the houses in the market. Since this model is intended to be used when analyzing prices of homes in the area, it is better not to include the outliers that most people don’t intend to buy. Since the error term is unimodal and symmetric, we can be at ease that there isn’t any other confounding factor in our model. Overall, this is a good model to use for inference and prediction as long as one doesn’t use it to describe the outliers.
+The conditions for inference are not fully met due to the equal variance assumption. This means that our model will be more inaccurate for some price range of homes than others. Looking at our residual analysis, it appears that the inaccuracies happen when the price of the home is higher. There weren’t many outliers in the dataset (6 out of 117 or 5%) so removing these outliers makes the model more representative to the majority of the houses in the market. Since this model is intended to be used when analyzing prices of homes in the area, it is better not to include the outliers that most people don't intend to buy. Since the error term is unimodal and symmetric, we can be at ease that there isn’t any other confounding factor in our model. Overall, this is a good model to use for inference and prediction as long as one doesn’t use it to describe the outliers.
### Conclusion
The multiple imputation model without outliers is the best model outlined in this paper for describing the price of housing in this region. The formula is re-expressed here
PRICE = 76.47917 + 0.64130(TAX) + 0.27290(SQFT) + 77.58816(CUST2)
-This states that for every dollar of tax spent on the home, the home increases on average by $64 given the other parameters stay constant. The same concept applies to square footage and custom design. For every square foot added to the home, the value of it increases on average by $27. Having a home with a custom design increases the value of the home by $7700. This model is more reliable the lower the price of the home is. When it comes to high cost homes, the error produced by the model increases. From this model, we conclude that property tax, square footage, and whether or not a home is built from a custom design are the most significant factors in the price of a home in Albuquerque, New Mexico.
\ No newline at end of file
+This states that for every dollar of tax spent on the home, the home increases on average by $64 given the other parameters stay constant. The same concept applies to square footage and custom design. For every square foot added to the home, the value of it increases on average by $27. Having a home with a custom design increases the value of the home by $7700. This model is more reliable the lower the price of the home is. When it comes to high cost homes, the error produced by the model increases. From this model, we conclude that property tax, square footage, and whether or not a home is built from a custom design are the most significant factors in the price of a home in Albuquerque, New Mexico.
diff --git a/content/blog/introrfpoweramp.md b/content/blog/introrfpoweramp.md
index 0b77d2d..8c0bedc 100644
--- a/content/blog/introrfpoweramp.md
+++ b/content/blog/introrfpoweramp.md
@@ -18,7 +18,7 @@ I opened up mini-circuits and was greeted with the following table. (Shorted for
| LZV-22+ | 0.1 | 200 | 43 | 8.9 | 42 | 52 | 1.4 | 4 | 24 | 6000 |
| ZHL-1W-63-S+ | 600 | 6000 | 35 | 12 | 30 | 35 | 2.5 | 3.5 | 15 | 1000 |
-Definitions
+### Definitions
F Low: Lowest frequency supported by the power amplifier
diff --git a/content/blog/male-vs-female-life-expectancy.md b/content/blog/male-vs-female-life-expectancy.md
index 2755d5a..1442309 100644
--- a/content/blog/male-vs-female-life-expectancy.md
+++ b/content/blog/male-vs-female-life-expectancy.md
@@ -14,7 +14,6 @@ tags: ["Statistics"]
It is well known that females live longer than males, but does that statement hold statistically? Matthew Martinez and I set out to find out.
-
## Population and the hypothesis
@@ -26,7 +25,7 @@ HA: The average female life expectancy is higher than the average male life expe
## Data preparation
-Since the website gives us an overlook at all of the counties in the United States we want to take a small sample of that so we can perform statistics. Using the entire dataset will result in looking at population parameters which doesn’t leave room for inference.
+Since the website gives us an overlook at all of the counties in the United States we want to take a small sample of that so we can perform statistics. Using the entire dataset will result in looking at population parameters which doesn't leave room for inference.
A random number was chosen to pick the state and then the county. This was done a total of 101 times. The CSV file is located [here](https://brandonrozek.com/wp-content/uploads/2017/03/LifeExpectancy.csv) for convenience.
@@ -46,9 +45,9 @@ femaleExpectancy = LifeExpectancy$Life.Expectancy.Female
## Summary Statistics
-Before we begin our inferential statistics, it is a good idea to look at what we have in our sample. It will give us a good feeling for what we’re working with and help us answer some questions involving the assumptions in parametric tests.
+Before we begin our inferential statistics, it is a good idea to look at what we have in our sample. It will give us a good feeling for what we're working with and help us answer some questions involving the assumptions in parametric tests.
-We’re interested in the minimum, mean, maximum, and interquartile range of the data
+We're interested in the minimum, mean, maximum, and interquartile range of the data
```R
# Summary statistics
@@ -65,7 +64,7 @@ Looking at the table below, we can see that the average male lives to be around
summary
## Min Mean Max IQR
## Male 69.0 74.952 80.9 2.775
-## Female 76.1 80.416 84.1 2.350
+## Female 76.1 80.416 84.1 2.350
```
## Inferential Statistics
@@ -78,11 +77,11 @@ Since our data is quantitative in nature, we will attempt to perform a two sampl
Performing a t-test comes with several assumptions we need to check before confidently reporting our results.
-Independence Condition: One county’s life span does not affect the lifespan of another.
+**Independence Condition:** One county's life span does not affect the lifespan of another.
-Independent groups assumption: The lifespan of a male does not directly impact a lifespan of a female.
+**Independent groups assumption:** The lifespan of a male does not directly impact a lifespan of a female.
-Nearly Normal Condition: We need to check the histograms to see if they’re unimodal and symmetric and check to see if any outliers exist
+**Nearly Normal Condition:** We need to check the histograms to see if they're unimodal and symmetric and check to see if any outliers exist
The male life expectancy distribution appears to be unimodal and symmetric.
@@ -91,7 +90,7 @@ The male life expectancy distribution appears to be unimodal and symmetric.
hist(maleExpectancy, main = "Male Life Expectancy", xlab = "Age")
```
-