-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
22 changed files
with
701 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
#builtin function | ||
a<-45.6 | ||
print(floor(a)) | ||
print(ceiling(a)) | ||
print(abs) | ||
|
||
x<-c(26.36,25.3,26.96) | ||
print(trunc(x)) | ||
|
||
y<-45 | ||
print(sqrt(y)) | ||
print(exp(y)) | ||
print(sin(y)) | ||
print(log(y)) | ||
|
||
|
||
f<-c("123456789") | ||
substr(a,2,7) | ||
#isame tumhe 3 cheeje deni padati hai pahla jisame pata karna ho substring then start and stop point | ||
|
||
|
||
u<-c("abd","anbvhdy","abcde") | ||
pat<-"^abd" | ||
print(grep(u,pat)) | ||
|
||
|
||
|
||
g<-15 | ||
h<-15 | ||
print(sum(g+h)) | ||
|
||
|
||
k<-c(238,36,96,85,454,58,91,65) | ||
print(max(k)) | ||
print(min(k)) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
example_function=function(x,y) | ||
{c(x+1,y+10)} | ||
example_function(5,6) | ||
|
||
|
||
log(2) | ||
tan(5) | ||
exp(12) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
hspA=list(gene="hsp1a",amino.acids=650,nucleotideds=550) | ||
print(hspA) | ||
|
||
|
||
#lets pull out just the gene | ||
hspA$gene | ||
#lets pull out the amino acids | ||
hspA$amino.acids | ||
#lets pull out the nucleotides | ||
hspA$nucleotideds | ||
|
||
#let's ceate three list and combine them into data frame | ||
|
||
gene=c("hspa1","hspa2","hspa3","hspa4","hspa5","hspa6") | ||
amino.acids=c(125,365,254,654,158,369) | ||
nucleotides=c(2400,2600,2500,2500,3600,2900) | ||
|
||
hsp=data.frame(gene,amino.acids,nucleotides) | ||
print(hsp) | ||
#just pull out the gene from dataframe | ||
hsp$gene | ||
#let's pull out the nucleotides from data frame | ||
hsp$nucleotides | ||
#let's search for specific amino acids | ||
hsp$amino.acids[hsp$gene=="hspa6"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
#logical datatype | ||
log1<-as.logical(0) | ||
log1 | ||
|
||
log2<-as.logical(26L) | ||
log2 | ||
|
||
log3<-as.logical("2654156bjgu") | ||
log3 | ||
|
||
|
||
log4<-as.logical(23261.31653416) | ||
log4 | ||
|
||
# logic datatypes me fralse ke liye zero baki usake alawa koi bhi value aaye true | ||
#non zero value==true | ||
#zero value ==false | ||
|
||
|
||
|
||
#numeric | ||
|
||
num1<-as.numeric(TRUE) | ||
num1 | ||
|
||
num2<-as.numeric(FALSE) | ||
num2 | ||
|
||
num3<-as.numeric("1542615") | ||
num3 | ||
|
||
num4<-as.numeric(26L) | ||
num4 | ||
|
||
num5<-as.numeric(25+6i) | ||
num5 | ||
|
||
num6<-as.numeric(36523.323654) | ||
num6 | ||
|
||
|
||
#COMPLEX | ||
|
||
comp1<-as.complex(25L) | ||
comp1 | ||
|
||
comp2<-as.complex(2653.365254) | ||
comp2 | ||
|
||
comp3<-as.complex("26444") | ||
comp3 | ||
|
||
comp4<-as.complex(455465464L) | ||
comp4 | ||
|
||
comp5<-as.complex(TRUE) | ||
comp5 | ||
|
||
|
||
#INTEGER | ||
|
||
int1<-as.integer(TRUE) | ||
int1 | ||
|
||
int2<-as.integer(2635.3265) | ||
int2 | ||
|
||
int3<-as.integer("1542") | ||
int3 | ||
|
||
int4<-as.integer(2422242) | ||
int4 | ||
|
||
int5<-as.integer(26+5i) | ||
int5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#datatypes in r | ||
|
||
#logical,integer,raw,complex,character,numeric | ||
|
||
#numeric--->15,26.265,11.154,1542 | ||
|
||
#complex=45+2i | ||
|
||
#integer=125L | ||
|
||
#caharacter="faad dunga","2.365","hello","vibhanshu singh gaharwar" | ||
|
||
#logical=TRUE,FALSE | ||
|
||
|
||
num<-15 | ||
class(num) | ||
typeof(num) | ||
|
||
|
||
intl<-15 | ||
class(intl) | ||
|
||
intl<-as.integer(intl) | ||
class(intl) | ||
|
||
int2<-15L | ||
class(int2) | ||
typeof(int2) | ||
|
||
int3<-16L | ||
class(int3) | ||
|
||
comp<-15-12i | ||
class(comp) | ||
|
||
logi<-TRUE | ||
class(logi) | ||
|
||
char<-"vibhu singh gaharwar" | ||
class(char) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
days=c("monday","tuesday","wednesday","thursday","friday","saturday","sunday") | ||
days[5] | ||
days[1:6] | ||
days[1:7] | ||
weakdays=days[(4:6)] | ||
print(weakdays) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#for loop | ||
|
||
for (val in 1:10) { | ||
print(paste("number:,",val)) | ||
# paste for concatanation of string | ||
|
||
} | ||
|
||
|
||
f<-c("mango","banana","apple","pomgranate","orange","watermalon") | ||
for (i in f) { | ||
print(i) | ||
print(f) | ||
|
||
} | ||
|
||
|
||
|
||
|
||
#repeat | ||
# repeat -------------------> loop without any condition | ||
|
||
a<-c("atul","singh","gaharwar","vibhu","singh","dadu") | ||
x<-2 | ||
repeat{ | ||
x<-x+1 | ||
if(x>5){ | ||
break | ||
} | ||
print(a) | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
#function | ||
examplefunction=function(x,y) | ||
{c(x+10,y+36)} | ||
examplefunction(36,45) | ||
|
||
|
||
|
||
|
||
|
||
new_function<-function(x,y,z){ | ||
res<-x+y+z | ||
print(res) | ||
|
||
} | ||
new_function(x=45,y=36,z=14) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
square_function=function(){ | ||
for (i in 1:5){ | ||
print(i^2) | ||
} | ||
|
||
} | ||
square_function() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
x<-45 | ||
if(x==45){ | ||
print("x is equal to 45") | ||
}else{ | ||
print("x is not equal to 45") | ||
} | ||
|
||
|
||
a<-26 | ||
b<-15 | ||
if(a<b){ | ||
print("a is less than b") | ||
}else{ | ||
print("a is not less than b") | ||
} | ||
|
||
|
||
|
||
marks<-36 | ||
if(marks>75){ | ||
print("pass with first class") | ||
}else if(marks>65){ | ||
print("pass with second class ") | ||
}else if(marks>45){ | ||
print("pass with third class") | ||
}else{ | ||
print("fail") | ||
} | ||
|
||
|
||
|
||
|
||
y<-c("vibhu","singh","gaharwar"," is", "dsciplined","boy") | ||
if("vibhu" %in% y){ | ||
print("vibhu is found in vector ") | ||
}else{ | ||
print("vibhu is not found in vector ") | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name<-readline(prompt = "enter your name:") | ||
age<-readline(prompt = "enter your age:") | ||
|
||
print(paste("hello my name is ",name,"and my age is",age)) | ||
paste("vibhu","ram","2320") | ||
paste0("vibhu","ram","2365") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#welcome to r programming language | ||
sum1<-45+36 | ||
sum1 | ||
sessionInfo() | ||
x<-1:10 | ||
plot(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# vector me ek hi tarah ke datatypes ko bas rakh sakte h | ||
|
||
#list----using list() function | ||
|
||
vec<-c(8,9,4,7,6) | ||
char_vect<-c("ram","shayam","mohan","sohan","rohan") | ||
logic_vec<-c(TRUE,FALSE,TRUE,FALSE,TRUE) | ||
list1<-list(vec,char_vect,logic_vec) | ||
list1 | ||
|
||
list2<-list("ram","sohan",c(1,2,3,4,5),TRUE,FALSE,25L,26.35) | ||
list2 | ||
|
||
|
||
# naming of list | ||
list3<-list(c("ram","syam","mohan"),c(15,36,96),c("btech","ba","b.sc")) | ||
list3 | ||
names(list3)<-c("students","marks","courses") | ||
list3 | ||
# accesing the list | ||
print(list3[3]) | ||
print(list3["marks"]) | ||
print(list3$marks) | ||
|
||
#unlist----->convert list into vector | ||
|
||
list3<-list(5:9) | ||
list3 | ||
list4<-list(14:19) | ||
list4 | ||
|
||
|
||
|
||
|
||
v1<-unlist(list3) | ||
v2<-unlist(list4) | ||
res<-v1+v2 | ||
res | ||
|
||
class(v1) | ||
typeof(v1) | ||
list3<-list(5:9) | ||
list4<-list(14:18) | ||
mer<-list(list3,list4) | ||
mer | ||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.