I have the following code snippet:
require(lattice)
f.barchart <- function(...) {
barchart(...,
panel = function(x, y, ...) {
panel.barchart(x, y, ...)
}
)
}
x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), c = c(1,2,2,1))
f.barchart(a ~ b, data = x, groups = c)
Which results in the following error ...
There is an option in R to get control over digit display. For example:
options(digits=10)
is supposed to give the calculation results in 10 digits till the end of R session. In the help file of R, the definition for digits parameter is as follows:
digits: controls the number of digits
to print when printing numeric values.
It...
How can dataframe column type be converted to numeric
...
I have been using surveygizmo which is an amazingly powerful online questionnaire presenter. The data can be exported as a csv file but alas it has two [not one] header rows. The first row specifies the question and the second row contains possible responses that the respondent could have checked off. This seems highly aberant in the dat...
Hello R comrades:
I have a bunch of loglinear models, which, for our purposes will just be glm() objects called mx, my, mz. I want to get a nicely-formatted xtable of the analysis of deviance, so naturally I would want to perform xtable(anova(mx, my, mz, test = "Chisq")).
The vanilla output of xtable, however, doesn't include the mode...
Statistical analysis/programming, is writing code. Whether for descriptive or inferential, You write code to: import data, to clean it, to analyse it and to compile a report.
Analyzing the data can involve many twists and turns of statistical procedures, and angles from which you look at your data. At the end, you have many files, with ...
I am creating some graphs which I want to update into a database table. The procedure I am following is:
create the graphs as a png/jpeg file.
Read that file as a binary vector
sqlUpdate
My code for steps 2 & 3:
pngfile <- file(<filename>, "rb")
N <- 1e6
repeat{
pngfilecontents <- readBin(pngfile, what="raw", n=N)
if(l...
Let's say I have created the following matrix:
> x <- matrix(1:20000,nrow=100)
> x[1:10,1:10]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 101 201 301 401 501 601 701 801 901
[2,] 2 102 202 302 402 502 602 702 802 902
[3,] 3 103 203 303 403 503 603 703 803 903
[4,] 4 104 ...
Is there java or .net version of R ?
(like jython / ironpython for python language)
I guess some r-packages which use c or fortran may not run on java/.net version of R, but as long as pure r code can be run, it must be great.
...
I have a large data set I am plotting in R, and I'd like to have an axis on each side of the graph show the data in two different scales. So for example, on the left vertical axis I'd like to plot the data directly (e.g. plot(y ~ x) ) and on the right axis, I'd like to have a linear scaling of the left axis. (e.g. plot( y*20 ~ x).
So t...
Hi!
I'm trying to read data from csv file, but instead of e.g. 001000 I get 1000 in my data.
I've tried to set as.is=!stringsAsFactors, but got error: object stringsAsFactors not found.
Anybody can help?
...
I have two vectors in R of different size, and I want to add them, but without repeating the shorter one - instead, I want the "missing" numbers to be zeroes.
Example:
x<-c(1,2)
y<-c(3,4,5)
z<-x+y
Now, z is 4 6 6, but I want it only 4 6 5.
...
What's the most efficient way to sort two vectors in lockstep in R? The first vector should be sorted in ascending order and the second should be reordered in lockstep such that elements with corresponding indices before the sort still have corresponding indices after the sort. For example:
foo <- c(1,3,2, 5,4)
bar <- c(2,6,4,10,8)
so...
I'm taking my first course in multiple linear regression, so I'm still a beginner in R. We've recently learned a bit about taking slices of bivariate scatterplot data, both horizontally and vertically. What I'd like to know is how to go beyond a basic scatterplot, and take advantage of conditionally grouping data by slices to examin...
My question is how to extract the name of a variable from a function that is called in another function in R?
To illustrate, here is an example:
a <- function(variable) {
print(deparse(substitute(variable)))
internala(substitute(variable))
}
internala <- function(variableXX) {
namex=deparse(substitute(variableXX))
...
Is it possible to include .R files in the data directory of my package in the roxygen process?
I have put several .R files in the data directory. When they are sourced with data(), they read in raw data files and perform some transformations.
...
I have a dendrogram given to me as images. Since it is not very large, I can construct it "by hand" into an R object.
So my question is how do I manually create a dendrogram (or "hclust") object, when all I have is the dendrogram image ?
I see that there is a function called "as.dendrogram" But I wasn't able to find an example on how t...
Many algorithms for clustering are available. A popular algorithm is the K-means where, based on a given number of clusters, the algorithm iterates to find best clusters for the objects.
What method do you use to determine the number of clusters in the data in k-means clustering?
Does any package available in R contain the V-fold cros...
I'm trying to understand how the order() function works in R. I was under the impression that it returned a permutation of indices, which when sorted, would sort the original vector.
For instance,
> a <- c(45,50,10,96)
> order(a)
[1] 3 1 2 4
I would have expected this to return 2 3 1 4, since the list sorted would be 10 45 50...
Hey all,
I've just started playing around with the roxygen package and I've very happy with the results so far. However I was wondering, is there a way to specify to roxygen that it should ignore certain functions that are not user-accessible?
Specifically, I'd rather not have a .Rd file pop up because I'm using the .onLoad() hook in ...