Using R Libraries and Working with Data

Packages in R can contain code, data, and documentation. These are stored in libraries, and provide functionality features to R, like reading .csv files. Packages can be installed with the install.packages() command.
Example:

install.packages(“readx…


This content originally appeared on DEV Community and was authored by Natalie Taktachev

Packages in R can contain code, data, and documentation. These are stored in libraries, and provide functionality features to R, like reading .csv files. Packages can be installed with the install.packages() command.
Example:

install.packages("readxl")

Whenever you use a library that is not native to R, it must be loaded into R by using the library() function.

library("readxl")

Excel files can be read with the read_excel() function.

read_excel("/filepath/file.xls)

Similarly, data from a .csv file can be stored and accessed like this:

data <- read.csv("/filepath/datafile.csv")

data

That should show you the rows and columns from the .csv file, which you can then perform operations and analysis on.

More useful functions for working with data files:

readLines() - read text file into character vector
write() - export a dataset as text file
write.csv() & write.table() - export a dataset as .csv file
write.xlsx() - export a dataset as Excel file
save() - save R objects in .RData files


This content originally appeared on DEV Community and was authored by Natalie Taktachev


Print Share Comment Cite Upload Translate Updates
APA

Natalie Taktachev | Sciencx (2021-11-07T20:23:48+00:00) Using R Libraries and Working with Data. Retrieved from https://www.scien.cx/2021/11/07/using-r-libraries-and-working-with-data/

MLA
" » Using R Libraries and Working with Data." Natalie Taktachev | Sciencx - Sunday November 7, 2021, https://www.scien.cx/2021/11/07/using-r-libraries-and-working-with-data/
HARVARD
Natalie Taktachev | Sciencx Sunday November 7, 2021 » Using R Libraries and Working with Data., viewed ,<https://www.scien.cx/2021/11/07/using-r-libraries-and-working-with-data/>
VANCOUVER
Natalie Taktachev | Sciencx - » Using R Libraries and Working with Data. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/07/using-r-libraries-and-working-with-data/
CHICAGO
" » Using R Libraries and Working with Data." Natalie Taktachev | Sciencx - Accessed . https://www.scien.cx/2021/11/07/using-r-libraries-and-working-with-data/
IEEE
" » Using R Libraries and Working with Data." Natalie Taktachev | Sciencx [Online]. Available: https://www.scien.cx/2021/11/07/using-r-libraries-and-working-with-data/. [Accessed: ]
rf:citation
» Using R Libraries and Working with Data | Natalie Taktachev | Sciencx | https://www.scien.cx/2021/11/07/using-r-libraries-and-working-with-data/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.