Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

istribution with a mean of 500 and a standard deviation of 10 5. Complete the fo

ID: 3736550 • Letter: I

Question

istribution with a mean of 500 and a standard deviation of 10 5. Complete the following tasks. Save the commands in a history file called question5.txt. Create a data frame with data of your choosing (don't use data from the notes): it must have mixed data types. Min of 10 rows, min of 5 cols . show how to use the $ shortcut to access individual columns of data convert your data frame to a matrix, store it as a different object (i.e. different name) save both (frame and matrix) to different files, save the matrix to a text file and the frame to a binary file. e 6. Load the Beginning.RData file and perform the following tasks. Save the commands in a history file called question6.txt. arch

Explanation / Answer

df <-data.frame(c(100,'a',40.5,TRUE,"xyz",50,'b',50.9,"Ram",1),c(400,'b',50.0,"600",FALSE,30.7,TRUE,'q',"John",100),c(700,'w',80.0,"Pat","TRUE",20,'q',0.0,100,50),c(500,'c',"Kevin",30.0,FALSE,"TRUE",700,4.5,'r',TRUE),c(700,'w',80.9,"Sal","TRUE",TRUE,'q',0.5,100,"FALSE"))
#defining the dataframe headers and naming each column
names(df)<-c("c1","c2","c3","c4","c5")
#accessing 5th column
df$c5
#accessing 3rd column
df$c3
#accessing 1st column
df$c1
#converting dataframe into matrix
dfm<-data.matrix(df)
#storing matrix into .txt file
write.table(dfm, file="dfmMatrix.txt", row.names=FALSE, col.names=FALSE)
#storing dataframe into binary file
to.write = file("C:/dfBinary.dat", "wb")
writeBin(c(df$c1,df$c2,df$c3,df$c4,df$c5),to.write)
close(to.write)