Chapter 5 Creating and writing data
This is a useful feature and allows you to save data that you have created. The following code creates a small dataset and then allows you to save the data to your working directory.
<- c(21,1,66,7) # this variable contains the ID for four nurses
Nurse_ID <- c(2,3,4,5)# this variable contains the hours worked by the nurses on Mon
Hours_Mon <- c(4,4,4,4)# this variable contains the hours worked by the nurses on Tues
Hours_Tues<- Hours_Mon + Hours_Tues
Hours_Total
<- cbind(Nurse_ID, Hours_Mon, Hours_Tues,Hours_Total)
Nurses <- data.frame(Nurses)
Nurses
write.csv(Nurses,"Nurses.csv")
Nurses
## Nurse_ID Hours_Mon Hours_Tues Hours_Total
## 1 21 2 4 6
## 2 1 3 4 7
## 3 66 4 4 8
## 4 7 5 4 9