Skip to main content

Posts

Showing posts with the label Analytics

How to read a CSV file in R | Lecture 4

How to read a CSV file in R CSV is called as Comma Separated Value file which can be easily generated using any spreadsheet application like OpenOffice, LibreOffice, MS Office, etc...  We can also create csv files using any text editor as well as given below.  Create a csv file as per the format given below: Name, Age, Science, Maths, Social Kumar,14,57,67,78 Anand,24,98,97,90 Balakumar, 25,35,45,56 To read this file > mydata=read.csv("users.csv"); > mydata        name age science maths social 1     kumar  14      57    67     78 2     Anand  24      98    97     90 3 Balakumar  25      35    45     56 To create a new file, df <- data.frame(name = c("Jon", "Bill", "Maria"),  age = c(23, 41, 32), science=c(20,30,40), maths=c(56,67,78), social=c(98,76,65)) write.csv(df,"anewfile.csv", row.names = FALS...

Arrays and Matrices in R | Lecture 3

Arrays and Matrices in R Arrays are declared in R using the dim() or array() functions.  For example: > mycarsale.array<-1:30 > mycarsale.array  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 [17] 17 18 19 20 21 22 23 24 25 26 27 28 29 30 The above command allocates a vector of 1 to 30 to the variable array called mycarsale.array  To make it as a matrix, we can use dim() function as given below  > dim(mycarsale.array)<-c(3,5,2) > mycarsale.array , , 1      [,1] [,2] [,3] [,4] [,5] [1,]    1    4    7   10   13 [2,]    2    5    8   11   14 [3,]    3    6    9   12   15 , , 2      [,1] [,2] [,3] [,4] [,5] [1,]   16   19   22   25   28 [2,]   17   20   23   26   29 [3,]   18   21   24  ...

How to Use R as a Calculator | Lecture 2

R as a Calculator How to use R as a calculator  Open R Studio either through GUI or through Command/Terminal Mode by typing  $] rstudio In the Console Window, type the following  > 2+3 > log(10) >log10(10) > 3^2+4^3 > exp(5) > exp(1) Check the output given in the following Window. To clear the console Window, use the Shortcut key Ctl+L,  in R, pi is recognised as PI = 3.141 >pi  [1] 3.141593 We can use -ve sign also in front of the numbers  > -9 + 1 [1] -8

Basics of R | Lecture 1

Basics of R Its a software and programming language used  for statistical computing and report generation.  Its Free and open source with GPL Licensing  It has a GUI to work upon called as RStudio.  This software can be installed using the following command in  Ubuntu $] sudo apt update $] sudo apt install build-essential autoconf automake libxmu-dev $] sudo apt install r-base rstudio To open the software, you can use either through the GUI or through terminal using  $] rstudio The GUI looks like this  R Studio Features of R Its based on object oriented design R Commands can be included or embedded with other software or applications or programming languages namely C++. Java and other commercial tools. It supports multiple Operating systems like Windows, Linux, Mac OS, etc. Advantages of R Good community to help  Works in a interactive way Plotting and graphs are easy to plot using the libraries. New libraries can be easily generated. Its comple...