R Markdown-Importing files

Hello! I'm trying to import filesinto my markdown document. This is the code I used

daily_activity <- read_csv("dailyActivity_merged.csv")
sleep_data <- read_csv("sleepDay_merged.csv")
weight_log <- read_csv("weightLogInfo_merged.csv")

The code comes out like a text in my R markdown file insted of a data set. Why is this happening? When I run ths code in my console, it works but it doesn't show on the makdown file.

Hi @Ibifubara_Orabere, try to check the correct path of theses files.
For set the work directory you could use setwd(dir ='path of directoy').
Other way is put the full path of each object with file.choose()

Thank you! Am I supposed to add these codes to my code chunk or write them in my console?

Please, provide us with more details

I'm trying to import and knit 3 files to a R markdown doc. The code I used is below:

daily_activity <- read_csv("dailyActivity_merged.csv")
sleep_data <- read_csv("sleepDay_merged.csv")
weight_log <- read_csv("weightLogInfo_merged.csv")

When I try to knit it, it comes out like a text and when i try to use the head(), an error message says "no object like daily_activity found".
I used getwd() to find out my working directory and gives me "/cloud/project". I have also used file.choose() to find the correct path of my files. The result is;
"/cloud/project/dailyActivity_merged.csv"
"/cloud/project/sleepDay_merged.csv"
"/cloud/project/weightLogInfo_merged.csv"
I changed the code to;

daily_activity <- read_csv("/cloud/project/dailyActivity_merged.csv")
sleep_data <- read_csv("/cloud/project/sleepDay_merged.csv")
weight_log <- read_csv("/cloud/project/weightLogInfo_merged.csv")

After knitting, the result still shows as a text in my Rmd file. I need help!

This may be an unhelpful question, but did you put the code inside an R code block in the markdown file?

```{r}
daily_activity <- read_csv("/cloud/project/dailyActivity_merged.csv")
sleep_data <- read_csv("/cloud/project/sleepDay_merged.csv")
weight_log <- read_csv("/cloud/project/weightLogInfo_merged.csv")
```

Yes, I did. Also, the small green “Run” button that's supposed in the upper right hand corner of the code block isn't there.

What happens when you make the default R Markdown file and knit it? Does that one work?

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.