How to read a file in R?Explain with an example

823    Asked by Daminidas in Data Science , Asked on Nov 29, 2019
Answered by Damini das

There are many file formats of data to read and analyze but one of the most commonly used format is comma separated value or CSV file.To read a CSV file, we can use the following code

# Pass in the entire file path if not in same directory

ex <- read.csv('example.csv')

Here ‘example’ is the name of the file name and we have to pass in the entire file path if not in same directory

To check the column names of the dataframe, we can use colnames() function

# Check column names

colnames(ex)

'Name' 'Orders' 'Date'



Your Answer

Interviews

Parent Categories