Questions for r


How to add a 2nd y-axis for a density plot superimposed on a histogram in R?

I have a histogram shown below, and I have added 2 density plots on top of that. It corresponds to the 2 classes that make up the data.

How to write coercion methods

I'm having a bunch of custom-made Reference Classes and would like to write coercion methods for some of them. It'd be nice if a function call would look like this:

How to get started with Big Data Analysis

I've been a long time user of R and have recently started working with Python. Using conventional RDBMS systems for data warehousing, and R/Python for number-crunching, I feel the need now to get my

How to manually set coefficients for variables in linear model?

In R, how can I set weights for particular variables and not observations in lm() function?

R - How to sum objects in a column between an interval defined by conditions on another column

This comes as an application to this question:Sum object in a column between an interval defined by another column

Create a table for N, Min/Max, SD, Mean, and Median in R

I'm very new to R, so please bear with me on this basic question.

How can an line be overlaid on a a bar plot using ggplot2?

I'm looking for a way to plot a bar chart containing two different series, hide the bars for one of the series and instead have a line (smooth if possible) go through the top of where bars for the ...

R Cannot allocate memory though memory seems to be available

After running several models I need to run a system() command on my R script to shutdown my EC2 instance, but when I get to that point I get:

ggplot2 plot fill page in landscape (pdf)

I'm trying to render a plot to a PDF using the following approach:

Extracting Certain Data from a Data Set Using R

I have difficulties in extracting certain line from a data.

Discarding non-decimal values in R

I've got the a data frame called "odds" in R containing a couple of odds I kept track of in several formats:

Sample with constraint, vectorized

What is the most efficient way to sample a data frame under a certain constraint?

How do I set values to a Tk combobox in R

I sometimes have a dropdown box with only one item to choose from, but this item might be a string with spaces. How can I do this in R? Here is the problem:

How can I color the ocean blue in a map of the US?

I would like to draw a map of the US over an image, but then fill in the oceans.

R: format the output of `warning()` for a list of options over more than one line

I'm writing error handling steps for an R function that fails to find the right match to a query, so presents users with a list of options. I have the output of potential matches in a list, and I'...

Beginner's questions (figures, bibliography) with Sweave/R/LaTeX---my first document

I am just starting with Sweave and with R. Here I am using R to output some data and I am also trying to include a plot. The code does not sweave. I have one Sweave example from the web that compiles

Plot only diagonal entries with data.frame of many time-series in R

I have several time series, which when I plot using,

R as a general purpose programming language

I liked Python before because Python has rich built-in types like sets, dicts, lists, tuples. These structures help write short scripts to process data.

What's the fastest way to merge/join data.frames in R?

For example (not sure if most representative example though):

Why I obtain wrong answer when using “==”

Something I do not understand is happening on two of my computers. I wonder why this is happening:

R incrementing by decimal value does not return expected value

I am writing a function in R that requires me to increment a counter by 0.05. When I condition on the value of the counter I am getting told that the value is not what it appears.

How to add layers with new data to a ggplot with a POSIX axis?

I'm used to this if I want to add a point to a ggplot, it works just fine:

using stringr to split vectors, unexpected result length

Something simple I'm messing up in using stringr to manipulate character vectors. I have a data frame of the following sort

Save graph from R as editable graphic in Excel

I am writing a GUI in R, and one of the functions I must implement is a button to save graphical output to an Excel sheet, ideally the graphic should be editable in Excel. I am trying to do this the

big.matrix as data.frame in R

I've recently started using R for data analysis. Now I've got a problem in ranking a big query dataset (~1 GB in ASCII mode, over my laptop's 4GB RAM in binary mode). Using bigmemory::big.matrix fo...

R 2.14 byte compilation - how much performance increase

I saw that the latest R version supports byte compilation. What is the performance gain I can expect? And are specific tasks more positively impacted that others?

R: Plotting 4x4 plot with for -loop and png, why getting 1x1 plot instead of 4x4?

I can get the 4x4 plot working when I try it on command line but not with for -loop and png element in the code below. I am frustrated what the heck the problem is, I have tried to understand this ...

Change dots of a ggplot to text labels

Recently i asked a question about getting multiple graphs within 1 picture. I got some pretty good answers but 1 question still remains.

Group rows by attributes

I have a data frame containing data about student lateness to various classes. Each row contains data about a late student and his class: date and time of the class, name of the class, class size, ...

My R has memory leaks?

I'm using R 2.15.3 on Ubuntu 12.04 (precise) 64-bit.

Subset data using non-sequential row numbers

I have a data frame with 30 rows and 100 columns (X).

R - How to do Python's Try Except

I'm starting to work with R. Although I'm more used to python.

Predicted Probabilities with Predict.Plot

I'm running the following logistic regression model in R and one of the important predictors is our_bid, which is a numeric and continuous variable that ranges from 0.30 to 0.80. When I attempt to...

R lapply statement with index

Is there a way I can make an lapply statement also show the index? More specifically, consider the following example:

Regular expression in R

I am having some troubles with the regular expression in R. I use str_extract from the library stringr and my problem is :

Solving quadratic programming using R

I would like to solve the following quadratic programming equation using ipop function from kernlab :

Apply function on each cell in a column and add the result to a new column

I have a data.table as shown below. What I want is to apply a function to each of the elements in column C. The function will take in a vector(since Col C contains vector elements) and return another

R and ggplot- Changing x axis to Date removes position dodge

I've been using ggplot to create plots, and I always like to offset my data points horizontally so the error bars don't overlap. I've found that when I used Date data for my x axis, I loose the abi...

Efficient way to define a class with multiple, optionally-empty slots in S4 of R?

I am building a package to handle data that arrives with up to 4 different types. Each of these types is a legitimate class in the form of a matrix, data.frame or tree. Depending on the way the dat...

How do I call a namespaced function without evaluating the parameters you are giving it?

In R, the idiomatic way to call another function without evaluating the parameters you give it is apparently as follows:

Trouble reading a data set into R

I am new to R and I am trying to read in a data set. The data set is here:

Plotting multiple columns with ggplot2

I need to plot the following dataset in the same graph.

How to install 2 different R versions on Debian?

On our server, R 2.12.1 is installed following the instructions on , using apt-get install etc etc.

How do I calculate weighted degree distributions with igraph in R?

Consider a dataframe df where the first two columns are node pairs and successive columns V1, V2, ..., Vn represent flows between the nodes (potentially 0, implying no edge for that column's networ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.