r

How do I load example datasets in R?

Let's say I want to reproduce an example posted on StackOverflow. Some have suggested posters use dput() to help streamline this process or one of the datasets available in the base package. In this case, however, suppose I have only been given the output of the dataframe: > site.data site year peak 1 ALBEN 5 101529.6 2 ...

R character encodings across windows, mac and linux

I use OS X and I am currently cooperating with a windows user and deploying the scripts on a linux server. We use git for version control, and I keep getting R scripts from his end where the character encoding used has mixed latin1 and utf8 encodings. So I have a couple of questions. Is there a simple to use editor for windows that h...

Best IDE / TextEditor for R

Duplicate Recommendations for Windows text editor for R Which IDE for R in Linux? Which IDE or TextEditor do you use to write R code? ...

How to examine the code of a function in R that's object class sensitive

Hello. I'm trying to write a function to do a particular job (in my case, analyse a data set for outliers) so the first things I want to do is look at how other people have done similar jobs. I can do this to load a particular package and examine the code of a function, but some functions seem to depend on what class of object you thro...

Creating a sequential list of letters with R

I would like to be able to create a sequence of letters in R (to assist in importing data from a SPSS file) It's quite easy to create a sequence of numbers, for example: seq(1,1000) [1] 1 2 3 4 5 6 ... 1000 paste("something_",1:12,sep="") [1] something1 something2 ... something12 But is there any functionality for appending, pasting...

Plotting color map with zip codes in R or Python

I have some US demographic and firmographic data. I would like to plot zipcode areas in a state or a smaller region (e.g. city). Each area would be annotated by color and/or text specific to that area. The output would be similar to http://maps.huge.info/ but a) with annotated text; b) pdf output; c) scriptable in R or Python. Is there ...

How to use Outlier Tests in R Code

As part of my data analysis workflow, I want to test for outliers, and then do my furthur calculation with and without those outliers. I've found the outlier package, which has various tests, but I'm not sure how best to use them for my workflow. ...

R script line numbers at error?

If I am running a long R script from the command line (R --slave script.R), how can I get it to give line numbers at errors? I don't want to add debug commands to the script if at all possible -- I just want R to behave like most other scripting languages ... ...

Change default prompt and output line prefix in R?

For the purposes of teaching and preparing written instructions about R, one of the things that's always frustrated me is that I can't simply copy commands and output from R and paste them into another R session. For example, if I do something trivial, such as > x <- rnorm(10) > x [1] 1.76975998 1.19722850 -0.39274507 -1.10979974 0....

Display Values in R Plot

How can I render the value of points in a plot in the plot itself? Thank you. ...

Does an R compiler exist?

I'm wondering about the best way to deploy R. Matlab has the "matlab compiler" (MCR). There has been discussion about something similar in the past for R that would compile R into C or C++. Does anyone have any experience with the R to C Compiler (RCC) that was developed by John Garvin at Rice? I've looked into it, and it seems to be...

Best way to integrate R and Flash/Flex

I want to make a Flash or Flex front end for my R code, I want to call an R function from a website (using Flash) what is the best way to go about connecting Flash and R? ...

What does "not run" mean in R help pages?

Sometimes on an R help page the phrase "not run" appears in comments. Check out this from the help page for "with()": Examples require(stats); require(graphics) #examples from glm: **## Not run:** library(MASS) with(anorexia, { anorex.1 <- glm(Postwt ~ Prewt + Treat + offset(Prewt), family = gaussian) summar...

visualize associations between two groups of data

Where each datapoint has a pairing of A and B and there multiple entries in A and multiple entires in B. IE multiple syndromes and multiple diagnoses, although for each datapoint there is one single syndrome-diagnoses pair. Examples, suggestions, or ideas much appreciated here's what the data is like. And I want to see connections betw...

Adding multiple columns, transforming with multiple variables

How do I add the values from many variables. So if I just had two variables (columns) I could simply go summation.variable <- variable1 + vabirable2 or if it was all in a dataframe transform(dataframe,summation.col = column1 + column2) How do I do it if I have about 10 variables and I do not want to type each one as in col1+col2+co...

Word-wrapping in the R environment for Windows

(Asking this on behalf of a member of our Bay Area R Group. I did not have a ready answer as I run ESS within Emacs. I assume this question refers to running R within the command-line environment that ships in the standard Windows distribution). I'm new to R, but what I've found in searching for my answer is that there isn't anything ...

Forcing garbage collection to run in R with the gc() command

Periodically I program sloppily. Ok, I program sloppily all the time, but sometimes that catches up with me in the form of out of memory errors. I start exercising a little discipline in deleting objects with the rm() command and things get better. I see mixed messages online about whether I should explicitly call gc() after deleting lar...

Good ways to code complex tabulations in R?

Hi R-ers, Does anyone have any good thoughts on how to code complex tabulations in R? I am afraid I might be a little vague on this, but I want to set up a script to create a bunch of tables of a complexity analogous to the stat abstract of the united states, (e.g.: http://www.census.gov/compendia/statab/tables/09s0015.pdf). And I wou...

how do I get the difference between two R named lists?

OK, I've got two named lists, one is "expected" and one is "observed". They may be complex in structure, with arbitrary data types. I want to get a new list containing just those elements of the observed list that are different from what's in the expected list. Here's an example: Lexp <- list(a=1, b="two", c=list(3, "four")) Lobs <- lis...

Correlation clustering in r

I'd like to use correlation clustering and I figure R is a good place to start. I can present the data to R as a set of large, sparse vectors or as a table with a pre-computed dissimilarity matrix. My question is are there existing R functions to turn this into a hierarchical cluster with agnes that uses correlation clustering? Will I ...