I'm getting a weird error when training a glmnet regression.
invalid class "dgCMatrix" object: length(Dimnames[[2]])' must match Dim[2]
It only happens occasionally, and perhaps only under larger datasets.
I'm not sure whether it's consistent it happens given a certain dataset.
Any clues?
...
I want do fit some sort of multi-variate time series model using R.
Here is a sample of my data:
u cci bci cpi gdp dum1 dum2 dum3 dx
16.50 14.00 53.00 45.70 80.63 0 0 1 6.39
17.45 16.00 64.00 46.30 80.90 0 0 0 6.00
18.40 12.00 51.00 47.30 82.40 1 0 0 6.57
19.35 7.00 42.00...
I am trying to export biometric data from an analysis using the ROCR package. Here is the code that I've done so far:
pred = performance(Matching.Score,Distribution)
perf = prediction(pred,"fnr", "fpr")
An object of class “performance”
Slot "x.name":
[1] "False positive rate"
Slot "y.name":
[1] "False negative rate"
Slot "alpha.n...
Is there an R timer or stopwatch function similar to MATLAB's tic/toc?
...
I have a data frame showing four classes for each year, along with their respective shares of the total for that year.
> head(df)
class year share
1 class1 1975 0.806
2 class2 1975 0.131
3 class3 1975 0.018
4 class4 1975 0.045
5 class1 1976 0.788
6 class2 1976 0.151
When I run ggplot with no fill specified, I ...
I understand how outer() works in R:
> outer(c(1,2,4),c(8,16,32), "*")
[,1] [,2] [,3]
[1,] 8 16 32
[2,] 16 32 64
[3,] 32 64 128
It basically takes 2 vectors, finds the crossproduct of those vectors, and then applies the function to each pair in the crossproduct.
I don't have two vectors, however. I have two li...
I have a dataframe df.all and I'm plotting it in a bar plot with ggplot2 using the code below. I'd like to make it so that the order of the dodged bars is flipped. That is, so that the bars labeled "Singular" come before the bars labeled "Plural".
ggplot(df.all, aes(gram, V1, fill=number)) +
geom_bar(stat="identity", position="dodg...
Dear all,
I'm trying to generate GOFrame objects to generate a gene ontology mapping in R for unsupported organisms (see http://www.bioconductor.org/packages/release/bioc/vignettes/GOstats/inst/doc/GOstatsForUnsupportedOrganisms.pdf).
However, following the instructions literally doesn't help me.
Here's the code I execute (R 2.9.2 on u...
What is the best way to make use of a C++ library in R, hopefully preserving the C++ data structures. I'm not at all a C++ user, so I'm not clear on the relative merits of the available approaches. The R-ext manual seems to suggest wrapping every C++ function in C. However, at least four or five other means of incorporating C++ exist...
I am trying to load an hdf5 into R and running into some problems. Here are the steps I took to configure my environment:
R 2.10.0 (x64) on Mac OS X 10.6
hdf5 1.8.3 installed via macports
hdf5_1.6.9.tar.gz from CRAN
I suspect the problem I am having relates to incompatibilities in my version of HDF5 and the one the R module expects....
Hello,
I have very large tables that I would like to load as a dataframes in R. read.table() has a lot of convenient features, but it seems like there is a lot of logic in the implementation that would slow things down. In my case, I am assuming I know the types of the columns ahead of time, the table does not contain any column heade...
I find R documentation to be important but also time-consuming to create/maintain. Has anyone used Roxygen yet, and if so, does it help in maintaining an R package? I've used Doxygen in the past, but those projects didn't have the man structure that R packages require.
You can find the vignette here.
...
I am trying to run an analysis by invoking R through the command line as follows:
R --no-save < SampleProgram.R > SampleProgram.opt
For example, consider the simple R program below:
mydata = read.csv("test.txt", header=T)
attach(mydata)
summary(Variable1)
q()
The output is displayed in SampleProgram.opt (only partially shown):
...
I have been struggling with how to make a Pareto Chart in R using the ggplot2 package. In many cases when making a bar chart or histogram we want items sorted by the X axis. In a Pareto Chart we want the items ordered descending by the value in the Y axis. Is there a way to get ggplot to plot items ordered by the value in the Y axis? I t...
I often hear people complain how expensive MATLAB licenses are. Then I wonder why they don't just use R. But is it right? Can you use R to replace MATLAB?
...
I'm working with a small team of analysts and statisticians on what will be a medium-sized body of R code. They're smart people, but they're not trained or experienced as programmers, per se. (I am.) They've written some R code, but for our project to be expandable, efficient, and maintainable, it needs to become well-structured, and rat...
Anyone know an R function that will return the number of items in a list?
Thanks
Karl
...
Spaces are redundant when reporting a binary sequence. This code
x <- '1 0 0 0 0 0 1 1 0 1 0 1 1 0 '
y<-gsub(' +', '', x)
does the job so I can copy and paste from R. How do I do the same for 0-1 sequences (and other one-digit data) in others formats, e.g.,
x <- c(1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0)
or
toString(x)
or whate...
What are differences in the assignment operators '=' and '<-' in R? I know that operators are slightly different as this example shows
> x <- y <- 5
> x = y = 5
> x = y <- 5
> x <- y = 5
Error in (x <- y) = 5 : could not find function "<-<-"
But is this the only difference?
...
Hi all,
I'm curious to know if R can use its "eval" function to perform calculations provided by e.g. a string.
This is a common case
> eval("5+5")
However, instead of 10 I get
[1] "5+5"
Any solution? :-)
...