Hi,
Try:
data_test<-data.frame(id, dates, info, sqfootage,
lotsize,stringsAsFactors=FALSE)
data_test[order(with(data_test,as.Date(dates,"%m/%d/%Y"))),]
id dates info sqfootage lotsize
3 ID3 2/03/2013 siding 3000 0.75
2 ID2 1/16/2014 wood 2000 0.50
1 ID1 2/16/2014 br
Thank you very much for your posts. I updated the example, which was taken
from the following:
http://cran.r-project.org/doc/contrib/Torfs+Brauer-Short-R-Intro.pdf
Hopefully the below is a bit more representative question, but unfortunately,
it looks like I'm not inputting the dates informati
Try:
t[order(t$z),]
#or
t[with(t,order(z)),]
A.K.
On Sunday, March 16, 2014 12:27 AM, Jason Rupert wrote:
Evidently, I'm overlooking something simple. I'm trying to used order with
data.frame.
For example:
t = data.frame(x = c(11,12,14), y = c(19,20,21), z = c(10,9,7))
t[order(z), ]
It is not order that you are having difficulty with... it is name scope. Your
"z" is not a standalone variable, but a column in your "t" data frame.
Try
t[order(t$z), ]
Note that "t" is the name of a commonly-used function in R that transposes
matrices. It is generally not a good idea to reuse
Indeed you are -- the syntax for selecting columns of a data frame (or
components from a list).
Advice: Read "An Introduction to R" or online tutorial of your choice
to learn proper syntax.
Cheers,
Bert
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
"Data is not information. In
Evidently, I'm overlooking something simple. I'm trying to used order with
data.frame.
For example:
t = data.frame(x = c(11,12,14), y = c(19,20,21), z = c(10,9,7))
t[order(z), ]
Error in order(z) : object 'z' not found
Thank you for any insights and advice provided.
[[alternative
6 matches
Mail list logo