Displaying 20 results from an estimated 10000 matches similar to: "how to make automatically each level from data.frame to vector"
2011 Feb 18
3
How to change dataframe to tables
The data is in the attachment.
What I wanna get is:
, , Sex = Male
Eye
Hair Brown Blue Hazel Green
Black 32 11 10 3
Brown 53 50 25 15
Red 10 10 7 7
Blond 3 30 5 8
, , Sex = Female
Eye
Hair Brown Blue Hazel Green
Black 36 9 5 2
Brown 66 34 29 14
Red 16 7 7 7
Blond 4
2010 Sep 19
1
odds ratios for n-way tables: seeking an *apply-able method
I'm looking for a way to generalize the calculation of (log) odds
ratios for 2 x 2 x {strata} frequency
tables in vcd::oddsratio() to R x C x {strata} tables.
For an R x C table, F, odds ratios can be defined
in several ways; one simple way, particularly for tables with ordered
factors, is to calculate the
set of continuation odds ratios, based on the (R-1)x(C-1) set of 2x2
tables with
2009 Dec 15
2
Diagonal Labels on "Beside" Bars in Barplot
My question is based on an example provided in the following:
Referencing:
Statistics with R
Vincent Zoonekynd
<zoonek at math.jussieu.fr>
6th January 2007
URL:
http://zoonek2.free.fr/UNIX/48_R/all.html
data(HairEyeColor)
a <- as.table( apply(HairEyeColor, c(1,2), sum) )
# Provided Example
barplot(a, beside = TRUE,
legend.text = attr(a, "dimnames")$Hair)
# I
2010 Oct 03
1
plyr: a*ply with functions that return matrices-- possible bug in aaply?
I have an application where I have a function to calculate results for
a 2-way table or matrix, which
returns a matrix with one less row and column. To keep this short, the
function below captures the structure:
fun2way <- function(f){
if (!length(dim(f)) ==2) stop("only for 2-way arrays")
R <- dim(f)[1]
C <- dim(f)[2]
f[1:(R-1), 1:(C-1)]
}
Now, I want to
2006 Dec 06
2
vcd package, assoc()
Hello,
I am trying to use the extended assocplot() function: assoc(), from vcd
package. Trouble is that it cannot even run its own examples on my
installation. I get this output:
$> example(assoc)
assoc> data("HairEyeColor")
assoc> (x <- margin.table(HairEyeColor, c(1, 2)))
Eye
Hair Brown Blue Hazel Green
Black 68 20 15 5
Brown 119 84 54
2007 Jul 18
0
HSAURtable question
It appears that HSAURtable only works on two dimensional tables. Is this
correct?
For example, here is HairEyeColor:
, , Sex = Male
Eye
Hair Brown Blue Hazel Green
Black 32 11 10 3
Brown 38 50 25 15
Red 10 10 7 7
Blond 3 30 5 8
, , Sex = Female
Eye
Hair Brown Blue Hazel Green
Black 36 9 5 2
2003 Jun 13
0
mca & contingency tables - error: "All variables must be factors"
Hi,
I would like to do a multiple correspondence analysis with the mca function in
the MASS library on data that I have as a contingency table (which I've tried
converting to a data frame).
For example,
=========
> data(HairEyeColor)
> hair.df <- as.data.frame(HairEyeColor)
> hair.df
Hair Eye Sex Freq
1 Black Brown Male 32
2 Brown Brown Male 38
3 Red
2009 Aug 04
4
array slice notation?
Suppose I have an n-diml array A and I want to extract the first "row" -- ie
all elements A[1, ...]
Interactively if I know 'n' I can write A[1,,,,,] with (n-1) commas.
How do I do the same more generally, eg in a script?
(I can think of doing this by converting A to a vector then extracting the
approp elements then reshaping it to an array, but I wonder if there isn't a
2002 Jan 30
1
mosaicplot(formula, data)--- bugged?
I have been tinkering with mosaicplot() and friends as a way
of learning R. As part of this, I've written a pair.table()
method for mosaic matrices, and would like to extend mosaicplot
to work with loglin and logln (MASS) objects. I'm using
R 1.4.0 on Win 98.
I've been trying to figure out the formula interface, and think
there's a bug, but not sure how to find it, yet alone fix
2002 Feb 08
2
bugs or imperfect implementation?
I am using R to teach, and here are a couple of things that I thought
would work didn't work.
1. I noticed the utility data(***,package=***) recently and like it
very much, but unless I type in the whole word "package" I'll get an
error in 1.4.0. For example, data(cats,package=MASS) works fine but
data(cats,pac=MASS) doesn't.
2. drop1 doesn't seem to be as smart as
2005 Dec 20
1
Help to find only one class and differennt class
Dear R users,
I have a problem, which I can not find a solution.
Probably someone could help me?
I have a result from my classification, like this
> credit.toy
[[1]]
age married ownhouse income gender class
1 20-30 no no low male good
2 40-50 no yes medium female good
[[2]]
age married ownhouse income gender class
1 20-30 yes yes high male
2001 Nov 30
1
mosaic.by(): vectorizing args passed by apply()?
I've just started learning R, so I'm still on the steep part of the
learning curve, but my enthusiasm was heightened by learning that
there's a very nice implementation of mosaicplot().
As a learning project, I've already done a basic implementation
of a pairs.table() function which does a mosaic scatterplot matrix,
and now I'm trying to do conditional mosaic plots (discrete
2007 Oct 05
3
Tart charts
It being friday, I would like to call your attention to an innovative
data analysis by Leslie Lamport available from:
http://research.microsoft.com/users/lamport/pubs/hair.pdf
I particularly liked the graphics.
url: www.econ.uiuc.edu/~roger Roger Koenker
email rkoenker at uiuc.edu Department of Economics
vox: 217-333-4558 University of Illinois
2005 Feb 23
2
data.frame error message
Dear R users,
I am using v2.0.1 on Windows 2000. I have read a ".dat" file with several
vectors, including 2 factors (2 levels x 3 levels), and a vector of
responses, into R. There are no unique row names. When I try plot(x,y) or
lm(y~x) the following error is returned:
Error in model.frame(formula, rownames,...extranames: variable lengths differ
What am I doing wrong? I am a
2003 Dec 11
1
packaging standards for rda files?
Dear everybody:
We used the fine foreign library to bring in an SPSS dataset that was
about 9 megabytes and I can squeeze it into a much smaller R object
using compression with
save(ndat, file="NatAnnES2000.rda", compress=T).
I can use load() to get the "ndat" dataframe back, that's all good as
far as I can see. If I put that file in the data subdirectory, then the
2013 Aug 18
1
How does R_UnboundValue and removing variables work?
Reading "R Internals" made me believe that R_UnboundValue was a placeholder
that would be skipped over in variable lookup. viz. the section of R
Internals "Hash tables" says "items are not actually deleted but have their
value set to R_UnboundValue.", which seems to align with what I read in
envir.c.
So, I reasoned, if I have a function that returns R_UnboundValue,
2010 May 01
2
Average Login based on date
Hi All,
I have the data like this :
>sample <- read.csv(file="sample.csv",sep=",",header=TRUE)
> sample
stdate Domain sex age Login
1 01/11/09 xxx FeMale 25 2
2 01/11/09 xxx FeMale 35 4
3 01/11/09 xxx Male 18 30
4 01/11/09 xxx Male 31 3
5 02/11/09 xxx Male 32 11
6 02/11/09 xxx Male 31 1
7 02/11/09
2008 Feb 12
3
help with bwplot
Dear list,
I have following data set, which I want to plot the "Scale" variable on the
x-axis and "Mean"´on the y-axis for each Ageclass and for each sex. The Mean
value of each Ageclass for each sex would be connected by a line. Totally,
there should be 6 lines, from which three present the Mean values of each
Ageclass for respective sex. Are there any easy ways to do
2005 Dec 24
2
grouping data
Hello R-users/experts,
I am new to R-
I have a simple question:
Let say I have a data set as follows
temp:[file attached]
the data structure is a follows:
sex age
female 28
female 53
female 53
female 36
male 42
male 29
male 43
male 36
male 41
Here we are grouping all male value into male and all female value in to
female