frequency-distribution

Frequency distribution in R

让人想犯罪 __ 提交于 2019-12-04 22:10:54
I have five columns with numbers. I want to plot the frequency distribution of five columns in one graph with different colors in R. Can some one help me out how i can do this with an example. I am very new to R. Using the sample data from @eddi, you can also consider the "lattice" package: set.seed(1) d <- data.frame(a = rnorm(100), b = rnorm(100, 1), c = rnorm(100, 2), d = rnorm(100, 3), e = rnorm(100, 4)) library(lattice) densityplot(~ a + b + c + d + e, data = d) This will yield: If you have many columns, you can also create your plot by first creating a formula : myFormula <- as.formula

Get a histogram plot of factor frequencies (summary)

非 Y 不嫁゛ 提交于 2019-12-04 08:06:24
问题 I've got a factor with many different values. If you execute summary(factor) the output is a list of the different values and their frequency. Like so: A B C D 3 3 1 5 I'd like to make a histogram of the frequency values, i.e. X-axis contains the different frequencies that occur, Y-axis the number of factors that have this particular frequency. What's the best way to accomplish something like that? edit: thanks to the answer below I figured out that what I can do is get the factor of the

Plotting frequency spectrum with c++

有些话、适合烂在心里 提交于 2019-12-04 07:21:53
Please see the Edits in the answer below this question. I have written a script to plot the frequency spectrum of a sinusoidal signal with c++. Here are the steps Applying Hanning window Apply FFT using fftw3 library I have three graphs: Signal, Signal when is multiplied to Hanning function, and the frequency spectrum. The frequency spectrum looks wrong. It should have a peak at 50 Hz. Any suggestion would be appreciated. Here is the code: #include <stdlib.h> #include <stdio.h> #include <time.h> #include <fftw3.h> #include <iostream> #include <cmath> #include <fstream> using namespace std; int

Frequency tables with weighted data in R

馋奶兔 提交于 2019-12-03 11:40:23
I need to calculate the frequency of individuals by age and marital status so normally I'd use: table(age, marital_status) However each individual has a different weight after the sampling of the data. How do I incorporate this into my frequency table? You can use function svytable from package survey , or wtd.table from rgrs . EDIT : rgrs is now called questionr : df <- data.frame(var = c("A", "A", "B", "B"), wt = c(30, 10, 20, 40)) library(questionr) wtd.table(x = df$var, weights = df$wt) # A B # 40 60 That's also possible with dplyr : library(dplyr) count(x = df, var, wt = wt) # # A tibble:

Calculating grouped variance from a frequency table in R

我与影子孤独终老i 提交于 2019-12-02 05:32:58
How can I, in R calculate the overall variance and the variance for each group from a dataset that looks like this (for example): Group Count Value A 3 5 A 2 8 B 1 11 B 3 15 I know to calculate the variance as a whole, ignoring the groups I would do: var(rep(x$Value, x$Count)), but how do I automatically calculate the variance for each group accounting for the frequency? E.g., the variance for group A, group B, etc.,.. I would like my output to have the following headers: Group, Total Count, Group Variance I have also reviewed this link; R computing mean, median, variance from file with

MATLAB : frequency distribution

余生颓废 提交于 2019-11-30 19:27:16
问题 I have raw observations of 500 numeric values (ranging from 1 to 25000) in a text file, I wish to make a frequency distribution in MATLAB. I did try the histogram (hist), however I would prefer a frequency distribution curve than blocks and bars. Any help is appreciated ! 回答1: If you pass two output parameters to HIST, you will get both the x-axis and y-axis values. Then you can plot the data as you like. For instance, [counts, bins] = hist(mydata); plot(bins, counts); %# get a line plot of

Frequency table including zeros for unused values, on a data.table

孤人 提交于 2019-11-30 13:42:55
I have a data set that is as follows: library(data.table) test <- data.table(structure(list(Issue.Date = structure(c(16041, 16056, 16042,15990, 15996, 16001, 15995, 15981, 15986, 15996, 15996, 16002,16015, 16020, 16025, 16032, 16023, 16084, 16077, 16102, 16104,16107, 16112, 16113, 16115, 16121, 16125, 16128, 16104, 16132,16133, 16135, 16139, 16146, 16151), class = "Date"), Complaint = structure(c(1L,4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L,5L, 3L, 1L, 3L, 1L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 1L, 3L,3L, 3L), .Label = c("A", "B", "C", "D", "E"), class = "factor"), yr = c

Frequency table including zeros for unused values, on a data.table

亡梦爱人 提交于 2019-11-29 18:55:27
问题 I have a data set that is as follows: library(data.table) test <- data.table(structure(list(Issue.Date = structure(c(16041, 16056, 16042,15990, 15996, 16001, 15995, 15981, 15986, 15996, 15996, 16002,16015, 16020, 16025, 16032, 16023, 16084, 16077, 16102, 16104,16107, 16112, 16113, 16115, 16121, 16125, 16128, 16104, 16132,16133, 16135, 16139, 16146, 16151), class = "Date"), Complaint = structure(c(1L,4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L,5L, 3L, 1L, 3L, 1L, 4L, 4L, 3L,

R compute percentage values in data frame

做~自己de王妃 提交于 2019-11-29 12:19:42
My question today refers to a data frame I'm working on in R. The header of the data frame looks like the following: String(unique), Integer N[0-23] Those 24 Integer values represent the frequency of the String associated with each hour of the day. Logically, the int values in each row sum up to the number how often the string appears in the data in general. Thing is, I don't need the real frequency of the string at a certain hour but the percentage this frequency represents in relation to the sum of the integer values in all rows. My lecturer hinted that table() might be the right R tool for

R compute percentage values in data frame

雨燕双飞 提交于 2019-11-28 06:08:57
问题 My question today refers to a data frame I'm working on in R. The header of the data frame looks like the following: String(unique), Integer N[0-23] Those 24 Integer values represent the frequency of the String associated with each hour of the day. Logically, the int values in each row sum up to the number how often the string appears in the data in general. Thing is, I don't need the real frequency of the string at a certain hour but the percentage this frequency represents in relation to