This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.
library(statsr)
## Warning: package 'statsr' was built under R version 4.0.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.2
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
x <- rnorm(100, mean = 100, sd = 20)
mean(x)
## [1] 100.4846
sd(x)
## [1] 23.09992
getwd()
## [1] "C:/Users/Jerome/Documents/0000_Work_Files/0000_Coursera/Statistics_with_R_Specialization/Course_1_Probability_&_Data/Week_4_Thinking_plus_Course_Materials"
head(x)
## [1] 71.51319 115.47459 116.34087 120.89071 57.23384 95.65640
write.table(x=x, file ="x.csv", row.names = FALSE)
random <-read.csv("random.csv", header = TRUE)
#x <-read.csv("x.csv", header = TRUE)
a null file. But when i opened it in Excel from the folder, it had data; it was not null. I then read it into r, and then i could write it again to save it. So when you generate a random number vector, you must read it in before you can write it, i think. At the end i’ll try it w/ kobe_streak.
#mean(random$random_no)
#mean(x$x)
#sd(x$x)
#median(x$x)
#sd(random$random_no)
#median(random$random_no)
that wd to Week 4 thinking; didn’t move all the x and random stuff there.
data("kobe_basket")
write.table(kobe_basket, file ="kobe_basket.csv", row.names = FALSE)
write.csv( kobe_basket, file = "kobe_basket.csv", row.names = FALSE)
6 variables, just like it should. But to run sd and median, i had to delete the OT rows.
#mean(kobe_basket$quarter)
#sd(kobe_basket$quarter)
#median(kobe_basket$quarter)
and the descriptives wouldn’t process.
#after deleting the OT rows
kobe_basket <- read.csv("kobe_basket.csv", header = TRUE)
mean(kobe_basket$quarter)
## Warning in mean.default(kobe_basket$quarter): argument is not numeric or
## logical: returning NA
## [1] NA
sd(kobe_basket$quarter)
## Warning in var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm =
## na.rm): NAs introduced by coercion
## [1] NA
median(kobe_basket$quarter)
## [1] "2"
w/ it, write it, etc. But it seems I must read it 1st.