similar to: R code for overlapping variables -- count

Displaying 20 results from an estimated 6000 matches similar to: "R code for overlapping variables -- count"

2024 Jun 03
1
R code for overlapping variables -- count
If they are binary (0/1 dummies), can't you just "&" them as in table(Female & USA & MidIncome) (or sum() if you don't care about the number of 0s) -pd > On 2 Jun 2024, at 00:31 , Shadee Ashtari <shadee.ashtari at gmail.com> wrote: > > Hi! > > I am trying to find the code for how to get counts for intersectional > variables. For example,
2024 Jun 02
2
R code for overlapping variables -- count
Dear Shadee, If you have a data.frame with the following columns: n = 100; # population size x = data.frame( ??????Sex = sample(c("M","F"), n, T), ??????Country = sample(c("AA", "BB", "US"), n, T), ??????Income = as.factor(sample(1:3, n, T)) ) # Dummy variable ONE = rep(1, nrow(x)) r = aggregate(ONE ~ Sex + Income + Country, length, data = x)
2024 Jun 02
1
R code for overlapping variables -- count
?s 18:34 de 02/06/2024, Leo Mada via R-help escreveu: > Dear Shadee, > > If you have a data.frame with the following columns: > > n = 100; # population size > x = data.frame( > ??????Sex = sample(c("M","F"), n, T), > ??????Country = sample(c("AA", "BB", "US"), n, T), > ??????Income = as.factor(sample(1:3, n, T)) > )
2005 Mar 29
1
Mosaicplot with different colors
This dataset below is one sample answer the questioner from our customer. > testbank <- read.table("testbank.txt", header=T) > testbank age married income gender ownhouse class 1 20-30 no high female yes 1st 2 30-40 no high female yes 1st 3 40-50 no low female yes 1st 4 50-60 no high female yes 1st 5 60-70
2012 Aug 15
1
shade overlapping portions of circles (or other shapes)
I'm making some illustrations and it would be convenient to automatically shade the overlapping portions of circles. These illustrations are for Social Choice theory, a field in political science and economics. I've wrestled together some examples so you can see what I mean, but have not mastered the "color overlapping sections" problem (as you will see):
2007 Aug 05
1
Selectively shading areas under two density curves
Dear Listers, I am drawing a plot of two density curves, for male and female incomes. I would like to shade/hatch/color (whatever) the areas under the curves which are distinctive for each gender. This is the code I have tried so far: m <- density(topmal.d$y, bw = "sj") f <- density(topfem.d$y, bw = "sj") par(mfrow = c(1,1)) plot(x = c(0,400), y = c(0,0.02), type =
2010 Apr 08
2
erasing an area of a graph
I have a case where the easiest way to draw a particular symbol would be to draw something a little bigger, and then use polygon(... , col=0) to erase the extra stuff. Just how to do this best when par('bg') = 'transparent' is, however, eluding me. I've looked through the archives and the book R Graphics without quite seeing the light. Help or pointers to help would be
2013 Apr 18
6
count each answer category in each column
Hey, Is it possible that R can calculate each options under each column and return a summary table? Suppose I have a table like this: Gender Age Rate Female 0-10 Good Male 0-10 Good Female 11-20 Bad Male 11-20 Bad Male >20 N/A I want to have a summary table including the information that how many answers in each category, sth like this: X
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
2008 Aug 20
4
Removing
I'm trying to remove the elements "No" from the character vector
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
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
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
2010 May 07
2
extract required data from already read data
Hi all, I have 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
2009 Mar 17
2
converting null to some values
Hi, I have newbie question. Suppose I have the following data: temp <- data.frame(type1 = c("male", "female", "male", "female", "female"), type2 = c("low", "med", "high", "low", "med"), a = c(1,2,4, NA, 3), b = .... [TRUNCATED] temp type1 type2 a b c 1 male low 1 5 0 2 female
2008 Nov 16
1
confint.glm(...) fails for binomial count data format
##Q1. confint.glm(...) fails for an example of HSAUR data("womensrole", package = "HSAUR"); ## summary(womensrole); womensrole_glm_2 <- glm(fm2, data = womensrole,family = binomial()) ## summary(womensrole_glm_2); confint(womensrole_glm_2); ## -------Fail--------- # Waiting for profiling to be done... # Error in if (any(y < 0 | y > 1)) stop("y values must be 0
2008 May 02
1
Cant resolve Error Message
Hi, Im having trouble creating the following graph. Here is my code: library(plotrix) library(prettyR) female_improvement <-read.table("C://project/graphs/gender/breakdown/gender-improvement/female-improvement.csv", sep=",", header=TRUE) barp(rbind(rep(length(female_improvement$gender),2),freq(female_improvement$reason)[[1]]), ylab="22 Males participated in the
2008 Nov 17
5
how to calculate another vector based on the data from a combination of two factors
Hi, I have a data set similar to the following State Gender Quantity TX Male 1 NY Female 2 TX Male 3 NY Female 4 I need to calculate cumulative sum of the quantity by State and Gender. The expected output is State Gender Quantity CumQuantity TX Male 1 1 TX Male 3 4 NY Female 2 2 NY Female 4 6 I highly appreciate if someone can give me some hints on solving that in R. Hao -- View this
2006 May 01
3
pulling items out of a lm() call
I want to write a function to standardize regression predictors, which will require me to do some character-string manipulation to parse the variables in a call to lm() or glm(). For example, consider the call lm (y ~ female + I(age^2) + female:black + (age + education)*female). I want to be able to parse this to pick out the input variables ("female", "age",
2005 Jun 25
1
Confidence interval bars on Lattice barchart with groups
I am trying to add confidence (error) bars to lattice barcharts (and dotplots, and xyplots). I found this helpful message from Deepayan Sarkar and based teh code below on it: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/50299.html However, I can't get it to work with groups, as illustrated. I am sure I am missing something elementary, but I am unsure what. Using R 2.1.1 on various