Onkar
July 28, 2021, 5:28am
1
#my code is below
pkgs <- c("moments", "ggplot2", "dplyr", "tidyr", "tidyverse")
install.packages(pkgs, repos = "http://cran.us.r-project.org ")
library(ggplot2)
ggplot(data= dailyActivity )+
geom_point(mapping = aes(x= TotalSteps, y=Calories ))
ggplot(data= dailyActivity )+
geom_point(mapping = aes(x= VeryActiveMinutes, y=Calories ))
ggplot(data= dailyActivity )+
geom_point(mapping = aes(x= TotalDistance, y=Calories ))
install.packages("rmarkdown")
library(markdown)
#i am getting following error while Knit into HTML. pls help
Quitting from lines 3-20 (knit.spin.Rmd)
Calls: ... withCallingHandlers -> withVisible -> eval -> eval -> ggplot
mara
July 28, 2021, 1:56pm
2
This is because you need this dataset included in your R Markdown document.
1 Like
The first problem I see is that you shouldn't include install commands in your Rmd file, you only need to install packages once in your system, but if you include this command, you are going to be installing them every time you knit the document.
Now, about your issue, when you knit a document the code gets executed in a clean environment other than the one you are currently working on, so if you do not include the code you have used to load dailyActivity
into memory, the dataset is not going to exist in the clean environment.
1 Like
Onkar
July 28, 2021, 2:09pm
4
hi this is the error
Quitting from lines 3-40 (knit.spin.Rmd)
Error in contrib.url(repos, "source") :
trying to use CRAN without setting a mirror
Calls: ... withVisible -> eval -> eval -> install.packages -> contri
Onkar
July 28, 2021, 2:11pm
5
please help now i am getting this error
+-rmarkdown::render(...)
| -knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
| -knitr:::process_file(text, output)
| +-base::withCallingHandlers(...)
| +-knitr:::process_group(group)
| -knitr:::process_group.block(group)
| -knitr:::call_block(x)
| -knitr:::block_exec(params)
| -knitr:::eng_r(options)
| +-knitr:::in_dir(...)
| -knitr:::evaluate(...)
| -evaluate::evaluate(...)
| -evaluate:::evaluate_call(...)
| +-evaluate:::timing_fn(...)
| +-base:::handle(...)
| +-base::withCallingHandlers(...)
| +-base::withVisible(eval(expr, envir, enclos))
| -base::eval(expr, envir, enclos)
| -base::eval(expr, envir, enclos)
+-ggplot2::ggplot(data = dailyActivity)
-ggplot2:::ggplot.function(data = dailyActivity)
Execution halted
To help us help you, could you please prepare a repr oducible ex ample (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
1 Like
Onkar
July 28, 2021, 2:42pm
7
head(dailyActivity)
# A tibble: 6 x 15
Id ActivityDate TotalSteps TotalDistance TrackerDistance LoggedActivitiesDi~
<dbl> <chr> <dbl> <dbl> <dbl> <dbl>
1 1.50e9 04-12-2016 13162 8.5 8.5 0
2 1.50e9 4/13/2016 10735 6.97 6.97 0
3 1.50e9 4/14/2016 10460 6.74 6.74 0
4 1.50e9 4/15/2016 9762 6.28 6.28 0
5 1.50e9 4/16/2016 12669 8.16 8.16 0
6 1.50e9 4/17/2016 9705 6.48 6.48 0
# ... with 9 more variables: VeryActiveDistance <dbl>,
# ModeratelyActiveDistance <dbl>, LightActiveDistance <dbl>,
# SedentaryActiveDistance <dbl>, VeryActiveMinutes <dbl>,
# FairlyActiveMinutes <dbl>, LightlyActiveMinutes <dbl>, SedentaryMinutes <dbl>,
# Calories <dbl>
library(rmarkdown)
library(tidyverse)
library(ggplot2)
dailyActivity <- read.csv
joined_hourly_data<- read.csv
view(dailyActivity)
view(joined_hourly_data)
ggplot(data= dailyActivity )+
geom_point(mapping = aes(x= TotalSteps, y=Calories ))
ggplot(data= dailyActivity )+
geom_point(mapping = aes(x= VeryActiveMinutes, y=Calories ))
ggplot(data= dailyActivity )+
geom_point(mapping = aes(x= TotalDistance, y=Calories ))
Quitting from lines 3-22 (new-markdown.spin.Rmd)
Error: You're passing a function as global data.
Have you misspelled the `data` argument in `ggplot()`
Backtrace:
x
1. +-rmarkdown::render(...)
2. | \-knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
3. | \-knitr:::process_file(text, output)
4. | +-base::withCallingHandlers(...)
5. | +-knitr:::process_group(group)
6. | \-knitr:::process_group.block(group)
7. | \-knitr:::call_block(x)
8. | \-knitr:::block_exec(params)
9. | \-knitr:::eng_r(options)
10. | +-knitr:::in_dir(...)
11. | \-knitr:::evaluate(...)
12. | \-evaluate::evaluate(...)
13. | \-evaluate:::evaluate_call(...)
14. | +-evaluate:::timing_fn(...)
15. | +-base:::handle(...)
16. | +-base::withCallingHandlers(...)
17. | +-base::withVisible(eval(expr, envir, enclos))
18. | \-base::eval(expr, envir, enclos)
19. | \-base::eval(expr, envir, enclos)
20. +-ggplot2::ggplot(data = dailyActivity)
21. \-ggplot2:::ggplot.function(data = dailyActivity)
Execution halted
Onkar
July 28, 2021, 2:47pm
8
done please check if this is understandable
This is not valid R code, so you basically have the same problem as before. You need to include valid code to read your data frame into memory.
1 Like
Onkar
July 28, 2021, 2:57pm
11
thank you very much. Was able to knit.
I am just a beginner in this field so learning step by step.
system
Closed
August 4, 2021, 2:58pm
12
This topic was automatically closed 7 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.