Thursday, March 05, 2015

R: Appending rows to create new data (appending columns)

If you have a requirement of appending rows from different sources to create a new data row (for eg. Professor and Department he works in, to create an information snippet) here is the simplest trick, use cbind:

> profSharma<-professors(professors$Pid==3,)
> phyDepartment<-department(department$Did==19,)
> cbind(profSharma,phyDepartment)
Happy Programming!

No comments:

Interview Question Preperation : Find longest subarray whose sum is equal to K

Software Engineering Practice interview question Given a array of N elements. Find the length of Longest Subarray whose sum is equal to give...