Upload R project/Rmarkdown to kaggle

Hello everyone,
I
am working on my first r project, and I want to upload it to Kaggle but couldn't success. This is my third day trying and I will appreciate any help. so I created a new notebook from a kaggle page where the original data set exist, it's called Bellabet. Apparently, I could successfully download the dataset. But when I give command read.csv I get an error "No such file or directory” Error in file(file, "rt"): cannot open the connection"

When I run the code to download the data, it runs without errors but I can't see the data even when I write view() but when I use read.csv i get an error. I am attaching two screenshot below. What could be the problem? Also, I tried to change the directory. I tried to upload the project using Rmarkdown after watching and reading many sources and followed the steps very carefully but also couldn't success. Also, with my limited experience I am not sure what else to try

Any help will be much appreciated!
Thank you

Message (please cut-and-paste rather than screenshot—almost illegible) indicates that the file can’t be found by that name under the current working directory.

Many thanks for your help!
here are the codes:
list.files(path = "../../kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16")
my_path <-"../../Downloads/Fitabase Data 4.12.16-5.12.16/"
output:

  1. 'dailyActivity_merged.csv'
  2. 'dailyCalories_merged.csv'
  3. 'dailyIntensities_merged.csv'
  4. 'dailySteps_merged.csv'
  5. 'heartrate_seconds_merged.csv'
  6. 'hourlyCalories_merged.csv'
  7. 'hourlyIntensities_merged.csv'
  8. 'hourlySteps_merged.csv'
  9. 'minuteCaloriesNarrow_merged.csv'
  10. 'minuteCaloriesWide_merged.csv'
  11. 'minuteIntensitiesNarrow_merged.csv'
  12. 'minuteIntensitiesWide_merged.csv'
  13. 'minuteMETsNarrow_merged.csv'
  14. 'minuteSleep_merged.csv'
  15. 'minuteStepsNarrow_merged.csv'
  16. 'minuteStepsWide_merged.csv'
  17. 'sleepDay_merged.csv'
  18. 'weightLogInfo_merged.csv'

second code that i am getting error:
sleep <- read.csv("/kaggle/input/sleepDay_merged.csv",header = T)
intensity <- read.csv("/kaggle/input/dailyIntensities_merged.csv",header = T)
activity <- read.csv("/kaggle/input/dailyActivity_merged.csv",header = T)
steps <- read.csv("/kaggle/input/dailySteps_merged.csv",header = T)
calories <- read.csv("/kaggle/input/dailyCalories_merged.csv",header = T)
weight <- read.csv("/kaggle/input/weightLogInfo_merged.csv",header = T)
Warning message in file(file, "rt"):
“cannot open file '/kaggle/input/sleepDay_merged.csv': No such file or directory”
Error in file(file, "rt"): cannot open the connection
Traceback:

  1. read.csv("/kaggle/input/sleepDay_merged.csv", header = T)
  2. read.table(file = file, header = header, sep = sep, quote = quote,
    . dec = dec, fill = fill, comment.char = comment.char, ...)
  3. file(file, "rt")

What is the mistake?

Still not there. Type

dir()

from the console or navigate in the files pane to check

Thanks, I wrote it in the console and I get the following result but I still don't understand

dir()
[1] "notebook_source.ipynb"

I also run

getwd()
[1] "/kaggle/working"

I am not sure where to use dir()
is my first code wright?
list.files(path = "../../kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16")
my_path <-"../../Downloads/Fitabase Data 4.12.16-5.12.16/"

getwd() and dir() together shoe show that there is no directory named input where the function was told to look. Either move it to the working directory or give the full system pathname. Consider organizing your work in an RStudio project and using the {here} libtay and the function of the same name.

Okay, but how to change the working directory? so the the path to my data is "/kaggle/working/" right? then what is the output of dir()?

Also, when I click on one of the files to get the path, I get this path, so i am confused
/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/sleepDay_merged.csv

what should I replace in my first and second code? and where should I place them? Sorry, too many questions, I am very new to R and programming in general. Thank you very much for your help

From R

setwd("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16")

and try again. This is only a temporary expedient. Some attention to infrastructure is needed.

  1. From the RStudio menu `File | New Project | New Directory | New Project
  2. Adjust the PATH and name to somewhere you can find it
  3. Move /kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/sleepDay_merged.csv to that directory
1 Like

This is really very helpful, thank you very much for your kind help!

best regards,

hello again and thanks for your help! I checked them all and the column is exist


but i still can't run the code

I can't tell anything from the screenshot;the second shows that the variable ActivityMinutes is missing from sleep.

I had the same problem when I tried to upload my answers to a competition. Until now, I cannot use any of the datasets miscellaneous for the competition then, I will follow your post for checking a solution

Is it a problem with the upload process or with the data attempted to be uploaded, as above?

I am not sure to be honest, but when I write View() or head() I get:
A data.frame: 6 × 6
||Id|ActivityMinute|Calories|Intensity|Steps|METs|
||||||||
|1|1503960366|4/12/2016 12:00:00 AM|0.7865|0|0|10|
|2|1503960366|4/12/2016 12:01:00 AM|0.7865|0|0|10|
|3|1503960366|4/12/2016 12:02:00 AM|0.7865|0|0|10|
|4|1503960366|4/12/2016 12:03:00 AM|0.7865|0|0|10|
|5|1503960366|4/12/2016 12:04:00 AM|0.7865|0|0|10|
|6|1503960366|4/12/2016 12:05:00 AM|0.9438|0|0|12|

so the column ActivityMinute is exist but I can't group_by. Is there any mistake with the following command?
sleep %>% group_by(Id,ActivityMinute) %>% count() %>% View()
The ActivityMinute column is and the Id column is

Is that your own data or is it available for download?

it is online. It's called fitbit. can you help me please? I have two days left to the deadline

Data is on kaggle, link FitBit Fitness Tracker Data | Kaggle
These are the steps i did:

list.files(path = "/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16")

sleep <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/sleepDay_merged.csv", header = T)
intensity <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/dailyIntensities_merged.csv",header = T)
activity <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/dailyActivity_merged.csv",header = T)
steps <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/dailySteps_merged.csv",header = T)
calories <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/dailyCalories_merged.csv",header = T)
weight <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/weightLogInfo_merged.csv",header = T)

sleep %>% group_by(Id,SleepDay) %>% count() %>% View()
sleep$Id <- as.character(sleep$Id)
sleep <- sleep %>% unique()

colnames(activity)[2] <- "ActivityDay"
activity$Id <- as.character(activity$Id)
sleep$Id <- as.character(sleep$Id)
sleep$ActivityDay <- substring(sleep$SleepDay,1,9)
daily <- left_join(activity,sleep)

weight$Id <- as.character(weight$Id)
weight$ActivityDay <- substring(weight$Date,1,9)

daily <- left_join(daily, weight)

daily <- daily %>% select(-c(Date,SleepDay))

daily$QualitySleep <- daily$TotalMinutesAsleep / daily$TotalTimeInBed * 100

calories <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/hourlyCalories_merged.csv", header = T)
intensities <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/hourlyIntensities_merged.csv", header = T)
steps <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/hourlySteps_merged.csv", header = T)

hourly <- left_join(calories,intensities)
hourly <- left_join(hourly,steps)

calories_narrow <- read.csv( "/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/minuteCaloriesNarrow_merged.csv", header = T)
intensities_narrow <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/minuteIntensitiesNarrow_merged.csv", header = T)
steps_narrow <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/minuteStepsNarrow_merged.csv", header = T)
sleep <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/minuteSleep_merged.csv", header = T)
met <- read.csv("/kaggle/input/fitbit/Fitabase Data 4.12.16-5.12.16/minuteMETsNarrow_merged.csv", header = T)

minute <- left_join(calories_narrow,intensities_narrow)
minute <- left_join(minute,steps_narrow)
minute <- left_join(minute,met)

rm(calories_narrow,intensities_narrow,steps_narrow,met)

sleep %>% group_by(Id,ActivityMinute) %>% count() %>% View()
I am stuck here

I’ll take a look. Meanwhile in the first screenshot it shows the minute data frame, not sleep. Which one should be used?

thank you very much! I divided the data and merged it by: Daily, Hourly, and By Minute as written in the codes above. So the data frame you are asking about became minute