Module II Notes - 1
Module II Notes - 1
Module II Notes - 1
To read an excel file read_excel() function is used. This function is present in the package named
“readxl”. Hence before using this function the package "readxl" has to be installed.
A package is a collection of functions, data, and other code that are highly organized in a
reusable manner. R packages are an essential part of the R ecosystem and contribute
greatly to the flexibility and power of the language.
The base packages which are come with the default installation of R. But some other packages
which is not comes under the base packages can be installed using the install.packages() function
in R.
To install the same the following syntax (Syntax in R refers to the set of rules and conventions
that must be followed when writing R code.) can be used.
install.packages("package_name")
Replace "package_name" with the name of the package you want to install.
Eg. install.packages("readxl")
install.packages("ggplot2")
Once installed, a package, it can be loaded into an R session using the library() function,
which makes all the functions and data in the package available to the user. The library() function
is used to load packages into the current R session. The syntax for the library() function is as
follows:
library(package name)
Replace "package_name" with the name of the package
Eg. library(readxl)
Before reading a file it is necessary to set the working directly properly, for the same two common
functions getwd() and setwd () are used.
getwd() : the getwd() function is used to get the current working directory :
setwd () : the setwd() function is to set the working directory to a specific directory
eg. setwd("C:\\Users\\vimalkumar\\Desktop")
setwd("C:\\Users\\KSBB\\Desktop")
or setwd("C:/Users/KSBB/Desktop ")
setwd("C:/Users/vimalkumar/Desktop")
Eg.
aa <- read_excel("rabbit.xlsx")
bb <- read_excel("index.xlsx")
ac <- read_excel("name.xlsx")
View(xy)
View(xy)
View(xy)
To select specific number of rows and column tablename[row, column] is used
Eg.
https://genome.ucsc.edu/ENCODE/
we can also import data from websites… try with the following site for reading a text file
form awebsite
print (pbc)
estrol
***************************************************
Eg.
write.csv(data2,"output.csv")
write.csv(data2,"output1.csv",row.names = FALSE)
C()
The c function in R programming stands for 'combine.' It combines multiple values into a vector
or list.
c(value1, value2,value3,…)
write.table(ggg, file="vkk.text")
write.table(ggg, file="vkk.text",row.names = FALSE)