<jupyter_start><jupyter_text>History about RBell labs develops s language in 1976. In 1993 <NAME> and <NAME> created R in new zealand. R become free source in 1995. R version 1.0.0 is released in 2000 to the public. IDE Rstdio is release in 2011.  IntroductionR is a programming language and software environment for statical computing and graphics supported by the R foundation. R is not like a general-purpose programming language like Java, C, because it was created by statisticians as an active environment. Interactivity is the critical characteristic that allows R to explore our data. It is also a programming language and development environment for statistical testing and graphical testing. Each statistical testing is either linear, non-linear modeling, classification or many more. Different types of the plot are required while doing data analysis. In order to run R, we will use IDE(according to Wikipedia an integrated development environment(IDE) is a software application that provides comprehensive facilities to the programmer for software development). The core component which is required for every R program is BaseR. These core components contain only the code importing bits that run our code successfully.    Installing and Setting up R in your Windows Step 1: Downloading installation file * Download R tools from [Official Website](https://cran.r-project.org/bin/windows/Rtools/)* Next, we need to have an IDE, most popular one is Rstudio. We can download it from [this link](https://www.rstudio.com/products/rstudio/download/).After downloading installation file, install them on desired places and then open the console.Now we can write our R codes within console or we can do it via Rstudio. I prefer to use Jupyter Notebook for runing R because it is more friendly for me. A good tutorial is available at [Anaconda's Documentation](https://docs.anaconda.com/anaconda/navigator/tutorials/r-lang/). Assigning Variable and operator in R A Variable is a container that stores values. An assignment statement set or reset the value store in the storage location(s) denoted by variable name(by Wikipedia). The assignment operator is a command that is it telling the computer to assign the text apple to the variable product. we can also assign by `assign('products', ' apple)`. We can assign the variable in R in many ways like below.  Way 1<jupyter_code>('apple'-> product)<jupyter_output><empty_output><jupyter_text>Way 2<jupyter_code>(product = 'apple')<jupyter_output><empty_output><jupyter_text>Way 3<jupyter_code>assign( product,  'apple')
(product = 'apple')<jupyter_output><empty_output><jupyter_text>Logical Operators in R Logical operator means those which gives `True` and `False` value. For example  Example 1<jupyter_code>apple <- 2
banana <- 3
mostexpensive <- banana> apple
mostexpensive<jupyter_output><empty_output><jupyter_text>Example 2<jupyter_code>apple <- 2
banana <- 3
mostexpensive <- banana< apple
mostexpensive<jupyter_output><empty_output><jupyter_text>Example 3<jupyter_code>apple <- 2
banana <- 2
mostexpensive <- banana == apple
mostexpensive<jupyter_output><empty_output><jupyter_text>Example 4<jupyter_code>apple <- 2
banana <- 2
mostexpensive <- banana != apple
mostexpensive
result <- (1+2)*3 # it does not give any value because it assume that result will be store for future use.
assign('result2',(3+1-2)*3)
print(result2)
calculation <- result <- 15
calculation
result
(abs(-6))
(factorial(4))<jupyter_output><empty_output><jupyter_text>Some Commonly Used Data Types in RData is centre for analysis if there is no data there is no analysis. Every piece of data are working with some characteristics thses characteristics can be summarize with data type.* `Character` :Anything inside quotation is a character.* `Number`: Number in R is double. Working with whole and fraction is a unique feature of double. Another is integer. * `Integer` Integer is actually simplified version of double. It store data as a string we must use capital letter L. In our use we need to use double rather than integer.* `Logical(Boolean)`:`Yes` or `No`. Also `T` or `F`.* `Complex Number`:$$ 2 + 6i $$* `Raw`:It is not so popular data type. It is not easy to create variable of raw type. If we really need to create raw function as a result of calling this function we get raw type data.All the fundamental data types are called atomic data type.  Examples<jupyter_code>a <- 2L
class(a)

a <- 2
class(a)
typeof(a)
quantity <- 2
typeof(quantity)
quantity_integer <- 2L
typeof(quantity_integer)<jupyter_output><empty_output><jupyter_text>CommentsComments are used to give important information about the code. Comments are not run by the program but a programmer writes it for better explanation of the code.<jupyter_code># This is a comment line<jupyter_output><empty_output><jupyter_text>Exploring vectors and factorsData structure as name suggest represent way to organize data to facilate different operations to perform faster calculations.* `Vectors`:Collection of data of same structure.* `Factors`:Which are used to store categorical data.* `Array`:Is a matrix which are generalization of vectors.* `List\DataFrame`:Elements of different list are dataframe. List are more complex data structure because they allow us to store other list too. We can think data frame as spreadsheets where  data are organize as columns and rows where each column has specific data type. Within a data frame we have all kinds of datatype but within one column we have only one data type. Other criteria to categorize our data is by dimensional. Vector and list are one dimensional objects. Matrices and dataframe are two dimensional data structure. Array are the object that have more than two dimensions.> Vector have two properties they are one dimensional and containing element of same type.  Assigning a column vectorLets assign a column vector,<jupyter_code>assign('b',c(1,2,3,4))
print(b)<jupyter_output>[1] 1 2 3 4<jupyter_text>Vectors attributes:* `length`: It is denoted by length(a) and its meaning is number of elements.* `Name`:  names(a), it allows us to add element in the list.* `Type`: typeof(a), It gives type of data.There are six vectors types* Double* logical* character* complex* Raw* Integer<jupyter_code>vector <- c("Durga","Puja","Ram","Hari")
vector
length(vector) # length 
names(vector)= "Sita" #names
typeof(vector) # type
vector<jupyter_output><empty_output><jupyter_text>Manipulating vectors.Manipulating of vectors consists of sorting, ordering, indexing.* `sorting`: Sort the data in some order.* `Ordering`:The order function return the index needed to get the vector sort.* `Indexing`:Selecting specifics iteam by position.<jupyter_code>quantity <- c(1,3,2,5,6,7)
sort(quantity)
order(quantity)
a <- c(1,7,36,0,7,5)
a[2]
a[3:5]
a[c(2,4)]
a[c(4,7)]# it return particular element from vector
a[-2]
a[-(2:4)] # it skip the element in the vector.
a[a==1]
a[a>3]
a[a %in%c(2,4)] # it gives matching element.<jupyter_output><empty_output><jupyter_text>Operating vectorAdding or multiplying vector of different size is called recycling rule. For recycling largest vector must be multiple of small one.<jupyter_code>c <- 1:6
d <- 1:3
c * d<jupyter_output><empty_output><jupyter_text>Sequence generationIt is used to create sequence of elements in a vector. `seq()` function takes length and difference between values as optional argument. In a code below, I take elements in the range 1 to 5 in the interval of 1.5. Example:<jupyter_code>seq(1,5,by = 1.5)
seq(1,5,by = 3)<jupyter_output><empty_output><jupyter_text>Replicating elementsIt is used to return the replicating element in the list in a specified times. In the following code I replicate the numbers from 1 to 6 two times. A builtin function `rep()` is used. Example:<jupyter_code>e<- rep(1:6,times = 2)
e<jupyter_output><empty_output><jupyter_text>Example:<jupyter_code>x <- rep(c(1),each = 10)
x<jupyter_output><empty_output><jupyter_text>Conversion of different type of data into character type is called implicit coercianR convert coerced data type into character.<jupyter_code>x <- c(1,'two',4,"durga")
x
typeof(x)<jupyter_output><empty_output><jupyter_text>Explicit type coercian* We do this by typing `as.desire data type`. Explicit type coercian helps us to deal with incorectly catagorized data.* We can not transfer numeric into character * Character into numberic.<jupyter_code>num <- 1:5
num_char <- as.character(num)
num_char
product <- c("apple",1,"banana")
as.numeric(product)<jupyter_output>Warning message in eval(expr, envir, enclos):
"NAs introduced by coercion"<jupyter_text>Installing Packages in RThere are numerous useful packages to do various tasks in R and with those packages, we could do things better and faster way. Once simpler way to install packages is via console;<jupyter_code>install.packages("haven")
library("haven") # allows to read sav file
saq8 <- read_sav("F:/Statisticts with R/CSV file for covid data/SAQ8.sav")<jupyter_output><empty_output><jupyter_text>In above example, I first installed package named as `haven` and then I used it to read `sav` file.  Array<jupyter_code>a <- c(1,2,3,4,5,4)
b <- c(4,5,6,7,8,6)
c<- c(3,8,7,5,6,7)
d<- rbind(a,b,c)
d
quantity_day1 <- d 
quantity_day1
quantity_day2 <- d*2
shopping_data <- array(c(quantity_day1,quantity_day2), dim= c(3,6,2))
shopping_data[,,1]<jupyter_output><empty_output><jupyter_text>List<jupyter_code>a <- c(1,2,3,4,5,4)
b <- c(4,5,6,7,8,6)
c<- c(3,8,7,5,6,7)
d<- list(a,b,c)
d

basket_detail <- list( store = 'store',product = c('apple','cookies'),price= c(12,45))
basket_detail
basket_detail[[1]]
basket_detail[[2]]
basket_detail[[3]]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09016900247320693, 'fraction_numerical': 0.018239901071723002, 'mean_word_length': 5.642710472279261, 'pattern_counts': {'":': 0, '<': 129, '<?xml version=': 0, '>': 89, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '21', 'dir': 'jupyter-structured-clean-dedup', 'id': '433962', 'license': 'CC0-1.0', 'n_tokens_mistral': 3056, 'n_tokens_neox': 2846, 'n_words': 1193, 'path': 'R/Getting started with R.ipynb', 'repo_name': 'Omgupta0312/hacktoberfest2021-5', 'size': '9718'}