FDP Indoglobal Group of Colleges: 27 April To 1 May R Programming Language Assignment Submission
FDP Indoglobal Group of Colleges: 27 April To 1 May R Programming Language Assignment Submission
R Programming Language
Assignment Submission
[email protected]
Feedback of FDP
At first, want to say a big thanks to organizing committee who arrange
this FDP. This gives an immense pleasure to learner, provides a platform
to learn many other things apart from just R language. There were
number of different session which assign a new directions to participants
likewise IBM computing session by Dr. Mani Madukar.
Suggestion from my side are that
1. This would be better if you provide a feedback form to
participants where you can ask questions about sessions.
2. A Proper road map should give to participants, like wise number of
video lecture could be divide into number of days.
Assignments
> log2(2^5)
[1] 5
> log(exp(1)*exp(2))
[1] 3
Explore the Help tab in RStudio: Change the labels, title, etc.
> help(title)
> help("labels")
Check whether plyr package is installed on your machine. If yes, load it.
library(plyr)
1. Find out how to calculate median - using Help button and web search.
help(median)
# Create a vector.
x <- c(12,7,3,4.2,18,2,54,-21,8,-5)
# Find Mean.
result.median <- median(x)
print(result.median)
2. Calculate mean and median of the data frame CO2.
Mean : Average
Median : Middle Value
Mode : Most Often
name<-c("Mahi","Saurav","Azahar","Patudi","Sunny")
name
name<-c("Mahi","Saurav","Azahar","Patudi","Sunny","Dravid")
name
played=c(23,45,56,67,78)
played
won=c(11,23,34,45,56)
lost<-c(11,22,12,23,34)
y=c(12,34,23,45,12,15)
capatin<-data.frame(name,played,won,lost,y)
lost<-c(11,22,12,23,34,22)
capatin<-data.frame(name,played,won,lost,y)
played=c(23,45,56,67,78,33)
capatin<-data.frame(name,played,won,lost,y)
won=c(11,23,34,45,56,44)
capatin<-data.frame(name,played,won,lost,y)
view(captain)
View(captain)
View(capatin)
capatin$name
ratio=capatin$won/capatin$played
> ratio
[1] 0.4782609 0.5111111 0.6071429 0.6716418 0.7179487
[6] 1.3333333
> ratio=(capatin$won/capatin$played)*100
> ratio
[1] 47.82609 51.11111 60.71429 67.16418 71.79487
[6] 133.33333
3. Take the help of R for all the commands shown in this tutorial.
st=read.csv("CO3-4-5.csv")
st=st[1:12,]
View(st)
load("matrices.R")
Create a new folder on your computer and make it your working directory.
Step1 Click on files plate..left side of R Studio
Step 2 Click on Folder—Working R Dirctory
Step 3 Click on More
Step 4 Choose set as Working Directory
vect3
mat1<-matrix(vect3,nrow = 4,ncol = 3,byrow=TRUE)
mat1
vect3
mat1<-matrix(vect3,nrow = 4,ncol = 3,byrow=TRUE)
mat1
Using built-in dataset iris, implement all the functions we have learnt in this
tutorial.
library(XML)
rm(list=ls())
student=read.csv("Iris.csv")
subdata<-student[1:12,]
student1<-subdata
student1
summary(student1)
class(student1)
typeof(student1)
head(student1,2)
tail(student1,2)
str
str(student1)
student2=read.csv("Iris.csv")
View(student2)
MergeData<-merge(student1,student2,by="Student.Name")
View(MergeData)
xmldata<-xm
xmldata<-xmlToDataFrame("student2.xml")
View(xmldata)
lst=list(st,mat1,myvector)
rm(list=ls())
st=read.csv("moviesData.csv")
st<-st[1:12,]
View(st)
rm(list=ls())
st=read.csv("CO3-4-5.csv")
st<-st[1:12,]
hist(st$Total,main="Student Marks",
xlab = "Total MArks",xlim = c(0,18),
col="blue",breaks = 2)
generalCount<-table(st$Total)
View(generalCount)
pie(generalCount)
rm(list=ls())
st=read.csv("moviesData.csv")
st<-st[1:10,]
View(st)
barplot(st$Total,ylab = "Total",
xlab = "Total Marks",col="Blue",
ylim = c(0,10),main = "Total Marks")
library("ggplot2")
rm(list = ls() )
movies <-
read.csv("C:\\Users\\Harish\\Documents\\R_Working_Directory\\movies
Data.csv")
View(movies)
ggplot(data=movies,mapping=aes(x=mpaa_rating))+
geom_point()
geom_bar()
1. Consider the built-in data set mtcars. Find the cars with hp greater
than 100 and cyl equal to 3.
2. Arrange the mtcars data set based on mpg variable.
library(dplyr)
rm(list = ls() )
1. Use the built-in data set airquality. Using select function, select the
variables Ozone,Wind, and Temp in this data set.
2. Use the built-in data set mtcars. Rename the variables mpg and cyl
with MilesPerGallonvand Cylinder, respectively.
MoviesTGI<-select(movies,title,genre,imdb_rating)
View(MoviesTGI)
Use the built-in data set iris. Using the pipe operator, group the owers by
their
Species.
Summarise the grouped data by the mean of Sepal.Length and Sepal.Width.
library(datasets)
data(iris)
summary(iris)
1. Use the built-in data set iris. Find the Species, in which Sepal.Length is
greater than Petal.Length.
2. Count all such Species.
Functions in R - Assignment
1. Create a function which computes combination of two numbers.
2. Create a function which takes a natural number as an argument, and
prints Fibonacci series. For example, consider fibonacci(5). It should
print the _rst 5 elements of Fibonacci series, i.e. 1, 1, 2, 3, 5.
combinations(3,2,letters[1:3])
combinations(3,2,letters[1:3],repeats=TRUE)