R is capable of reading data from most formats, including files created in other statistical packages. Whether the data was prepared using Excel (in CSV, XLSX, or TXT format), R can read and load the data into memory.
R also has two native data formats Rdata (sometimes shortened to Rda) and Rds.
Before reading any data in Rstudio you first need to check that you are in the same directory that as of the Data you want to load.
> getwd()
[1] "C:/Users/Admin/Desktop"
> setwd("C:/Users/Admin/Desktop/zogya_d") # the data is present in the folder name zigya_d
Function: read.table()
Common Parameters:
To import a word.txt file from your local, the syntax would be:
# Read a txt file, named "mtcars.txt"
and storing it in vector named my_data
> my_data <- read.tabe("word.txt", header=TRUE, sep= " ")
By default numeric items (except row labels) are read as numeric variables. We can change this if we want.
Function: read.csv()
Common Parameters:
# Read a csv file, named "word.csv"
and storing it in vector named my_data
> my_data <- read.csv("word.csv")
We covered how to read data from .txt files and .csv files as well, along with the change the directory in which the data is present.
This brings the end of this Blog. We really appreciate your time.
Hope you liked it.
Do visit our page www.zigya.com/blog for more informative blogs on Data Science
Keep Reading! Cheers!
Zigya Academy
BEING RELEVANT
Through the standard form offers different advantages in mathematical calculations and scientific notation. Firstly, it…
Introduction Stress is a feeling caused by an external trigger that makes us frustrated, such…
Sociology is a broad discipline that examines societal issues. It looks at the meaningful patterns…
Some info about Inch Inches are a unique measure that persuades us that even the…
You should be familiar with logarithms to understand antilogarithms in a better manner. Logarithms involve…
यहां "नाटककार सुरेंद्र वर्मा" पुस्तक की पीडीएफ विद्यार्थी, शोधार्थी और जो इसका अभ्यास के लिए…