Monte Carlo simulation

The way I was using it is kind of a bastardization of the statistical concept mara linked to. I just meant that, with the information that the R interpreter has, it can't tell that two expressions are supposed to be separate when they're only separated by spaces.

since I couldnt access the clipboard (automatically) I did it this way(manually) . what am I doing wrong ?


# This line of sample code simulates four random games where the Celtics either lose or win. Each game is independent of other games.
simulated_games <- sample(c("lose","win"), 4, replace = TRUE, prob = c(0.6, 0.4))


# The variable 'B' specifies the number of times I want the simulation to run. I will run the Monte Carlo simulation 10,000 times.
B <- 10000


# Use the `set.seed` function to make sure my answer matches the expected result after random sampling.
set.seed(1)


# Create an object called `celtic_wins` that first replicates the sample code generating the variable called `simulated_games` for `B` iterations and then tallies the number of simulated series that contain at least one win for the Celtics.

celtic_wins <- replicate(B, {simulated_games <- sample(c("lose","win"), 4, replace = TRUE, prob = c(0.6, 0.4)); any(simulated_games == c("win"))})  


# Calculate the frequency out of B iterations that the Celtics won at least one game.  
mean(celtic_wins) 
#> [1] 0.8757

I think I created the .md correctly manually, not sure though. I couldn't copy and paste it into the forum, so I opened it in r studio and copied it there and pasted it into the forum ? am I good ?