together with the summary show you is going on with the data The whole end of

Together with the summary show you is going on with

This preview shows page 2 - 4 out of 8 pages.

together with the summary show you is going on with the data? The whole end of the file is filled with NA rows, and it looks like someone did some calculations or saved other things in the first column after the main part of the data. Next we will clean the data. First I’m going to rename a column (to make it easier to reference). Then we want to remove the rows with NAs in all of the columns. There are various ways, such as the one I show you below, or by using the subset() or other functions in R so that you only have entries that are complete. ## renaming a column names (dat)[ 3 ]<- "Hunger" ## Here is one way dat<-dat[ ! is.na (dat $ Conc.ppm),] summary (dat) ## Tank Conc.ppm Hunger Rep Date ## 2 : 24 Min. : 0.0 : 0 Min. :1.00 5/30/02:175 ## 28 : 24 1st Qu.: 5.0 H:473 1st Qu.:2.00 6/3/02 :150 ## 31 : 24 Median : 50.0 L:452 Median :3.00 6/10/02:136 ## 38 : 24 Mean :153.3 Mean :3.47 5/31/02: 79 ## 11 : 23 3rd Qu.:500.0 3rd Qu.:5.00 5/29/02: 74 ## 29 : 23 Max. :500.0 Max. :6.00 6/5/02 : 66 ## (Other):783 (Other):245 ## ExpDay Mass.g Length.cm ## Min. : 57.00 Min. :0.3912 Min. :2.130 ## 1st Qu.: 57.00 1st Qu.:0.7161 1st Qu.:2.620 ## Median : 62.00 Median :0.8485 Median :2.750 ## Mean : 64.14 Mean :0.8752 Mean :2.758 ## 3rd Qu.: 69.00 3rd Qu.:1.0022 3rd Qu.:2.890 ## Max. :115.00 Max. :1.8081 Max. :3.500 ## Now we want to include only the columns for tank, atrazine concentration, hunger level, mass, and length. In the TryR course you should have learned how to access columns in a matrix. Do that here, and save the output as a new variable. Then look at the levels of the hunger variable. You’ll notice that there’s a blank level. Using the droplevels function will clean-up the levels. 2
Image of page 2
d<-dat[ , c ( 1 , 2 , 3 , 7 , 8 ) ] ## update this with which columns you want levels (d $ Hunger) ## [1] "" "H" "L" d<- droplevels (d) levels (d $ Hunger) ## [1] "H" "L" summary (d) ## Tank Conc.ppm Hunger Mass.g Length.cm ## 2 : 24 Min. : 0.0 H:473 Min. :0.3912 Min. :2.130 ## 28 : 24 1st Qu.: 5.0 L:452 1st Qu.:0.7161 1st Qu.:2.620 ## 31 : 24 Median : 50.0 Median :0.8485 Median :2.750 ## 38 : 24 Mean :153.3 Mean :0.8752 Mean :2.758 ## 11 : 23 3rd Qu.:500.0 3rd Qu.:1.0022 3rd Qu.:2.890 ## 29 : 23 Max. :500.0 Max. :1.8081 Max. :3.500 ## (Other):783 Finally, save your new, clean data set as a new file using the write . csv function. ## I suggest you include the argument "row.names = FALSE" : write.csv (d, file = "MetamorphMassLength_clean.csv" , row.names = FALSE ) Visualizing the data Histograms As with the pickup data from class, first make histograms for the numeric portion of the data, that is everything except hunger level and tank. Are they what you expect?
Image of page 3
Image of page 4

You've reached the end of your free preview.

Want to read all 8 pages?

  • Spring '14

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes