Hello,
This one has been bugging me for a long time and I have never found a
solution. I am using R version 2.15.1 but it has come up in older versions of R
I have used over the past 2-3 years.
Q: Am I wrong to expect that R should handle hundreds of iterations of the
base model or statistical
Hi,
You could also use:
apply(cbind(v1,v2),1,function(x) x[order(x)])
#or
unique(t(apply(cbind(v1,v2),1,sort.int,method="quick")))
By comparing different methods:
set.seed(51)
v1<-sample(0:9,1e5,replace=TRUE)
set.seed(49)
v2<-sample(0:9,1e5,replace=TRUE)
system.time(res1<-unique(t(apply(cbind(v1,
HI,
Not sure if this is what you wanted:
set.seed(14)
Z<-array(sample(1:100,80,replace=TRUE),dim=c(5,2,8))
set.seed(21)
Y<-matrix(sample(1:40,40,replace=TRUE),nrow=8)
do.call(cbind,lapply(seq_len(dim(Z)[1]),function(i) Z[i,,]%*%Y[,i]))
# [,1] [,2] [,3] [,4] [,5]
#[1,] 5065 6070 12328 11536
Hi:
I am trying to query pubmed abstracts using the following syntax:
url= "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?";
search = paste(url, "db=pubmed&term=", queryTerm1, "+AND+",
queryTerm2,"+OR+",queryTerm3, "+OR+", queryTerm4,
"[abstract]&retmax=100&usehistory=y", sep="")
do
I'm trying to read data a program produces in matrixmarket array format
into R and its giving me fits. I've tried read.MM (below) and readMM (from
the Matrix package) but neither works. One of them says array format isn't
supported, the other reports something indecipherable about Fortran.
Here's
(The same question was cross-posted in the knitr mailing list, so cc'ed as well)
According to the other email from Steven, this problem was solved by
reinstalling R. I cannot reproduce the problem under either Ubuntu or
Windows (regardless of 32-bit or 64-bit R), so I have no idea of what
happened
I think what you are doing is a tensor algebra. You may want to try tensorA:
http://cran.r-project.org/web/packages/tensorA/index.html
On 28 December 2012 06:33, Ranjan Maitra wrote:
> Any pointers on an efficient way of doing this? I considered using
> apply, but was not successful.
please pos
Thanks a lot for the explaination. Much appreciated. :-)
On Thu, Dec 27, 2012 at 10:31 PM, William Dunlap wrote:
> > Can you please elaborate. What are the negatives about the method
>
> Here are a few examples of eval(parse(text=paste())) failing:
> > cvtest <- list("Test-1"=1, Bozo=2, "Joe's
Hello,
I have been wondering of an efficient way to do this:
I have an n x m x p array Z and a p x n matrix Y.
I want to multiply each of the n matrices with the corresponding column
vector of Y.
In other words, I am wanting to matrix multiply:
Z[i, ,] %*% Y[, i]
which will give me a (two-di
I cannot reproduce your problem with the latest version of knitr
(0.9). This minimal document works fine for me:
\documentclass{article}
\begin{document}
<>=
group <- gl(3,5,20, labels=c("Ctl","Trt","prp"))
weight <- runif(20)
reg1 <- lm(weight ~ group)
library(estout)
eststo(reg1)
esttab()
@
\en
I am using the package Multicore/Parallel to do importance sampling. I have
5 cores on my computer. And I have
let's say 10 000 particles to generate. What I did was to send 5 particles
in each time, calling the package parallel. Which means in all I am calling
the parallel command 2000 times.
What
where is your sample code asked for in the Posting Guide?
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.#. ##.#. Live Go...
L
Dear R experts,
I try to extract certain child nodes from an XML document and construct a
table in which the parent node names are the columns and the child id
values, joined in a list, are the cell content.
If I first apply an XPath query to extract all above parent nodes, then
iterate over thos
This version has some minor bug fixes, plus some new features.
* The exact=TRUE option in predict and coef methods now works.
In earlier versions of glmnet, if you supplied a value of s different from the
sequence of lambdas used to compute the fit, predict used interpolation.
This is exact for
You can use environments. Have a look at this this discussion.
http://stackoverflow.com/questions/7439110/what-is-the-difference-between-parent-frame-and-parent-env-in-r-how-do-they
On 27 December 2012 21:38, Sam Steingold wrote:
> I have the following code:
>
> --8<---cut here--
At Thu, 27 Dec 2012 15:38:08 -0500,
Sam Steingold wrote:
> so,
> 1. is there a way for a function to modify a global variable?
Use <<- instead of <-.
> 2. how would you vectorize this loop?
This is hard. Your function has a feedback loop: an iteration depends
on the previous iteration's result.
It would help if we had some idea what data_min1$macdhist actually is. I
would not expect to see that error if it is a simple numeric vector, so it
probably has a class of some sort which causes the plot command to call a
specific method (but we don't know which one) which may not have a col
argum
The idiom of 'par(new=TRUE)' should be hidden, it is never the first thing
that you should try and is only rarely needed and as you have seen often
causes more problems than it helps.
First you should ask yourself if using 2 different coordinate systems in
the same plot is the best approach, you c
Others have mentioned the readability issues (which are important), but
think about what would happen in the case where the variable lambda rule
ended up with a value like:
lambda.rule <- "a;system('SomeEvilSytemCommand')"
Or what if the element of the list desired has a space in its name.
And t
Yep. There are methods for:
> methods(unique)
[1] unique.array unique.data.frame unique.default
[4] unique.matrix unique.numeric_version unique.POSIXlt
and for the matrix and data.frame methods, unique rows will be returned by
default. For array and matrix obje
I did not know that unique worked on entire rows!
That is great, thank you very much!
Emmanuel
On 27 December 2012 22:39, Marc Schwartz wrote:
> unique(t(apply(cbind(v1, v2), 1, sort)))
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailm
On 27 December 2012 21:23, Ben Bolker wrote:
> On 12-12-27 03:04 PM, Greg Hooper wrote:
> it more closely into R I would take the C code and figure out how I
> could integrate it into an R package as compiled code with a thin R
> wrapper around it. Since the code "license" is "public domain", you
There is also another fortune:
> fortune('toad')
The problem here is that the $ notation is a magical shortcut and like any
other magic if used incorrectly is likely to do the programmatic equivalent
of
turning yourself into a toad.
-- Greg Snow (in response to a user that wanted to access a c
On Dec 27, 2012, at 2:30 PM, Emmanuel Levy wrote:
> Hi,
>
> I've had this problem for a while and tackled it is a quite dirty way
> so I'm wondering is a better solution exists:
>
> If we have two vectors:
>
> v1 = c(0,1,2,3,4)
> v2 = c(5,3,2,1,0)
>
> How to remove one instance of the "3,1"
I have the following code:
--8<---cut here---start->8---
d <- rep(10,10)
for (i in 1:100) {
a <- sample.int(length(d), size = 2)
if (d[a[1]] >= 1) {
d[a[1]] <- d[a[1]] - 1
d[a[2]] <- d[a[2]] + 1
}
}
--8<---cut here---end
Hi,
I've had this problem for a while and tackled it is a quite dirty way
so I'm wondering is a better solution exists:
If we have two vectors:
v1 = c(0,1,2,3,4)
v2 = c(5,3,2,1,0)
How to remove one instance of the "3,1" / "1,3" double?
At the moment I'm using the following solution, which is q
thanks Ben - that sounds a lot more efficient
On 28 December 2012 06:23, Ben Bolker wrote:
> On 12-12-27 03:04 PM, Greg Hooper wrote:
> > thanks again Mehmet - the midicsv utility is in C (of which I am
> > ignorant). I will have a look at that to see if I can write a native R
> > version. It on
On 12-12-27 03:04 PM, Greg Hooper wrote:
> thanks again Mehmet - the midicsv utility is in C (of which I am
> ignorant). I will have a look at that to see if I can write a native R
> version. It only has to do midi_in and midi_out, the rest can be left up
> to R. That will take me ages, but I can j
Hello,
I have problem with using color.
plot(data_min1$macd,col='black',main="1 min MACD",type="l")
lines(data_min1$macdsig,col="red")
par(new=T)
plot(data_min1$macdhist,col=data_min3$histcol,type="h",main="")
axis(4,col='black')
par(new=F)
When I remove ",col=data_min3$histcol"
Hello,
I'd like to draw 2 plots in one graph.
Here is my code:
plot(data_min1$macd,main="1 min MACD",type="l")
lines(data_min1$macdsig,col="red")
par(new=T)
plot(data_min1$macdhist,type="h",main="")
axis(4)
par(new=F)
It seems it works.
But left axes of two graphs are over-draw
Hi,
Try
which(!duplicated(c(3,4,1,2,1,1,2,3,5)))
#[1] 1 2 3 4 9
which(!duplicated(c(1,1,2,2,3,3,4,4)))
#[1] 1 3 5 7
A.K.
- Original Message -
From: Emmanuel Levy
To: R-help Mailing List
Cc:
Sent: Thursday, December 27, 2012 2:17 PM
Subject: [R] Retrieve indexes of the "first occurre
thanks again Mehmet - the midicsv utility is in C (of which I am ignorant).
I will have a look at that to see if I can write a native R version. It
only has to do midi_in and midi_out, the rest can be left up to R. That
will take me ages, but I can just use the utility externally for the moment
Gr
?duplicated will help.
M
On Dec 27, 2012, at 8:17 PM, Emmanuel Levy wrote:
> Hi,
>
> That sounds simple but I cannot think of a really fast way of getting
> the following:
>
> c(1,1,2,2,3,3,4,4) would give c(1,3,5,7)
>
> i.e., a function that returns the indexes of the first occurrences of
x <- c(1,1,2,2,3,3,4,4)
match(unique(x),x)
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.#. ##.#. Live Go...
Live: OO#.. De
Hi,
That sounds simple but I cannot think of a really fast way of getting
the following:
c(1,1,2,2,3,3,4,4) would give c(1,3,5,7)
i.e., a function that returns the indexes of the first occurrences of numbers.
Note that numbers may have any order e.g., c(3,4,1,2,1,1,2,3,5), can
be very large, a
Hello,
Your dataset is not in tabular form, so I find it difficult to transform
it into a data.frame, but you can see it in R with the following.
install.packages("RJSONIO", dependencies = TRUE)
library(RJSONIO)
url <-
"http://apistat.istat.it/?q=getdatajson&dataset=DCIS_POPSTRBIL&dim=1,0,0,0
> Can you please elaborate. What are the negatives about the method
Here are a few examples of eval(parse(text=paste())) failing:
> cvtest <- list("Test-1"=1, Bozo=2, "Joe's Test"=3)
>
> lambda.rule <- "Test-1"
> eval(parse(text=paste0("cvtest$", lambda.rule))) # want 1
[1] 0
>
> la
Hi,
thank you very much for your help, but I need something different.
For example, I wrote this code to highlight the standard deviation area
of each distribution
fn <- function(x, y, scale, scale2)
dnorm(x,mean=1,sd=scale)*dnorm(y,mean=-1,sd=scale) +
dnorm(x,mean=2,sd=scale2)*dnorm(y,mean=1,sd
Hi All,
I need to access the node informations (viz. child nodes, split variable,
split criterion etc.) for different trees packages like, CHAID, rpart,
party etc. Is there an in-built function which I can use to get the requied
info?
Thanks a lot in advance!!
Regards
Ashish Kumar
[[alt
Frank Harrell vanderbilt.edu> writes:
>
> Unlike L1 (lasso) regression or elastic net (mixture of L1 and L2), L2 norm
> regression (ridge regression) does not select variables. Selection of
> variables would not work properly, and it's unclear why you would want to
> omit "apparently" weak vari
Unlike L1 (lasso) regression or elastic net (mixture of L1 and L2), L2 norm
regression (ridge regression) does not select variables. Selection of
variables would not work properly, and it's unclear why you would want to
omit "apparently" weak variables anyway.
Frank
maths123 wrote
> I have a .txt
On 27 December 2012 08:46, Greg Hooper wrote:
> thanks Ben - hmm I think I will use a midi/csv utility
> http://www.fourmilab.ch/webtools/midicsv/ and see how that goes. Another
Hi Greg, Yes you are right, It is for wav analysis but as Ben
suggests. Conversion
should not be difficult. Also I thin
On 27 December 2012 08:46, Greg Hooper wrote:
> thanks Ben - hmm I think I will use a midi/csv utility
> http://www.fourmilab.ch/webtools/midicsv/ and see how that goes. Another
Hi Greg, Yes you are right, It is for wav analysis but as Ben
suggests. Conversion
should not be difficult. Also I thin
Hello to everybody,
I need to convert a json dataset in an R dataframe.
I suppose that I'd need to use rjson or rjsonio package.
The json dataset is:
http://apistat.istat.it/?q=getdatajson&dataset=DCIS_POPSTRBIL&dim=1,0,0,0&lang=1&tr=&te=
It would be nice if someone can help me to create a functio
it is also a fortune.
> fortune('parse')
If the answer is parse() you should usually rethink the question.
-- Thomas Lumley
R-help (February 2005)
On Thu, Dec 27, 2012 at 5:44 AM, Heramb Gadgil wrote:
> I am not sure why "Never ever!"
>
> Can you please elaborate. What are the negati
On 27.12.2012 13:04, Heramb Gadgil wrote:
Agreed.
But the initial question was to get the output with paste function. That is
the reason why I went for eval.
Please let me know in case I am going the wrong way
You solution is valid to answer the question. But the original poster
probably d
Agreed.
But the initial question was to get the output with paste function. That is
the reason why I went for eval.
Please let me know in case I am going the wrong way
On Thu, Dec 27, 2012 at 4:34 PM, Jessica Streicher wrote:
> Well for one, if ever someone looks at your code, cvtest[[lambda.r
On 26.12.2012 03:03, Pascal Oettli wrote:
Hello,
Did you contact the package maintainer?
Mark M. Fredrickson
There is also a webpage:
https://github.com/markmfredrickson/optmatch
Actually the function is private to the package, i.e. not exported from
the package's NAMESPACE.
Best,
Uwe
Well for one, if ever someone looks at your code, cvtest[[lambda.rule]] is much
easier to read and understand than
eval(parse(text=paste0("cvtest$",lambda.rule)))
On 27.12.2012, at 11:44, Heramb Gadgil wrote:
> I am not sure why "Never ever!"
>
> Can you please elaborate. What are the negative
I am not sure why "Never ever!"
Can you please elaborate. What are the negatives about the method
Warm Regards,
Heramb M. Gadgil
On Thu, Dec 27, 2012 at 3:50 PM, Uwe Ligges wrote:
>
>
> On 27.12.2012 08:09, Heramb Gadgil wrote:
>
>> eval(parse(text=paste0("**cvtest$",lambda.rule)))
>>
>
> No,
On 27.12.2012 08:09, Heramb Gadgil wrote:
eval(parse(text=paste0("cvtest$",lambda.rule)))
No, never ever!
There is an R idiom made for it:
cvtest[[lambda.rule]]
Uwe Ligges
I hope this works.
On Wed, Dec 19, 2012 at 12:57 AM, Thomas Stewart
wrote:
Soyeon-
A possible solution:
ge
Hi Jim,
Sorry, it fails.
Tx for catching.
asd1 <- as.Date(c("2012-01-03","2012-12-25","2012-01-12","2012-10-01"))
gsub("(.*/)0(.*/.*)","\\1\\2",gsub("^0(.*/.*/.*)","\\1",format(asd1,"%d/%m/%Y")))
#[1] "3/1/2012" "25/12/2012" "12/1/2012" "1/10/2012"
A.K.
- Original Message -
From
Man, if that medicine doesn't cure you of wanting to create dozens of different
objects in memory, I don't know what will. Let's see:
1) Creates a potentially large number of global objects with names unrelated to
their content
2) Creates and updates a global variable for future race condition d
53 matches
Mail list logo