Code
<- 10 my_variable
DANL 200: Introduction to Data Analytics
Marcus Smith
February 19, 2024
Plain text
DANL and DANL
DANL and DANL
Check out Classwork 3 - Markdown Basics
“Tidy datasets are all alike, but every messy dataset is messy in its own way.” — Hadley Wickham
R is a powerful language and environment for statistical computing and graphics. It is widely used among statisticians and data analysts for data analysis and developing statistical software. Here are some basic concepts and elements of R to help you get started:
R can be used as a simple calculator. You can perform arithmetic operations like addition (+
), subtraction (-
), multiplication (*
), and division (/
). For example, typing 2 + 2
in the R console will give you 4
.
Variables in R are used to store data. You can create a variable using the assignment operator <-
(option/Alt + -). For example:
This will store the value 10
in my_variable
.
R has several basic data types:
2.5
.2L
(the L
tells R it is an integer)."Hello"
.TRUE
or FALSE
).Vectors are a basic data structure in R. They contain elements of the same type. You can create a vector using the c()
function:
Data frames are used for storing data tables in R. It is a list of vectors of equal length. For example, to create a simple data frame:
Functions are used to carry out specific tasks in R. For example, sum()
is a function that adds numbers together:
R has a vast collection of packages for various statistical tasks. You can install a package using install.packages("packageName")
and load it using library(packageName)
.
To get help on a specific function or topic, use the help()
function or the shorthand ?
, like ?sum
on R Console.
---
title: R Basics
subtitle: "DANL 200: Introduction to Data Analytics"
author:
- name: Marcus Smith
date: last-modified
execute:
echo: true # true false
eval: true # true false
warning: false # true false
message: false # true false
fig-width: 9
# fig-height: 5
format:
html:
toc: true # true false
number-sections: true # true false
code-fold: show # true false show # https://quarto.org/docs/output-formats/html-code.html
code-tools: true # true false
highlight-style: atom-one # atom-one tango espresso # https://quarto.org/docs/output-formats/html-code.html#highlighting
---
```{r setup}
#| include: false
library(tidyverse)
library(hrbrthemes)
library(skimr)
library(DT)
```
# Markdown Syntax
Plain text
*DANL* and DANL
**DANL** and DANL
## Dive into Markdown syntax
Check out [Classwork 3 - Markdown Basics](https://bcdanl.github.io/200/danl-cw/danl-200-cw-03.html)
![](https://bcdanl.github.io/img/coding-cat-1.png)
<br><br>
# R Basics
> “Tidy datasets are all alike, but every messy dataset is messy in its own way.”
— Hadley Wickham
R is a powerful language and environment for statistical computing and graphics. It is widely used among statisticians and data analysts for data analysis and developing statistical software. Here are some basic concepts and elements of R to help you get started:
<br><br>
## 1. R as a Calculator
R can be used as a simple calculator. You can perform arithmetic operations like addition (`+`), subtraction (`-`), multiplication (`*`), and division (`/`). For example, typing `2 + 2` in the R console will give you `4`.
<br><br>
## Variables
Variables in R are used to store data. You can create a variable using the assignment operator `<-` (**option/Alt + -**). For example:
```{r}
my_variable <- 10
```
This will store the value `10` in `my_variable`.
<br><br>
## Data Types
- R has several basic data types:
- **Numeric**: For decimal values like `2.5`.
- **Integer**: For whole numbers like `2L` (the `L` tells R it is an integer).
- **Character**: For text or string values, e.g., `"Hello"`.
- **Logical**: For boolean values (`TRUE` or `FALSE`).
<br><br>
## Vectors
Vectors are a basic data structure in R. They contain elements of the same type. You can create a vector using the `c()` function:
```{r}
my_vector <- c(1, 2, 3, 4, 5)
```
<br><br>
## Data Frames
Data frames are used for storing data tables in R. It is a list of vectors of equal length. For example, to create a simple data frame:
```{r}
df <- data.frame(
Name = c("Alice", "Bob"),
Age = c(25, 30)
)
```
<br><br>
## Functions
Functions are used to carry out specific tasks in R. For example, `sum()` is a function that adds numbers together:
```{r}
sum(1, 2, 3) # Returns 6
```
<br><br>
## Packages
R has a vast collection of packages for various statistical tasks. You can install a package using `install.packages("packageName")` and load it using `library(packageName)`.
<br><br>
## Help System
To get help on a specific function or topic, use the `help()` function or the shorthand `?`, like `?sum` on R Console.
<br><br><br><br>
# References
- [https://quarto.org/docs/output-formats/html-basics.html](https://quarto.org/docs/output-formats/html-basics.html)
- [https://quarto.org/docs/websites/](https://quarto.org/docs/websites/)
- [R for Data Science](http://r4ds.hadley.nz) by [Hadley Wickham](https://hadley.nz)