R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

require(data.table)
cat("\f") # clear the console in R and RStudio
Sys.time()
print("Load csv file")
cats <- read.csv(url("https://raw.github.com/dburtsev/CUNYR/master/catsM2.csv"))
dt <- data.table(cats)
print("Use the summary function to gain an overview of the data set.")
print("colums are:")
colnames(dt)
print("numbers of rows in table:")
dt[,.N] 
print("display the mean and median for at least two attributes.")
print("mean for Body weight in kg:")
dt[,mean(Bwt),]
print("medianfor Body weight in kg:")
dt[,median(Bwt),]
print("mean for Heart weight in g:")
dt[,mean(Hwt),]
print("medianfor Heart weight in g:")
dt[,median(Hwt),]
# Create a new data frame with a subset of the columns and rows. Make sure to rename it.
dt3 <- dt[Bwt=="3"] 
# Create new column names for the new data frame.
setnames(dt3,"Bwt","BodyWeight") 
setnames(dt3,"Hwt","HeartWeight") 
# dt3
# Use the summary function to create an overview of your new data frame. The print the mean and median for the same two attributes. Please compare.
print("colums are:")
colnames(dt3)
print("numbers of rows in table:")
dt3[,.N] 
print("mean for Body weight in kg:")
dt3[,mean(BodyWeight),]
print("medianfor Body weight in kg:")
dt3[,median(BodyWeight),]
print("mean for Heart weight in g:")
dt3[,mean(HeartWeight),]
print("medianfor Heart weight in g:")
dt3[,median(HeartWeight),]
# For at least 3 values in a column please rename so that every value in that column is renamed.
dt3[,Sex:="F"]
# Display enough rows to see examples of all of steps 1-5 above.
dt3
Sys.time()