On Sat, 2010-07-17 at 13:15 +0800, elaine kuo wrote:> Dear List,
>
> I tried to conduct cca using csv data but failed.
> The message said that data.frame is required.
>
> Please kindly share how to convert a csv-imported file to a data.frame.
> Thank you.
It was a dataframe. You aren't giving ade4:::cca a dataframe because you
are extracting a single component of that data frame in your call.
Witness:
> dat <- data.frame(X = rnorm(10), Y = rnorm(10))
> class(dat$X)
[1] "numeric"> is.data.frame(dat$X)
[1] FALSE
The reason ade4:::cca expects a dataframe is that CCA is generally used
for a *multivariate* response. Here you are supplying a univariate
response.
HTH
G
>
> Elaine
>
> code
>
> rm(list=ls())
> spec
<-read.csv("c:/migration/M_R_20100718_winterM_spec_vegan.csv",header=T,
> row.names=1)
> dim(spec)
> spec[1,]
>
> envi
<-read.csv("c:/migration/M_R_20100718_winterM_envi_vegan.csv",header=T,
> row.names=1)
> dim(envi)
> envi[1,]
>
> library(ade4)
>
> w.cca <- cca(spec$WinterM_ratio, envi, scan=TRUE)
> error in cca(spec$WinterM_ratio, envi, scan = FALSE) :
> data.frame expected
>
> [[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.
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%