Hello everyone and welcome back!
Today I’m going to introduce you to R programming language, so lets get started with it : First download and install R and Rstudio, then run it.
- Download and Install R
https://cran.r-project.org/mirrors.html - Download and install RStudio
https://www.rstudio.com/products/rstudio/download/ - Run Rstudio
Now we can start learning!
Code used:
#1 and 1024
k <- c(1,1024)
plot(k)
#1 to 1024
k <- (1:1024)
hist(k)
#k[number] in console to view the number k[40] - 40
k <- c(0.5, 1) # k = 0.5, 1
k <- c(k, 1.5) # k = 0.5, 1, 1.5
k <- c(k, c(2, 2.5)) # k = 0.5, 1, 1.5, 2, 2.5
k <- c(k, k) # k = 0.5, 1, 1.5, 2, 2.5, 0.5, 1, 1.5, 2, 2.5
k <- c(0.5, 1) # k is a vector
k[1] # is 0.5 (remember, R indices start on 1)
k[3] # Error example, if we dont have 3
arr <- (1:250)
plot(arr)
print(arr)
#setwd("F:/All of my stuff/r")
#readmyfile <- read_csv("myfile.csv")
#install.packages("readr")
#library(readr)
#-ggpubr for a more graphical display and dplyr for grouping data
#hist(readmyfile$columnB) #histogram of just a certain column
data()
View(discoveries)
plot(discoveries)
newvar <- discoveries
#maths
somevalue <- 7
othervalue <- 2
latestvalue <- somevalue + othervalue
print(latestvalue)
#cool statistics stuff
print(max(newvar))
print(min(newvar))
print(mean(newvar))#average
print(median(newvar))#central value
print(range(newvar))#min and max values
print(newvar)
#,na.rm) - removes the missing values
#boxplot(somedata$ispitA,somedata$ispitB, main="Uspjeh na ispitu A i B",
#xlab="Ispit", ylab="Bodovi")
#lets see the example from the documentation
plot(discoveries, ylab = "Important Discoveries",las=1 )
#the las=1 is the way your labels will be set up,
#lets change it to 2 or 3
#we can try to , xlab="Years" -change the label as well
title(main = "discoveries from 1860 to 1959 ")
#we can change the size using cex.main=<sizeYouWantinNumbers>
agemeasure <- c(10:60)
#agemeasure2 <- seq(from, to, by= )
agemeasure2 <- seq(10, 60, by=2 )
print(agemeasure)
print(agemeasure2)
View(women)#not sure if data is in cm/kg or else
plot(women$height, women$weight, main="Weight of people in this group",
xlab="Weight", ylab="Hight", las=2 , cex.main=0.6)
#this is why data is reverse here - comparing the table