frequency

Frequency count for a specific category

落花浮王杯 提交于 2019-11-28 06:48:02
问题 I have a data set like this. a <- structure(list(Prone = c("M", "N", "N", "N", "M", "N", "M", "N", "M", "M"), Type = c("A", "B", "C", "A", "A", "A", "B", "B", "C", "B"), Alc = c("A", "B", "N", "A", "A", "A", "B", "B", "B", "B"), Com = c("Y", "N", "Y", "Y", "Y", "Y", "Y", "N", "N", "Y")), .Names = c("Prone", "Type", "Alc", "Com"), row.names = c(NA, -10L), class = "data.frame") a Prone Type Alc Com 1 M A A Y 2 N B B N 3 N C N Y 4 N A A Y 5 M A A Y 6 N A A Y 7 M B B Y 8 N B B N 9 M C B N 10 M B

Counting number of instances of a condition per row R [duplicate]

烈酒焚心 提交于 2019-11-28 05:11:19
问题 This question already has an answer here: How to count the frequency of a string for each row in R 2 answers I have a large file with the first column being IDs, and the remaining 1304 columns being genotypes like below. rsID sample1 sample2 sample3...sample1304 abcd aa bb nc nc efgh nc nc nc nc ijkl aa ab aa nc I would like to count the number of "nc" values per row and output the result of that to another column so that I get the following: rsID sample1 sample2 sample3...sample1304 no_calls

Graphing the pitch (frequency) of a sound

你说的曾经没有我的故事 提交于 2019-11-28 02:59:22
I want to plot the pitch of a sound into a graph. Currently I can plot the amplitude. The graph below is created by the data returned by getUnscaledAmplitude() : AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream(file))); byte[] bytes = new byte[(int) (audioInputStream.getFrameLength()) * (audioInputStream.getFormat().getFrameSize())]; audioInputStream.read(bytes); // Get amplitude values for each audio channel in an array. graphData = type.getUnscaledAmplitude(bytes, 1); public int[][] getUnscaledAmplitude(byte[] eightBitByteArray,

Plot weighted frequency matrix

三世轮回 提交于 2019-11-28 02:51:45
问题 This question is related to two different questions I have asked previously: 1) Reproduce frequency matrix plot 2) Add 95% confidence limits to cumulative plot I wish to reproduce this plot in R: I have got this far, using the code beneath the graphic: #Set the number of bets and number of trials and % lines numbet <- 36 numtri <- 1000 #Fill a matrix where the rows are the cumulative bets and the columns are the trials xcum <- matrix(NA, nrow=numbet, ncol=numtri) for (i in 1:numtri) { x <-

Sql server function for displaying word frequency in a column

爷,独闯天下 提交于 2019-11-28 00:24:19
I have a table that lists a freet text input from a survey where enterents were allowed to enter their responses (regarding colours they would like to have in their wedding) I would like to write a sql function that gathers all the information from this column, and orders counts the frequency of each word, ordering the result set by this count. Response -------- Red and White green White and blue Blue Dark blue I would like the above table to be ordered as follows Response Frequency -------- --------- Blue 3 White 2 And 2 Red 1 Green 1 I can strip all the rubbish words like "and" after the

Setting a relative frequency in a matplotlib histogram

冷暖自知 提交于 2019-11-27 20:31:29
问题 I have data as a list of floats and I want to plot it as a histogram. Hist() function does the job perfectly for plotting the absolute histogram. However, I cannot figure out how to represent it in a relative frequency format - I would like to have it as a fraction or ideally as a percentage on the y-axis. Here is the code: fig = plt.figure() ax = fig.add_subplot(111) n, bins, patches = ax.hist(mydata, bins=100, normed=1, cumulative=0) ax.set_xlabel('Bins', size=20) ax.set_ylabel('Frequency',

Determine frequency from signal data in MATLAB

六月ゝ 毕业季﹏ 提交于 2019-11-27 19:51:22
I have data from a sensor and I need to find the frequency of it. It looks like fft() seems to be the way to go, but the MATLAB docs only show how to get a graph of the frequencies, I don't know what to do from there. Here's what my data looks like: One way to go is indeed to use an fft. Since the fft gives you the frequency representation of the signal, you want to look for the maximum, and since the fft is a complex signal, you will want to take the absolute value first. The index will correspond to the normalized frequency with maximum energy. Last, if your signal has an offset, as is the

Show frequencies along with barplot in ggplot2

落爺英雄遲暮 提交于 2019-11-27 19:49:59
I'm trying to display frequencies within barplot ... well, I want them somewhere in the graph: under the bars, within bars, above bars or in the legend area. And I recall (I may be wrong) that it can be done in ggplot2 . This is probably an easy one... at least it seems easy. Here's the code: p <- ggplot(mtcars) p + aes(factor(cyl)) + geom_bar() Is there any chance that I can get frequencies embedded in the graph? geom_text is tha analog of text from base graphics: p + geom_bar() + stat_bin(aes(label=..count..), vjust=0, geom="text", position="identity") If you want to adjust the y-position of

Include zero frequencies in frequency table for Likert data

主宰稳场 提交于 2019-11-27 16:28:58
问题 I have a dataset with responses to a Likert item on a 9pt scale. I would like to create a frequency table (and barplot) of the data but some values on the scale never occur in my dataset, so table() removes that value from the frequency table. I would like it instead to present the value with a frequency of 0 . That is, given the following dataset # Assume a 5pt Likert scale for ease of example data <- c(1, 1, 2, 1, 4, 4, 5) I would like to get the following frequency table without having to

frequency table with several variables in R

纵饮孤独 提交于 2019-11-27 15:12:06
问题 I am trying to replicate a table often used in official statistics but no success so far. Given a dataframe like this one: d1 <- data.frame( StudentID = c("x1", "x10", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9"), StudentGender = c('F', 'M', 'F', 'M', 'F', 'M', 'F', 'M', 'M', 'M'), ExamenYear = c('2007','2007','2007','2008','2008','2008','2008','2009','2009','2009'), Exam = c('algebra', 'stats', 'bio', 'algebra', 'algebra', 'stats', 'stats', 'algebra', 'bio', 'bio'), participated = c('no',