Re: [R] import contingency table

2012-05-28 Thread Rui Barradas
David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Rui Barradas Sent: Monday, May 28, 2012 9:43 AM To: Milan Bouchet-Valat Cc:

Re: [R] import contingency table

2012-05-28 Thread David L Carlson
4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Rui Barradas > Sent: Monday, May 28, 2012 9:43 AM > To: Milan Bouchet-Valat > Cc: r-help > Subject: Re: [R] import contingency table > > Ok, try

Re: [R] import contingency table

2012-05-28 Thread Rui Barradas
Ok, try the following. df2table <- function(x, Var1="Var1", Var2="Var2"){ tbl <- as.matrix(x) dnames <- list(rownames(x), colnames(x)) names(dnames) <- c(Var1, Var2) attr(tbl, "dimnames") <- dnames attr(tbl, "class") <- "table" tbl } df2table(xls_contingency) # using de

Re: [R] import contingency table

2012-05-28 Thread Milan Bouchet-Valat
Le lundi 28 mai 2012 à 15:19 +0200, sylvain willart a écrit : > no, > the problem is that the lines in my file do not correspond to > individuals, but are variables, just like are the columns, > my file is already a contingency table, with each cell being a frequency: > > here is a sample of it: >

Re: [R] import contingency table

2012-05-28 Thread sylvain willart
no, the problem is that the lines in my file do not correspond to individuals, but are variables, just like are the columns, my file is already a contingency table, with each cell being a frequency: here is a sample of it: *** ,AUC,Alin,BLG,B

Re: [R] import contingency table

2012-05-28 Thread sylvain willart
Thanks Rui, but my problem is not to read an xls file, I converted already to csv, but rather to read a contingency table into R, and telling R it is astually a contingency table, and not a data.frame... file below, if it helps... Sylv ,AUC,Alin,BLG,BrDep,CRF,CrfMkt,CAS,Casto,Confo,ElecDep,Geant

Re: [R] import contingency table

2012-05-28 Thread Rui Barradas
Hello, Try function read.xls in library gdata Also, a good way of avoiding such doubts is library(sos) findFn('xls') It returns read.xls as the first line. Hope this helps, Rui Barradas Em 28-05-2012 11:32, sylvain willart escreveu: hello everyone, i often work on contingency table that I

[R] import contingency table

2012-05-28 Thread sylvain willart
hello everyone, i often work on contingency table that I create from data.frame (with table() function) but a friend sent me an excel sheet wich *already is* a contingency table (just a simple 2 way table !...) any clue on how to import it in R (keeping row names and col names) ? any tuto I com