[R] how to create the data frame

arun smartpink111 at yahoo.com
Thu Jul 12 04:31:33 CEST 2012



Hi,

dat1<-read.table(text="
    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
",sep="",header=TRUE)

str(dat1)
'data.frame':    5 obs. of  1 variable:
 $ weekly.returns: num  -0.01593 -0.01504 0.00535 -0.04932 -0.05267
#dates in the dataframe represents row names.
rownames(dat1)
[1] "2010-1-4"  "2010-1-11" "2010-1-18" "2010-1-25" "2010-2-1" 

A.K.



----- Original Message -----
From: sureshraj <sureshmallikaraj at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Wednesday, July 11, 2012 5:32 AM
Subject: Re: [R] how to create the data frame

Hi Dude!!

It seems that your column names are not sequentially arranged, I guess, 

If so u just reorder them and do it your way...it will work..

for example,

colnames(data)[2]<–"weekly.returns" ## sometimes u can use like this as
well, if u want to assign at last most column 
                                                                   ## in
your data frame
                                                                   ## 
names(data)[ncol(data)]<–"weekly.returns"
and
colnames(data)[1]<– "date"

I hope it will work for your bug!!!

--
View this message in context: http://r.789695.n4.nabble.com/how-to-create-the-data-frame-tp4636111p4636117.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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