Unable to Load Data Set (Working on My Goggle Data Analytic Capstone Project)

Hello everyone, I just finished my Goggle Data Analytic Courses, am currently working on my Capstone Project (Bella Beat).

Here is my challenges am unable to load the data either from my computer or the Kaggle link where the data is stored.
Here is my code from R to load the Data using CSV or excel
#............Installation of Packages.........%
install.packages(c("tidyverse", "lubridate", "dplyr", "ggplot2", "tidyr"))
library(tidyverse)
library(lubridate)
library(dplyr)
library(ggplot2)
library(tidyr)
#............Reading and writing of data files.........%
install.packages(c('rjava','xlsxjars', 'xlsx'))
library(rJava)
library(xlsxjars)
library(xlsxjars)
library(xlsx)
#Reading data from Excel files
installed.packages('readxl', respos="http:cran.rstudio.com")
library(readxl)
#Read data from the sheet using read excel
Activity<-read_excel("C:\Users\User1\Documents\DATA ANALYSIS\Portfolio\BellaBeat_20241116_v1\2\DailyActivity.xlsx, sheet='dailyActivity')

The output it display is
Activity<-read_csv("C:\Users\User1\Documents\DATA ANALYSIS\Portfolio\BellaBeat_20241116_v1\2\dailyActivity.csv")
Error: '\U' used without hex digits in character string (:1:24)

Activity<-read_excel("C:\Users\User1\Documents\DATA ANALYSIS\Portfolio\BellaBeat_20241116_v1\2\DailyActivity.xlsx, sheet='dailyActivity')
Error: '\U' used without hex digits in character string (:1:26)

Have you tried using / instead of \ ? R uses the latter as an escape character so cannot read normal Windows paths correctly.

Warning: I have never used Windows for R, just macOS and linux.

BTW, library(tidyverse) will load dplyr, ggplot2, lubridate, and tidyr (along with forcats, purrr, stringr, readr, tibble) so there is no reason for library(dplyr), library(ggplots2)... .
Also, the readxl package has no external dependencies, unlike xlsx which needs Java.
If you are using your own computer, you only need to install packages once. They should appear in your User Library.

2 Likes

Yes, \ can not be used directly, either use / or double the backslashes:

"C:/Users/User1/Documents"
"C:\\Users\\User1\\Documents"
1 Like

Thanks it worked, and I have removed the uncessary library(dplyr and the rest). But I try to use read. csv does not worked and read_excel
Here is the output for both

Output of read.csv

Error in read.table(file = file, header = header, sep = sep, quote = quote, :
unused argument (sheet = "DailyActivityy")

Output of read_excel

Error: path does not exist: ‘C:\Users\User1\Documents\DATA ANALYSIS\Portfolio\BellaBeat_20241116_v1\2\DailyActivity.xlsx

I do not know the reasons for this because the file exit on the PC

Thanks but worked still having trouble with Error: path does not exist

Please post your current code, not just the errors.

Did you check for typos? You have lots of spellings of "daily activity" floating around. In the error message, it says you put an an argument sheet = "DailyActivityy". Is the sheet actually called that, or did you accidentally add an extra "y"? And in your original code, you put sheet='dailyActivity', which is a different spelling. You also have DailyActivity.xlsx and dailyActivity.csv.

1 Like