Re: [R] Data Frame Column Name Attribute

2016-04-23 Thread William Dunlap via R-help
You could use transform() instead of [[<- to add columns to your data.frame so the new columns get transformed they way they do when given to the data.frame function itself. E.g., > dd <- data.frame(X=1:5, Y=11:15) > str(transform(dd, Z=matrix(X+Y,ncol=1,dimnames=list(NULL, "NewZ" 'data.frame

Re: [R] Data Frame Column Name Attribute

2016-04-23 Thread David Winsemius
> On Apr 23, 2016, at 8:59 AM, thomas mann wrote: > > I am attempting to add a calculated column to a data frame. Basically, > adding a column called "newcol2" which are the stock closing prices from 1 > day to the next. > > The one little hang up is the name of the column. There seems to be

Re: [R] data frame column name change

2011-01-17 Thread Pete Brecknock
or d = data.frame(Col1=c(1,2,3),Col2=c(2,3,4),Col3=c(3,4,5)) names(d) names(d)[1] = "NewName1" names(d) HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/data-frame-column-name-change-tp3220684p3221214.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] data frame column name change

2011-01-16 Thread Jorge Ivan Velez
Hi eric, Try colnames(x) colnames(x)[1] <- 'newname' colnames(x) HTH, Jorge On Sun, Jan 16, 2011 at 11:28 PM, eric <> wrote: > > How do I change the name of one column in a data frame ? Suppose I have a > data frame x with 5 columns. If the names were date, col1, col2, col3, col4 > and I want

Re: [R] Data frame column

2010-03-05 Thread David Winsemius
On Mar 5, 2010, at 8:26 AM, ManInMoon wrote: I have a big data frame and I have extracted a bit by doing: y<-d[1:10,6] y [1] Headings 0-49 -98 -49 -41 -120 -155 -204 -169 92329 Levels: -0 -1 -10 -100 -1000 -1 -10001 -10002 -10003 -10004 -10005 -10

Re: [R] Data frame column name as function argument?

2009-09-22 Thread David Winsemius
On Sep 22, 2009, at 5:07 PM, bamsel wrote: Any help is very much appreciated. The following is a toy example: #1. Create a data frame with two named columns (x,y): DF <- data.frame(cbind(x=1:5, y=6:10)) DF x y 1 1 6 2 2 7 3 3 8 4 4 9 5 5 10 #2. Define a function to compute the sum o

Re: [R] data frame column name as a function argument

2008-09-26 Thread Hutchinson,David [PYR]
First - you need to pass the data frame into the function. testing <- function (d, colname) { return (d[[colname]]) } d <- data.frame(cbind(x=1, y=1:10)) print (testing(d, 'x')) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of eric lee Sent: Friday, S