[R] help to add a new column filled with value 1

Greg Snow Greg.Snow at imail.org
Tue Nov 9 18:38:08 CET 2010


Here are 2 possibilities:

cbind( iris[,1, drop=FALSE], 1, iris[,2:5] )
cbind( iris, 1) [ ,c(1,6,2:5) ]



-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Mohan L
> Sent: Tuesday, November 09, 2010 7:26 AM
> To: r-help at r-project.org
> Subject: [R] help to add a new column filled with value 1
> 
> Dear All,
> 
> I have a data frame with  5 column and 201 row data. I want to add one
> more column between column 1 and 2 with value of 1. So the new column
> has to be the second column filled with 1. Any help will be
> appreciated.
> 
> Thanks for your time.
> 
> 
> Thanks & Rg
> Mohan L
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list