




Sent from Samsung Mobile

-------- Original message --------
Subject: R basic data manipulation Queries
From: Pavneet Arora <pavneet.arora@uk.rsagroup.com>
To: pavneet17@yahoo.co.uk
CC: 

Hello Guys

I am new in R, so please excuse the really basic questions. I have tried reading numeral tutorials, but I am still stuck. 
Question 1: 
If I perform correlation on my data [cor(nums2)] or try to produce variance matrix [var(nums2)]. The output comes in R console. Is there any way I can make it go directly to excel somehow? 

Question 2: 
Also is there any way I can permanently change the variable name in a data frame. 
I basically imported my dataset from SAS using "read.ssd" function in library(foreign). However, this package cuts off the variable names and only allows 8 characters! So that means I will have to rename some of my variable names, so they make more sense as to what it is. 

part (a): 
At the moment, I did the following to change the variable names, using library(plyr). First of all, is this the most succint way of doing this? 
new_acc <- rename(acc_mod,c("NAME_OF_"="weekName", "ACCIDENT"="AccSev", "YEARMONH"="YrMonHr",
"X_1ST_ROA"="1RdCls.N", "ROAD_TYP"="RdType.N", "LOCATION"="LocEast")) 

part (b): 
Secondly, I wanted to do the above, to change the name permanently - but I don't think it worked, because when I do the following, I get: 
class(LocEast) # New name of "LOCATION"
class(LOCATION) 
R Output: 
> class(LocEast) 
Error: object 'LocEast' not found 
> class(LOCATION) 
[1] "numeric" 

Thanks so much! 
	[[alternative HTML version deleted]]

