[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-572063-105":53,"doc-detail-572063-en":127},{"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":120,"head_meta":122,"extra_data":124,"updated_unix":126},105,"en","data-import-r-data-import-with-readr-and-readxl","data-import - R data import with readr and readxl","","Guide to importing external tabular data into R, focusing on readr and related tools. Covers reading delimited text and comma/semicolon/tab-separated files using functions like read_delim, read_csv, read_csv2, and read_tsv, plus saving outputs with write_delim/write_csv/write_tsv. Explains key read arguments such as headers, column selection, missing-value handling, locale decimal marks, skipping lines, and n_max. Includes spreadsheet import via readxl and Google Sheets via googlesheets4, plus column type specification concepts.",{"@graph":63,"@context":119},[64,80,102],{"@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-import-r-data-import-with-readr-and-readxl/572063/",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-import-r-data-import-with-readr-and-readxl/572063.png","ImageObject",442,249,{"name":88,"@type":89},"McGucket","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-21","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":101},"InteractionCounter",{"@type":100},"ViewAction",7,{"@type":103,"mainEntity":104},"FAQPage",[105,111,115],{"name":106,"@type":107,"acceptedAnswer":108},"How can tabular text files be imported into R using readr?","Question",{"text":109,"@type":110},"Use read_delim for any delimiter, or use read_csv/read_csv2 for comma or semicolon-separated formats, and read_tsv for tab-delimited files. You can also specify missing values and locale decimal marks when needed.","Answer",{"name":112,"@type":107,"acceptedAnswer":113},"How do you save imported data back to files with readr?",{"text":114,"@type":110},"Use write_delim for custom delimiters, or use write_csv, write_csv2, and write_tsv for common CSV/TSV formats. The write_* functions support options such as NA handling and quoting/escaping.",{"name":116,"@type":107,"acceptedAnswer":117},"How can spreadsheet data be imported into R from Excel or Google Sheets?",{"text":118,"@type":110},"Import Excel files using read_excel, where sheet can be selected by name or position. For Google Sheets, use googlesheets4, and follow the same idea of specifying what to read from the sheet.","https://schema.org",{"og:url":78,"og:type":121,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":123,"canonical":78},"index,follow",{"doc_id":125,"site_id":56},572063,1792242391,{"code":4,"msg":5,"data":128},{"doc_id":125,"user_id":129,"nickname":88,"user_avatar":130,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":101,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":73,"language":136,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":61,"update_tm":140,"read_time":9},1236954412713,"https://us-avatar.wpscdn.com/davatar_29158cc5080c5b710cf443261637dec0","One of the first steps of a project is to import outside data into R. Data is often stored in tabular formats, like csv files or spreadsheets.  \nThe front page of this sheet showshow to import and save text files into R using readr.  \nThe back page shows how to import spreadsheet data from Excel files using readxl or Google Sheets using googlesheets4 .  \nA|B|C 1|2|3 4|5|NA  \n\n| A | B | C |\n| --- | --- | --- |\n| 1 | 2 | 3 |\n| 4 | 5 | NA |\n\nread_ *(file, col_names = TRUE, col_types = NULL, col_select = NULL, id = NULL, locale, n_max = Inf, skip = 0, na = c(\"\", \"NA\"), guess_max = min(1000, n_max), show_col_types = TRUE) See ?read_delim  \nread_delim(\"file.txt\", delim = \"|\") Read files with any delimiter. If no delimiter is specified, it will automatically guess.  \nTo make file.txt, run: write_file(\"A|B|C\\n1|2|3\\n4|5|NA\", file = \"file.txt\")  \nread_csv(\"file.csv\") Read a comma delimited file with period decimal marks.  \nwrite_file(\"A,B,C\\n1,2,3\\n4,5,NA\", file = \"file.csv\")  \nData import with the tidyverse : : CHEATSHEET  \nOTHER TYPES OF DATA  \nTry one of the following  \npackages to import other types of files:  \n• haven-SPSS, Stata, and SAS files  \n• DBI-databases  \n• jsonlite-json  \n• xml2-XML  \n• httr-Web APIs  \n• rvest-HTML (Web Scraping)  \n• readr::read_lines() -text data  \nRead Tabular Data with readr  \nA,B,C 1,2,3 4,5,NA  \n\n| A | B | C |\n| --- | --- | --- |\n| 1 | 2 | 3 |\n| 4 | 5 | NA |\n\nA;B;C  \n1,5;2;3  \n4,5;5;NA  \nA B C  \n1 2 3  \n4 5 NA  \nread_csv2(\"file2 .csv\") Read semicolon delimited files with comma decimal marks.  \nwrite_file(\"A;B;C\\n1,5;2;3\\n4,5;5;NA\", file = \"file2.csv\")  \nread_tsv(\"file.tsv\") Read a tab delimited file. Also read_table() . read_fwf(\"file.tsv\", fwf_widths(c(2, 2, NA))) Read a fixed width file. write_file(\"A\\tB\\tC\\n1\\t2\\t3\\n4\\t5\\tNA\\n\", file = \"file.tsv\")  \nUSEFUL READ ARGUMENTS  \nNo header  \nread_csv(\"file.csv\", col_names = FALSE)  \nProvide header  \nread_csv(\"file.csv\", col_names = c(\"x\", \"y\", \"z\"))  \nRead multiple files into a single table  \nread_csv(c(“f1.csv”,“f2.csv”,“f3.csv\"), id = \"origin_file\")  \n\n| 1 | 2 | 3 |\n| --- | --- | --- |\n| 4 | 5 | NA |\n\n\n| A | B | C |\n| --- | --- | --- |\n| 1 | 2 | 3 |\n\n\n| A | B | C |\n| --- | --- | --- |\n| NA | 2 | 3 |\n| 4 | 5 | NA |\n\nA;B;C  1,5;2;3,0  \nSkip lines  \nread_csv(\"file.csv\", skip = 1)  \nRead a subset of lines  \nread_csv(\"file.csv\", n_max = 1)  \nRead values as missing  \nread_csv(\"file.csv\", na = c(\"1\"))  \nSpecify decimal marks  \nread_delim(\"file2 . csv\", locale = locale(decimal_mark = \",\"))  \nSave Data with readr  \nwrite_ *(x, file, na = \"NA\", append, col_names, quote, escape, eol, num_threads, progress)  \n\n| A | B | C |\n| --- | --- | --- |\n| 1 | 2 | 3 |\n| 4 | 5 | NA |\n\nwrite_delim(x, file, delim = \" \") Write files with any delimiter. write_csv(x, file) Write a comma delimited file.  \nwrite_csv2(x, file) Write a semicolon delimited file.  \nwrite_tsv(x, file) Write a tab delimited file.  \nColumn Specification with readr  \nColumn specifications define what data type each column of a file will be imported as. By default readr will generate a column spec when a file is read and output a summary.  \nspec(x) Extract the full column specification for the given imported data frame.  \n\n| spec(x)\u003Cbr>\\# cols(\u003Cbr>\\# age = col_integer(),\u003Cbr>\\# edu = col_character(),\u003Cbr>\\# earn = col_double()\u003Cbr>\\# ) | \u003Cbr>age is an integer |\n| --- | --- |\n\nedu is a  \nearn is a double (numeric) character  \nCOLUMN TYPES  \nEach column type has a function and corresponding string abbreviation.  \n• col_logical() - \"l\"  \n• col_integer() - \"i\"  \n• col_double() - \"d\"  \n• col_number() - \"n\"  \n• col_character() - \"c\"  \n• col_factor(levels, ordered = FALSE) - \"f\"  \n• col_datetime(format = \"\") - \"T\"  \n• col_date(format = \"\") - \"D\"  \n• col_time(format = \"\") - \"t\"  \n• col_skip() - \"-\", \"_ \"  \n• col_guess() - \"?\"  \nUSEFUL COLUMN ARGUMENTS  \nHide col spec message  \nread_ *(file, show_col_types = FALSE)  \nSelect columns to import  \nUse names, position, or selection helpers. read_*(file, col_select = c(age, ","cbCaia9uMMKWlD4p","https://ap.wps.com/l/cbCaia9uMMKWlD4p","pdf",649898,"English","# Import outside data into R\n## Reading delimited text files\n## Save data with readr\n## Importing spreadsheets (Excel and Google Sheets)\n## Column types and useful read arguments","[{\"question\":\"How can tabular text files be imported into R using readr?\",\"answer\":\"Use read_delim for any delimiter, or use read_csv/read_csv2 for comma or semicolon-separated formats, and read_tsv for tab-delimited files. You can also specify missing values and locale decimal marks when needed.\"},{\"question\":\"How do you save imported data back to files with readr?\",\"answer\":\"Use write_delim for custom delimiters, or use write_csv, write_csv2, and write_tsv for common CSV/TSV formats. The write_* functions support options such as NA handling and quoting/escaping.\"},{\"question\":\"How can spreadsheet data be imported into R from Excel or Google Sheets?\",\"answer\":\"Import Excel files using read_excel, where sheet can be selected by name or position. For Google Sheets, use googlesheets4, and follow the same idea of specifying what to read from the sheet.\"}]","data-import - R data import with readr and readxl | PDF",1791925298]