Welcome to the Simplilearn Community

Want to join the rest of our members? Sign up right away!

Sign Up

Data Science with R | Oct 17 - Nov 22 | Priyanka D

Hi Priyanka,

I have downloaded and stored the R studio, and after opening the studio it is showing me a pop up like this (kindly check the attachment for the same), could you help me that how should I start the software from here.

Regards,
Achal Gupta
 

Attachments

  • Capture.PNG
    Capture.PNG
    100.4 KB · Views: 9
Assessment 1
1. ":" --> this is used to decide range
ex: a <- c(6:10)
output--> 6,7,8,9,10
2. "%in%" --> this is used to search an element in vector which will return "true" if it is found in a vector.
ex: 3 %in% c(1,2,3,4)
output: True
 

Sonal_33

Member
upload_2020-10-18_13-22-0.png

1) in %in% it is checking in the vector whether those nos 2,4,6,8 are present or not. We are getting Boolean o/p at that particular index

2) : = it is creating vector or 1D array 1 indicates starting number and 10 represents last number upto what u want to create vector
 
I am attaching the assignment here.
Added my comments on the code regarding the explanation of the operator.
1) "a:b" operator would create a range of values from a to b like a series of numbers in a sequence for a vector
2) item1 %in% TestVector2 checks if the item1 is present in the range of values/vector or sequence (i.e item1 is inside TestVector2)
item1 %in% TestVector2 will return TRUE in case item1 is present withinTestVector2
item1 %in% TestVector2 will return FALSE in case item1 is not present withinTestVector2
 

Attachments

  • Assignment_18th_October_2020_Debendra.txt
    671 bytes · Views: 10
Assignment 1- Understanding Operators ":" and "%in%"


> x=1:10
> print(x)
[1] 1 2 3 4 5 6 7 8 9 10
Comment for ":" operator - The ":" operator creates a sequence of numbers.
> x=1:10
> print(x)
[1] 1 2 3 4 5 6 7 8 9 10
> y=2:6
> print(y %in%x)
[1] TRUE TRUE TRUE TRUE TRUE
Comment for "%in%" operator - The "%in%" operator checks the values of one variable inside another variable and returns a boolean result.
 

Hitesh H S

Well-Known Member
Staff member
Simplilearn Support
May i know where can i access to supplementary materials on the basic statistic please.
Thank you
Hi Joycelyn Ong Huey-Theeng,

The slides are available in the self-learning section under the course resources and all the other materials used during the session will be shared by the trainer over the Google drive link.

Happy Learning !!!!
 
upload_2020-10-18_17-4-32.png


In R programming
1) x: y provide value from x to y i.e. if we have 1:8 it will give numbers from 1 to 8
2) x%in%y checks if the value of x is there in vector y or not. i.e. if x=2 and y=c(1,2,3) then x%in%y will return true. If x=9 Then same will return false.
 

Kiran Joshy

New Member
Assignment 1- Understanding Operators ":" and "%in%"

: - Colon operator. Creates a series of numbers in sequence.
E.g.
> a = 2:10
> a
[1] 2 3 4 5 6 7 8 9 10

%in% - Used to check if an item belongs to a vector. Returns TRUE or FALSE.
E.g.
> a = 2:10
> a
[1] 2 3 4 5 6 7 8 9 10
> 3 %in% a
[1] TRUE
> 23 %in% a
[1] FALSE
>
 
Assessment 1
:
A=5
B=10
K=A:B
print(K)
Out put : int [1:6] 5,6,7,8,9,10 -- : it gives the range of number from 5 till 10

%n%
p=10%in%c(1,5,10)
print(p)
Out put: True -- it checks in the vector whether 10 is there in vector and gives output as a boolean value( i.e True or False)
 
# The colon operator is used to display the range or sequence between two given numbers
# Simple range >>
print(0:9)
print(3:-4)
# Store a range in variable Num_range >>
Num_range = 10:(20^1)
print(Num_range)
# Find the mean and median
mean(Num_range)
median(Num_range)
#
# -------------------------------------------------------------------
# %in% compares a value or range with another given value or range
# Simple example >>
4 %in% 3:8
4:-4 %in% 0
median(1:7) %in% c(0,1,1,2,3,5,8,13)
# Compare characters
"X3" %in% c("X1","X3","X5","XS")
NULL %in% c("a","b","c",NULL) # why this strange output?
# Return index
# Compare set of values with a range
c(15,20,45) %in% Num_range
 
Assignment-18th Oct 2020

1. %in%-
This operator is used to check if a value is present in a given data set.
For example:
a= c(1,2,3)
b= 2
b %in% a

Output: TRUE (Because 2 is present in variable a)

2. : -This operator is used to assign a range of integers to a variable.
For example:
c= 1:20
On running the above command, the variable c has values which are all integers starting from 1 and ending at 20, as seen in the global environment.
 

Hitesh H S

Well-Known Member
Staff member
Simplilearn Support
Hi Priyanka,

I have downloaded and stored the R studio, and after opening the studio it is showing me a pop up like this (kindly check the attachment for the same), could you help me that how should I start the software from here.

Regards,
Achal Gupta
Hi Achal,

From the screenshot that you have shared, I can see that you have opened R and not R studio. Kindly search for R studio on your system and open it. If you have not installed R studio on your system, you can download and install it from the below link:
https://rstudio.com/products/rstudio/download/


I hope this helps you.

Happy Learning !!!!
 

Rohan Bheda

New Member
Assignment

Colon Operator is used to create vectors, subscript arrays

If we want to create a row vector, containing integers from 5 to 10

Z <- 5:10
print(Z)

Output is 5 6 7 8 9 10

%in% This operator is used to identify if an element belongs to a vector.

M1 <- 4
M2 <- 8
Z <- 5:10
print(M1 %in% Z)
print(M2 %in% Z)

Output is
M1 = FALSE M1 doesn't belong to vector Z
M2 = TRUE M2 belongs to vector Z
 

_90116

Member
Assignment 1: - Karl

1: Use of ":" - The colon operator


From my understanding, this defines the sequence of the data. So if its A:B, the result is the data "from A to B" in the intervals of +/- 1. The operator handles both integers and Numeric values. When its tried with the combined values, it takes the first element from the defined values.

Ex:

Script:
g=c(45,64,78)
h=c(64,45,28)

Console: (with the message)
> g:h
[1] 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
Warning messages:
1: In g:h : numerical expression has 3 elements: only the first used
2: In g:h : numerical expression has 3 elements: only the first used

2: Use of "%in%" - The in operator

This checks if one value is available in a series.

Ex:

Script:
g=c(45,64,78)
h=c(64,45,28)

Console:
> g%in%h
[1] TRUE FALSE TRUE

Result: Checks 45 in h and gives a value of TRUE, similarly for 64 and 78.
 
Hello :) I have attached a pdf in the comment.
On the other hand, I been experimenting with these few possibilities, highlighted in the thumbnail below. May i know, whether is it possible to use the operation && and || as part of this exercise.
Thank you.

upload_2020-10-20_21-50-40.png
 

Attachments

  • Assignment_Operators_Joycelyn18102020.pdf
    75.6 KB · Views: 3

puneet_72

New Member
Assignment 1

: "Colon operator" - Creates a series of numbers in sequence.
Works as below -
> a = 3:9
> a
[1] 3 4 5 6 7 8 9

%in% - Used to check if an item belongs to a vector.
Output - Returns TRUE or FALSE.
E.g.
> a = 3:9
> a
[1] 3 4 5 6 7 8 9
> 3 %in% a
[1] TRUE
> 10 %in% a
[1] FALSE
>
 
Operator Colon :)) in "R" is used to execute or sequence or loops of figures between the Range assigned.
Example 1:6 will give output as 1 2 3 4 5 6

Operator (%n%) in R is used used to identify if an element or value belongs to a Data frame

Example
a1 <- 20
a2 <- 100
b<- c(1,2,4,5,6,9,10,100)
a1 %in% b

Output will be false as 20 which represents a1 is not there in b.

a1 <- 20
a2 <- 100
b<- c(1,2,4,5,6,9,10,100)
a2 %in% b

Output will be True as 100 which represents a2 is not there in b.

upload_2020-10-21_8-40-46.png
 
Assignment - ":" & "%in%" operators

The first ":" operator defines the sequence from one variable to another
(ex)
> y = 1:2
> print (y)

Console Output :

[1] 1 2

The second "%in%" operator checks if a variable from a vector is present in another vector and gives a boolean output.

(ex)
> I = 1:10
> print(I)
[1] 1 2 3 4 5 6 7 8 9 10
> A = 5
> B = 20
> print(A%in%I)
[1] TRUE
> print(B%in%I)
[1] FALSE
 
Assignment 1

1) %in% Operator

This operator is used to check if a particular value or element is within a group of elements such as a list or data frame.

Ex :

upload_2020-10-22_0-3-25.png


2) : Operator

This operator is used to generate a sequence of numbers from a to b (a : b).

Ex :

upload_2020-10-22_0-8-31.png
 

_54389

New Member
Hi Priyanka,
Kindly find attached assignment for second day. I am unable to upload R extension file so uploading same thing in txt file.
Thankyou
 

Attachments

  • 2nd day assignment_sandhya Gupta.txt
    653 bytes · Views: 4

Amrutha Mohan

New Member
Assignment

1) : operator - defines a sequence

For eg demo = 1:4 will give 1 2 3 4 as output.

2) %in% operator - used to find a particular value in a set of values.

eg.
v1 <-8
v2 <-12
t <-1:10
print(v1 %in% t) //output is True
print(v2 %in% t) //output is false
 
Assessment-1

Hi Priyanka,

Find my assessment below.

> A=1
> B=5> R=A:B> print(R)[1] 1 2 3 4 5

It takes a range from 1 to 5.

# %n%
S=20%in%c(21,22,23,24)
print(S)

Output is False because it checks the vector whether 20 is available and gives output as a boolean value( i.e True or False)
 
Usage of :
1. this helps in generating sequence of numbers.
2. also helped in quick sum & factorial of sequence of numbers
usage of %in%
1. this helped in checking if an assigned variable or a number is present in a sequence or group of numbers.

#usage of :
1:7
print (1:7) # resulted in numbers 1 to 7 showing step up by 1
add.scope(1:7) # tried to add but resulted in Error
v=c(1:7) # this went correct
v # printed 1 to 7
l=(2:8) # this went correct
l # printed 2 to 8
k=c(2:8) # this went correct
k # printed 2 to 8
mi=(2,8) # this is wrong
mi # this resulted in error

# tried for step 2 but didnt worked
ju = [2](2:10)
ju = 2(2:10)
ju=(2:10)
ju
mu=(2:10,2)
mu=(2:10 [2])

rnu=add.scope(1:10) # gave error
nu = sum(1:10)
nu
hi=factorial(2:4)
hi
sum(1:10)+factorial(2:4)



# usage of %in%
v=c(1:7) # this went correct
7%in%v
(1:4)%in%v
v1 <- 8
v2 <- 12
t <- 1:10
print(v1 %in% t)
print(v2 %in% t)
3%in%(1:10)
 
myList = list(l1 = c(1, 2, 5, 8),
l2 = c(1, 2, 4),
l3 = c(1, 1, 1, 5, 8, 70, 90))
# Apply unlist R function
x=unlist(myList)
x

#########################################

> x
l11 l12 l13 l14 l21 l22 l23 l31 l32 l33 l34 l35 l36 l37
1 2 5 8 1 2 4 1 1 1 5 8 70 90
 
#how to read 3 vector elements at same time

v1=c(3:23)

str(v1)

v1[1]

v1[c(1,2,3)]

v1[c(1,15,21)]

the output is as below
> v1=c(3:23)
> str(v1)
int [1:21] 3 4 5 6 7 8 9 10 11 12 ...
> v1[1]
[1] 3
> v1[c(1,2,3)]
[1] 3 4 5
> v1[c(1,15,21)]
[1] 3 17 23
 
Top