Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MSS PS: Introduction to R
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#MSS PS: Introduction to R! # this is the code wall editor (not live), you'll have to edit along with me- #you may need to click "Run it" in the bottom left corner to see the output & pretty graphs! #let's make up some data! set.seed(42) mydata<-rnorm(1:100, mean=50, sd=10) mydata_shifted<-mydata+20 mydata2<-rnorm(1:100, mean=50, sd=10) mydata_shifted_random<-mydata+sample(15:30, 100, replace=TRUE) randomdata<-sample(1:100, 100, replace=TRUE) #Descriptives #what is the mean of the data? #mean(mydata) #what is the standard deviation of the data? #sd(mydata) #what are the z scores of the data? #mydata_zscored<-scale(mydata) #Plotting #histogram/bar chart #hist(mydata) #box plots of the mydata and mydata_shifted #boxplot(mydata, mydata_shifted) #density plots of mydata (smoothed histogram) #plot(density(mydata)) #lines(density(mydata2), col="red") #density plot of shifted data #plot(density(mydata)) #lines(density(mydata_shifted), col="green") #desnity plot of randomly shifted data #plot(density(mydata)) #lines(density(mydata_shifted_random), col="orange") #Inferential Analyses #t test, paired, assuming equal variances #t.test(mydata, mydata_shifted_random, paired=TRUE, var.equal=FALSE) #ANOVA ("Analysis of Variance") test of mydata and mydata_shifted_random #aov(mydata~mydata_shifted_random) #plot of my data vs mydata_shifted_random #plot(mydata, mydata_shifted_random) #draw the line of best fit from the linear model/random #lines((c(0:100)*beta-intercept),c(0:100), col="purple") #Non-inferential Analyses #correlation between mydata & mydata_shifted_random #cor(mydata,mydata_shifted_random)
[
+
]
Show input
fork mode
|
history
|
discussion