Questions tagged [frequency-table]
38 questions
3
votes
3 answers
frequency table for repeated measure
original df:
ID <- c(1,1,1,1,2,2,2,2,3,3,3,3,3)
DX <- c("A","A","B","B","C","C","A","B","A","A","A","B","B")
df <- data.frame(ID,DX)
ID DX
1 1 A
2 1 A
3 1 B
4 1 B
5 2 C
6 2 C
7 2 A
8 2 B
9 3 A
10 3 A
11 3 A
12 3 …

Bruh
- 277
- 1
- 6
2
votes
1 answer
How do I create frequency tables for subsets of a dataframe?
I was helped earlier with applying a weight while generating a frequency table. Now I have a question about the next step, but here I'm merely looking for a better solution than the clumsy work-around I have managed to come up with.
My dataframe now…

SpecialK201
- 111
- 7
2
votes
1 answer
How to get median with frequency table in R?
Problem
I have changed the presentation of my question as there seems to be a lack of clarity.
So, we have thousands of hospitals. Their patients are between the ages of 0 and 100 years old. For each age, they have certain numbers of patients e.g.…

Namra
- 359
- 1
- 10
2
votes
2 answers
Creating a frequency distribution table in Python
I'm new to Python and Pandas, and i'm struggling to create a frequency distribution table form my df.
My dataframe is something like this:
Balances
Weight
10
7
11
15
12
30
13
20
10
15
13
20
edit: The balance numbers are its…

Croyd
- 39
- 5
2
votes
1 answer
How to create a box plot from a frequency table
In the table below, I have values and frequencies. I'd like to draw a box-plot using Jupyter Notebook. I googled it but not able to find any answers.
My idea is to create a column, 2,2,2,2,4,4,4,4,4,4,4,...
But I think there must be a better…

shin
- 31,901
- 69
- 184
- 271
1
vote
2 answers
How do I obtain a weighted frequency table with proportions?
I'm working on a dataset that includes a post-stratification weight, and I am looking for a way to get more info about specific variables after they have been weighted, but I am struggling.
Here's a sample dataframe:
a <- c(1, 3, 2, 1, 2, 2, 3, 3,…

SpecialK201
- 111
- 7
1
vote
1 answer
Write an R function that takes an amino acid sequence and stochastically returns a codon string
Using R, I'd like to write a "reverse translation" function that takes as input a string of amino acids and for each one returns a triplet codon that encodes that amino acid. The codon would be randomly chosen from a frequency table that I will…

yold6
- 15
- 3
1
vote
2 answers
Using a loop or lapply on the freq_table() function in R
I'm trying to create a series of frequency tables for several categorial variables using the freq_table() function. I've seen plenty of posts about this using similar table functions but can't get them to work with freq_table(), which I'm…

Shannon
- 93
- 8
1
vote
0 answers
Combining Categories and creation of new category from it
s = data['Lot Shape'].value_counts()
I took out the categories from the column Lot Shape. Now, I want to create a new category by combining the categories of Lot Shape such that the new category has two new categories.
For example,
If IR1, IR2, IR3…

Abhishek Venkatesh
- 17
- 1
1
vote
1 answer
Creating Table in R Using List of Values from Another Dataset with Different Length
I have a dataset of 50,000+ observations and I'm trying to create a table of my two variables of interest, chemical and lab_code. The code below outputs a working table that can be used to create a basic heatmap, but like the the main dataset, it…

Irene
- 47
- 8
1
vote
3 answers
expand a 2 by 2 contingency table
I have loaded data in the following format:
Gender
Yes
No
Male
2
1
Female
1
2
I would like to expand it to:
Gender
Result
Male
Yes
Male
Yes
Male
No
Female
Yes
Female
No
Female
No
I've tried using the expand.table…

code_rookie
- 57
- 5
1
vote
1 answer
Raw counts and percentages weighted by survey weight in R table?
I'm using the R package table1 to create a simple table of summary statistics for mostly factored variables (age categories, sex, race, etc.). The counts in the table need to be raw counts, but the percentages need to be weighted by a survey weight…

notasfarwest
- 71
- 5
1
vote
0 answers
Is there a way to retrieve SPSS output data in python from a frequency table using spssaux.GetValuesFromXMLWorkspace?
I'm trying to retrieve data from my SPSS output in python, so i can modify the data and write it to excel. I've got no problem retrieving the data from a descriptives table using the following code:
import spssaux
variables = 'Age'
vDict =…

Bart van Wensen
- 11
- 4
1
vote
2 answers
How can I create a frequency table for a categorical variable?
I'm new to R and am working with a dataset that involves the favourite colours of people collected in a survey.
I simply have a list of responses with colours being repeated, and so I want to make a frequency table I can work from (to create stacked…

JustinF
- 11
- 3
1
vote
1 answer
Using R and Table function can i use 4 specific columns out of a larger dataset to create a two by two frequency table
I have a few columns
Location|Yes M & M Peanuts| No M& M Peanuts | Yes M & M Almond| No M& M Almond|Location
5 10 20 6 NYC
I would like to do using the table function or…

user35131
- 1,105
- 6
- 18