After the huuuggeee amount of homeworks that I had to do lately, I found myself repeatedly googling for these snippets a lot. So I will start a series of posts on snippets that are important for me. Yes, for me, because the main reason I do this is to make my own one-stop-snippets-center when I’m doing my long queue of homeworks that I reaalllyy hope will end soon.
# Clear workspace environment
rm(list=ls())
# Create scatterplot and save to file
pdf('lgPower-Yr.pdf')
plot(lgPower ~ Yr)
dev.off()
# Several plots in one graph
par(mfrow=c(2,2))
# Concatenate string
paste('h=',i)
# Select vector index by value
y <- which(x>0.05)
# Get unique elements in a vector
unique(x)
# Get/set current working directory
getwd()
setwd(dir)
# Make a function
function.name <- function(x,y){}
Good resources for your R coding needs:
These snippets and resource list will be updated from time to time as long as I still need to use R ;p
Advertisement
Pingback: Important LaTex snippets | audi primadhanty