Code
[1] 37
In R, an Object is a container (like a variable) that holds data. A Function is a command (followed by parentheses ()) that performs an action on that data.
This is how we store information in R using the assignment operator <-.
Once you have a dataset (like chickwts), you need to inspect it.
weight feed
1 179 horsebean
2 160 horsebean
3 136 horsebean
4 227 horsebean
5 217 horsebean
6 168 horsebean
weight feed
66 352 casein
67 359 casein
68 216 casein
69 222 casein
70 283 casein
71 332 casein
[1] "data.frame"
[1] "factor"
weight feed
Min. :108.0 casein :12
1st Qu.:204.5 horsebean:10
Median :258.0 linseed :12
Mean :261.3 meatmeal :11
3rd Qu.:323.5 soybean :14
Max. :423.0 sunflower:12
You can work with specific parts of a dataset or get unique information from columns.
[1] horsebean linseed soybean sunflower meatmeal casein
Levels: casein horsebean linseed meatmeal soybean sunflower
[1] "numeric"
[1] 71
If you don’t need the whole dataset, you can “slice” it using square brackets [rows, columns].
R is very precise. If your data has a missing value (NA), most functions will fail unless you tell them how to handle it.
R has built-in functions for quick data inspection through plots.
Courses that contain short and easy to digest video content are available at premieranalytics.com.bd Each lessons uses data that is built into R or comes with installed packages so you can replicated the work at home. premieranalytics.com.bd also includes teaching on statistics and research methods.