[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-573144-105":53,"doc-detail-573144-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-cheatsheet","Data transformation with dplyr - Cheatsheet","","A concise dplyr cheatsheet focused on transforming tidy data using pipes. It explains the tidy data assumptions (variables as columns, observations as rows) and shows how to summarize grouped cases, count rows, and control grouping with group_by, rowwise, and ungroup. It also covers manipulating cases with filter, filter_out, distinct, slice, slice_min/max/head/tail, and arranging rows with arrange. Finally it demonstrates variable operations including select, pull, relocate, mutate, and rename, plus helper functions for selecting and applying transformations across multiple columns.",{"@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-cheatsheet/573144/",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-cheatsheet/573144.png","ImageObject",442,249,{"name":88,"@type":89},"LangkahRina","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-18","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 structure?","Question",{"text":108,"@type":109},"dplyr assumes tidy data where each variable is a column and each observation (case) is a row.","Answer",{"name":111,"@type":106,"acceptedAnswer":112},"How do pipes change the way functions are called in dplyr?",{"text":113,"@type":109},"With pipes, x |> f(y) becomes f(x, y), passing the left-hand data into the function.",{"name":115,"@type":106,"acceptedAnswer":116},"How can I create new columns or modify existing ones in dplyr?",{"text":117,"@type":109},"Use mutate() to compute new columns from existing ones; it applies vectorized functions and returns outputs aligned to the data length.","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},573144,1792014477,{"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},962090893776,"https://ap-avatar.wpscdn.com/davatar_155a257f0dc6eb9ab79c44ca47cae57d","Data transformation with dplyr : : CHEATSHEET   \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  \npipes  \nx |> f(y)  \nbecomes f(x, y)  \nSummarize Cases  \nApply summary functions to columns to create a new table of summary statistics. Summary functions take vectors as input and return one value (see back) .  \nsummarize( .data,…)  \nCompute table of summaries.  \nmtcars |> summarize(avg = mean(mpg))  \ncount( .data,…, wt = NULL, sort = FALSE, name = NULL) Count number of rows in each group defined by the variables in…Also tally(), add_count(), add_tally() .  \nmtcars |> count(cyl)  \nGroup Cases  \nUse group_by( .data,…, .add = FALSE, .drop = TRUE) to create a\"grouped\" copy of a table grouped by columns in ... dplyr functions will manipulate each \"group\" separately and combine the results.  \nAlternate grouping syntax with .by as an argument:  \nmtcars |>  \ngroup_by(cyl) |> summarize(avg = mean(mpg))  \nmtcars |> summarize(  \navg = mean(mpg), . by = cyl)  \nUse rowwise( .data,…) to group data into individual rows. dplyr functions will compute results for each row. Also apply functions to list-columns. See tidyr cheat sheet for list-column workflow.  \nstarwars |>  \nrowwise() |>  \nmutate(film_count = length(films))  \nungroup(x,…) Returns ungrouped copy of table. g_mtcars \u003C-mtcars |> group_by(cyl)  \nungroup(g_mtcars)  \nManipulate Cases  \nEXTRACT CASES  \nRow functions return a subset of rows as a new table.  \nfilter(.data,…, .preserve = FALSE) Extract rows that meet logical criteria.  \nmtcars |> filter(mpg > 20)  \nfilter_out(.data, ..., .preserve = FALSE): Drop rows that meet logical criteria (the complement to `filter()`) . Missing values in the dropped condition are kept by default, so you don't need to guard against NA explicitly.  \nmtcars |> filter_out(mpg > 20)  \nUse when_any() and when_all() inside filter() to combine multiple conditions.  \nmtcars |> filter(when_any(mpg > 30, hp > 300))  \ndistinct(.data,…, .keep_all = FALSE) Remove rows with duplicate values.  \nmtcars |> distinct(gear)  \nslice(.data,…, .preserve = FALSE) Select rows by position. mtcars |> slice(10:15)  \nslice_sample(.data,…, n, prop, weight_by = NULL, replace = FALSE) Randomly select rows. Use n to select a number of rows and prop to select a fraction of rows.  \nmtcars |> slice_sample(n = 5, replace = TRUE)  \nslice_min(.data, order_by,…, n, prop, with_ties = TRUE) and slice_max() Select rows with the lowest and highest values.  \nmtcars |> slice_min(mpg, prop = 0.25)  \nslice_head(.data,…, n, prop) and slice_tail() Select the first or last rows.  \nmtcars |> slice_head(n = 5)  \nLogical and boolean operators to use with filter()  \n== \u003C \u003C= [is. na](is. na) () %in% | xor()  \n!= > >= () ! &  \nSee ?base::Logic and ?Comparison for help.  \nARRANGE CASES  \narrange( .data,…, .by_group = FALSE) Order rows by values of a column or columns (low to high), use with desc() to order from high to low. mtcars |> arrange(mpg)  \nmtcars |> arrange(desc(mpg))  \nADD CASES  \nadd_row(.data,…, . before = NULL, .after = NULL) Add one or more rows to a table.  \ncars |> add_row(speed = 1, dist = 1)  \nManipulate Variables  \nEXTRACT VARIABLES  \nColumn functions return a set of columns as a new vector or table.  \npull( .data, var = -1, name = NULL,…) Extract column values as a vector, by name or index. mtcars |> pull(wt)  \nselect( .data,…) Extract columns as a table. mtcars |> select(mpg, wt)  \nrelocate( .data,…, . before = NULL, .after = NULL) Move columns to new position.  \nmtcars |> relocate(mpg, cyl, . after = last_col())  \n\n| \u003Cbr>Use these helpers with select() and across()\u003Cbr>e.g. mtcars |> select(mpg:cyl)\u003Cbr>contains(match) num_range(prefix, range) :, e.g., mpg:cylends_with(match) all_of(x)/any_of(x,…, vars) !, e.g., !gear\u003Cbr>starts_with(match) matches(match) everything() |  |\n| --- | --- |\n| MANIPULATE MULTIPLE VARIABLES AT ONCE\u003Cbr>df \u003C-tibble(x_1 = c(1, 2), x_2 = c(3, 4), y = c(4, 5))","cbCaibsXzrLhxjCe","https://ap.wps.com/l/cbCaibsXzrLhxjCe","pdf",903999,"English","# Summarize Cases\n## Count Cases\n# Group Cases\n## Rowwise and Ungroup\n# Manipulate Cases\n## Extract, Distinct, Slice\n## Logical Operators in filter\n## Arrange Cases\n# Add Cases\n# Manipulate Variables\n## Extract Variables\n## Make New Variables\n## Rename Variables\n## Vectorized Functions","[{\"question\":\"What does dplyr expect regarding tidy data structure?\",\"answer\":\"dplyr assumes tidy data where each variable is a column and each observation (case) is a row.\"},{\"question\":\"How do pipes change the way functions are called in dplyr?\",\"answer\":\"With pipes, x |\\u003e f(y) becomes f(x, y), passing the left-hand data into the function.\"},{\"question\":\"How can I create new columns or modify existing ones in dplyr?\",\"answer\":\"Use mutate() to compute new columns from existing ones; it applies vectorized functions and returns outputs aligned to the data length.\"}]","Data transformation with dplyr - Cheatsheet | PDF",1791933204]