Posts

Showing posts from March, 2023

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        ...

wk9

Image
  assas 2023-03-08 datai = read.csv ( "StressAnxiety.csv" ) datai = datai[, - 1 ] # create an empty plot with the correct axis limits plot (datai $ stress, datai $ anxiety, xlab= "stress" , ylab= "anxiety" ) # add the points to the plot points (datai $ stress, datai $ anxiety, pch= 16 , col= "blue" ) # add a title title ( "Stress vs Anxiety" )   #2 library (lattice) xyplot (datai $ anxiety ~ datai $ stress, data = datai, type = c ( "h" )) #3 library (ggplot2) ggplot (datai, aes ( x = stress, y = anxiety, group = stress)) +   geom_boxplot () #while R's built-in plotting functions can be useful for basic plotting needs, lattice and ggplot2 offer much more powerful and flexible visualization capabilities that enable users to create more complex and customized plots. However, there is a learning curve for using these packages, and they may not be the best choice for very simple plots or ...