Displaying 20 results from an estimated 7000 matches similar to: "transforming table into data frame"
2000 Aug 23
1
3D perspective of a contingency table
How can I draw a 3D perspective of a contingency table, that is
showing 3D bars whose height is in proportion of the table cells?
---------------
Charles RAUX,
Laboratoire d'Economie des Transports
CNRS-Universit? Lumi?re Lyon 2-ENTPE
email : charles.raux at let.ish-lyon.cnrs.fr
http://www.ish-lyon.cnrs.fr/let
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2002 Jul 12
2
Crosstabs in R
Before I reinvent the wheel, I have need for a relatively straightforward
crosstabulation (2 x n) function. I know that R has table(), ftable(),
xtabs(), and summary(xtabs()), but none of these produce a fully "tricked"
out cross-tabulation with marginal totals, expected cell frequencies, and
an array of statistics about the contingency table.
Is there a more complete (something
2007 Oct 05
1
creating objects of class "xtabs" "table" in R
I have an application that would generate a cross-tabulation in array
format in R. In particular, my application would give me a result
similar to that of :
array(5,c(2,2,2,2,2))
The above could be seen as a cross-tabulation of 5 variables with 2
levels each (could be 0 and 1). In this case, the data were such that
each cell has exactly 5 observations. I
Now, I want the output to look like the
2006 Dec 31
3
tabulate: switching columns and rows
Hi all,
Please, is there any way of controlling factors in row/columns when using ftable/xtabs? As far as I can see, the last cross-clasifing variable in the formula will appear in columns. The previous ones, in rows. For instance, is it possible to make tension and replicate appear in columns?
ftable(xtabs(breaks ~ wool + tension + replicate, data = warpbreaks))
After some years using SAS
2008 Jan 23
3
How to do more advanced cross tabulation in R?
Hi,
I am trying to reproduce some functionalities of Excel pivot table in R,
sadly, I couldn't figure out how to do it. I am wondering if this is even
possible in R. Does anyone know?
Here is an example:
year=rep(2003,16)
quarter=rep(1:4,each=4)
sales=1:16
company=rep(c("a","b","c","d"),4)
df=data.frame(year,quarter,sales,company) #this is the
2003 Feb 14
2
RODBC connection failed
I am trying to restart on R after 2 months stop. Start with previously
functioning procedure:
"ch<-odbcConnect("dBase Files")"
get
"Warning message:
ODBC connection failed in: odbcConnect("dBase Files") "
I have tried unsuccessfully different working directories.
The only change I see is that I am working with a new login account on
the same machine.
2015 Feb 09
3
xtabs and NA
Hi
I haven't found a way to produce a tabulation from factor data with NA
values using xtabs. Please find a minimal example below, it's also on
R-pubs [1]. Tested with R 3.1.2 and R-devel r67720.
It doesn't seem to be documented explicitly that it's not supported.
From reading the code [2] it looks like the relevant call to table()
doesn't set the "useNA"
2008 Mar 29
1
Tabulating Sparse Contingency Table
I have a sparse contingency table (most cells are 0):
> xtabs(~.,data[,idx:(idx+4)])
, , x3 = 1, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 31
2 0 0 112
3 0 0 94
, , x3 = 2, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 0
2 0 0 0
3 0 0 0
, , x3 = 3, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 0
2 0 0 0
3 0 0 0
, , x3 = 1, x4
2003 Nov 06
1
Question about computing offsets automatically
Hi,
I'm using R version 1.8.0 on Windows NT. When fitting a glm with Poisson
random component and a log link, I frequently need to include an offset.
Typically I use xtabs or table to get the counts for the contingency table,
and then I use as.data.frame.table to create a data frame that I can use in
the glm function. I have not found an option that allows me to total the
offset variable to
2000 Aug 28
2
Windows / RODBC / Accented characters
A disturbing behaviour of R: an import of data using RODBC library
(Windows 98, R 1.1.1) recognizes accented characters in variables
names but these can't be manipulated further. See below:
> library(Rodbc)
> ch<-odbcConnect("Paradox Files")
> pollut<-sqlFetch(ch,Pollutio)
> pollut
Mortalit? Densit? Pollution
1 82 600 110
2 97 960
2007 Jan 09
1
contingency table analysis; generalized linear model
Dear List,
I would appreciate help on the following matter:
I am aware that higher dimensional contingency tables can be analysed using either log-linear models or as a poisson regression using a generalized linear model:
log-linear:
loglm(~Age+Site, data=xtabs(~Age+Site, data=SSites.Rev, drop.unused.levels=T))
GLM:
glm.table <- as.data.frame(xtabs(~Age+Site, data=SSites.Rev,
2000 Aug 30
1
Memory management
Some naive questions:
1) How to remove a column in a data frame? I expected that rm would
work but this is not the case (e.g. rm(dat$yyy) gives Warning
message: remove: variable dat$yyy was not found). I only found to
assign NULL value (e.g.: dat$yyy<-NULL). Is it the right way?
2) Is the place formerly occupied by dat$yyy automatically gained by
R for other uses?
3) If t1 and t2 are 2 only
2000 Nov 24
1
groupe averages error
I want to get subsets averaged on numeric variables number 5:13 but I
get the error below that I cannot understand.
> is.factor(dat$Statut)
[1] TRUE
> s<-ave(dat[,5:13],dat$Statut)
Error in [<-.data.frame(*tmp*, , value = if (n) { :
Argument "i" is missing, with no default
Thanks in advance
---------------
Charles RAUX,
Laboratoire d'Economie des Transports
2000 Aug 31
2
Multiv / hierclust / plclust
I use hierclust (hierarchical clustering) in multiv package. In the
documentation it is said that plclust (plotting a dendrogram) is
available in S-plus. Can I find it anywhere (I have searched through
http://lib.stat.cmu.edu/S and found only quotations of plclust in
multiv) or is it only part of the S package (which I don't have)?
Thanks
---------------
Charles RAUX,
Laboratoire
2009 Dec 13
1
xtabs - missing combination
Dear list,
I am trying to make a contingency table with xtabs but I am getting
a 0 where I expect a 'NA'. Here is a simple example:
options(stringsAsFactors = FALSE)
rn <- LETTERS[1:4]
df1 <- data.frame(r07 = rep(rn, each=4),
r08 = rep(rn, 4), value = 1:16)
xtabs(value ~ r07 + r08, df1)
# Delete the combination [A, C]
df1 <- df1[-3,]
# Set 'value'
2000 Sep 04
2
plot history, libraries, weights
3 general questions:
1) How can I have the plot History Recording automatically turned on
each time I start R (Windows)?
2) How can I have some libraries automatically loaded at R start?
3) As far as I know weights can be specified only for lm. How can I
take account of weights with a weighted sample in other models or
functions (table but also other multivariate and cluster techniques)?
Thanks
2003 Apr 30
1
sorting factors
Hi,
I've been trying to sort the values of the factors of contingency tables
generated with xtabs. For example, I have a factor called "artic" with three
possible values that I would like to order in a specific way -- but I'm not
sure how to go about this.
> test <- read.table("test.tab",header=TRUE,sep="\t")
> artic =
2007 Dec 16
1
format numbers in a contingency table
Hi,
I am constructing a contingency table using xtabs. The function works great:
mo
yr Sep Oct Nov Dec
1950 -7.164486e-02 3.152674e-02 -1.283389e-02 1.570382e-01
1951 3.054293e-02 4.665234e-02 -2.445499e-04 8.720204e-02
1952 3.937034e-02 -4.790636e-02 5.022616e-02 1.180279e-01
but I wonder if there is an argument I can pass to xtabs
2008 Jan 25
4
Function for translation of a list into a matrix as used by ordination?
Hello.
Does anyone know of an existing function that takes a list in the form of:
Plot1 Species1 Abundance1
Plot1 Species2 Abundance2
Plot2 Species1 Abundance1
Plot2 Species3 Abundance3
.
.
.
PlotN SpeciesN AbundanceN
and translates into a matrix in the form of
Species1 Species2.... SpeciesN
Plot1 Abundance1 Abundance2... AbundanceN
Plot2 Abundance1
2000 Aug 14
5
Writing a workable function
After searching in R- Introduction, FAQ, help... I don't understand
this:
I write a function in a file (.R):
tt <- function(mc) { date()
mc<-read.csv2("machines.txt",na.strings="")
date()
}
I source it in R and I type tt(). The answer is
> tt()
[1] "Mon Aug 14 11:18:25 2000"
>
The instructions following the first "date()" are ignored. Why?