Posts

FInal

Image
final rmd 2023-04-24 library (datasets) library (tidyverse) ## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ── ## ✔ dplyr      1.1.1      ✔ readr      2.1.4 ## ✔ forcats    1.0.0      ✔ stringr    1.5.0 ## ✔ ggplot2    3.4.2      ✔ tibble     3.2.1 ## ✔ lubridate 1.9.2      ✔ tidyr      1.3.0 ## ✔ purrr      1.0.1      ## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ── ## ✖ dplyr::filter() masks stats::filter() ## ✖ dplyr::lag()     masks stats::lag() ## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors library (plotly) ## ## Attaching package: 'plotly' ## ## The following object is masked from 'package:ggplot...

wk13

Image
  wk13.R assas 2023-04-09 library (animation) # Create a function to plot a bouncing ball bounce_ball <- function () {   for (i in 1 : 50 ) {     plot.new ()     plot.window ( xlim = c ( 0 , 100 ), ylim = c ( 0 , 100 ))     x <- 50     y <- abs ( 100 * sin (i * pi / 10 ))     symbols (x, y, circles = 5 , inches = FALSE , add = TRUE )     Sys.sleep ( 0.1 )   } } # Create the animation ani.record ( reset = TRUE )   bounce_ball ()              ani.replay ()               saveGIF ({   bounce_ball () }, interval = 0.1 , movie.name = "bouncing_ball.gif" ) ## Output at: bouncing_ball.gif ## [1] TRUE This R code generates a basic animation that shows a blue dot moving horizontally from left to right. Th...

wk12

Image
  wk12.R assas 2023-03-28 # Load required libraries library (GGally) ## Warning: package 'GGally' was built under R version 4.2.3 ## Loading required package: ggplot2 ## Warning: package 'ggplot2' was built under R version 4.2.3 ## Registered S3 method overwritten by 'GGally': ##    method from    ##    +.gg    ggplot2 library (network) library (sna) library (ggplot2) # Create a random graph with 10 nodes net <- rgraph ( 10 , mode = "graph" , tprob = 0.5 ) # Convert the graph to a network object net <- network (net, directed = FALSE ) # Create custom labels for the vertices vertex_labels <- c ( "A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" , "I" , "J" ) # Customize the network visualization ggnet2_customized <- ggnet2 (net,                             node...

wk11

Image
  assas 2023-03-23 library (ggplot2) library (ggExtra) ## Warning: package 'ggExtra' was built under R version 4.2.3 library (ggthemes) ## Warning: package 'ggthemes' was built under R version 4.2.3 p <- ggplot (faithful, aes (waiting, eruptions)) + geom_point () + theme_tufte ( ticks= F) ggMarginal (p, type = "histogram" , fill= "transparent" ) #the code makes a scatterplot of the waiting and eruptions variables in the faithful dataset using ggplot2. The geom_point() function is used to add the points to the plot, and theme_tufte(ticks=F) removes the tick marks from the plot, giving it a sleek look. # After that, the ggMarginal function is called, using the p object as input along with some additional parameters. This adds a histogram to the scatterplot, showing the distribution of the waiting variable on the x-axis and the eruptions variable on the y-axis. The fill = "transparent" argument makes the histogram ...

wk10

Image
  hotdogs <- read.csv ( "http://datasets.flowingdata.com/hot-dog-contest-winners.csv" ) head (hotdogs) ##    Year                        Winner Dogs.eaten        Country New.record ## 1 1980 Paul Siederman & Joe Baldini        9.10 United States           0 ## 2 1981               Thomas DeBerry        11.00 United States           0 ## 3 1982                Steven Abrams        11.00 United States           0 ## 4 1983        ...