This file contains hidden or 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
| library(rio) | |
| library(dplyr) | |
| read_file = function(file_path) { | |
| file_connection <- file(file_path, "r") | |
| read_data <- c() | |
| while ( TRUE ) { |
This file contains hidden or 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
| library(dplyr) | |
| data <- data.frame(cod = c(rep("A",9),rep("B",10)),id =c(c(1,3,4,5,6,7,8,9,10),seq(1,10))) | |
| data_complete <- filter(data,cod == "A") | |
| min_step <- min (data_complete$id) | |
| max_step <- max(data_complete$id) | |
| expected_sum <- (1/2)*max(data$id)*(min_step+max_step) | |
| actual_sum <- sum(data$id) | |
| check <- expected_sum - actual_sum |
This file contains hidden or 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
| library(rio) | |
| library(dplyr) | |
| library(ggplot2) | |
| # data from: https://www.kaggle.com/c/bike-sharing-demand/data | |
| rides_stat <- import ("train.csv") | |
| rides_stat %>% | |
| group_by(season) %>% | |
| summarise(total_rides = sum(count),mean_temp = mean(temp)) %>% | |
| ggplot(aes(x=season,y=total_rides, fill = mean_temp)) + | |
| geom_bar(stat='identity')+ |
This file contains hidden or 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
| require(ggplot2) | |
| #bernoulli | |
| bernoulli_trial <- function(p_succ,n_trials){ # probability of success (1) and number of trials | |
| p_insucc <- 1-p_succ # rpobability of failure | |
| trials <<- c() | |
| p_cumulative <<- c() | |
| for(i in 1:n_trials){ | |
| trials <<- rbind(trials,i) | |
| p_cumulative <<- rbind(p_cumulative,(((p_insucc)^(i -1))*p_succ)) # (p of success within n trials) = ((1-p)^n-1)*(p) | |
| } |
This file contains hidden or 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
| updateR(admin_password = "os_admin_user_password") |
This file contains hidden or 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
| library(dplyr) | |
| library(ggplot2) | |
| create_file <- function(name){ | |
| path <- paste(getwd(),"/",name,".png",sep = '') %>% | |
| file.path() %>% png(,width=960,height=480) | |
| } | |
| #this is the template: change the theme (and the name argument) to produce the other plots |