Publications by Peter

Factorial of 12

19.07.2020

my_factorial <- function(){ # input here is 12 val = 12 res = 1 # checking whether the number is negative, zero or positive if(val < 0) { print(" Factorial does not exist for such numbers. ") } else if(val == 0) { print(" The factorialof 0 is 1 ") } else { for( i in 1:val) { res = res * i } pri...

5 sym R (477 sym/2 pcs)

quadratic

19.07.2020

quadratic <- function(a, b, c) { res <- b ^ 2 - 4 * a * c if (res >= 0){ solution_1 = (-b + sqrt(res))/(2 * a) solution_2 = (-b - sqrt(res))/(2 * a) return(c(solution_1, solution_2)) } } print(quadratic(1,-1,0)) ## [1] 1 0 ...

5 sym R (253 sym/2 pcs)

create Dataframe

26.07.2020

elements <- read.csv(file.path("D:","datasets.csv")) df<- data.frame(elements$Rows, elements$Cols) colnames(df) <- c("Source","Destination") print(df[1:4,1:2]) ## Source Destination ## 1 60 3 ## 2 570 6 ## 3 12 1 ## 4 24 1 ...

5 sym R (285 sym/2 pcs)

Summary of .csv data

25.07.2020

elements <- read.csv(file.path("D:","datasets.csv")) print('SUMMARY IS AS BELOW:') ## [1] "SUMMARY IS AS BELOW:" summary(elements) ## Package Item Title Rows ## Length:1303 Length:1303 Length:1303 Min. : 2.0 ## Class :character Class :character Class :chara...

5 sym R (2288 sym/16 pcs)

Rename column values

26.07.2020

elements <- read.csv(file.path("D:","datasets.csv")) df<- data.frame(elements$Rows, elements$Cols) colnames(df) <- c("Source","Destination") ndf <- df[1:4,1:2] NewColumn <- c(TRUE, TRUE, TRUE, TRUE) ndf$NewColumn <- NewColumn #print(ndf) ndf$NewColumn[ndf$NewColumn == TRUE] <- FALSE print(ndf) ## Source Destination NewColumn ## 1 ...

5 sym R (476 sym/2 pcs)

Reading from GIT

26.07.2020

library(RCurl) x <- getURL("https://raw.githubusercontent.com/petferns/csvfile/master/datasets.csv") y <- read.csv(text = x) summary(y) ## Package Item Title Rows ## Length:1303 Length:1303 Length:1303 Min. : 2.0 ## Class :character Class :character Class...

5 sym R (1755 sym/2 pcs)

Survey of concern

30.08.2020

INTRODUCTION How Americans View The Coronavirus Crisis? This survey includes the polls conducted among Americans on thier concern towards cononavirus pandemic. How concerned Americans say they are that they, someone in their family or someone else they know will become infected with the coronavirus. The survey includes number of respondents, po...

619 sym R (1236 sym/3 pcs)

Homework1-606

31.08.2020

Smoking habits of UK residents. (1.10, p. 20) A survey was conducted to study the smoking habits of UK residents. Below is a data matrix displaying a portion of the data collected in this survey. Note that “\(\pounds\)” stands for British Pounds Sterling, “cig” stands for cigarettes, and “N/A” refers to a missing component of the dat...

4510 sym R (1699 sym/13 pcs)

homework-1_606

31.08.2020

Smoking habits of UK residents. (1.10, p. 20) A survey was conducted to study the smoking habits of UK residents. Below is a data matrix displaying a portion of the data collected in this survey. Note that “\(\pounds\)” stands for British Pounds Sterling, “cig” stands for cigarettes, and “N/A” refers to a missing component of the dat...

4510 sym R (1699 sym/13 pcs)

Movie-Rating-Survey

06.09.2020

Reading the movie rating data from Survey into Mysql db and then into R Overview of the solution Mysql database has two tables Movies and Survey Movies -movie id (primary key) -movie name Survey -name of the participant -age group -gender -movie id (Reference key) -rating Survey table has entry for each rating the participant voted fo...

698 sym R (1112 sym/3 pcs) 1 img