background preloader

Code School - Try R

Code School - Try R

heather.cs.ucdavis.edu/~matloff/r.html Professor Norm Matloff Dept. of Computer Science University of California at Davis Davis, CA 95616 R is a wonderful programming language for statistics and data management, used widely in industry, business, government, medicine and so on. And it's free, an open source product. Downloading R: R is available for Linux, Windows and Mac systems. You can download R from its home page. For Ubuntu Linux or other Debian-related OSs, a more direct method is: % sudo apt-get install r-base Learning R: There is a perception among some that R has a steep learning curve, but I disagree. I'll list a few tutorials below (not necessarily the best, just ones I know of). "When in doubt, try it out!" Here are some resources that I might recommend for learning R: A nice centralized collection of R resrouces. Advanced R: R Programming Tools: One of the most debated topics in R online discussions is that of programming tools for R, of which there are many. People you can talk to:

R Tutorial 321a Boyd Graduate Studies University of Georgia Athens, Georgia 30602 Introductory Materials¶ These materials are designed to offer an introduction to the use of R. Thank You! I have received a great deal of feedback from a number of people for various errors, typos, and dumb things. I have also written a book about programming R. Beginning Python Visualization We are visual animals. But before we can see the world in its true splendor, our brains, just like our computers, have to sort and organize raw data, and then transform that data to produce new images of the world. Beginning Python Visualization: Crafting Visual Transformation Scripts discusses turning many types of small data sources into useful visual data. And, you will learn Python as part of the bargain. What you’ll learn Write ten lines of code and present visual information instead of data soup. Who this book is for IT personnel, programmers, engineers, and hobbyists interested in acquiring and displaying data from the Web, sensors, economic trends, and even astronomical sources.

An Introduction to R Table of Contents This is an introduction to R (“GNU S”), a language and environment for statistical computing and graphics. R is similar to the award-winning1 S system, which was developed at Bell Laboratories by John Chambers et al. It provides a wide variety of statistical and graphical techniques (linear and nonlinear modelling, statistical tests, time series analysis, classification, clustering, ...). This manual provides information on data types, programming elements, statistical modelling and graphics. This manual is for R, version 3.1.0 (2014-04-10). Copyright © 1990 W. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Preface This introduction to R is derived from an original set of notes describing the S and S-PLUS environments written in 1990–2 by Bill Venables and David M. Comments and corrections are always welcome. Suggestions to the reader 1.1 The R environment Try ?

Visualizing data using a 3D printer In a break from my usual obsessions and interests here is a guest blog post by Ian Walker. I'm posting it because I think it is rather cool and hope it will be of interest to some of my regular readers. Ian is perhaps best known (in the blogosphere) for his work on transport psychology - particularly cycling - but is also an expert on psychological statistics. Some time ago, I had some data that lent themselves to a three-dimensional surface plot. The problem was, the plot was quite asymmetrical, and finding the right viewing angle to see it effectively on a computer screen was extremely difficult. Of course, displaying fundamentally three-dimensional items in two dimensions is an ancient problem, as any cartographer will tell you. I managed to meet up with Adrian back in May 2012, and he explained to me the structure of the STL (stereolithography) files commonly used for three-dimensional printing. To view and test your STL files before you print them, you can use various programs.

10 places where anyone can learn to code Teens, tweens and kids are often referred to as “digital natives.” Having grown up with the Internet, smartphones and tablets, they’re often extraordinarily adept at interacting with digital technology. But Mitch Resnick, who spoke at TEDxBeaconStreet, is skeptical of this descriptor. Sure, young people can text and chat and play games, he says, “but that doesn’t really make you fluent.” Mitch Resnick: Let's teach kids to code Fluency, Resnick proposes in this TED Talk, comes not through interacting with new technologies, but through creating them. The former is like reading, while the latter is like writing. The point isn’t to create a generation of programmers, Resnick argues. In his talk, Resnick describes Scratch, the programming software that he and a research group at MIT Media Lab developed to allow people to easily create and share their own interactive games and animations. While we’re at it: bonus!

Matrix Construction There are various ways to construct a matrix. When we construct a matrix directly with data elements, the matrix content is filled along the column orientation by default. For example, in the following code snippet, the content of B is filled along the columns consecutively. > B = matrix( + c(2, 4, 3, 1, 5, 7), + nrow=3, + ncol=2) > B # B has 3 rows and 2 columns [,1] [,2] [1,] 2 1 [2,] 4 5 [3,] 3 7 Transpose We construct the transpose of a matrix by interchanging its columns and rows with the function t . > t(B) # transpose of B [,1] [,2] [,3] [1,] 2 4 3 [2,] 1 5 7 Combining Matrices The columns of two matrices having the same number of rows can be combined into a larger matrix. > C = matrix( + c(7, 4, 2), + nrow=3, + ncol=1) > C # C has 3 rows [,1] [1,] 7 [2,] 4 [3,] 2 Then we can combine the columns of B and C with cbind. > cbind(B, C) [,1] [,2] [,3] [1,] 2 1 7 [2,] 4 5 4 [3,] 3 7 2 Deconstruction

The MakeR way: Using R to reify social media data via 3d printing If you’ve read any of my previous posts you know that I am constantly experimenting with different ways to represent and explore social network data with R. For example, in previous posts I’ve written about sonification of tweet data, animation of dynamic twitter networks, and various ways to plot social networks (here and here). In each case the underlying idea is finding different ways to explore data under the assumption that sometimes just looking at something from a different point of view reveals something novel. In this post I will briefly discuss how to go from data to 3D model network, to 3D object using R most of the way. First, why would anyone want to take network data, model it in 3D and then use a 3D printer to make it real? So how did I use R in this project? edge.list.df <- data.frame(from=retweeters, to=retweeted) g <- graph.data.frame(edge.list.df, directed=TRUE) The plot above shows the full network rendered in the RGL viewport. writeSTL("~myNetworkPrintFile.stl")

27 Ways to Learn to Program Online Whether you are looking to switch careers and become a full-time programmer, want to try to build a website or app on the side, or are just looking to round out your skill set, learning to code has certainly been something a lot of people have started to do lately. And while being a programmer might not be for everyone, there is a lot to be said about gaining a better, more educated view of how all those pixels get moved around all those screens. Before we delve into our list of learning resources sites, we wanted to share some advice from Marissa Louie, a self-taught product designer for Ness Computing. A former startup founder, Louie told TNW that the hardest part of being self-taught – whether it’s design, programming, or any other discipline is, “gathering the courage. The most important barrier is just to overcome your fears” (she also said having the ability to follow instructions helps as well). F**k it, we'll do it live! 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17.

R FAQ: How does R handle missing values? R FAQ How does R handle missing values? Version info: Code for this page was tested in R Under development (unstable) (2012-02-22 r58461) On: 2012-03-28 With: knitr 0.4 Like other statistical software packages, R is capable of handling missing values. However, to those accustomed to working with missing values in other packages, the way in which R handles missing values may require a shift in thinking. On this page, we will present first the basics of how missing values are represented in R. Very basics Missing data in R appears as NA. x1 <- c(1, 4, 3, NA, 7)x2 <- c("a", "B", NA, "NA") NA is the one of the few non-numbers that we could include in x1 without generating an error (and the other exceptions are letters representing numbers or numeric ideas like infinity). is.na(x1) is.na(x2) We can see that R distinguishes between the NA and "NA" in x2--NA is seen as a missing value, "NA" is not. Differences from other packages We can try the equivalent in R. x1 < 0 x1 == NA NA options in R na.omit(g)

Related: