Skip to content

Course Notes

Use this workspace to take notes, store code snippets, or build your own interactive cheatsheet! The datasets used in this course are available in the datasets folder.

# Import any packages you want to use here

# Load the ggplot2 package
#library(ggplot2)

# Explore the mtcars data frame with str()
#str(mtcars)

# Change the command below so that cyl is treated as factor
#ggplot(mtcars, aes(factor(cyl), mpg)) + geom_point()

#el orden para hacer las gráficas es el siguiente: data, astethics, geometries, themes, statistics, coordinates, facets, etc.

#x, y, color, fill, size, alpha, label and shape en el aes

#para asignarle nombre a los ejes  
	#labs(x = "nombre 1",  y = "nombre 2")

 # Set the fill color scale <- para asignarle color a las escalas
  #scale_fill_manual("legend title", values = vectores)

#Modifying aesthetics
	#position
		#Adjustment for overlapping
			#identity
			#dodge
			#stack
			#fill
			#jitter
			#jitterdodge
			#nudge

#ylim() to set the limits on the y-axis
#alpha es para la trasnparencia de colores

#To change stylistic elements of a plot, call theme() and set plot properties to a new value. For example, the following changes the legend position.
	#p + theme(legend.position = new_value)
	#Here, the new value can be
		#"top", "bottom", "left", or "right'": place it at that side of the plot.
		#"none": don't draw it.
		#c(x, y): c(0, 0) means the bottom-left and c(1, 1) means the top-right.

#Many plot elements have multiple properties that can be set. For example, line elements in the plot such as axes and gridlines have a color, a thickness (size), and a line type (solid line, dashed, or dotted). To set the style of a line, you use element_line(). For example, to make the axis lines into red, dashed lines, you would use the following.
		#p + theme(axis.line = element_line(color = "red", linetype = "dashed"))
		#Similarly, element_rect() changes rectangles and element_text() changes text. You can remove a plot element using element_blank()

#To set a single whitespace value, use unit(x, unit), where x is the amount and unit is the unit of measure.

#Borders require you to set 4 positions, so use margin(top, right, bottom, left, unit). To remember the margin order, think TRouBLe.

#The default unit is "pt" (points), which scales well with text. Other options include "cm", "in" (inches) and "lines" (of text).

#theme_gray() is the default.
#theme_bw() is useful when you use transparency.
#theme_classic() is more traditional.
#theme_void() removes everything but the data.




Take Notes

Add notes here about the concepts you've learned and code cells with code you want to keep.

Add your notes here

# Add your code snippets here