Veeramani Natarajan
Veeramani Natarajan

Reputation: 342

R is not reading my csv file properly?

I am new to R Programming language. I can able to load this csv file into R. it was semicolon separated csv file. There are totally 33 attributes. but R reads it as 1 column, The link for dataset is

https://archive.ics.uci.edu/ml/datasets/Student+Performance#

I had tried using sep(";") while reading csv file in R. i had also tried to convert various formats from csv to text,dif, and nothing works.

Your help is appreciated.

Upvotes: 0

Views: 10844

Answers (2)

RHertel
RHertel

Reputation: 23788

df1 <- read.csv('student-mat.csv', sep=";")
df2 <- read.csv('student-por.csv', sep=";")

Works without any problem. Maybe you had just forgotten to put the equal sign between sep and ";".

> str(df1)
'data.frame':   395 obs. of  33 variables:
$ school    : Factor w/ 2 levels "GP","MS": 1 1 1 1 1 1 1 1 1 1 ...
$ sex       : Factor w/ 2 levels "F","M": 1 1 1 1 1 2 2 1 2 2 ...
$ age       : int  18 17 15 15 16 16 16 17 15 15 ...
$ address   : Factor w/ 2 levels "R","U": 2 2 2 2 2 2 2 2 2 2 ...
$ famsize   : Factor w/ 2 levels "GT3","LE3": 1 1 2 1 1 2 2 1 2 1 .
....

Upvotes: 2

Jot eN
Jot eN

Reputation: 6396

Using your data, it works well for me:

student_por <- read.csv2("student-por.csv")
student_mat <- read.csv2("student-mat.csv")

Upvotes: 0

Related Questions