.

To set up I am going to create the object employeeData0 by using the read function. Because the file I am reading is a csv file, I will use the function read_csv.

#Create object employeeData0
employeeData0=read_csv("https://raw.githubusercontent.com/mahmoudharding/R-You-a-Useful-Model/f1bd9f7558d7f9cf4a63208dc75f11354000a493/datasets/employeeData0.csv")
## Parsed with column specification:
## cols(
##   ID = col_double(),
##   Gender = col_character(),
##   `Birth Date` = col_character(),
##   Jobcat = col_double(),
##   Salary = col_character(),
##   `Job Time` = col_double(),
##   `Prev Exp` = col_double(),
##   Minority = col_double()
## )

Next I will create another object, employeeData1, using the read function. This file is a tab delimited file, which means I need to use the function read_tsv.

#Create object employeeData1
employeeData1=read_tsv("https://raw.githubusercontent.com/mahmoudharding/R-You-a-Useful-Model/f1bd9f7558d7f9cf4a63208dc75f11354000a493/datasets/employeeData0.csv")
## Parsed with column specification:
## cols(
##   `ID,Gender,Birth Date,Jobcat,Salary,Job Time,Prev Exp,Minority` = col_character()
## )

Now that both of those are working I will use the code given to me in the assignment to combine the files into a single object.

#Create object allEmployeeData by combing the other two objects
allEmployeeData=rbind(employeeData0,employeeData1)
## Error in rbind(deparse.level, ...): numbers of columns of arguments do not match

Maybe if I read employeeData1 as a csv they will match.

#Change employeeData1
employeeData1=read_csv("https://raw.githubusercontent.com/mahmoudharding/R-You-a-Useful-Model/f1bd9f7558d7f9cf4a63208dc75f11354000a493/datasets/employeeData0.csv")
## Parsed with column specification:
## cols(
##   ID = col_double(),
##   Gender = col_character(),
##   `Birth Date` = col_character(),
##   Jobcat = col_double(),
##   Salary = col_character(),
##   `Job Time` = col_double(),
##   `Prev Exp` = col_double(),
##   Minority = col_double()
## )
#Create object allEmployeeData by combing the other two objects
allEmployeeData=rbind(employeeData0,employeeData1)

That worked. Now I need to create a csv file containing the data from allEmployeeData. I’ll need to use the write_csv function for this, most likely. I’ll call the file “CombinedData.” I’m not sure how the syntax works but I’ll try anyways and see what happens.

#Create a file containing data from allEmployeeData
write_csv(CombinedData,path="allEmployeeData.csv")
## Error in is.data.frame(x): object 'CombinedData' not found

I didn’t expect that to work. I put the file name first and then the object, but I think I have it backwards. I think “allEmployeeData” comes first and then I need to create a file name after it.

#Create a file containing data from allEmployeeData
write_csv(allEmployeeData,path="CombinedData.csv")

I think that worked. Let’s see if I can read it, just to be sure.

#Attempt to read file CombinedData.csv
read_csv("CombinedData.csv")
## Parsed with column specification:
## cols(
##   ID = col_double(),
##   Gender = col_character(),
##   `Birth Date` = col_character(),
##   Jobcat = col_double(),
##   Salary = col_character(),
##   `Job Time` = col_double(),
##   `Prev Exp` = col_double(),
##   Minority = col_double()
## )
## # A tibble: 740 x 8
##       ID Gender `Birth Date` Jobcat Salary  `Job Time` `Prev Exp` Minority
##    <dbl> <chr>  <chr>         <dbl> <chr>        <dbl>      <dbl>    <dbl>
##  1     1 m      3-Feb-1952        3 $57,000         98        144        0
##  2     2 m      23-May-1958       1 $40,200         98         36        0
##  3     3 f      26-Jul-1929       1 $21,450         98        381        0
##  4     4 f      15-Apr-1947       1 $21,900         98        190        0
##  5     5 m      9-Feb-1955        1 $45,000         98        138        0
##  6     6 m      22-Aug-1958       1 $32,100         98         67        0
##  7     7 m      26-Apr-1956       1 $36,000         98        114        0
##  8     8 f      6-May-1966        1 $21,900         98          0        0
##  9     9 f      23-Jan-1946       1 $27,900         98        115        0
## 10    10 f      13-Feb-1946       1 $24,000         98        244        0
## # ... with 730 more rows

It worked!!