I have loaded a dataset, D, into R and I would like to perform a frequency of all the variables in D versus D$binary_outcome. How do I do that?
I would like to know if there is some code that is fairly generic and D may have any number of variables and the code should be able to handle a dataset with any number of variables.
In effect ...
I got the below piece of code and it keeps on printing the frequency tables. How do I stop it from doing this.
pl = read.csv("c:/pl.csv")
freqs = function(name){ assign(name, table(pl[,name],pl$bad_outcome), envir = .GlobalEnv);}
lapply(names(pl), freqs);
...
I have installed a modified Emacs version for Windows XP from Vincent Goulet and I want to run and edit R scripts contained on a remote Unix server using ess-remote. After a lot of searching I am able to connect to a remote R session in the following way:
Open a shell prompt with M-x shell
enter the following command: plink -X -C usern...
I've been trying to create a 3D bar plot based on categorical data, but have not found a way.
It is simple to explain. Consider the following example data (the real example is more complex, but it reduces to this), showing the relative risk of incurring something broken down by income and age, both categorical data.
I want to display t...
hi
i am trying to analyse wind data using the 'cut' command,
i want to set 16 wind directions
how can i cut directions 348.75 till 11.25 to a "0" label?
thank you
eliav
...
Is there any package in R that contains algorithm for feature selection using Gram-Schmidt orthogonalization?
...
Hi everyone,
I have toyed with a number of ideas to do this, but so far have only come up with some rather inelegant solutions. I'm sure I could make it work, but the code would neither be pretty nor efficient. Here's the problem:
I have a series of integer pairs that are presented as rows in a two-column data frame. The goal is thre...
We're all familiar with naming conventions in R (if not: Venables & Smith - Introduction to R, Chapter 1.8). Regular expressions, on the other hand, remain terra incognita and the most hated part in my programming life so far ... Recently, I've officially started JavaScript recapitulation, and I'm trying to create precise RegExp to check...
Dear R users,
I have a custom function that produces a scatter plot, fits an OLS model and then plots the best fit line with 95% CI bands. This works well, but I want to log the data and change the plot's axes to a log-scaled version of the original data (this is easily done using the 'plot' function's built in 'log' argument to alter t...
Recently, I needed to convert a series of dates from the form "July 25, 2010" to the standard R format "2010-07-25":
> head(old.data$dateoccurred)`
[1] "April 9, 2004" "September 1, 2004" "February 7, 2005
To solve this, I would like to make a 12-case switch-statement that returns the the numeric representation of a month; howeve...
For a tcltk application, I would like to start an R script without opening a console window or starting a DOS box. I already figured out that by creating a link to RScript.exe I can force the console window to start minimized, but I wonder if I can avoid the console window at all?
...
Given:
h_i=t_(i+1)-t_i for i=1,...,n-1 where n is a positive integer.
The matrix Q is an n by (n-2) matrix with entries q_(i,j) with i=1,...,n and j=2,...n-1 given by:
q_(j-1,j)=1/h_(j-1)
q_(j,j)=-(1/h_(j-1)+1/h_j)
q_(j+1,j)=1/h_j
q_(i,j)=0 for |i-j|>=2
I want to get a matrix Q. How do i write a program for this matrix in R? Many t...
I'm running a logistic regression model in R. I've used both the Zelig and Car packages. However, I'm wondering if there is a simple way to get the model fit statistics for the model. (pseudo R-square, chi-square, log liklihood,etc)
...
Is there a way to change the default number formatting in R so that numbers will print a certain way without repeatedly having to use the format() function? For example, I would like to have
> x <- 100000
> x
[1] 100,000
instead of
> x <- 100000
> x
[1] 100000
...
I am using R on some relatively big data and am hitting some memory issues. This is on Linux. I have significantly less data than the available memory on the system so it's an issue of managing transient allocation.
When I run gc(), I get the following listing
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 21471...
I have a set of data need to be plotted (1M rows) with R. The time column (column 1) is in hh:mm:ss.000 format. I would like to plot the graph in a time range, say from 08:05:00 to 09:00:00. How do I do it? I have searching the web and couldn't find a way to set the xlim properly.
Here's an short example of the data. Column 1 is time, ...
Suppose that you have a data frame with many rows and many columns.
The columns have names. You want to access rows by number, and columns by name.
For example, one (possibly slow) way to loop over the rows is
for (i in 1:nrow(df)) {
print(df[i, "column1"])
# do more things with the data frame...
}
Another way is to create "list...
The following code assigns a manual color scale of red and black to my points:
require(ggplot2)
require(directlabels)
dtest <- data.frame(x=1:20,
y=rnorm(20,0,5),
v=seq(1,2))
p <- ggplot(dtest, aes(x=x,y=y,color=as.factor(v))) + geom_point() + scale_colour_manual(values=c("red","black"))
p #this looks...
Hello!
I am passing data from C# to R over a COM interface. When the data arrives in R it is housed in a 'Matrix'. Some of the functions that I use require that the data be inside a 'DataFrame' instead. I convert the data structure using
newDataFrame <- as.data.frame(oldMatrix)
The table of data reaches R just fine, once I make the...
Hi all,
I'm tying to execute an R script from python, ideally displaying and saving the results. Using rpy2 has been a bit of a struggle, so I thought I'd just call R directly. I have a feeling that I'll need to use something like "os.system" or "subprocess.call," but I am having difficulty deciphering the module guides.
Here's the R...