In line John Kane Kingston ON Canada
> -----Original Message----- > From: pavnee...@yahoo.co.uk > Sent: Tue, 18 Mar 2014 10:10:38 +0000 > To: r-help@r-project.org > Subject: [R] Fwd: R basic data manipulation Queries > > > > > > > Sent from Samsung Mobile > > -------- Original message -------- > Subject: R basic data manipulation Queries > From: Pavneet Arora <pavneet.ar...@uk.rsagroup.com> > To: pavnee...@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? Not exactly but fairly easily. Have a look at the R-site and go to the Manuals section. There is a R Import and Export manual there. > > 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!B > [[alternative HTML version deleted]] > I have never used plyr for thhis but just names(aac.mod) <- c("Newname1, "Newname2") and so on for a new name for each column in the data.frame should do it. ____________________________________________________________ Protect your computer files with professional cloud backup. Get PCRx Backup and upload unlimited files automatically. Learn more at http://backup.pcrx.com/mail ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.