R Programming rearranging rows and colums from timeline data I am new to R programming and data analytics. This is probably a trivial question but I could not find an answer. I'm also limited with my ontology of data science and data manipulation. So, I'm not sure if I conveyed my question right.

I have huge irregular time series data close to 1 Million records. They are all in the form of time stamps with different discrete attributes. I want to rearrange the data as shown below.

An Example of what I am trying to achieve FROM log entry of every car sold and the nature of the sale.

Date         Vehicle        Sale Type       Registration    Profit
1-1-2017    Toyota  Camry   Cash Sale          CA           2500
1-1-2017    Toyota Rav4     Lease              CA           8500
1-1-2017    Toyota Camry    Installment        AZ           250
2-1-2017    Toyota Corolla  Installment        NV           250
4-1-2017    Toyota Etios    Cash Sale          AZ           2500
4-1-2017    Toyota Camry    Lease              CA           8500
4-1-2017    Toyota Prius    Installment        CA           250
13-1-2017   Toyota Prius    Installment        VA           250


TO with rows having car names and columns containing cash sale, lease, installment

Vehicle Type    Cash Sale   Lease   Installment
Toyota Camry       1           1           1
Toyota Rav4                    1    
Toyota Corolla                             1
Toyota Etios       1        
Toyota Prius                               2
This would do the job:

#install packages
library(qdapTools)
library(dplyr)
#set working directory
setwd("C:/Users")

#read csv
test &lt;- read.csv("test.csv")

#create dummy variable
#test.new &lt;- dummy.data.frame(test$Sale.Type, sep = ".")
test.new &lt;- cbind(test, mtabulate(test$Sale.Type))

#rename column
names(test.new)[names(test.new) == 'Cash Sale'] &lt;- 'cashsale'

#making new columns
test.new1 &lt;- test.new %&gt;%
                group_by(Vehicle) 

test.new2 &lt;-  test.new1 %&gt;%
                  mutate(sum_Cashsale = sum(cashsale)) %&gt;%
                  mutate(sum_Ins = sum(Installment)) %&gt;%
                  mutate(sum_Lease = sum(Lease))

#select few necessary colums
test.new3 &lt;- subset(test.new2, select=c("Vehicle", "sum_Cashsale", "sum_Ins","sum_Lease"))

#select the distict rows
test.new4 &lt;- dplyr::distinct(test.new3)


Just copy paste the code. 
saved your sample data to test.csv
Give your working directory details, do let me know if you have any issues.