[R] how to create the data frame
Ivan Calandra
ivan.calandra at u-bourgogne.fr
Wed Jul 11 09:40:09 CEST 2012
Hi,
Let's say you original data.frame is called df1, you can do:
df2 <- data.frame(date=row.names(df1), weekly.returns=df1[[1]])
Next time, think about giving us you sample data through the dput()
function. It makes it way easier.
HTH,
Ivan
--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calandra at u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra
Le 11/07/12 07:35, 水静流深 a écrit :
> there is a data frame £¬x
> weekly.returns
> 2010-1-4 -0.015933327
> 2010-1-11 -0.015042868
> 2010-1-18 0.005350297
> 2010-1-25 -0.049324703
> 2010-2-1 -0.052674121
> when i input
> colnames(data)[1] <- 'date'
> it becomes
> date
> 2010-1-4 -0.015933327
> 2010-1-11 -0.015042868
> 2010-1-18 0.005350297
> 2010-1-25 -0.049324703
> 2010-2-1 -0.052674121
> how can i change ti into:
> date weekly.returns
> 1 2010-1-4 -0.015933327
> 2 2010-1-11 -0.015042868
> 3 2010-1-18 0.005350297
> 4 2010-1-25 -0.049324703
> 5 2010-2-1 -0.052674121
> [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> 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