Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count observations greater than a particular value [duplicate]

Tags:

r

I have a dataset output in R with a the variables V1,V2,V3,V4. How can I get the number of observations in V4 that area greater than 2000?

like image 707
ustroetz Avatar asked Mar 27 '14 14:03

ustroetz


People also ask

How do I count repeated values in R?

Use the length() function to count the number of elements returned by the which() function, as which function returns the elements that are repeated more than once. The length() function in R Language is used to get or set the length of a vector (list) or other objects.

How do you count in R?

count in R by using base functionalityBy using the dim function, you can count rows and columns at the same time. The table function is a great addition to that that helps to count by categories in a column.

How do I Count cells with values greater than a particular number?

To count the number of cells that have values greater than a particular number, you can use the COUNTIF function. In the generic form of the formula, rng represents a range of cells that contain numbers, and X represents the threshold above which you want to count. In the example shown, the active cell contains this formula:

How do you count the number of observations per type?

The SAS code below uses PROC FREQ to count the number of observations per Type. As you can see, PROC FREQ doesn’t only provide the count per group, but also the percentage, the cumulative frequency, and cumulative percentage.

Does colsums count the number of observations in a table?

I don't think colSums will give you the right answer since it doesn't counts the number of observations, but only sums the columns' values. I think that this will give you what you want , I hope.

How to count cells with scoring marks greater than 80 in Excel?

Here, cell range C3:C12 contains the scoring marks of all the students, and we want to test these scores against criteria, greater than 80 marks, in double quotation marks in criterion expression. COUNTIF function counts the number of cells that contain a value greater than 80 and return the output as number as shown below.


2 Answers

Try using logical test and then sum over the values meeting the condition

sum(output$V4 > 2000)
like image 131
Jilber Urbina Avatar answered Sep 28 '22 10:09

Jilber Urbina


if using a data.frame you could also use:

nrow(output[output$V4>2000, ])

like image 37
DataTx Avatar answered Sep 28 '22 08:09

DataTx