[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-573757-105":53,"doc-detail-573757-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-wrangling-with-dplyr-and-tidyr-cheat-sheet-tidy-data-and-dplyrtidyr-syntax","Data Wrangling with dplyr and tidyr - Cheat Sheet - Tidy Data and dplyr/tidyr Syntax","","Cheat sheet for data wrangling in R using dplyr and tidyr, centered on tidy data principles: each variable in its own column and each observation in its own row. Summarizes core dplyr workflows such as tbl conversion, glimpse/view, piping with %>%, grouping and summarising, filtering, distinct, sampling, sorting, renaming, and selecting columns. Covers tidyr reshaping operations including gather, separate, spread, unite, plus creating optimized data frames, and outlines common logical and helper functions.",{"@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-wrangling-with-dplyr-and-tidyr-cheat-sheet-tidy-data-and-dplyrtidyr-syntax/573757/",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-wrangling-with-dplyr-and-tidyr-cheat-sheet-tidy-data-and-dplyrtidyr-syntax/573757.png","ImageObject",442,249,{"name":88,"@type":89},"DoDO","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-16","2026-10-14",true,{"@type":98,"interactionType":99,"userInteractionCount":73},"InteractionCounter",{"@type":100},"ViewAction",{"@type":102,"mainEntity":103},"FAQPage",[104,110,114],{"name":105,"@type":106,"acceptedAnswer":107},"What makes a dataset “tidy” for wrangling in R?","Question",{"text":108,"@type":109},"A tidy dataset stores each variable in its own column and each observation in its own row. This structure complements R’s vectorized operations and keeps manipulations straightforward.","Answer",{"name":111,"@type":106,"acceptedAnswer":112},"How does the %>% pipe in dplyr improve code readability?",{"text":113,"@type":109},"%>% passes the object on the left-hand side as the first argument to the function on the right-hand side. It helps write chained transformations that read more naturally.",{"name":115,"@type":106,"acceptedAnswer":116},"Which tidyr functions are used to reshape data between wide and long formats?",{"text":117,"@type":109},"Use gather to gather columns into rows and spread to spread rows into columns. Additional helpers include separate to split one column into several and unite to merge multiple columns into one.","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},573757,1792128032,{"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":73,"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},962093270745,"https://ap-avatar.wpscdn.com/davatar_9964176cb1d06d4a9deccf72a44ae3dc","Data Wrangling with dplyr and tidyr  \nCheat Sheet  \nTidy Data -A foundation for wrangling in R  \nIn a tidy data set:  \nEach variable is saved in its own column  \nEach observation is saved in its own row  \nTidy data complements R’s vectorized operations. R will automatically preserve observations as you manipulate variables. No other format works as intuitively with R.  \n*  \nM * A  \nSyntax -Helpful conventions for wrangling  \ndplyr::tbl_df(iris)  \nConverts data to tbl class. tbl’s are easier to examine than data frames. R displays only the data that fits onscreen:  \nSource: local data frame [150 x 5]  \nSepal.Length Sepal.Width Petal .Length  \n1  \n2 3  \n4  \n5  \n5.1  \n4.9  \n4.7  \n4.6  \n5.0  \n3.5  \n3.0  \n3.2  \n3.1  \n3.6  \n1.4  \n1.4  \n1.3  \n1.5  \n1.4  \nVariables not shown: Petal.Width (dbl), Species (fctr)  \ndplyr::glimpse(iris)  \nInformation dense summary of tbl data. utils::View(iris)  \nView data set in spreadsheet-like display (note capital V) .  \ndplyr::%>%  \nPasses object on left hand side as first argument (or . argument) of function on righthand side.  \nx %>% f(y) is the same as f(x, y) y %>% f(x, . , z) is the same as f(x, y , z )  \n\"Piping\" with %>% makes code more readable, e. g. iris %>%  \ngroup_by(Species) %>%  \nsummarise(avg = mean(Sepal.Width )) %>% arrange(avg)  \nReshaping Data -Change the layout of a data set  \ntidyr::gather(cases, \"year\", \"n\", 2:4) Gather columns into rows.  \ntidyr::separate(storms, date, c(\"y\", \"m\", \"d\")) Separate one column into several.  \ntidyr::spread(pollution, size, amount) Spread rows into columns.  \ntidyr::unite(data, col, ..., sep) Unite several columns into one.  \ndplyr::data_frame(a = 1:3, b = 4:6) Combine vectors into data frame (optimized) .  \ndplyr::arrange(mtcars, mpg) Order rows by values of a column (low to high) .  \ndplyr::arrange(mtcars, desc(mpg)) Order rows by values of a column (high to low) .  \ndplyr::rename(tb, y = year) Rename the columns of a data frame.  \nSubset Observations (Rows)  \ndplyr::filter(iris, Sepal. Length > 7) Extract rows that meet logical criteria. dplyr::distinct(iris)  \nRemove duplicate rows.  \ndplyr::sample_frac(iris, 0.5, replace = TRUE) Randomly select fraction of rows.  \ndplyr::sample_n(iris, 10, replace = TRUE) Randomly select n rows.  \ndplyr::slice(iris, 10:15) Select rows by position. dplyr::top_n(storms, 2, date)  \nSelect and order top n entries (by group if grouped data) .  \n\n| | Logic in R - ?C | omparison, ?base | ::Logic  |\n| --- | --- | --- | --- |\n| \u003C | Less than | != | Not equal to |\n| > | Greater than | %in% | Group membership |\n| == | Equal to | [is.na](is.na) | Is NA |\n| \u003C= | Less than or equal to | ! [is.na](is.na) | Is not NA |\n| >= | Greater than or equal to | &, | ,!,xor,any,all | Boolean operators |\n\nSubset Variables (Columns)  \ndplyr::select(iris, Sepal.Width, Petal. Length, Species) Select columns by name or helper function.  \n\n|  | Helper funct | ions for select- ? | select |\n| --- | --- | --- | --- |\n| select(iris, contains(\".\"))\u003Cbr>Select columns whose name contains a character string.\u003Cbr>select(iris, ends_with(\"Length\"))\u003Cbr>Select columns whose name ends with a character string.\u003Cbr>select(iris, everything())\u003Cbr>Select every column.\u003Cbr>select(iris, matches(\".t.\"))\u003Cbr>Select columns whose name matches a regular expression.\u003Cbr>select(iris, num_range(\"x\", 1:5))\u003Cbr>Select columns named x1, x2, x3, x4, x5 .\u003Cbr>select(iris, one_of(c(\"Species\", \"Genus\")))\u003Cbr>Select columns whose names are in a group of names.\u003Cbr>select(iris, starts_with(\"Sepal\"))\u003Cbr>Select columns whose name starts with a character string.\u003Cbr>select(iris, Sepal.Length:Petal.Width)\u003Cbr>Select all columns between Sepal. Length and Petal.Width (inclusive) .\u003Cbr>select(iris, -Species)\u003Cbr>Select all columns except Species. |  |  |  |\n\nRStudio® is a trademark of RStudio, Inc. • CC BY  RStudio • [info@rstudio.com](info@rstudio.com) • 844-448-1212 •  [rstudio.com](rstudio.com) devtools::install_github(\"rstudio/EDAWR\") for data sets Learn more with browseVignettes(package = c(\"dp","cbCaidqn4hm65teb","https://ap.wps.com/l/cbCaidqn4hm65teb","pdf",504140,"English","# Tidy Data -A foundation for wrangling in R\n# Syntax -Helpful conventions for wrangling\n## dplyr tbl_df, glimpse, View, and piping (%>% )\n# Reshaping Data -Change the layout of a data set\n## gather, separate, spread, unite\n# Summarise Data -Create summaries and counts\n# Make New Variables -mutate and transmute\n# Group Data -group_by and window/ranking helpers\n# Subset Observations (Rows) -filter, distinct, sample, slice, top_n\n# Subset Variables (Columns) -select and selection helper functions","[{\"question\":\"What makes a dataset “tidy” for wrangling in R?\",\"answer\":\"A tidy dataset stores each variable in its own column and each observation in its own row. This structure complements R’s vectorized operations and keeps manipulations straightforward.\"},{\"question\":\"How does the %\\u003e% pipe in dplyr improve code readability?\",\"answer\":\"%\\u003e% passes the object on the left-hand side as the first argument to the function on the right-hand side. It helps write chained transformations that read more naturally.\"},{\"question\":\"Which tidyr functions are used to reshape data between wide and long formats?\",\"answer\":\"Use gather to gather columns into rows and spread to spread rows into columns. Additional helpers include separate to split one column into several and unite to merge multiple columns into one.\"}]","Data Wrangling with dplyr and tidyr - Cheat Sheet - Tidy Data and dplyr/tidyr Syntax | PDF",1791945042]