Last active
August 29, 2015 14:07
-
-
Save iracooke/ba2acafb5c21a784f12f to your computer and use it in GitHub Desktop.
R Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toxin_counts = c(2273,2306,2235,19,183,61,210) | |
taxa = c("Gastropods","Snakes","Arachnids","Mammals","Jellyfish","Amphibians","other") | |
df = data.frame(toxin_counts,taxa) | |
pie(df$toxin_counts,labels=df$taxa) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create example data | |
abc = c("a","c","b") | |
one23 = c(1,3,2) | |
df = data.frame(abc,one23,stringsAsFactors=FALSE) | |
# Generate a sort index based on the abc column | |
df.sortidx = sort(df$abc,index.return=TRUE)$ix | |
# Recorder the original data frame based on the sort index | |
sorteddf = df[df.sortidx,] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create example data | |
abc = c("a","c","b") | |
one23 = c(1,3,2) | |
df = data.frame(abc,one23,stringsAsFactors=FALSE) | |
# Select data for which the numeric column (one23) is greater than 1 | |
df[which(df$one23>1),] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment