Displaying 20 results from an estimated 3000 matches similar to: "Using a list as multidimensional indexer"
2011 Mar 04
3
Generic mixup?
Hello list.
This is from an R session (admittedly, I''m still using R 2.11.1):
> print
function (x, ...)
UseMethod("print")
<environment: namespace:base>
> showMethods("print")
Function "print":
<not a generic function>
Don''t the two results contradict each other? Or do I have a terrible
misunderstanding of what
2011 Sep 22
4
R CMD check file issues
This problem is likely to be specific to Windows, and particularly Win7.
After a successful build of a package (R CMD build addendum), I immediately
run an R CMD check for the same package.
Not always, but _very_ often, I get the following error:
C:\Users\nisabbe\Documents\@Doctoraat\R>R CMD check addendum
Loading required package: tcltk
Loading Tcl/Tk interface ... done
Loading
2011 Jan 28
1
plot not generic
Hello list.
I was trying to see some of the code for plot.glmnet in package glmnet (this
function name is in the documentation).
After loading the library, I tried the obvious typing in the name, but I
received a message telling me it could not be found.
So I fiddled around a little, and noticed that R does not recognize ''plot''
as a generic function, and as such,
2011 Jan 28
2
Injecting code in a package?
Dear list,
I''ve had this a few times now, and wonder if this is possible:
I''m using a package, often for plotting something, but I want to tune the
way the plotting goes, in a way that was not foreseen by the maker of the
package.
Now, most of the time, these kinds of R functions (say pkg::plot.something)
call into other R functions (say pkg::plot.something.internal), and
2010 Oct 22
2
Linking to lapack
Hello all.
I'm developing a package for R holding a Gibbs sampler, which tends to have
better performance when written in C than in R.
During each iteration in the Gibbs sampler, I need the inverse of a
symmetric matrix.
For this, I wish to use lapack, as is concisely suggested in "Writing R
extensions", since this will have better performance than I could ever write
myself.
After
2010 Dec 07
1
Dataframe from list of similar lists: not _a_ way, but _the best_ way
Hi All.
I often find myself in this situation:
. Based on some vector (or list) of values, I need to calculate a
few new values for each of them, where some of the new values are numbers,
but some are more of descriptive nature (so: character strings)
. So I use e.g. sapply, passing a custom function that returns a
list with all the calculated values
. The result of
2011 Apr 29
2
abline outside of plot region
Hi R people.
I ran into this problem: I created a plot with errbars, like this:
> errbar(x=c(1,2,3,4), y=c(2,1,3,3), yminus=c(1.5,0.5,2.5,2.5),
yplus=c(2.5,1.5,3.5,3.5))
Next, I wanted to accentuate some x value with an abline, like this:
> abline(v=2)
In one of my R sessions (which admittedly I have had open for quite a while
now), the abline draws outside of the plotting region
2012 Jun 01
1
Dependencies on recommended packages
Dear all,
I've recently had some issues getting my package to successfully "check".
This was on R-Forge, so it's not obvious for me to provide SessionInfo or
the likes (if necessary, Stefan can chime in?).
After some research (mainly by Stefan Theussler, driving force behind
R-Forge), this turned out to be the root cause:
On R-Forge, the version of R installed was the
2011 Sep 22
1
R check error / update.packages
While building/checking a package of mine that depends on glmnet, I got the
following message:
* checking whether the name space can be loaded with stated dependencies
...Warn
ing: running command
''"C:/Users/nisabbe/Documents/R/R-2.13.1/bin/i386/Rterm.exe"
R_DEFAULT_PACKAGES=NULL --vanilla --slave -f
C:\Users\nisabbe\AppData\Local\Tem
p\RtmpZpjj07\Rin121ae93''
2010 Dec 08
2
problem accessing complex list data frames
Hi all.
I am currently attempting to build a list of sparse matrixes. That I have
already achieved, by
> vmat <- list()
> for (i in 1:n) {
> vmat <- c(vmat, sparseMatrix(i,j,x=data)
> }
How I am trying to select those elements from the list where the column e.g.
999 is not null. I can do this for one of the sparse matrices with
> which(vmat[[1]][,999] != 0)
which
2011 Mar 31
3
choosing best 'match' for given factor
Folks,
I have a 'matching' matrix between variables A, X, L, O:
> a <- structure(c(1, 0.41, 0.58, 0.75, 0.41, 1, 0.6, 0.86, 0.58,
0.6, 1, 0.83, 0.75, 0.86, 0.83, 1), .Dim = c(4L, 4L), .Dimnames = list(
c("A", "X", "L", "O"), c("A", "X", "L", "O")))
> a
A X L O
A 1.00 0.41
2011 Apr 01
3
programming: telling a function where to look for the entered variables
Hi there,
Could someone help me with the following programming problem..?
I have written a function that works for my intended purpose, but it
is quite closely tied to a particular dataframe and the names of the
variables in this dataframe. However, I'd like to use the same
function for different dataframes and variables. My problem is that
I'm not quite sure how to tell my function in
2011 Jan 13
1
Repeating value occurence
How can achieve this in R using seq, or rep function
c(-1,0,1,0,-1,0,1,0,-1,0)
The range value is between-1 and 1, and I want it such that there could be
n number of points between -1 and 1
Anyone? Please help Thanks
Rusty
[[alternative HTML version deleted]]
2010 Oct 25
1
if statement and truncated distribution
Hi R helpers,
I am trying to use the if statement to generate a truncated random variable
as follows:
if (y[i]==0) { v[i] ~ rnorm(1,0,1) | (-inf ,0) }
if (y[i]==1) { v[i] ~ rnorm(1,0,1) | (0, inf) }
I guess I cannot use " | ( , ) " to restrict the range of a variable in R.
Could you let me know how to write the code correctly in R?
Many thanks for your help.
Maomao
[[alternative
2011 Mar 16
2
One to One Matching multiple vectors
Dear R helpers
Suppose,
x = c(0, 1, 2, 3)
y = c("A", "B", "C", "D")
z = c(1, 3)
For given values of z, I need to the values of y. So I should get "B" and "D".
I tried doing
y[x][z] but it gives
> y[x][z]
[1] "A" "C"
Kindly guide.
Regards
Vincy
[[alternative HTML version deleted]]
2011 Jun 09
1
Rcpp and Object Factories
Hello,
I'm not exactly sure how to ask this question, but let me give it a shot...
Is it possible (easy) to use Rcpp Modules in conjunction with object
factories? For example
what I am trying to do is something like this:
// c++ classes
class Foo {
public:
void do_something() {};
};
class Foo_Factory {
public:
Foo * create_foo() {
return new Foo();
}
};
## R Code
2010 Oct 27
2
keep adding elements to the matrix
Hello everyone,
I would like to create a "dynamic" array to keep storing number in it
for (i in c(2:length(final))){
myarray <-final[i]-final[i-1]
myarray2<-2*final[i]
}
At the end I would like to use myarray as the x values of an array
and the myarray2 as the yvalues of the same array.
I tried cbind but it didnot work.
Could you please help me with that?
Best
2010 Oct 25
2
Find index of a string inside a string?
Hi,
I am searching for the equivalent of the function Index from SAS.
In SAS: index("abcd", "bcd") will return 2 because bcd is located in the 2nd cell of the abcd string.
The equivalent in R should do this:
> myIndex <- foo("abcd", "bcd") #return 2.
What is the function that I am looking for?
I want to use the return value in substr, like I do
2011 Aug 10
2
glmnet
Hi All,
I have been trying to use glmnet package to do LASSO linear regression. my x data is a matrix n_row by n_col and y is a vector of size n_row corresponding to the vector data. The number of n_col is much more larger than the number of n_row. I do the following:
fits = glmnet(x, y, family="multinomial")I have been following this
2011 Feb 03
1
glmnet with binary predictors
Hi Everybody!
I must start with a declaration that I am a sparse user of R. I am
creating a credit scorecard using a dataset which has a variable
depicting actual credit history (good/bad) and 41 other variables of
yes/no type. The procedure I am asked to follow is to use a penalized
logistic procedure for variable selection. I have located the package
"glmnet" which gives the complete