0

How would I create a function that returns 4 columns from from two separate files.

The files are: Incident: ID, Incident.Number, Date.Time, Street.Name, City, State, Station.Responding, Zip.

SalaryData: CalendarYear, EmployeeName, Department, JobTitle, AnnualRate, Regularrate, OvertimeRate, IncentiveAllowance, Other, YeartoDate.

I want to create a function that returns a dataframe with 4 columns:
1) Year type character
2) #ofIncidents
3) TotalWages
4) CostperIncident

I am not worried about how to calculate the columns, just how to write a function that reads two files and creates a data frame with the 4 columns. Just the basic order or syntax that would get me started.

If more information is needed I will gladly provide it.

I sincerely appreciate any help to get me started.

Thank you.

digEmAll
  • 56,430
  • 9
  • 115
  • 140
SuperCereal
  • 89
  • 1
  • 8
  • How are the two data frames being combined? – Tim Biegeleisen Oct 21 '15 at 06:09
  • 1
    See `read.files`, `lapply`, `sapply`, `do.call`, e.g. http://stackoverflow.com/questions/11433432/importing-multiple-csv-files-into-r – Roman Luštrik Oct 21 '15 at 06:09
  • I was trying to combined them with the year. However, one is date.time (yyyy/mm/dd) and the other is Year(yyyy). So, I am trying to create a separate column in Incident that is just Year(yyyy), then I will combine them. – SuperCereal Oct 21 '15 at 06:18
  • 1
    Please read the info about how to give a [minimal reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610). – Jaap Oct 21 '15 at 06:19
  • 1
    Furthermore, I noticed that you didn't accept any answer on any of the questions you asked. Although it is not mandatory to accept an answer, it is considered good practice to do so if one of the answers worked for you. This will give future readers a clue about the value of the solution. See also this help page: [What should I do when someone answers my question?](http://stackoverflow.com/help/someone-answers) – Jaap Oct 21 '15 at 06:20
  • Relax. Relax. Relax. – SuperCereal Oct 21 '15 at 06:39

0 Answers0