Collection of R programming commands (update: 6/21/2020)

R-programming

Variable anything that can change, it could be qualitative (color, fruit) or quantitative (height, weight)

-          Dependence and independence

-          Dose not have to use quote “”

-          Case sensitive – the alphabet has to be exact match

Vector

-          Simplest type of data structure

-          Sequence of data elements

-          Member of a vector – components

-          For example; c(1, 2, 3) – this is called vector

-          1, 2, 3 are components?

-          Example

o   length (c("aa", "bb", "cc", "dd", "ee")) – I think this is factors – type of vector that used for categorization

§  Length is variable

§  Aa, bb, cc are elements

o   c(TRUE, FALSE, TRUE, FALSE, FALSE) – logical value

o   c(2, 3, 5) -- number

Combining vectors

-          c() – for concatenate

-          fruits <- c("Apple", "oranges", "banana")

-          vegetables <- c("cabbage", "spinach", "tomatoes")

-          fruits <- c("Apple", "oranges", "banana")

Ref:

https://datascienceplus.com/vectors-and-functions-in-r/#:~:text=A%20vector%20is%20the%20simplest,a%20vector%20of%20logical%20values.

##for commenting the command

Hit tab -- > to get automated command

View() -- > to view data

Library

-          collection of command tools

-          After loading library -- > click tab to see the command in the library

-          Rcurl -- > using for retrieving data from html/ftp

-          Skimr -- > provide more parameter on statistic

-          Caret -- > using for plotting predictive model

Clear screen

-          ctr+L

$ after the data -- > show the variable in data

Number in front of the row -- > the order

Run command

-         ctrl+enter

To visualize the simple statistic summary



Cross mark - > real-time check, the command is wrong

infographic <- read.csv(text = getURL("https://raw.githubusercontent.com/tlerksuthirat/sample-dataset/master/json_infographics_csv"),

                     header = TRUE)

View(variable) -- > show the data table in Rscript

View(infographic)

View("C:/Users/tassanee.l/Desktop/infographic.xlsx")

read_xlsx("C:/Users/tassanee.l/Desktop/infographic.xlsx")

The data will be in the console.

Code relates to this note: https://github.com/tlerksuthirat/R-learning/blob/master/Learning%20basic%20command.R

Comments

Popular posts from this blog

Useful links (updated: 2024-12-13)

Odd ratio - อัตราส่วนของความต่าง

Note: A Road to Real World Impact (new MU-President and Team) - update 12 Sep 2024