Thursday, March 19, 2015

R : Adding column names to data

Sometimes you have a huge data with multiple fields and the data stored in your file is not marked with header information (i.e. column names).
To add column names to your data frame or matrix after it is read into a variable run the following command:

> CustColName <- c("time", "Age", "Surname", "Standard", "RollNo", "Name")
> colnames(StudData) <- CustColName

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...