Tag: R Language

  • Getting a New R Package–#SQLNewBlogger

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    I was trying to test an R script the other day and got this:

    > library(randomForest)
    Error in library(randomForest) : 
      there is no package called ‘randomForest’

    A common error if you have just a base R installation. In my case, I’d installed R Studio, but nothing else. I knew that many packages are installed at CRAN, but I’d never gotten one. So I did.

    The first step was a quick google for syntax. In this case, r-bloggers.com had a nice short piece. The install.packages() function is used.

    I decided to just try it. In may case, I was happy to use the defaults for now. I ran:

    > install.packages("randomForest")
    Installing package into ‘E:/Documents/R/win-library/3.3’
    (as ‘lib’ is unspecified)
    trying URL 'https://mran.revolutionanalytics.com/snapshot/2016-11-01/bin/windows/contrib/3.3/randomForest_4.6-12.zip'
    Content type 'application/zip' length 177208 bytes (173 KB)
    downloaded 173 KB
    
    package ‘randomForest’ successfully unpacked and MD5 sums checked
    
    The downloaded binary packages are in
    	C:\Users\Steve\AppData\Local\Temp\RtmpUl3h6d\downloaded_packages

    After that, my library() function ran fine.

  • Do I Need to Learn Linux and R and Python?

    The big changes coming in SQL Server 2017 are the Linux version and the addition of Python as a language used to analyze data. In SQL Server 2016, we had the R language added, and quite a few people have been on crash courses learning R, or worrying about the fact they don’t understand how to write an R script. Now many of these same DBAs and data professionals worry that they also need to find time to pick up some Python and Linux.

    I really like Python. I spent some time with the language and still dabble here and there. It’s a clean, easy to write and read language. My son took an intro CS course this spring in college and we shared some programming thoughts and ideas in Python. If you’re interested, I’d recommend the Dive Into Python book, as well as the meeting series from SDTIG. If you want to learn R, I’ve been dabbling at TryR from CodeSchool. There are also resources from Grant Fritchey and Buck Woody. For Linux, there are tons of resources out on the Internet. I don’t have a recommendation, but feel free to leave one in the discussion.

    If you are a data professional that works with data scientists or others that might want to incorporate some machine learning or complex analysis inside SQL Server, do you need to learn R and Python? Is that the feeling that you have? Are these languages require to ensure that you can perform your job?

    I’d argue that for many of us, we don’t need to understand the language or be able to write R or Python scripts that are being run in SQL Server, or even in a tool like Power BI, to support our users. We should understand how to execute these scripts, and maybe how to correct simple typos. A working knowledge of HTML has come in handy many times for me when helping users display their data and a quick change was needed. However, I wasn’t the person you’d call to design a complex CSS and interactive HTML pages. I can just fix a few simple mistakes.

    You might feel differently, but I don’t think most SQL Server professionals, developer or DBA, really need to learn R or Python. Feel free to do so if you like, and I’d put in a recommendation for Python, which I really like, but I don’t expect that either one will be a significant part of your job in the future. Learn Linux if you want to experiment with another OS, but for the most part, SQL Server on Linux is just SQL Server. Learn some rudimentary Linux skills, but spend most of your time making sure you understand the SQL platform and you’ll be fine.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 3.7MB) podcast or subscribe to the feed at iTunes and Libsyn.

  • Where Do You Run Your R Scripts?

    I know most of you don’t work with the R language. In fact, plenty of you might not know anything about R other than a cursory understand of this as some sort of data analysis language. If you want to know more, here’s what the R Project is.

    Microsoft wants you to use R Services in SQL Server, or the R Server product available as a standalone system. However, I saw someone ask the question why would someone run their R scripts inside SQL Server, because these are expensive CPU cycles to burn on analysis. Someone else noted that Microsoft loves your licensing dollars, so their push to use R Services is perhaps a little self serving.

    Push the intellignce to the data makes sense. Isn’t that what we do with large data warehousing queries or SSAS cubes? We’re trying to get the analysis done at scale without having to move the data elsewhere, especially considering we’ve (usually) already moved the data in some sort of ETL (or ELT) process. Gaining insights from our ever increasing scales of data requires some computational cycles somewhere.

    What’s the alternative? Large queries that pull data to some client? I think that’s fine, and that might be a better alternative since simple queries to pull data don’t burn as many CPU cycles as those that might perform analysis. I certainly understand that the licensed CPU cycles for a SQL Server instance are expensive, and we want to be careful how they are used. Adding complex R scripts might not be the best use of our licensing dollars. On the other hand, if I can perform analysis quicker, that is more useful, than perhaps I can eliminate other random queries analysts want to run on my database?

    Ultimately I think that R Services make some sense in SQL Server, but not as some experiment. I would suggest that the R client is the way to experiment, preferably on a copy of data that allows someone to build scripts and determine if there is insight to be gained from a particular set of data. Build a Proof of Concept (POC), and only deploy it to a SQL Server if you find it provides value.

    And if you do so, continue to experiment. That R script you run today might not be as useful in six months as your application, database, and business evolve. Data analysis isn’t a set-it-and-forget-it, but rather an ongoing, iterative process.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 3.8MB) podcast or subscribe to the feed at iTunes and Libsyn.

  • Why Use R Services?

    I ran across a blog post from the very talented Joe Sack recenty, who I hope makes a few more minutes for me the next time we’re in the same town together ;).

    The post is a look at some of the customers that are using R Services in SQL Server 2016. As you might expect, there are highlights from customers that show dramatic improvement in performance. Going from 200 valuations/hour to 12,000/minute and taking a process from 2 days to 1 hour. I’m sure not all operations improved that much, but I bet most had some improvement. R Services is a big improvement in the way data is analyzed with the R language.

    What I really like, however, is that the piece includes some of the gotchas customers experienced, with links on how one might go about fixing the issues. There are also hints on visualizations and performance tuning options. I like looks at technology that include some details on those items that work well or don’t work well. This is a good overview that I hope gets more customers interested in using R services.

    But, I hope that we see deeper pieces that can give technical guidance on specific scenarios. Which models scale well and which don’t? Which options in some analysis improved (or hurt) performance? There are plenty of items which are best answered with specific examples, rather than general advice. With all the customers and data Microsoft gathers, especially for companies that might use R Services in azure, I’d expect that we could get some useful, detailed examples on how this (and other) technologies actually work in the real world. I’d like to see this guidance, not just with R Services, but with other technologies as well. Certainly providing some sample data sets and code that performs well really (or tuning options), is what most of us want to see.

    Of course, I’d like to see more of these stories and details at SQLServerCentral as well, so if you are solving problems and want to publish something, drop us a note. We’d love articles from the real world, whether on SQL Server 2016, or any prior version. The more reference problems and solutions we have, the more people learn to code better.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 3.1MB) podcast or subscribe to the feed at iTunes and LibSyn.