1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
library(RODBC) # Connect to the database while mentioning database name explicitly. channel <- odbcDriverConnect("driver=SQL Server;server=ServerName;database=DatabaseName") # Change all Columns to Strings to avoid errors for (col.name in colnames(Students)) { Students[,col.name] <- as.character(Students[,col.name]) } # Drop the table sqlDrop(channel, 'idin.Students2') # Write the table into the database sqlSave(channel, Students, tablename = 'idin.Students2', append = FALSE, rownames = FALSE) close(channel) |
Author: Idin
R: Reading from SQL Server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
library(RODBC) channel <- odbcDriverConnect("driver=SQL Server;server=ServerName") # Request information on the ODBC connection odbc.info <- odbcGetInfo(channel) getSqlTypeInfo(odbc.info[1]) # Read data query <- "SELECT * FROM Database.dbo.Student AS Student LEFT JOIN Database.dbo.Teacher AS Teacher ON Teacher.id=Student.teacher_id WHERE Student.gpa<'60' ORDER BY Student.gpa DESC" Students <- sqlQuery(channel, query) close(channel) |
R: Saving a Multiple-Column Boxplot into PDF
1 2 3 4 5 6 7 8 9 10 |
n_audio = length(levels(tlx$audio)) par(mfrow = c(1, n_audio)) for (i in levels(tlx$audio)) { boxplot(tlx_overall~guidance, outline = FALSE, data = subset(tlx, audio==i), main = "All Data", xlab = i, ylab="TLX (Overall)", cex = 1, cex.lab = 1, cex.main = 1, cex.axis = 1, pch = 23, col = 3, lwd=.5) } dev.copy2pdf(device = quartz, file = "tlx_per_audio_x_guidance.pdf") dev.off (); |
Ruby: Kernel Caller
1 |
caller(start=1, length=nil) |
1 |
→ array or nil |
Returns the current execution stack—an array containing strings in the form file:line or file:line: in `method’. The optional start parameter determines the number of initial stack entries to omit from the top of the stack. A second optional length parameter can be used to limit how many entries are returned from the stack. […]
Sublime Text: How to Install Package Control on Sublime Text 3
Ruby: Useful Regular Expressions
Ruby: DataMapper Important Rules
1 |
belongs_to :post # defaults to :required => true |
belongs_to relationships will be required by default (the parent resource must exist in order for the child to be valid). You can make the parent resource optional by passing :required => false as an option to belongs_to.
Ruby: Convert an Object to Hash
LaTeX: Online Table Editor
WordPress: Display One Post Per Category
WordPress: pre_get_posts filter to display one post per category. Displays the latest sticky post and therefore excludes the category of the sticky post as we only want one post per category. By: Silvan Hagen