Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imported a csv-dataset to R but the values becomes factors

I am very new to R and I am having trouble accessing a dataset I've imported. I'm using RStudio and used the Import Dataset function when importing my csv-file and pasted the line from the console-window to the source-window. The code looks as follows:

setwd("c:/kalle/R") stuckey <- read.csv("C:/kalle/R/stuckey.csv") point <- stuckey$PTS time <- stuckey$MP 

However, the data isn't integer or numeric as I am used to but factors so when I try to plot the variables I only get histograms, not the usual plot. When checking the data it seems to be in order, just that I'm unable to use it since it's in factor form.

like image 861
Joe Avatar asked Mar 03 '11 23:03

Joe


People also ask

How do I import a csv dataset into RStudio?

In RStudio, click on the Workspace tab, and then on “Import Dataset” -> “From text file”. A file browser will open up, locate the . csv file and click Open. You'll see a dialog that gives you a few options on the import.


1 Answers

Both the data import function (here: read.csv()) as well as a global option offer you to say stringsAsFactors=FALSE which should fix this.

like image 197
Dirk Eddelbuettel Avatar answered Sep 20 '22 14:09

Dirk Eddelbuettel