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

[R] Data Frame Column Name Attribute

2016-04-23 Thread thomas mann
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 an additional data column name included in the attributes (dimnam

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

[R] data frame column name change

2011-01-16 Thread eric
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 wanted to simply change the name of date, what would the command be ? I tried the following and it didn't seem to work : names(x[1]) <- "newn

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

[R] Data frame column

2010-03-05 Thread ManInMoon
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 -10006 -10007 -10008 -10009 -1001 -10010 -100

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

[R] Data frame column name as function argument?

2009-09-22 Thread bamsel
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 of a given column: > foo.fnc = function

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

2008-09-26 Thread Hutchinson,David [PYR]
lee Sent: Friday, September 26, 2008 3:10 PM To: r-help@r-project.org Subject: [R] data frame column name as a function argument Hello, I'd like to pass a column name as the argument for a function, but I'm getting "NULL" as a return value. Any suggestions? Thanks. > d <

[R] data frame column name as a function argument

2008-09-26 Thread eric lee
Hello, I'd like to pass a column name as the argument for a function, but I'm getting "NULL" as a return value. Any suggestions? Thanks. > d <- data.frame(cbind(x=1, y=1:10)) > d x y 1 1 1 2 1 2 3 1 3 4 1 4 5 1 5 6 1 6 7 1 7 8 1 8 9 1 9 10 1 10 > testing <- function(var) {