Mahammad Rafi Karuru
123 * 453
## [1] 55719
5^2 * 40
## [1] 1000
TRUE & FALSE
## [1] FALSE
TRUE | FALSE
## [1] TRUE
75 %% 10
## [1] 5
75 / 10
## [1] 7.5
first_vector <- c(17, 12, -33, 5)
first_vector
## [1] 17 12 -33 5
counting_by_fives <- c(5, 10, 15, 20, 25, 30, 35)
counting_by_fives
## [1] 5 10 15 20 25 30 35
second_vector<- c(20:1)
second_vector
## [1] 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
counting_vector<- c(5:15)
counting_vector
## [1] 5 6 7 8 9 10 11 12 13 14 15
grades <- c(96, 100, 85, 92, 81, 72)
grades
## [1] 96 100 85 92 81 72
bonus_points_added <- grades+3
bonus_points_added
## [1] 99 103 88 95 84 75
one_to_one_hundred <- c(1:100)
one_to_one_hundred
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
## [37] 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
## [55] 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
## [73] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
## [91] 91 92 93 94 95 96 97 98 99 100
### Add 20 to each number of second_vector
second_vector + 20
## [1] 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
### Multiply by 20 to each number of second_vector
second_vector * 20
## [1] 400 380 360 340 320 300 280 260 240 220 200 180 160 140 120 100 80 60 40
## [20] 20
### To cehck the second_vector value is >=20 or not and disply boolean value like TRUE or FALSE
second_vector >= 20
## [1] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
### To cehck the second_vector value is !=20 or not and disply boolean value like TRUE or FALSE
second_vector != 20
## [1] FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [13] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
total <- sum(one_to_one_hundred)
total
## [1] 5050
average_value <- mean(one_to_one_hundred)
average_value
## [1] 50.5
median_value <- median(one_to_one_hundred)
median_value
## [1] 50.5
max_value <- max(one_to_one_hundred)
max_value
## [1] 100
min_value <- min(one_to_one_hundred)
min_value
## [1] 1
first_value <- second_vector[1]
first_value
## [1] 20
first_three_values <- second_vector[1:3]
first_three_values
## [1] 20 19 18
vector_from_brackets <- second_vector[c(1,5,10,11)]
vector_from_brackets
## [1] 20 16 11 10
boolean_vector<- c(FALSE, TRUE, FALSE, TRUE)
# Taken boolean values in a function and assigned to boolean_vector
vector_from_boolean_brackets <- first_vector[boolean_vector]
# extracting the data from first_vector and checking the boolean vector and printing the data
vector_from_boolean_brackets
## [1] 12 5
second_vector >= 10
## [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE
## [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
### Using Logical Operator (>=) it will check the each digit in second_vector and give the boolean value like if it's greater than or equal to 10 then it will give TRUE otherwise FALSE
one_to_one_hundred[one_to_one_hundred >= 20]
## [1] 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
## [20] 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
## [39] 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
## [58] 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
## [77] 96 97 98 99 100
### In one_to_one_hundred vector it will check each number with the logic given (>=20) and print all the nummbers which are greater than or equal to 20
temp_vector<- grades[grades>85]
lowest_grades_removed <- temp_vector
lowest_grades_removed
## [1] 96 100 92
third_and_fourth_elements_removed <- c(-3,-4)
middle_grades_removed <- grades [third_and_fourth_elements_removed]
middle_grades_removed
## [1] 96 100 81 72
five_and_ten_index_remove <- c(5,10)
fifth_vector<- second_vector[- five_and_ten_index_remove]
fifth_vector
## [1] 20 19 18 17 15 14 13 12 10 9 8 7 6 5 4 3 2 1
set.seed(5)
random_vector <- runif(n=10, min = 0, max = 1000)
sum_vector<- sum(random_vector)
sum_vector
## [1] 5295.264
cumsum_vector<- cumsum(random_vector)
cumsum_vector
## [1] 200.2145 885.4330 1802.3088 2086.7083 2191.3584 2892.4159 3420.3759
## [8] 4228.3111 5184.8112 5295.2642
mean_vector <- mean(random_vector)
mean_vector
## [1] 529.5264
sd_vector <- sd(random_vector)
sd_vector
## [1] 331.3606
round_vector <- round(random_vector)
round_vector
## [1] 200 685 917 284 105 701 528 808 957 110
sort_vector <- sort(random_vector)
sort_vector
## [1] 104.6501 110.4530 200.2145 284.3995 527.9600 685.2186 701.0575 807.9352
## [9] 916.8758 956.5001
#Download the data file
first_dataframe <- read.csv("ds_salaries.csv")
first_dataframe
summary(first_dataframe)
## X work_year experience_level employment_type
## Min. : 0.0 Min. :2020 Length:607 Length:607
## 1st Qu.:151.5 1st Qu.:2021 Class :character Class :character
## Median :303.0 Median :2022 Mode :character Mode :character
## Mean :303.0 Mean :2021
## 3rd Qu.:454.5 3rd Qu.:2022
## Max. :606.0 Max. :2022
## job_title salary salary_currency salary_in_usd
## Length:607 Min. : 4000 Length:607 Min. : 2859
## Class :character 1st Qu.: 70000 Class :character 1st Qu.: 62726
## Mode :character Median : 115000 Mode :character Median :101570
## Mean : 324000 Mean :112298
## 3rd Qu.: 165000 3rd Qu.:150000
## Max. :30400000 Max. :600000
## employee_residence remote_ratio company_location company_size
## Length:607 Min. : 0.00 Length:607 Length:607
## Class :character 1st Qu.: 50.00 Class :character Class :character
## Mode :character Median :100.00 Mode :character Mode :character
## Mean : 70.92
## 3rd Qu.:100.00
## Max. :100.00