About the data

The data considered here is a dataset which has five colors cloths and their reaction to cooling and heating in every 10 minutes. Below are the variables description in the data

Load the data

The dataset is placed in a csv file in the github repository and loaded here using read.csv function. kable library is used to display data tables.

# get the github URL from github
theURL <- "https://raw.githubusercontent.com/amit-kapoor/data607/master/week6/hcdata.csv"

# read the data from csv
tempreact_df <- read.csv(theURL)

# show intial rows through head
kable(head(tempreact_df), align = "l")
color minute.0 minute.10 minute.20 minute.30 minute.40 minute.50 minute.60 phase
white 78 81 83 88 93 96 98 heating
red 78 82 90 93 98 106 109 heating
pink 78 82 84 90 96 99 102 heating
black 78 88 92 98 108 116 121 heating
green 78 81 85 91 95 102 105 heating
white 98 96 93 80 78 78 78 cooling

Tidying the data

Approach: My goal is to make data appear in a way which would be easy for further analysis. Here are the steps being performed.

# rename columns
tempreact_df <- tempreact_df %>% 
  rename("temp_initial"=minute.0) %>% 
  rename("temp_after_10"=minute.10) %>% 
  rename("temp_after_20"=minute.20) %>% 
  rename("temp_after_30"=minute.30) %>% 
  rename("temp_after_40"=minute.40) %>% 
  rename("temp_after_50"=minute.50) %>% 
  rename("temp_after_60"=minute.60)


# show intial rows through head
kable(head(tempreact_df), align = "l")
color temp_initial temp_after_10 temp_after_20 temp_after_30 temp_after_40 temp_after_50 temp_after_60 phase
white 78 81 83 88 93 96 98 heating
red 78 82 90 93 98 106 109 heating
pink 78 82 84 90 96 99 102 heating
black 78 88 92 98 108 116 121 heating
green 78 81 85 91 95 102 105 heating
white 98 96 93 80 78 78 78 cooling
cooling_phasedf <- filter(tempreact_df, tempreact_df$phase == "cooling")
kable(cooling_phasedf)
color temp_initial temp_after_10 temp_after_20 temp_after_30 temp_after_40 temp_after_50 temp_after_60 phase
white 98 96 93 80 78 78 78 cooling
red 109 106 95 87 82 80 78 cooling
pink 102 96 90 83 80 78 78 cooling
black 121 108 98 90 84 79 78 cooling
green 105 94 90 82 80 78 78 cooling
#Change from Wide to long
cooling_long_df <- gather(cooling_phasedf, Temperature, Value, "temp_initial":"temp_after_60")
cooling_long_df
##    color   phase   Temperature Value
## 1  white cooling  temp_initial    98
## 2    red cooling  temp_initial   109
## 3   pink cooling  temp_initial   102
## 4  black cooling  temp_initial   121
## 5  green cooling  temp_initial   105
## 6  white cooling temp_after_10    96
## 7    red cooling temp_after_10   106
## 8   pink cooling temp_after_10    96
## 9  black cooling temp_after_10   108
## 10 green cooling temp_after_10    94
## 11 white cooling temp_after_20    93
## 12   red cooling temp_after_20    95
## 13  pink cooling temp_after_20    90
## 14 black cooling temp_after_20    98
## 15 green cooling temp_after_20    90
## 16 white cooling temp_after_30    80
## 17   red cooling temp_after_30    87
## 18  pink cooling temp_after_30    83
## 19 black cooling temp_after_30    90
## 20 green cooling temp_after_30    82
## 21 white cooling temp_after_40    78
## 22   red cooling temp_after_40    82
## 23  pink cooling temp_after_40    80
## 24 black cooling temp_after_40    84
## 25 green cooling temp_after_40    80
## 26 white cooling temp_after_50    78
## 27   red cooling temp_after_50    80
## 28  pink cooling temp_after_50    78
## 29 black cooling temp_after_50    79
## 30 green cooling temp_after_50    78
## 31 white cooling temp_after_60    78
## 32   red cooling temp_after_60    78
## 33  pink cooling temp_after_60    78
## 34 black cooling temp_after_60    78
## 35 green cooling temp_after_60    78
heating_phasedf <- filter(tempreact_df, tempreact_df$phase == "heating")
kable(heating_phasedf)
color temp_initial temp_after_10 temp_after_20 temp_after_30 temp_after_40 temp_after_50 temp_after_60 phase
white 78 81 83 88 93 96 98 heating
red 78 82 90 93 98 106 109 heating
pink 78 82 84 90 96 99 102 heating
black 78 88 92 98 108 116 121 heating
green 78 81 85 91 95 102 105 heating
#Change from Wide to long
heating_long_df <- gather(heating_phasedf, Temperature, Value, "temp_initial":"temp_after_60")
heating_long_df
##    color   phase   Temperature Value
## 1  white heating  temp_initial    78
## 2    red heating  temp_initial    78
## 3   pink heating  temp_initial    78
## 4  black heating  temp_initial    78
## 5  green heating  temp_initial    78
## 6  white heating temp_after_10    81
## 7    red heating temp_after_10    82
## 8   pink heating temp_after_10    82
## 9  black heating temp_after_10    88
## 10 green heating temp_after_10    81
## 11 white heating temp_after_20    83
## 12   red heating temp_after_20    90
## 13  pink heating temp_after_20    84
## 14 black heating temp_after_20    92
## 15 green heating temp_after_20    85
## 16 white heating temp_after_30    88
## 17   red heating temp_after_30    93
## 18  pink heating temp_after_30    90
## 19 black heating temp_after_30    98
## 20 green heating temp_after_30    91
## 21 white heating temp_after_40    93
## 22   red heating temp_after_40    98
## 23  pink heating temp_after_40    96
## 24 black heating temp_after_40   108
## 25 green heating temp_after_40    95
## 26 white heating temp_after_50    96
## 27   red heating temp_after_50   106
## 28  pink heating temp_after_50    99
## 29 black heating temp_after_50   116
## 30 green heating temp_after_50   102
## 31 white heating temp_after_60    98
## 32   red heating temp_after_60   109
## 33  pink heating temp_after_60   102
## 34 black heating temp_after_60   121
## 35 green heating temp_after_60   105

Data Analysis

For data analysis I used ggplot, geom_point, geom_line methods from ggplot2 library. I plotted the color on x-axis and temperature on y-axis. I created 2 graphs below to show the cooling and heating effects for different color in data.

cooling_phasedf %>% ggplot(aes(x=cooling_phasedf$color)) + scale_x_discrete(limits=cooling_phasedf$color) + 
  geom_point(aes(y=cooling_phasedf$temp_initial , group=1)) + geom_line(aes(y=cooling_phasedf$temp_initial, group=1, col="Intial Temp"), size=1) + 
  geom_point(aes(y=cooling_phasedf$temp_after_10, group=1)) + geom_line(aes(y=cooling_phasedf$temp_after_10, group=1, col="Temp after 10"), size=1) + 
    geom_point(aes(y=cooling_phasedf$temp_after_20 , group=1)) + geom_line(aes(y=cooling_phasedf$temp_after_20, group=1, col="Temp after 20"), size=1) + 
  geom_point(aes(y=cooling_phasedf$temp_after_30, group=1)) + geom_line(aes(y=cooling_phasedf$temp_after_30, group=1, col="Temp after 30"), size=1) + 
  geom_point(aes(y=cooling_phasedf$temp_after_40, group=1)) + geom_line(aes(y=cooling_phasedf$temp_after_40, group=1, col="Temp after 40"), size=1) +
  geom_point(aes(y=cooling_phasedf$temp_after_50, group=1)) + geom_line(aes(y=cooling_phasedf$temp_after_50, group=1, col="Temp after 50"), size=1) + 
  geom_point(aes(y=cooling_phasedf$temp_after_60, group=1)) + geom_line(aes(y=cooling_phasedf$temp_after_60, group=1, col="Temp after 60"), size=1) +
  labs(title="Cooling Temperature Versus Color", x="Color", y="Degrees in Farenheit", colour="") + 
  scale_colour_manual(values = c("orange", "grey" , "blue" , "green", "cyan" , "black" , "red"))

heating_phasedf %>% ggplot(aes(x=heating_phasedf$color)) + scale_x_discrete(limits=heating_phasedf$color) + 
  geom_point(aes(y=heating_phasedf$temp_initial , group=1)) + geom_line(aes(y=heating_phasedf$temp_initial, group=1, col="Intial Temp"), size=1) + 
  geom_point(aes(y=heating_phasedf$temp_after_10, group=1)) + geom_line(aes(y=heating_phasedf$temp_after_10, group=1, col="Temp after 10"), size=1) + 
    geom_point(aes(y=heating_phasedf$temp_after_20 , group=1)) + geom_line(aes(y=heating_phasedf$temp_after_20, group=1, col="Temp after 20"), size=1) + 
  geom_point(aes(y=heating_phasedf$temp_after_30, group=1)) + geom_line(aes(y=heating_phasedf$temp_after_30, group=1, col="Temp after 30"), size=1) + 
  geom_point(aes(y=heating_phasedf$temp_after_40, group=1)) + geom_line(aes(y=heating_phasedf$temp_after_40, group=1, col="Temp after 40"), size=1) +
  geom_point(aes(y=heating_phasedf$temp_after_50, group=1)) + geom_line(aes(y=heating_phasedf$temp_after_50, group=1, col="Temp after 50"), size=1) + 
  geom_point(aes(y=heating_phasedf$temp_after_60, group=1)) + geom_line(aes(y=heating_phasedf$temp_after_60, group=1, col="Temp after 60"), size=1) +
  labs(title="Heating Temperature Versus Color", x="Color", y="Degrees in Farenheit", colour="") + 
  scale_colour_manual(values = c("orange", "grey" , "blue" , "green", "cyan" , "black" , "red"))

Summary/Conclusion

This data used a small .csv file to demonstrate the color effect. I found above graphs interesting for both heating and cooling analysis. We can see above that black color cloth absorbs all colors and appears warmer than white color. More light a color absorbs, more warmer it would be.