Home > other >  importing data frame csv file into R
importing data frame csv file into R

Time:01-16

I have a problem importing my data file to R. My laptop has broke down so that I am currently using the PC at university. There is a problem reading a csv file into R suddenly, the error I get is "unexpected error in..."

The code I was using yet was (after renaming the data a few times since it did not work): setwd("C:/Users/s1101923/Desktop) getwd() library(readr) data <- read_csv("C:/Users/s1101923/Desktop/logreg.csv") data1 <- read_csv("C:/Users/s1101923/Desktop/data_for_today.csv")

CodePudding user response:

did you try

library(readr)
data <- read_csv("C:/Users/s1101923/Desktop/data_for_today.csv")

CodePudding user response:

Try df=read.csv('file_name.csv') and you dont need any library for this. and you dont need to specify the whole path. just save the csv file where your r programs are saved and type data=read.csv('data_for_today.csv') make sure you have save the csv file in the location where your r programs will be saved.

CodePudding user response:

You have a typo in your code when setting the working directory. You forgot the closing quotation marks. It should be like this:

setwd("C:/Users/s1101923/Desktop")

Also, you can just use the data name when reading your csv file. No need for the entire path.

  • Related