Thank you Phil, Bernardo and Jorge for all your help. All your suggested
options work very well !

Regards
Himanshu
\\

On Fri, Oct 17, 2008 at 5:01 AM, Bernardo Rangel Tura
<tura@centroin.com.br>wrote:

> Em Qui, 2008-10-16 às 22:31 +0200, Himanshu Ardawatia escreveu:
> > Hello,
> >
> > I am running Kruskal-Walis test in R. When I try to save results using
> > write.table it gives me the following error :
> >
> > Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors
> =
> > stringsAsFactors) :
> >   cannot coerce class "htest" into a data.frame
> >
> > The overall code is as follows :
> >
> > >data_file = read.table("~/DATA.dir/data_file.txt", header=T)
> >
> > >attach(data_file)
> >
> > >data_file.out <- krukal.test(data_file)
> >
> > >write.table(data_file.out, "~/DATA/results/data_file_out.txt")
> >
> > Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors
> =
> > stringsAsFactors) :
> >   cannot coerce class "htest" into a data.frame
> > Results do come in data_file.out after analysis as seen below:
> >
> > >data_file.out
> >
> >
> >     Kruskal-Wallis rank sum test
> >
> > data:  value by pathway
> > Kruskal-Wallis chi-squared = 5.6031, df = 3, p-value = 0.1326
> >
> >
> > I am wondering if I am making a mistake with using write.table (It works
> > very well saving results from anova analysis) or is there any other way
> to
> > save results in a file for future use..
> >
> > Thanks
> > Himanshu
>
>
> Hi Himanshu
>
> Well the output of htests is a list so data_file.out is a lista to.
>
> You don't put a list ins a data.frame so you need make this
>
>
> data.frame(unlist(data_file.out))
>
> --
> Bernardo Rangel Tura, M.D,MPH,Ph.D
> National Institute of Cardiology
> Brazil
>
> Dear Himanshu,
Try ?sink() :


data_file.out <- krukal.test(data_file)
sink("~/DATA/results/data_file_out.txt")
data_file.out
sink()


HTH,

Jorge

	[[alternative HTML version deleted]]

