Skip to content

Instantly share code, notes, and snippets.

@aurora-mareviv
Created September 30, 2014 22:35
Show Gist options
  • Save aurora-mareviv/f12bc0ff63ec1b9ff6b2 to your computer and use it in GitHub Desktop.
Save aurora-mareviv/f12bc0ff63ec1b9ff6b2 to your computer and use it in GitHub Desktop.
Script to start playing with R on Android
###########################################
### COMMANDS TO START WITH R ON ANDROID ###
###########################################
# Under GNU-GPL license
# R in Android installed via the apps "GNURoot" and "GNURoot Wheezy", and sources.list updated with the newest CRAN repositories.
# I strongly recommend to set the working directory of R to a folder that can be accessed from Android such as /sdcard
setwd("/sdcard/R")
# Just copy and paste the following commands, and press ENTER to see the results.
# You can recycle these commands to make new ones suitable for your own data!
# Note: the lines of text preceeded by "#" are considered comments, and they are not executed even if they are pasted.
# Let's begin with real data:
setwd("/sdcard/R")
var0 <- c(64,76,66,47,72,82,66,58,64,69,80,57,66,63,71,55,57,71,45,77,69,61,47,55,59,45,61,56,68,74,55,71,72,64,52,62,69,53,76,62,65,54,73,79,74,38,61,73,75,71,74,52,48,45,65,59,79,78,82,61,70,73,68,76,71,65,78,65,80,69,73,70,80,50,67,70,63,68,70,37,73,68,53,73,79,76,68,80,79,78,75,82,72,77,75,66,72,66,66,58,70,71,69,81,74,45,73,81,71,76,79,80,72,64,81,79,74,69,75,56,62,60,83,55,74,47,70,59,47,81,73,59,74,70,69,81,29,77,72,78,68,60,65,83,66,76,68,80,82,79,74,74,22,62,81,75,75,44,72,75,72,77,76,67,70,76,42,56,76,84,75,76,83,73,63,50,78,70,79,74,59,54,74,68,72,82,69,48,64,48,78,62,87,79,65,70,85,80,79,72,71,77,76,79,76,81,82,70,65,79,76,83,75,63,52,80,86,63,68,69,78,82,74,86,69,85,72,64,57,74,78,22,77,64,63,51,74,71,71,47,63,66,73,43,72,75,81,40,56,71,77,77,71,69,68,58,64,76,73,81,73,81,59,68,57,62,66,76,66,47,72,82,66,58,64,69,80,57,66,63,71,55,57,71,45,77,69,61,47,55,59,45,61,56,68,74,52,71,72,64,52,62,69,53,76,62,65,54,73,79,74,38,61,73,75,71,75,82,72,77,75,66,72,66,66,58,81,74,45,73,81,71,76,79,80,72,64,81,
79,74,69,75,56,62,60,83,55,74,47,70,59,47,81,73,59,74,70,69,81,29,77,72,78,68,60,65,83,66,76,68,80,82,79,74,74,22,62,81,75,75,44,72,75,72,77,76,67,70,76,42,56,76,84,75,76,83,73,63)
var1 <- c("1","2","1","2","1","1","1","1","1","1","1","1","1","1","1","2","2","1","1","1","2","1","2","1","1","1","1","1","1","1","2","2","1","2","1","1","1","1","1","1","2","1","1","1","1","1","1","2","2","1","2","1","2","2","1","1","1","2","1","2","2","2","2","2","1","1","1","1","1","1","1","1","2","1","1","1","2","1","1","1","1","2","1","1","1","1","1","2","1","2","1","1","1","1","1","1","1","2","1","1","1","2","1","1","2","1","1","2","2","2","1","2","1","2","1","1","1","1","2","2","2","2","2","1","1","1","1","2","2","1","1","1","1","1","1","2","1","1","2","1","2","1","1","1","1","1","2","1","1","1","1","1","2","1","1","2","1","2","1","1","1","1","1","2","1","2","2","1","2","2","1","1","1","1","1","2","2","1","1","1","2","1","2","1","1","1","1","1","1","1","1","1","1","2","1","1","1","2","2","1","2","1","1","1","1","2","1","1","1","1","1","1","2","2","1","1","1","1","2","1","1","1","1","2","1","2","1","1","2","1","1","1","1","1","2","2","1","1","1","1","1","1","1","1","1","2","1","2","1","1","1","2","1",
"2","2","1","1","1","1","1","1","1","1","1","1","2","1","2","1","1","1","1","2","1","1","1","2","1","2","2","1","1","1","1","2","1","1","1","1","1","1","1","1","1","1","1","2","1","1","1","2","1","1","1","2","2","1","1","2","2","1","1","1","2","1","1","1","1","1","2","1","1","1","1","1","2","1","2","2","1","1","1","1","1","2","1","2","1","1","1","1","1","1","2","1","2","1","1","1","1","1","1","2","2","1","1","2","1","2","2","1","2","2","1","2","2","2","1","2","1","2","2","1","1","1","1","1","1","1","1","1","2","2","1","1","2","2","2","1","2","2","2","2","1","2","1","1","2")
var2 <- c("0","1","0","0","0","0","0","0","0","0","1","0","0","0","0","0","0","0","1","0","1","0","0","0","1","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","1","1","0","0","1","1","0","0","0","0","1","0","1","1","0","0","0","0","0","0","0","0","0","1","0","0","1","0","0","1","1","0","0","0","0","1","1","1","1","0","0","1","0","0","0","0","1","0","1","0","0","0","0","0","0","0","1","0","1","0","0","1","1","1","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","1","1","1","1","0","0","1","1","0","0","0","0","1","0","1","0","0","0","0","1","0","1","1","0","0","0","0","0","1","0","0","0","1","0","0","0","0","0","0","1","0","1","0","0","0","0","0","1","0","0","0","0","1","0","0","1","0","0","0","0","0","0","0","1","1","1","0","0","1","0","1","0","1","0","0","1","0","0","0","1","0","0","1","1","0","0","0","0","1","0","1","1","0","1","1","1","0","0","0","0","0","1","0","1","0","0","0","0","1","0","0",
"0","0","0","0","0","1","0","0","0","1","0","1","0","0","0","1","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","1","0","0","1","0","0","0","0","0","1","1","0","1","0","0","1","0","0","0","0","0","0","0","0","1","0","0","0","1","0","0","0","0","1","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0")
mydatab <- data.frame(var0,var1,var2) # joins the vectors into a data frame
# Global summary of my data.
summary(mydatab)
# Save the data.frame:
save(mydatab, file="mydatab.RData")
# Now we will print a plot using the pdf() function!
pdf("myplotr.pdf")
hist(mydatab$var0, breaks=30)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment