Terry

Manipulating Data Frames in R

Learn To Manipulate Data Frames Using The “mtcars” Dataset

Task 1: Create a new column to find Displacement per Cylinder 

Create a new variable (DisplacementPerCylinder), to calculate the total displacement per cylinder in cubic inches for each vehicle from the mtcars dataset.

# "str" allows you to display the internal structure of an R object
str(mtcars) 
## 'data.frame':    32 obs. of  11 variables:
##  $ mpg : num  21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
##  $ cyl : num  6 6 4 6 8 6 8 4 4 6 ...
##  $ disp: num  160 160 108 258 360 ...
##  $ hp  : num  110 110 93 110 175 105 245 62 95 123 ...
##  $ drat: num  3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
##  $ wt  : num  2.62 2.88 2.32 3.21 3.44 ...
##  $ qsec: num  16.5 17 18.6 19.4 17 ...
##  $ vs  : num  0 0 1 1 0 1 0 1 1 1 ...
##  $ am  : num  1 1 1 0 0 0 0 0 0 0 ...
##  $ gear: num  4 4 4 3 3 3 3 4 4 4 ...
##  $ carb: num  4 4 1 1 2 1 4 2 2 4 ...
# As a backup we can copy the original data frame into a new one to work with
# That way if there is any issues we can go back

my_mtcars <- mtcars
# Calculate Displacement Per Cylinder by dividing the values (disp) and (cyl)

my_mtcars$DisplacementPerCylinder <- my_mtcars$disp / my_mtcars$cyl

# Report a summary of the variable
summary(my_mtcars$DisplacementPerCylinder)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   17.77   26.92   34.48   35.03   43.19   59.00

Task 2: Create your own data frame

Gather data from family & friends on the number of pets they have, the birth order they are in their family and the number of siblings. 

# Family/Friends ID
friendID  <- c(1, 2, 3, 4, 5)

# Number of pets they have
Pets <- c(4, 4, 2, 3, 1)

# The birth order they are in their family
Order <- c(1, 2, 2, 1, 1)

# Number of Siblings 
Siblings <- c(2, 2, 1, 2, 0)

# Binding the vectors into a data frame called myFriends
myFriends <- data.frame(friendID, + Pets, + Order, + Siblings)

# Command to report the structure of the data frame myFriends
str(myFriends)

## 'data.frame':    5 obs. of  4 variables:
##  $ friendID  : num  1 2 3 4 5
##  $ X.Pets    : num  4 4 2 3 1
##  $ X.Order   : num  1 2 2 1 1
##  $ X.Siblings: num  2 2 1 2 0
# Rename the columns to get rid of the "x." in front of the names
colnames(myFriends) <- c("FriendID", "Pets", "Order", "Siblings")
str(myFriends)
## 'data.frame':    5 obs. of  4 variables:
##  $ FriendID: num  1 2 3 4 5
##  $ Pets    : num  4 4 2 3 1
##  $ Order   : num  1 2 2 1 1
##  $ Siblings: num  2 2 1 2 0
# Listing the values of the vector friendID from the data frame myFriends
myFriends$FriendID 
## [1] 1 2 3 4 5
# Listing the values of the vector Pets from the data frame myFriends
myFriends$Pets
## [1] 4 4 2 3 1
# Listing the values of the vector Order from the data frame myFriends
myFriends$Order
## [1] 1 2 2 1 1
# Listing the values of the vector Siblings from the dataframe myFriends
myFriends$Siblings
# [1] 2 2 1 2 0
# Report a summary of the dataframe
summary(myFriends)
##     FriendID      Pets         Order        Siblings  
##  Min.   :1   Min.   :1.0   Min.   :1.0   Min.   :0.0  
##  1st Qu.:2   1st Qu.:2.0   1st Qu.:1.0   1st Qu.:1.0  
##  Median :3   Median :3.0   Median :1.0   Median :2.0  
##  Mean   :3   Mean   :2.8   Mean   :1.4   Mean   :1.4  
##  3rd Qu.:4   3rd Qu.:4.0   3rd Qu.:2.0   3rd Qu.:2.0  
##  Max.   :5   Max.   :4.0   Max.   :2.0   Max.   :2.0
SolaceCoin

SolaceCoin: Helping Others One Block At A Time

SolaceCoin:

SolaceCoin was created to help charities while also serving as a currency for daily usage.

How it works

6% of each block mined will be given the “Dev wallet”

30% of which will go to the charity wallet. the rest will be used to get listed on exchanges and support continuing development.

These coins will be slowly released to exchanges and the proceeds will be donated to a charity.
Charities are chosen by the community through voting.

Driven by CryptoNote: Anonymous transactions, no public ledger; used by other coins such as Monero

“SolaceCoin is a Crypto Currency waiting to make the world a better place one block at a time”

Specs:

Algorithm: Cryptonight Heavy

Block Window Time: 60 Seconds

Total Supply: 21 Billion

Block reward +- 6000 as block reward varies

Using Camel distribution: Accelerates over years with the block reward changing every month.

Forked from the Ombre team

Wallet: https://www.solace-coin.com/getting-started/

CPU and GPU Mining supported

XMR-STAK

XMRIG

xbox controller

PC Build to Compete with Xbox One X

How does the Xbox One X compare to a gaming computer?

 Xbox One X Specs:

CPU: 8 custom x86 cores clocked at 2.3GHz

GPU: 40 customized compute units at 1172MHz

Memory: 12GB GDDR5

Hard Drive: 1TB 2.5-inch

Optical Drive: 4k UHD Blu-ray

Xbox One X

 

Things to remember:

On the Xbox One X, the hardware and software will be tightly integrated allowing the hardware to be fully optimized. The memory will be split up with not all going to the GPU but some will be used as the systems ram. The optical drive that comes with the Xbox is a top of the line piece of hardware that is truly impressive to be included.

Budget Version:

Type

Item

Price

CPU

AMD – Ryzen 3 1200 3.1GHz Quad-Core Processor

$99.99 @ Amazon

Motherboard

ASRock – AB350 Pro4 ATX AM4 Motherboard

$73.98 @ Newegg

Memory

G.Skill – Ripjaws V Series 8GB (2 x 4GB) DDR4-3200 Memory

$105.99 @ Newegg

Storage

Western Digital – Caviar Blue 1TB 3.5″ 7200RPM Internal Hard Drive

$41.77 @ OutletPC

Video Card

PowerColor – Radeon RX 580 8GB Red Devil Video Card

$288.99 @ SuperBiiz

Case

DIYPC – P48-W ATX Mid Tower Case

$24.98 @ Newegg

Power Supply

EVGA – 500W 80+ Bronze Certified ATX Power Supply

$41.39 @ OutletPC

Optical Drive

LG – WH14NS40 Blu-Ray/DVD/CD Writer

$46.29 @ OutletPC

Total (before mail-in rebates)

$753.38

Mail-in rebates

-$30.00

Total

$723.38

You could save money on this build if you wanted to go with slower ram, ( Please Note: Ryzen processors do much better with faster memory). The issues you will find with this build will be the optical drive not being able to compete with the optical drive found on the Xbox. The Xbox drive is capable of reading 4k discs.

If you will run Windows on the computer that could run you another $100, or you can run any Linux distro for free.

Preferred build for budget 4k 30 fps

 

Type

Item

Price

CPU

AMD – Ryzen 7 1700 3.0GHz 8-Core Processor

$284.99 @ Amazon

Motherboard

ASRock – X370 KILLER SLI/ac ATX AM4 Motherboard

$123.98 @ Newegg

Memory

G.Skill – Ripjaws V Series 16GB (2 x 8GB) DDR4-3200 Memory

$189.80 @ Amazon

Storage

Samsung – 960 EVO 250GB M.2-2280 Solid State Drive

$124.99 @ Amazon

Storage

Western Digital – Caviar Blue 1TB 3.5″ 7200RPM Internal Hard Drive

$41.77 @ OutletPC

Video Card

XFX – Radeon RX VEGA 56 8GB Video Card

$469.99 @ Best Buy

Case

DIYPC – P48-W ATX Mid Tower Case

$24.98 @ Newegg

Power Supply

EVGA – SuperNOVA P2 850W 80+ Platinum Certified Fully-Modular ATX Power Supply

$103.98 @ Newegg

Optical Drive

LG – WH14NS40 Blu-Ray/DVD/CD Writer

$46.29 @ OutletPC

Total (before mail-in rebates)

$1,465.77

Mail-in rebates

-$55.00

Total

$1,410.77

 

This build prices out to $1410 after mail in rebates which is almost $1,000 more than the Xbox One X. Plus add in if you want a Windows operating system and/or a better optical drive.

With a stronger 8-core, 16 thread Ryzen CPU you won’t find any CPU bottlenecks. This build also includes the new Samsung 960 M.2 drive offering much fast read and write speeds which will help loading times for games. Included in this build is the new AMD Vega 56 GPU offering a much smoother display especially when paired with a Freesync monitor.

KEY BUILD NOTES:

CPU: AMD Ryzen 7 1700
  • This CPU rocks a true 8 core processor with 16 total threads. You will not see any bottlenecking of the CPU with any games you can throw at it and if a game is optimized to use more cores then be ready to see this show its true power.
RAM: G.Skill – Ripjaws V Series 16GB (2 x 8GB) DDR4-3200 Memory
  • Knowing Ryzen processors do much better with a higher speed ram we went with DDR4 – 32oo
  • We added another 8GB of ram to make it 16gb to make sure you won’t have any issues running games.
Storage: Samsung 960 EVO 250GB M.2-2280 SSD

With the drive capacity only being 250GB we would recommend running the OS on this drive as well as any games/ applications you mainly use. Anything else you can throw on the 1 TB spinning hard drive also included.

  • Max read/write speeds up to 3200/1500 MBps
Graphics Card: XFX – Radeon RX VEGA 56 8GB Video Card

AMD’s newest line of GPUs the VEGA series includes the 56 and 64 VEGA. This build includes the 56 version which is capable of running 4k with at least 30 fps.

Power Supply: EVGA – SuperNOVA P2 850W 80+ Platinum Certified Fully-Modular ATX Power Supply

This build we went with a higher quality PSU that was certified platinum and fully modular allowing an easier build time and cleaner cable management.

The Verdict:

The Xbox One X is priced very well for the amount of power you’re getting. Pair it with a new 4k Freesync monitor and you will really be able to tell a difference. Some say the jump in resolution feels more like going from 480p to 720p rather than the last jump of 720p to 1080p.

 

Do you think you can build a better computer priced closer to $500 ? Let me know and show me what you got!

 

 

raspberry-pi

Implementing a Raspberry Pi into a small business

Abstract:

Technology has become a complex beast for businesses to handle in the modern age. Especially small businesses that rely on technology for their daily workday. Businesses tend to think that complex systems are better than a simple solution. That is not always the case; often simple solutions can cut costs and produce benefits. A great example of this would be a Raspberry Pi computer. Utilizing a Raspberry Pi as a database and web server for a small business is a simple solution that has greater benefits than trying to run a complex solution where other companies are required to provide a service. Such benefits include the low cost of operation, control, and security of business information.

To be able to build a Raspberry Pi capable of this task will require a LAMP (Linux, Apache, MySQL, PHP) software stack. Once configured to the specific business needs the outcome will be a fully functioning web server graphical user interface (GUI) that will be connected on the back end to a MySQL database.

 The Project

As technology evolves, businesses continue looking for new ways to provide benefits at cheaper costs. Small businesses typically have a major disadvantage compared to corporations because of their lack of capital to invest in new technology. If a small business needs to have an operating database or server, they could be looking at spending thousands of dollars, if not more, to pay for a service company to create and support their database.

The Raspberry Pi computer could eliminate the need for an outside company, and in doing so could help a business to save on expenses. In recent years, the security of some of the world’s biggest companies has been breached. In this new era of business, a major concern is the security of the company’s information, as well as the customer’s information. For small businesses, this is especially complicated, because unlike major corporations, they don’t have the same resources to fight or fix any security issues. Thinking in these terms, running a Raspberry Pi is a great way to ensure that the company is secure because it holds all of its information on site.

*The small business that will be the focus of this project is a local lacrosse equipment store in a typical suburban town. This business is looking to get away from paper files, files that include information on employees, customers, and products. They would like everything to be in one place in order to reduce the time spent searching for documents. Previously, They have looked into buying cloud-based databases as well as storage services from a corporate company, but the expenses are too high for the business to absorb.*

What is a Raspberry Pi Computer?

A Raspberry Pi computer is a single-board computer that is about the size of a deck of playing cards. Inside this small board is everything necessary for a computer, even including an HDMI port for display and USB ports for peripherals. There are many benefits to using a Pi computer instead of just an ordinary desktop. First, Raspberry Pi computers are very inexpensive; prices range from five to thirty-five dollars. Various attachments and configurations, though not needed, can be purchased for additional costs. For this project, the basics of the Raspberry Pi 2 model B, and a case for the card were used. This put us at a total cost of approximately forty dollars. Raspberry Pi computers are often programmed to run autonomous programs; here we will be using software to turn the Pi into a small database and web server.

The objective of the Project:

The objective of this project is to provide a new cost-efficient way for smaller businesses to manage their own databases while still having complete control. The Raspberry Pi will be a headless unit that is able to run a database and can be accessed by any computer on the network. There will also be a web server connected to the database through a local website, making it simpler to use. This will allow employees with no knowledge of SQL to easily add, delete, or search the database.

Scope and Limitations:

Scope:

The Raspberry Pi computer is designed to benefit smaller businesses by fulfilling the roles of both a database and a web server. It is great for a business that wants a low overhead, or one that is low on space. A larger company could also use Raspberry Pi computers, as each one could be designed for a small project, and then connected with others. For this specific project, a low cost and secure device is a perfect fit for the business.

Limitations:

A business would need an employee that knows how to set up the device, and knows MySQL language. Or, a contractor would need to be hired to come in and set up the system. The major limitation of using a Pi computer is that the processing power is lower than that of a normal computer. This means that the database cannot handle a lot of people using it at the same time. User overload could become problematic.

Requirements:

• At least an 8GB SD card (can be larger)

• Raspberry Pi 2 B Computer

• A case for the Pi (Not Required but highly recommended)

• USB WiFi stick or an Ethernet connection

Software:

Operating System: Raspbian (Kernel version 4.4)

Database Software: MySQL (Version 5.5)

Server Software: Apache (Version 2.4)

PHP (Version 5.6)

Hardware:

Raspberry Pi: Raspberry Pi 2 Model B

Pi Case: Raspberry Pi Case (Black) fits Raspberry Pi 3, 2 and B+

Wi-Fi USB adapter: CanaKit Raspberry Pi WiFi Wireless Adapter / Dongle (802.11 n/g/b 150 Mbps)

SD Card: Lexar microSDHC 16GB

The Raspberry Pi was built using a 16GB SD card; you can upgrade all the way up to a 64 GB, but for this build a 16GB was sufficient. The first task was to install an operating system on the SD card. In order to do this, the SD card was plugged into the SD reader on my Mac. Then the operating system (OS) Raspbian was installed. Raspbian is similar to most Linux operating systems but is specific to Raspberry Pi.

Once the OS was installed on the SD card, it was then plugged into the Pi and turned on. Once turned on, it was time to install updates in order to ensure that software running was the newest version.

Since this Pi will be running off WiFi, you will need to manually change the network configuration files to allow this. At this time,  it would be best to give the Pi a static IP address, so that anytime it is restarted, it would still be found under the same IP.

The last thing physically done at the Pi when connected to a monitor and keyboard was to enable SSH. Once enabled, I could then continue building the project from any computer on the same network.

Database Design:

Raspberry Pi MySQL Database Example

• An admin table only non-connected table used to login to the web server to make changes to the database.
• The employee table is connected to transaction with Employee_ID.
• Customer is connected to Transaction with Customer_ID.
• Product is connected to both Transaction and Supplier by Product_ID.

Building the database using MySQL.

First, the structure of the database was built, including the tables that were going to be used. Then deciding on the primary keys and foreign keys, which allow the tables to be connected and have relations with each other. Lastly, the database was filled with data in order to do some testing, checking to make sure that everything was working in the correct way. Testing was conducted by running queries and making sure that the information that came back was as expected and that the primary and foreign keys were working properly.

After building the database

It’s time to build a web server that would have the MySQL database incorporated into it and could run from the Raspberry Pi. The server will be running Apache server and will be using both HTML and PHP code. The server will also be secured by having employees log in with their given username and password.

Prototype

The finished prototype is a functioning server that will house the company’s database and the web GUI used to access and edit the database. The Pi will already have a LAMP stack installed. The actual physical product will be a simple Raspberry Pi card, housed in a case for safety. Attached to the device will be either an Ethernet cord or a WiFi USB adapter, depending on what works best in the specific environment. The device will then have a micro USB power cord connected.

Implementation Plan

The first step to actually implementing the device is to gather information beforehand. I want to find out if the device will be connected with Ethernet or WIFI; if WIFI is chosen, then we must change the networking configuration and will need a USB WIFI adapter
Once the hardware is all set we can move on to the software necessary. On the Raspberry Pi should be a LAMP stack already installed and ready to begin. We will need to make some changes to the Apache configuration files to make sure the web server works correctly. We will need to set the IP address and create the root user.

Next, create the MySQL database structure that will be used and then connected when we are finished to the local web server. First, we log into MySQL through our terminal as the root user, and then we need to make the database, which for this project will be named Capstone. Now we will build our database structure and relations that we will be able to populate with data through the web server. The tables that we will create are Employee, Customer, Supplier, Product, Transaction, and admin. The admin table will be where we create users that can interact with the database by logging into the web page.

Once the database structure is all set we can move onto creating the local web page that employees can log into from any computer or device while on the same network. We will start by making a directory that will house the files that will become our web page. Within this directory, there will be subdirectories for each table and an option to search, insert, or delete from the database. We will also need to create files that connect us to the database and a way to secure the site by utilizing an employee’s login page.

Recommendation:

After completing the project, you can see how a Raspberry Pi can successfully be implemented in a business setting. Doing so can benefit a business in ways that the typical route of paying a company for a service can’t. The biggest benefit is the affordability of the Pi device.

If you had gone with a professional service, your information would more than likely be stored in a cloud setting. Information in a cloud storage setting has already had a history of being breached. My recommendation for other businesses is that this type of device is more suited for a smaller company. One that might not have the room and overhead to run another type of local server. I would look into how many employees would actually be accessing the device at once. How much processing power and storage your business would need.  A bigger company could also go this route by running multiple Pi devices as almost a small supercomputer.

Phrame

Amazon wants your house and car keys

Yup…Amazon the giant company that you order all the products you love is now searching a way to have access to your house and/or car.

Why?

A survey of 1,001 US homeowners conducted by August last year claimed that upwards of 11 million homeowners had packages stolen during the year. They also found that 69% of homeowners believed that letting someone inside their house to leave packages was better than leaving them outside.

This is causing Amazon to search for new ways to have delivery workers be able to access your home and even your car. To do this, they are looking to new tech inventions like the smart lock for the door. If you feel you don’t want them to have access to inside your house then you can opt for them to leave the package (if it fits) inside your car. They hope to do this by possibly utilizing a smart license plate, like the one built already by Phrame.

 

Phrame

Image credit: Phrame

 

The idea currently is to allow them access to your smart plate with a generated token (like a VPN token) from their smartphone app. Once the plate is unlocked they can grab the keys from a pocket and they can then unlock the car and leave the package inside.

It’s a good idea but what stops them from using the keys to drive away in that car?

One solution to this being special keys being made that only allow a car to be unlocked. If the car is a push to start, the special keys would not be able to start the car only unlock.

Would you be open to letting somebody deliver packages directly inside your home or car?