Questions tagged [proportions]

A fractional value typically found by dividing a count of items with particular characteristics by a counts of items in a larger group.

92 questions
3
votes
2 answers

Get the frequency percentages for multiple variables in a dataset

I am writing a function to produce a frequency table using prop.table, and want to produce this for several categorical variables in the data set. I am using datasets::mtcars for this example. I am looking to write the function with a group_by on…
four77
  • 49
  • 4
3
votes
3 answers

How to exclude percentages from Total column and row when using janitor::adorn_percentages()

Is there any way I can get the output below directly from adorn functions? library(janitor) library(stringr) df <- mtcars %>% tabyl(am, cyl) %>% adorn_totals(c("row", "col")) %>% adorn_percentages("row") %>% adorn_pct_formatting(digits = 2)…
Mathica
  • 1,241
  • 1
  • 5
  • 17
2
votes
1 answer

Obtaining proportions and confidence intervals with prop.test() for multiple groups in R

I need to get the positivity rate by county for multiple drugs and multiple counties. The real data includes more drugs and more counties. The NA values mean that the test was not ordered so they should not be counted as the total number of…
Mando
  • 47
  • 3
2
votes
1 answer

How to calculate the 95% CI for a difference in proportions for survey weighted data?

When calculating a difference in two proportions I've seen that you can use the svyglm function in the survey package (gaussian family) to fit the model. Is there a way to obtain wilson 95% CIs for difference in proportions for survey weighted…
s.g
  • 126
  • 7
2
votes
2 answers

R frequency tables only for certain values

I have a vector with 15 values ranging from 1 to 4. values <- c(1,2,3,1,2,3,1,2,2,2,1,3,1,2,4) Lets say this is an item in a questionnaire and 15 people got asked a certain question. 1 to 2 means, the respondant is referring to that question with a…
Sascha
  • 159
  • 6
2
votes
0 answers

How do I get the proportion of variability between 0 and 1

working on SVD and the question is this: s being the svd(data), the proportion of variabiilty in the data explained by the xth column of is equal to s$d[x]^2 divided by the sum of all s$d values. It asks the 'proportion' for different column values…
2
votes
3 answers

How to calculate a proportion in R

I have this reproducible DataFrame: structure(list(age = c(62.84998, 60.33899, 52.74698, 42.38498, 79.88495, 93.01599, 62.37097, 86.83899, 85.65594, 42.25897), death = c(0, 1, 1, 1, 0, 1, 1, 1, 1, 1), sex = c("male", "female",…
barnsm2
  • 185
  • 7
2
votes
1 answer

Prop.test on count data with multi-level factors in R

I'm having trouble figuring out if prop.test can run this much data (See below) or if I would need to run the code for each level of the factor "Zone" individually. So far I've seen many examples written in this format, but I have many more factor…
Nate
  • 411
  • 2
  • 10
2
votes
1 answer

s3 is there a way to combine prop.table for character variables?

Noob here, I'm stuck trying to use S3 to summarise proportion data for a data.frame where there are four columns of character data. My goal is to build a summary method to show the proportions for every level of every variable at one time. I can see…
iKcon
  • 71
  • 7
1
vote
1 answer

R ggplot facetted pie chart: whole pies vs parts of pies

I want to plot a facetted pie chart in R/ggplot. There are 3 dimensions to be plotted. The plot I was able to realise is generally what I wanted, except one detail: with geom_bar(stat="identity",......,position=position_fill())+ all 3 circles are…
michel
  • 33
  • 6
1
vote
0 answers

Can I use quasi-binomial regression on proportion data in this way?

prop.pass = proportion of students who passed the exam num = number of students who sat the exam urban = if school is in urban area (1 = urban, 0 = rural) %dis = % pupils at school defined as "disadvantaged" (by parental income). Students either are…
Jess
  • 11
  • 2
1
vote
1 answer

SE calculation for proportions using "survey" package in R

I am analysing data using the survey package. There is a function svyciprop that allows for CI calculation but I am trying to find a proper way to calculate standard errors for proportions. Only two things worked until now, using…
1
vote
1 answer

Julia function for conditional proportions given margins of multi-dimensional array

I am new to Julia and looking for a function to compute the proportions of multidimensional array give some dimensions as margin. Basically, it is dividing each element of the array by the sum of element in the desired dimensions. In R,…
Mohammad
  • 97
  • 5
1
vote
1 answer

Can i compare frequency of values within one column?

So let's say I have a one column dataset: this column is a categorical variable with 5 levels (a,b,c,d,e). How can I compare the frequency of of each level to each other? Is there a way to do so? Thank you. I tried but couldnt work it out
learningr
  • 11
  • 1
1
vote
0 answers

Randomly split sample into two groups with proportional representation on 2+ variables

I'd like to divide a sample into two groups such that there is proportional representation of 2 or more variables in those two groups. For instance, in the mtcars dataset, here are the proportions of the last 3 variables in the data.frame: >…
Jon
  • 753
  • 8
  • 18
1
2 3 4 5 6 7