{"id":1044,"date":"2023-07-27T21:02:56","date_gmt":"2023-07-27T21:02:56","guid":{"rendered":"https:\/\/statorials.org\/it\/conta-se-r\/"},"modified":"2023-07-27T21:02:56","modified_gmt":"2023-07-27T21:02:56","slug":"conta-se-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/conta-se-r\/","title":{"rendered":"Come eseguire una funzione conta.se in r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Spesso potresti voler contare <em>solo<\/em> il numero di righe in un frame di dati R che soddisfa determinati criteri. Fortunatamente, questo \u00e8 facile da fare utilizzando la seguente sintassi di base:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>sum(df$column == value, na.rm= <span style=\"color: #008000;\">TRUE<\/span> )\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">I seguenti esempi mostrano come utilizzare in pratica questa sintassi sul seguente frame di dati:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <b><span style=\"color: #008080;\">#create data frame<\/span>\ndata &lt;- data.frame(team=c('Mavs', 'Mavs', 'Spurs', 'Spurs', 'Lakers'),\n                   points=c(14, NA, 8, 17, 22),\n                   rebounds=c(8, 5, 5, 9, 12))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>data\n\n    team points rebounds\n1 Mavs 14 8\n2 Mavs NA 5\n3 Spurs 8 5\n4 Spurs 17 9\n5 Lakers 22 12\n<\/b><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 1: contare le righe pari a un determinato valore<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come contare il numero di righe in cui il nome della squadra \u00e8 uguale a &#8220;Mavs&#8221;:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>sum(data$team == ' <span style=\"color: #008000;\">Mavs<\/span> ')\n\n[1] 2\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come contare il numero di righe in cui il nome della squadra \u00e8 uguale a &#8220;Mavs&#8221; o &#8220;Lakers&#8221;:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>sum(data$team == ' <span style=\"color: #008000;\">Mavs<\/span> ' | data$team == ' <span style=\"color: #008000;\">Lakers<\/span> ')\n\n[1] 3<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come contare il numero di righe in cui il nome della squadra <em>non<\/em> \u00e8 uguale a &#8220;Lakers&#8221;:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>sum(data$team != ' <span style=\"color: #008000;\">Lakers<\/span> ')\n\n[1] 4<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 2: conteggio delle righe maggiori o uguali a un determinato valore<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come contare il numero di righe in cui i punti sono maggiori di 10:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>sum(data$points &gt; 10, na.rm= <span style=\"color: #008000;\">TRUE<\/span> )\n\n[1] 3<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come contare il numero di righe in cui i rimbalzi sono inferiori o uguali a 9:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>sum(data$rebounds &lt;= 9, na.rm= <span style=\"color: #008000;\">TRUE<\/span> )\n\n[1] 4<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 3: contare le linee tra due valori<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come contare il numero di righe in cui i punti sono compresi tra 10 e 20:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>sum(data$points &gt; 10 &amp; data$points &lt; 20, na.rm= <span style=\"color: #008000;\">TRUE<\/span> )\n\n[1] 2<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come contare il numero di righe in cui i rimbalzi sono compresi tra 8 e 10:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>sum(data$rebounds &gt; 8 &amp; data$rebounds &lt; 10, na.rm= <span style=\"color: #008000;\">TRUE<\/span> )\n\n[1] 1<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p><a href=\"https:\/\/statorials.org\/it\/contare-per-gruppo-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">Come contare le osservazioni per gruppo in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/dati-curriculum-di-gruppo-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">Come raggruppare e riassumere i dati in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spesso potresti voler contare solo il numero di righe in un frame di dati R che soddisfa determinati criteri. Fortunatamente, questo \u00e8 facile da fare utilizzando la seguente sintassi di base: sum(df$column == value, na.rm= TRUE ) I seguenti esempi mostrano come utilizzare in pratica questa sintassi sul seguente frame di dati: #create data frame [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Come eseguire una funzione CONTA.SE in R - Statorials<\/title>\n<meta name=\"description\" content=\"Una semplice spiegazione di come eseguire una funzione CONTA.SE in R, incluso un esempio.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/it\/conta-se-r\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come eseguire una funzione CONTA.SE in R - Statorials\" \/>\n<meta property=\"og:description\" content=\"Una semplice spiegazione di come eseguire una funzione CONTA.SE in R, incluso un esempio.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/conta-se-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T21:02:56+00:00\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/conta-se-r\/\",\"url\":\"https:\/\/statorials.org\/it\/conta-se-r\/\",\"name\":\"Come eseguire una funzione CONTA.SE in R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-27T21:02:56+00:00\",\"dateModified\":\"2023-07-27T21:02:56+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Una semplice spiegazione di come eseguire una funzione CONTA.SE in R, incluso un esempio.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/conta-se-r\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/conta-se-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/conta-se-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come eseguire una funzione conta.se in r\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come eseguire una funzione CONTA.SE in R - Statorials","description":"Una semplice spiegazione di come eseguire una funzione CONTA.SE in R, incluso un esempio.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/it\/conta-se-r\/","og_locale":"it_IT","og_type":"article","og_title":"Come eseguire una funzione CONTA.SE in R - Statorials","og_description":"Una semplice spiegazione di come eseguire una funzione CONTA.SE in R, incluso un esempio.","og_url":"https:\/\/statorials.org\/it\/conta-se-r\/","og_site_name":"Statorials","article_published_time":"2023-07-27T21:02:56+00:00","author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"2 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/conta-se-r\/","url":"https:\/\/statorials.org\/it\/conta-se-r\/","name":"Come eseguire una funzione CONTA.SE in R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-27T21:02:56+00:00","dateModified":"2023-07-27T21:02:56+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Una semplice spiegazione di come eseguire una funzione CONTA.SE in R, incluso un esempio.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/conta-se-r\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/conta-se-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/conta-se-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come eseguire una funzione conta.se in r"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1044"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=1044"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1044\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}