R Flashcards
(110 cards)
argument
(r) information that a function needs in order to run
variable
representation of a value in R that can be stored for use later during programming (can also be called OBJECT)
vector
a group of data elements of the same type stored in a sequence in R
Pipe
a tool in R for expressing a sequence of multiple operations, represented with “%>%”; takes the output of one statement and makes it the input of the next statement
The 4 types of Vectors
logical (TRUE, FALSE), character (words), integer (1L, 2L, 3L), double (2.5, 4.561)
create a data frame
data.frame(x=c(1,2,3), y=c(1.4, 5.4, 10.4)
create a new folder
dire.create (“destination_folder”)
create a file
file.create(“new_word_file.docx”)
copy a file
file.copy (“new_text_file.txt”, “destination_folder”)
OR operator
I or II
NOT operator
!
common function to preview data (1st 6 rows)
head()
these functions return summary - high level view of each column in your data arranged horizontally
str()- horizontal summary, and glimpse()
function for returning a list of column names from dataset
colnames()
renaming a column
rename(diamonds, carat_new = carat, cut_new = cut)
summarizing your data
summarize(diamonds, mean_carat = mean(carat))
separates plots by a charactaristic
+ facet_wrap(~cut)
code for using diamonds dataset, plotting x axis carat, , y axis price, and dots are colored differently for different cuts, scatter plot, different plots for different cuts
ggplot(data = diamonds, aes(x = carat, y = price, color = cut)) +
geom_point() +
facet_wrap (~cut)
packages (R)
units of reproducible R code
vignette
documentation that acts asa guide to an R package
browseVignettes()
filter by vitamin c dose 0.5
filtered_tg
sort by tooth length (after a filter)
arrange(filtered_tg, len)
Pipe operator shortcut
ctrl + shift + m
switch between a date-time to a date
as_date() (in the lubridate package)