R!

pdf

School

Arizona State University *

*We aren’t endorsed by this school

Course

350

Subject

Statistics

Date

Feb 20, 2024

Type

pdf

Pages

3

Uploaded by CaptainMouse297

Report
Name: Date: Please answer the following questions on your own. If you have any trouble or questions, email me at Fabio.Albuquerque@asu.edu, and I will be happy to help. Total number of points:100 Open R software. 1. Find the solution for the following problems: (10 points) a) √100 Write your code here: >sqrt (100) b) log (3) Write your code here: >log2(3) c) 1 1 - (3.2 x +12)/2, if x = 1.1 Write your code here: >x=1.1 >11-(3.2*x+12)/2 >[1]3.24 2. Find the basal area of a tree (cross-sectional area of a tree trunk in m 2 ) if the diameter is 5 km. Hint: Area = π r 2 . (10 points) Write your code here: >pi*(2.5*1000)^2 3. What is the volume of a sphere in km 3 if the radius is 5 km and we assume it is a perfect sphere? Hint: V= 4/3( π r 3 ). (10 points) Write your code here: >4/3*(pi*5^3) Download Achatina_fulica data from your folder (Canvas>Content>Data). Assignment 1 ABS 350: Applied statistics
This dataset consists of weight (in grams) and length (in centimeters) values of the Giant African Snail ( Achatina fulica ). 4. Use R to open the CSV file Achatina_fulica.csv . (70 points) a) Use the “ setwd” function to Set Working Directory Write your code here: > setwd("C:/Users/palac/OneDrive/Documents/ABS350") > setwd() [1] "C:/Users/palac/OneDrive/Documents/ABS350" b) Read the Achatina_fulica.csv data. You should create an object and name it as my. achatina” . Write your code here: > my.achatina=my.data c) How many snails are described in this dataset? Write your code here: > str(my.achatina) 'data.frame': 2012 obs. of 3 variables: $ Id: int 1 2 3 4 5 7 8 9 10 11 ... $ Wt: num 13.8 12.7 19.4 14.3 14.4 ... $ Lt: num 63.9 63.4 79.2 65 59.9 ... d) Use the subset function to find the length and the weight of the 41 th snail. Use subscription and indices to extract this value. You should create an object and name it as “ sub” . (Hint = Id). Write your code here: > my.achatina[37,] Id Wt Lt 37 41 19.52511 71.6 e) How many snails have a weight higher or equal to 31? You should create an object and name it as “ sub1” . Use the subset function. Write your code here: > sub1=subset(my.achatina,Wt>=31) > sub1 Id Wt Lt 6 7 50.24695 107.6 10 11 50.36839 118.3 14 15 43.56000 93.4 16 17 35.92908 90.1 17 20 40.68290 100.8 20 23 34.03488 96.2 22 25 36.06900 95.7 28 32 49.96761 109.2 32 36 76.30871 118.1 There are more rows but I didn’t include all of them > nrow(sub1) [1] 515
f) How many snails have a length lower or equal to 55? You should create an object and name as “ sub2” . Use the subset function. Write your code here: [1] 515 > sub2=subset(my.achatina,Lt<=55) > sub2 Id Wt Lt 165 183 10.007910 54.8 272 299 10.688535 52.0 328 361 12.808620 52.6 382 426 9.781530 54.5 466 517 10.044705 52.0 500 554 12.808620 52.6 503 557 9.931845 54.9 539 595 10.745625 54.6 568 625 11.060940 54.3 722 797 10.059555 50.8 797 877 12.808620 52.6 836 918 10.017810 54.9 859 943 10.527000 54.0 886 972 10.502250 50.2 1278 1372 12.338535 53.6 1334 1428 14.458620 54.3 1472 1566 11.694705 53.6 1506 1600 14.458620 54.3 1728 1822 11.709555 52.5 1803 1897 14.458620 54.3 1892 1986 12.152250 51.8 > nrow(sub2) [1] 21
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