Doesnt show the output of "rolldie()" and/or "tosscoin()"

Hi, I'm an undergraduate Economics student, new to RStudio and learning how to utilize it on my Statistics class. I've been doing great untill now that we started with the "prob" package, for some reason the program doesnt show me the ouput of "rolldie()" or "tosscoin()", and by extension other code lines that depend on this. Here's what appears to me

```{r}
library(prob)
library(rmarkdown)
```

```{r}
#a
omega <- rolldie(2)
dim(omega)
omega
```
[1] 36  2

```{r}
#b
G <- subset(omega, X1 + X2 == 10); G  
```

*Doesn't show me anything at all

Any help would be gladly recibed, thanks for taking the time to read.

It works fine. R only shows output when you step through or "Run" but not when you "Source". To get output when you "Source" you need to use print() or cat() statements.

library(prob)
library(rmarkdown)

#a
omega <- rolldie(2)
dim(omega)
#> [1] 36  2
omega
#>    X1 X2
#> 1   1  1
#> 2   2  1
#> 3   3  1
#> 4   4  1
#> 5   5  1
#> 6   6  1
#> 7   1  2
#> 8   2  2
#> 9   3  2
#> 10  4  2
#> 11  5  2
#> 12  6  2
#> 13  1  3
#> 14  2  3
#> 15  3  3
#> 16  4  3
#> 17  5  3
#> 18  6  3
#> 19  1  4
#> 20  2  4
#> 21  3  4
#> 22  4  4
#> 23  5  4
#> 24  6  4
#> 25  1  5
#> 26  2  5
#> 27  3  5
#> 28  4  5
#> 29  5  5
#> 30  6  5
#> 31  1  6
#> 32  2  6
#> 33  3  6
#> 34  4  6
#> 35  5  6
#> 36  6  6

#b
G <- subset(omega, X1 + X2 == 10)
G 
#>    X1 X2
#> 24  6  4
#> 29  5  5
#> 34  4  6

Created on 2021-03-06 by the reprex package (v0.3.0)

Still doesnt work, even when I use print() or cat() and run the chunk. I dont know what else to do/try

Oh you're in RMarkdown. Probably your default chunk options are set wrongly. You might need echo = TRUE or include = TRUE.

Neither of those resolve the problem, I've already uninstalled and installed again RStudio twice, I dont know what else to do.

Can you provide your whole Rmd file?

Sure

---
title: "Tarea7Marzo"
author: "HernanV"
date: "5/3/2021"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
library(prob)
library(rmarkdown)
```

```{r setup, include= TRUE}
#a
omega <- rolldie(2)
dim(omega)
```
[1] 36  2

```{r}
#b
G <- subset(omega, X1 + X2 == 10); G  
```

(I tried what u said but it was still the same)

I made the file only to show the problem.

Try this. Your file wasn't knitting (did you notice it was throwing an error?) because you have two chunks called "setup".

---
  title: "Tarea7Marzo"
  author: "HernanV"
  date: "5/3/2021"
  output: html_document
---
  
```{r setup, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(prob)
library(rmarkdown)
```

```{r include= TRUE}
# a
omega <- rolldie(2)
dim(omega)
```

```{r}
# b
G <- subset(omega, X1 + X2 == 10)
G
```

Wow, it actually works when it knits. Thank you so much man.

No problem. RMarkdown is a bit fiddly.

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.