Project- Orange

Discription of project:

The Orange data frame has 35 rows and 3 columns of records of the growth of orange trees.

Let us investigate

Step 1: Load the data

data("Orange")

View(Orange)
str(Orange)
## Classes 'nfnGroupedData', 'nfGroupedData', 'groupedData' and 'data.frame':   35 obs. of  3 variables:
##  $ Tree         : Ord.factor w/ 5 levels "3"<"1"<"5"<"2"<..: 2 2 2 2 2 2 2 4 4 4 ...
##  $ age          : num  118 484 664 1004 1231 ...
##  $ circumference: num  30 58 87 115 120 142 145 33 69 111 ...
##  - attr(*, "formula")=Class 'formula'  language circumference ~ age | Tree
##   .. ..- attr(*, ".Environment")=<environment: R_EmptyEnv> 
##  - attr(*, "labels")=List of 2
##   ..$ x: chr "Time since December 31, 1968"
##   ..$ y: chr "Trunk circumference"
##  - attr(*, "units")=List of 2
##   ..$ x: chr "(days)"
##   ..$ y: chr "(mm)"
tr <- Orange$Tree
ag <- Orange$age
cr <- Orange$circumference

At first we loaded the data into global environment, than we check the structure to have better understanding of the given dataset.

Step 2: Ensure you have the right package for the analysis - ggplot2

library(ggplot2)

Step 3: Scatter plot

ggplot(data = Orange, aes(x=ag, y=cr)) + geom_point()

Step 4: Now, we can add ‘Trees’ variable as color

ggplot(data = Orange, aes(x=ag, y=cr, color=tr)) + geom_point()

### Step 5: For better clearity we will take manual and automatic seperately

ggplot(data = Orange[Orange$tr <2,], aes(x=ag, y=cr, color=tr)) + geom_point()

### Step 6: To see the averages for the circumference, let us run the following line.

ggplot(data = Orange[Orange$tr <2,], aes(x=ag, y=cr, color=tr)) + geom_point() + geom_smooth()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

## Conclusion: From the above analysis we can observe that as the age of the tree growths the circumference of the tree also increase and the frequency of the tree also increase over the period. as we see the graph all the lines are in a up trend which indicates that the relation between age and circumferance is positive.