[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-573145-105":53,"doc-detail-573145-en":126},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":119,"head_meta":121,"extra_data":123,"updated_unix":125},105,"en","data-transformation-with-dplyr-cheat-sheet","Data Transformation with dplyr - Cheat Sheet","","Concise cheat sheet covering dplyr data transformation workflows in R using tidy data and pipes. Summarises cases with summarise(), count(), and summarise_* variants; groups cases with group_by() and ungroups with ungroup(). Extracts and manipulates rows via filter(), distinct(), sample_frac(), slice(), top_n(), and arrange(). Extracts and transforms variables using select(), pull(), mutate(), transmute(), rename(), and add_row/add_column, plus vectorised helper patterns.",{"@graph":63,"@context":118},[64,80,101],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":11,"@type":70,"position":76},"https://docshare.wps.com/template/presentations/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/data-transformation-with-dplyr-cheat-sheet/573145/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/data-transformation-with-dplyr-cheat-sheet/573145.png","ImageObject",442,249,{"name":88,"@type":89},"hdkawk","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-19","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":76},"InteractionCounter",{"@type":100},"ViewAction",{"@type":102,"mainEntity":103},"FAQPage",[104,110,114],{"name":105,"@type":106,"acceptedAnswer":107},"What does dplyr expect regarding tidy data?","Question",{"text":108,"@type":109},"dplyr functions work with pipes and expect tidy data where each variable is a column and each observation is a row.","Answer",{"name":111,"@type":106,"acceptedAnswer":112},"How do you create summary tables and counts in dplyr?",{"text":113,"@type":109},"Use summarise() to compute summary statistics, count() to count rows per group, and summarise_all()/summarise_at()/summarise_if() to apply functions across columns.",{"name":115,"@type":106,"acceptedAnswer":116},"How can you extract or rearrange rows in dplyr?",{"text":117,"@type":109},"Extract rows with filter(), remove duplicates with distinct(), subset by position using slice(), and order them with arrange() (optionally with desc()).","https://schema.org",{"og:url":78,"og:type":120,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":122,"canonical":78},"index,follow",{"doc_id":124,"site_id":56},573145,1792382552,{"code":4,"msg":5,"data":127},{"doc_id":124,"user_id":128,"nickname":88,"user_avatar":129,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":130,"file_id":131,"file_url":132,"file_type":133,"file_size":134,"view_count":76,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":73,"language":135,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":136,"faqs":137,"seo_title":138,"seo_description":61,"update_tm":139,"read_time":9},3985747859855,"https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c","Data Transformation with dplyr : : CHEAT SHEET   \ndplyr  \ndplyr functions work with pipes and expect tidy data. In tidy data:  \nEach variable is in its own column  \nA B C  \nEach observation, or case, is in its own row  \nSummarise Cases  \nThese apply summary functions to columns to create a new table of summary statistics. Summary functions take vectors as input and return one value (see back) .  \nsummarise ( .data,…)  \nCompute table of summaries.  \nsummarise(mtcars, avg = mean(mpg))  \ncount (x, ..., wt = NULL, sort = FALSE) Count number of rows in each group defined by the variables in…Also tally() .  \ncount(iris, Species)  \nsummarise_all() -Apply funs to every column.  \nsummarise_at() -Apply funs to specific columns.  \nsummarise_if() -Apply funs to all cols of one type.  \nGroup Cases  \nUse group_by() to create a \"grouped\" copy of a table.  \ndplyr functions will manipulate each \"group\" separately and then combine the results.  \nmtcars %>%  \ngroup_by(cyl) %>% summarise(avg = mean(mpg))  \ngroup_by( .data, ..., add = FALSE)  \nReturns copy of table grouped by…  \ng_iris \u003C-group_by(iris, Species)  \nungroup(x,…) Returns ungrouped copy of table.  \nungroup(g_iris)  \nManipulate Cases  \n\n| EXTRACT CASES\u003Cbr>Row functions return a subset of rows as a new table. |  |  |  |  |  |  |  |  |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- |\n|  |  |  | |  |  |  |  | filter( .data,…) Extract rows that meet logical criteria. filter(iris, Sepal.Length > 7)\u003Cbr>distinct( .data, ..., .keep_all = FALSE) Remove rows with duplicate values.\u003Cbr>distinct(iris, Species)\u003Cbr>sample_frac(tbl, size = 1, replace = FALSE, weight = NULL, .env = parent.frame()) Randomly select fraction of rows.\u003Cbr>sample_frac(iris, 0.5, replace = TRUE)\u003Cbr>sample_n(tbl, size, replace = FALSE, weight = NULL, .env = parent.frame()) Randomly select size rows. sample_n(iris, 10, replace = TRUE)\u003Cbr>slice( .data,…) Select rows by position.\u003Cbr>slice(iris, 10:15)\u003Cbr>top_n(x, n, wt) Select and order top n entries (by group if grouped data). top_n(iris, 5, Sepal.Width) |\n|  |  |  |  |  |  |  |  |  |\n| \u003Cbr>|  |  |  |  |  |  |  |  |\n| \u003Cbr>Logical and boolean operators to use with filter()\u003Cbr>\u003C \u003C= [is. na](is. na) () %in% | xor() |  |  |  |  |  |  |  |  |\n| > >= () ! &\u003Cbr>See ?base::logic and ?Comparison for help. |  |  |  |  |  |  |  |  |\n| ARRANGE CASES |  |  |  |  |  |  |  |  |\n| |  |  |  |  |  |  |  | arrange( .data,…) Order rows by values of a column or columns (low to high), use with desc() to order from high to low.\u003Cbr>arrange(mtcars, mpg)\u003Cbr>arrange(mtcars, desc(mpg)) |\n\nADD CASES  \nadd_row(.data, ..., . before = NULL, .after = NULL) Add one or more rows to a table.  \nadd_row(faithful, eruptions = 1, waiting = 1)  \n\n| Manipulate Variables\u003Cbr>EXTRACT VARIABLES\u003Cbr>Column functions return a set of columns as a new vector or table. |  |  |  |  |  |  |  |\n| --- | --- | --- | --- | --- | --- | --- | --- |\n|  |  |  | |  | pull( .data, var = -1) Extract column values asa vector. Choose by name or index.\u003Cbr>pull(iris, Sepal.Length)\u003Cbr>select( .data,…)\u003Cbr>Extract columns as a table. Also select_if() . select(iris, Sepal.Length, Species) |  |  |\n|  |  |  |  |  |  |  |  |\n|  |  |  |  |  |  |  |  |\n|  |  |  |  |  |  |  |  |\n|  |  |  |  |  |  |  |  |\n|  |  |  | |  |  |  |  |\n|  |  |  |  |  |  |  |  |\n|  |  |  |  |  |  |  |  |\n|  |  |  |  |  |  |  |  |\n| Use these helpers with select (), |  |  |  |  |  |  |  |\n| [e.g. select](e.g. select)(iris, starts_with(\"Sepal\")) |  |  |  |  |  |  |  |\n| contains(match) |  |  |  |  |  | num_range(prefix, range) | :, e.g. mpg:cyl |\n| ends_with(match) |  |  |  |  |  | one_of(…) | -, e.g, -Species |\n| matches(match) |  |  |  |  |  | starts_with(match) |  |\n\nMAKE NEW VARIABLES  \nThese apply vectorized functions to columns. Vectorized funs take vectors as input and return vectors ofthe same length as output  \n(see back) .  \nmutate( .data,…)  \nCompute new column(s) .  \nmutate(mtcars, gpm = 1/mpg)  \ntransmute( .data,…)  \nCompute new column(s), drop others. transmute(m","cbCaipkEwVxW0emk","https://ap.wps.com/l/cbCaipkEwVxW0emk","pdf",2208760,"English","# Summarise Cases\n## Group Cases\n# Manipulate Cases\n## Extract Cases\n## Arrange Cases\n## Add Cases\n# Manipulate Variables\n## Extract Variables\n## Make New Variables\n# Vector Functions\n## Offsets and Cumulative Aggregates\n## Rankings\n## Math and Misc","[{\"question\":\"What does dplyr expect regarding tidy data?\",\"answer\":\"dplyr functions work with pipes and expect tidy data where each variable is a column and each observation is a row.\"},{\"question\":\"How do you create summary tables and counts in dplyr?\",\"answer\":\"Use summarise() to compute summary statistics, count() to count rows per group, and summarise_all()/summarise_at()/summarise_if() to apply functions across columns.\"},{\"question\":\"How can you extract or rearrange rows in dplyr?\",\"answer\":\"Extract rows with filter(), remove duplicates with distinct(), subset by position using slice(), and order them with arrange() (optionally with desc()).\"}]","Data Transformation with dplyr - Cheat Sheet | PDF",1791933205]