8140_A1

docx

School

Hamline University *

*We aren’t endorsed by this school

Course

8140

Subject

Mechanical Engineering

Date

Feb 20, 2024

Type

docx

Pages

4

Uploaded by MasterField13417

Report
MSBA 8140- Assignment 1 1. With respect to a language like R or Python, what is an interpreter and what does it do? Because of this, why are R and Python not "programming" languages in the strict sense of the word? An Interpreter is essentially a program compiles the code and directly executes script language without needing to covert it to machine language first. R and Python are NOT Programming Languages but scripting languages . This is because each line is compiled one at a time by an interpreter when the code is run, whereas programs are a set of code that must be compiled and executed in its entirety all at once 2. When trying to find a solution to a programming problem, it is often helpful to create a reproducible example of your code to share with others. This bit of code should focus on and reproduce the problem you are encountering. Describe three (3) ways to make sure that your example code is easy for others to read. Have Packages loaded and visible at the top of the script Include Data efficiently and reproducibly. Use the smallest subset of the data possible while still revealing the problem and situation. Be concise with variables and cut everything from the code that's irrelevant to the problem. Also add comments to help people navigate to the issue and to better understand your problem. Question 5 goes into detail about what should be included on the top of a script 3. Tweak the following R statements so that they will work correctly: install.package s ("gapminder") setwd( " /Users/phil/my documents " ) Setting my working Directory for this course: setwd("/Users/liam/Hamline/MSBA_8140") l ibrary(tidyverse) 4. Explain what types of files should be stored together to re-create an analysis in order to begin exactly where you left off last time. Data files , scripts , and outputs should be stored together so that you can re-create and analysis/jump back in where you left off. This can be done easily in R by creating a Project and setting the working directory to the desired location. The Project will keep everything you need all in one place if you want to come back to it. 5. List three (3) elements of a script that should be included at the top of the script?
Comments/Header Information Loading libraries/packages Loading Data 6. Although you can write/edit a script in a simple text editor such as notepad or vim and run code through an interpreter using a terminal or command prompt, what are some advantages of using an IDE like RStudio or IDLE? The two main advantages of using an IDE or IDLE are being able to run multiple lines of code at a time as well as being able to save your code. 7. Scripts are good for saving code that will be reused later. When and why might you want to write code directly in a console/shell ? It might be good to use the console for doing quick commands, calculations, and one time stuff since it can be faster using it over an IDE/IDLE. 8. Look at the table on p. 29 of PDA. Use IPython to test out some of these commands. Choose a magic command that you think will be useful for you to remember (either from the table or from the list you get using %magic). What is the command and when/how will you use it? I agree that %who/%whos will be useful for seeing what variables there are and information about them, and %reset for deleting variables/names will be useful too. However, I would say %matplotlib (inline) might be the most useful for me to remember because it will allow me to view multiple plots in the notebook (inline) all at once, an essential tool for data visualization. 9. For each example below, determine whether the statement was most likely written for a Python script or an R script. Explain your reasoning. my_data.sort() Python Script R doesn't use periods as operators, periods are just another character like the letter "a". filter(my.data, x.variable == 4) R script This is because names such as "my.data" cannot contain periods in Python. This would be an example of when periods will appear in R scripts. Here we have periods being used in a name of the data frame and the name of a variable "x.variable" which is a part of "my.data". my_list <- list(1, 2, “apple”, “orange”) R Script
This is because R script uses arrows (<- ) as an assignment operator (and can also use " = ") but python uses " = " only as an assignment operator. 10. At 4:00 minutes into the video Shell, Command Line, Terminal Basics (7:30) , what do you expect would happen if we were to type the following command and press enter: miller_SSM_marijuana_jan.docx It will open the file, assuming you have navigated to the program. Because this is a docx file it needs the word program to be opened. If you have not specified the correct path before executing this command you will get a "command not found" error message. 11. Write pseudo-code (instructions for a computer, not using any real programming language) to instruct a humanoid robot to take out the garbage from your kitchen. Try to write instructions that are Atomic, Literal, Explicit, Complete, and Correct. Please limit your instructions to a single page. Before getting started I need to establish where the Robot's starting point will be. I am going to say it's located directly in front of the garbage, otherwise this could end up being longer than a single page. Additionally, I am going to assume that this robot already knows how to walk and use its humanoid body. Also, I'm not going to have it tie the garbage bag shut, I don't really care if trash gets everywhere once placed in the trash bin, and it might take me several pages to dictate. I am also going to make up numbers for the Robot's height and how many feet it will exactly need to move in each scenario such as walking or moving specific body parts. I'm also going to paraphrase positions in space using x, y, and z axis to make this shorter. Rotation, by default, will be clockwise. I'm also not going to make it come back to where it was after taking out the garbage since that wasn't Explicitly stated in your instructions to me. Additionally, instructing the robot to return would be more reading for you, while I would just copy paste and change a few numbers to make it reversed. Look at it as a favor from me to you, sacrificing my trash robot which will probably get confused for garbage after I leave it next to the bin. Wake up. Simultaneously, extend right arm 12 inches forward and 6 inches down (It would be so much easier to map this arm position as RA_X0_Y-6_Z12 or [arm = R, X = 0, Y= -6, Z=12]). Rotate right wrist 45 degrees. Start clamping right hand, then stop when fingers on right hand are 1mm from palm (Lets set this finger position for the right hand to C_1 [hand = R, position = C_1] and I'll do that for other hand positions in the future). Apply X units of pressure with right hand (to garbage bag). Bring right arm towards body (hinge at elbow), using X units of force, until right forearm reaches a 90-degree position relative to the right upper arm. Rotate entire body 180 degrees. Take 20 steps forward. Rotate 90 degrees. Take 5 steps forward. Simultaneously, extend left 12 inches forward and 10 inches to the right [arm = L, X = 10, Y=0, Z = 12]. Clamp left hand to position C_100 and apply X units of pressure (to door handle). Move left arm backwards (Z axis) 15 inches using x units of force. Return left hand position to neutral (letting go of the door handle), and immediately proceed to take 5 steps forward (out of the door). Return left arm to neutral position. Rotate 270 degrees (90 counterclockwise). Take 100
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
steps forward. Rotate 270 degrees (90 counterclockwise). Take 110 steps forward. Rotate 270 degrees (90 counterclockwise). Take 5 Steps forward. Rotate 90 degrees counterclockwise. Extend left arm 12 inches forward (Z axis). Clamp Left hand to position C_100 applying X units of pressure (to trash bin lid). Move Left Arm up 6 inches using X units of force (opening the trash bin). Move right arm forward 12 inches. Return Right hand position to neutral (Dropping trash bag in trash bin). Return left hand to position neutral (closing trash bin) Return left and right arms to position neutral. Enter sleep mode.