How can use the which() function to select rows from a data frame in R?2019 Community Moderator ElectionFilter data.frame rows by a logical conditionDrop factor levels in a subsetted data frameHow to join (merge) data frames (inner, outer, left, right)?R - list to data frameDrop data frame columns by nameExtracting specific columns from a data frameHow can we make xkcd style graphs?Select rows from a data frame using an array in RSelecting rows maintaining distribution percentage?R- Create function that selects entire row in data frame by column nameIn R, subtract value from previous row in data frame based on hierarchical data structure

Does the US political system, in principle, allow for a no-party system?

Did Amazon pay $0 in taxes last year?

What do you call someone who likes to pick fights?

How can I portion out frozen cookie dough?

If sound is a longitudinal wave, why can we hear it if our ears aren't aligned with the propagation direction?

Professor forcing me to attend a conference, I can't afford even with 50% funding

How to copy the rest of lines of a file to another file

Can one live in the U.S. and not use a credit card?

How do we create new idioms and use them in a novel?

What would be the most expensive material to an intergalactic society?

Help! My Character is too much for her story!

How exactly does an Ethernet collision happen in the cable, since nodes use different circuits for Tx and Rx?

ESPP--any reason not to go all in?

School performs periodic password audits. Is my password compromised?

How do spaceships determine each other's mass in space?

Why do we say 'Pairwise Disjoint', rather than 'Disjoint'?

What can I do if someone tampers with my SSH public key?

Cycles on the torus

The (Easy) Road to Code

What is Tony Stark injecting into himself in Iron Man 3?

I can't die. Who am I?

I reported the illegal activity of my boss to his boss. My boss found out. Now I am being punished. What should I do?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Rationale to prefer local variables over instance variables?



How can use the which() function to select rows from a data frame in R?



2019 Community Moderator ElectionFilter data.frame rows by a logical conditionDrop factor levels in a subsetted data frameHow to join (merge) data frames (inner, outer, left, right)?R - list to data frameDrop data frame columns by nameExtracting specific columns from a data frameHow can we make xkcd style graphs?Select rows from a data frame using an array in RSelecting rows maintaining distribution percentage?R- Create function that selects entire row in data frame by column nameIn R, subtract value from previous row in data frame based on hierarchical data structure










-1















Given the attached data set how can I calculate the percentage of students with grades between 55% and 75% (inclusive) using one line of R code, using the 'which()' R command to select rows?



ID age hours grade
284236 20 133 80
254494 20 140 74
229943 19 85 79
298668 20 49 72
221297 36 129 78
194162 37 53 77
162842 25 130 80
203841 35 100 61
250607 32 99 73
297495 14 69 71
110986 29 24 67
297498 43 22 80
210499 20 122 69
199181 20 18 74
174800 18 88 75
280547 20 23 74
169474 18 102 70
252912 17 47 78
186855 19 121 77
150336 17 57 80









share|improve this question









New contributor




peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 4





    What did you try so far?

    – Sotos
    Mar 6 at 13:55











  • Try this: subset(df,grade>=55 & grade<=75) and do your operation.

    – Saurabh Chauhan
    Mar 6 at 13:56






  • 6





    Is using which() a constraint imposed by a homework assignment?

    – John Coleman
    Mar 6 at 13:58











  • @JohnColeman Yes, of course! Along with using one-line of code

    – Sotos
    Mar 6 at 13:59







  • 2





    This will help you understand how to use which() to subset a vector or a data frame. I definitely don't want your professor to give me a good grade :) Hint: which(df$grade >= 55 & df$grade <= 75) will give you the relevant df rows number and df$grade[which(df$grade >= 55 & df$grade <= 75)] or df$grade[df$grade >= 55 & df$grade <= 75] the relevent components of the vector df$grade. Now try to compute the mean

    – ANG
    Mar 6 at 14:14
















-1















Given the attached data set how can I calculate the percentage of students with grades between 55% and 75% (inclusive) using one line of R code, using the 'which()' R command to select rows?



ID age hours grade
284236 20 133 80
254494 20 140 74
229943 19 85 79
298668 20 49 72
221297 36 129 78
194162 37 53 77
162842 25 130 80
203841 35 100 61
250607 32 99 73
297495 14 69 71
110986 29 24 67
297498 43 22 80
210499 20 122 69
199181 20 18 74
174800 18 88 75
280547 20 23 74
169474 18 102 70
252912 17 47 78
186855 19 121 77
150336 17 57 80









share|improve this question









New contributor




peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 4





    What did you try so far?

    – Sotos
    Mar 6 at 13:55











  • Try this: subset(df,grade>=55 & grade<=75) and do your operation.

    – Saurabh Chauhan
    Mar 6 at 13:56






  • 6





    Is using which() a constraint imposed by a homework assignment?

    – John Coleman
    Mar 6 at 13:58











  • @JohnColeman Yes, of course! Along with using one-line of code

    – Sotos
    Mar 6 at 13:59







  • 2





    This will help you understand how to use which() to subset a vector or a data frame. I definitely don't want your professor to give me a good grade :) Hint: which(df$grade >= 55 & df$grade <= 75) will give you the relevant df rows number and df$grade[which(df$grade >= 55 & df$grade <= 75)] or df$grade[df$grade >= 55 & df$grade <= 75] the relevent components of the vector df$grade. Now try to compute the mean

    – ANG
    Mar 6 at 14:14














-1












-1








-1








Given the attached data set how can I calculate the percentage of students with grades between 55% and 75% (inclusive) using one line of R code, using the 'which()' R command to select rows?



ID age hours grade
284236 20 133 80
254494 20 140 74
229943 19 85 79
298668 20 49 72
221297 36 129 78
194162 37 53 77
162842 25 130 80
203841 35 100 61
250607 32 99 73
297495 14 69 71
110986 29 24 67
297498 43 22 80
210499 20 122 69
199181 20 18 74
174800 18 88 75
280547 20 23 74
169474 18 102 70
252912 17 47 78
186855 19 121 77
150336 17 57 80









share|improve this question









New contributor




peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












Given the attached data set how can I calculate the percentage of students with grades between 55% and 75% (inclusive) using one line of R code, using the 'which()' R command to select rows?



ID age hours grade
284236 20 133 80
254494 20 140 74
229943 19 85 79
298668 20 49 72
221297 36 129 78
194162 37 53 77
162842 25 130 80
203841 35 100 61
250607 32 99 73
297495 14 69 71
110986 29 24 67
297498 43 22 80
210499 20 122 69
199181 20 18 74
174800 18 88 75
280547 20 23 74
169474 18 102 70
252912 17 47 78
186855 19 121 77
150336 17 57 80






r






share|improve this question









New contributor




peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Mar 6 at 13:53









Saurabh Chauhan

2,2521824




2,2521824






New contributor




peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 6 at 13:53









peterpeter

11




11




New contributor




peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






peter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 4





    What did you try so far?

    – Sotos
    Mar 6 at 13:55











  • Try this: subset(df,grade>=55 & grade<=75) and do your operation.

    – Saurabh Chauhan
    Mar 6 at 13:56






  • 6





    Is using which() a constraint imposed by a homework assignment?

    – John Coleman
    Mar 6 at 13:58











  • @JohnColeman Yes, of course! Along with using one-line of code

    – Sotos
    Mar 6 at 13:59







  • 2





    This will help you understand how to use which() to subset a vector or a data frame. I definitely don't want your professor to give me a good grade :) Hint: which(df$grade >= 55 & df$grade <= 75) will give you the relevant df rows number and df$grade[which(df$grade >= 55 & df$grade <= 75)] or df$grade[df$grade >= 55 & df$grade <= 75] the relevent components of the vector df$grade. Now try to compute the mean

    – ANG
    Mar 6 at 14:14













  • 4





    What did you try so far?

    – Sotos
    Mar 6 at 13:55











  • Try this: subset(df,grade>=55 & grade<=75) and do your operation.

    – Saurabh Chauhan
    Mar 6 at 13:56






  • 6





    Is using which() a constraint imposed by a homework assignment?

    – John Coleman
    Mar 6 at 13:58











  • @JohnColeman Yes, of course! Along with using one-line of code

    – Sotos
    Mar 6 at 13:59







  • 2





    This will help you understand how to use which() to subset a vector or a data frame. I definitely don't want your professor to give me a good grade :) Hint: which(df$grade >= 55 & df$grade <= 75) will give you the relevant df rows number and df$grade[which(df$grade >= 55 & df$grade <= 75)] or df$grade[df$grade >= 55 & df$grade <= 75] the relevent components of the vector df$grade. Now try to compute the mean

    – ANG
    Mar 6 at 14:14








4




4





What did you try so far?

– Sotos
Mar 6 at 13:55





What did you try so far?

– Sotos
Mar 6 at 13:55













Try this: subset(df,grade>=55 & grade<=75) and do your operation.

– Saurabh Chauhan
Mar 6 at 13:56





Try this: subset(df,grade>=55 & grade<=75) and do your operation.

– Saurabh Chauhan
Mar 6 at 13:56




6




6





Is using which() a constraint imposed by a homework assignment?

– John Coleman
Mar 6 at 13:58





Is using which() a constraint imposed by a homework assignment?

– John Coleman
Mar 6 at 13:58













@JohnColeman Yes, of course! Along with using one-line of code

– Sotos
Mar 6 at 13:59






@JohnColeman Yes, of course! Along with using one-line of code

– Sotos
Mar 6 at 13:59





2




2





This will help you understand how to use which() to subset a vector or a data frame. I definitely don't want your professor to give me a good grade :) Hint: which(df$grade >= 55 & df$grade <= 75) will give you the relevant df rows number and df$grade[which(df$grade >= 55 & df$grade <= 75)] or df$grade[df$grade >= 55 & df$grade <= 75] the relevent components of the vector df$grade. Now try to compute the mean

– ANG
Mar 6 at 14:14






This will help you understand how to use which() to subset a vector or a data frame. I definitely don't want your professor to give me a good grade :) Hint: which(df$grade >= 55 & df$grade <= 75) will give you the relevant df rows number and df$grade[which(df$grade >= 55 & df$grade <= 75)] or df$grade[df$grade >= 55 & df$grade <= 75] the relevent components of the vector df$grade. Now try to compute the mean

– ANG
Mar 6 at 14:14













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






peter is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55024753%2fhow-can-use-the-which-function-to-select-rows-from-a-data-frame-in-r%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








peter is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















peter is a new contributor. Be nice, and check out our Code of Conduct.












peter is a new contributor. Be nice, and check out our Code of Conduct.











peter is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55024753%2fhow-can-use-the-which-function-to-select-rows-from-a-data-frame-in-r%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved