On Wednesday, September 19, 2012, Jul_biologyGrad wrote:

> Thanks everyone for the help! I pulled together a bunch of your suggestions
> to get the result that I needed. I'm posting my final code below. Probably
> not the most efficient way of doing things but gets the job done in a way
> that a newbie can understand!
>
> ##Here again is the example dataset
>
> Sample<-c(1,1,1,2,2,2,3,3,3)
> Mass<-c(3,3.1,3.4,4,4.3,4.4,3,3.2,3.5)
> Time<-c(1,2,3,1,2,3,1,2,3)
> mydata<-as.data.frame(cbind(Sample,Time,Mass))
>
>
One (strongly advised) bit of advice. Don't use the
as.data.frame(cbind(....)) construction -- it's really quite odious.

cbind() forces its arguments all to the same mode, while the entire point
of a df is to allow different types. As.df could theoretically see values
of different types, but it has no idea what went into cbind() so it doesn't
bother to change it.

Rather you should use the data.frame constructor directly:

data.frame(Sample, Time, Mass)

It might not matter here but it will save you headaches down the road.

Cheers, RMW

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to