Re: [R] Column name assignment problem

2009-03-30 Thread Steve Murray
Dear Peter, Jim and all, Thanks for the information regarding how to structure 'assign' commands. I've had a go at doing this, based on your advice, and although I feel I'm a lot closer now, I can't quite get it to work: rnames <- sprintf("%.2f", seq(from = -89.75, to = 89.75, length = 360)) c

Re: [R] Column name assignment problem

2009-03-30 Thread Peter Dalgaard
Steve Murray wrote: > Dear all, > > Apologies for yet another question (!). Hopefully it won't be too tricky to > solve. I am attempting to add row and column names (these are in fact > numbers) to each of the tables created by the code (120 in total). > > > # Create index of file names > file

Re: [R] Column name assignment problem

2009-03-30 Thread Steve Murray
Dear all, Apologies for yet another question (!). Hopefully it won't be too tricky to solve. I am attempting to add row and column names (these are in fact numbers) to each of the tables created by the code (120 in total). # Create index of file names files <- print(ls()[1:120], quote=FALSE)

Re: [R] Column name assignment problem

2009-03-30 Thread Steve Murray
Jim and all, Thanks - I managed to get it working based on your helpful advice. I'm now trying to do something very similar which simply involves changing the names of the variables in column 1 to make them more succinct. I'm trying to do this via the 'levels' command as I figured that I might

Re: [R] Column name assignment problem

2009-03-27 Thread jim holtman
Since you want to generate your own variable names instead of using a list, do the operation in three steps: x <- get(paste("arunoff_",table_year, sep='')) colnames(x)[4] <- "COUNT" assign(paste("arunoff_",table_year, sep=''), x) On Fri, Mar 27, 2009 at 4:01 PM, Steve Murray wrote: > > Dear all

Re: [R] Column name assignment problem

2009-03-27 Thread Steve Murray
Dear all, I've been trying to implement the advice given to me, but without much success so far. I thought I'd provide the code in full in the hope that it might make more sense. Just to reiterate, I'm attempting to change the header of the 4th column of every table to "COUNT". year<- 1951:2

Re: [R] Column name assignment problem

2009-03-26 Thread Tal Galili
Way are you taking the forth argument of the paste ?paste("arunoff_",table_year, sep="")[4] Either way, way not use something like: colnames(x)[column to change] <- "text, or pasted text" Cheers, Tal On Thu, Mar 26, 2009 at 2:33 PM, Steve Murray wrote: > > Dear all, > > I'm trying to assign

[R] Column name assignment problem

2009-03-26 Thread Steve Murray
Dear all, I'm trying to assign a name to the fourth column whilst using 'assign', but keep encountering errors. What have I done wrong?! > assign(colnames(c(paste("arunoff_",table_year, sep="")[4]), "COUNT")) Error in if (do.NULL) NULL else if (nc> 0) paste(prefix, seq_len(nc), : argument