Displaying 20 results from an estimated 10000 matches similar to: "count of factors"
1999 Sep 02
1
trouble with the 'exclude' parameter of factor() (PR#265)
Full_Name: Laurent Gautier
Version: 0.65.0
OS: Irix 6.5
Submission from: (NULL) (195.110.4.98)
the following doesn't give what I expect
> test _ factor(ORGMORE[[1]],exclude=c(NA,"NOM"))
Warning message:
NAs introduced by coercion
> levels(test)
[1] "CYT" "EXC" "MEM" "NOM" "NUC" "SEC"
while this works...
>
1999 Jul 28
1
problem to install R-0.64.2 on mips-sgi-irix6.4
Dear all,
I hope the following problem haven't been discussed here recently (I
could not find anything about it the help archive files) :
I tried to compile R-0.64.2 from the source files without much
success...
the last lines from the output of the ./configure command were :
----------------------------------------------------------
R is now configured for mips-sgi-irix6.4
Source
2018 May 03
4
adding overall constraint in optim()
Hi ?
This is giving me a headache. I?m trying to do a relatively simple optimization ? actually trying to approximate the output from the Excel Solver function but at roughly 1000x the speed. ?
The optimization parameters look like this. The only trouble is that I want to add a constraint that sum(wgt.vect)=1, and I can?t figure out how to do that in optim.
Mo.vect <-
2006 Sep 04
3
Subsetting vectors based on condition
Hello,
I have a question regarding subsetting of vectors. Here's an example of
what I'm trying to do:
vect.1 <- c(76,195, 290, 380)
vect.2 <- c(63, 95, 133, 170, 215, 253, 285, 299, 325, 375)
I would like to subset vect.2 so that it has the same length as vect.1,
and its numbers are the first corresponging higher value compared to
vect.1.
The output should be:
final.output =
2008 Jun 09
1
Cross-validation in R
Folks; I am having a problem with the cv.glm and would appreciate someone
shedding some light here. It seems obvious but I cannot get it. I did read
the manual, but I could not get more insight. This is a database containing
3363 records and I am trying a cross-validation to understand the process.
When using the cv.glm, code below, I get mean of perr1 of 0.2336 and SD of
0.000139. When using a
2012 Dec 11
1
Rprof causing R to crash
I'm trying to use Rprof() to identify bottlenecks and speed up a particullary
slow section of code which reads in a portion of a tif file and compares
each of the values to values of predictors used for model fitting. I've
written up an example that anyone can run. Generally temp would be a
section of a tif read into a data.frame and used later for other processing.
The first portion
2018 May 06
1
adding overall constraint in optim()
Hi Michael,
A few comments
1. To add the constraint sum(wgt.vect=1) you would use the method of
Lagrange multipliers.
What this means is that in addition to the w_i (the components of the
weight variables) you would add an additional variable, call it lambda.
Then you would modify your optim.fun() function to add the term
lambda * (sum(wgt.vect - 1)
2. Are you sure that you have defined
2018 May 03
0
adding overall constraint in optim()
You can't -- at least as I read the docs for ?optim (but I'm pretty
ignorant about this, so maybe there's a way to tweak it so you can).
See here: https://cran.r-project.org/web/views/Optimization.html
for other R optimization capabilities.
Also, given your credentials, the r-sig-finance list might be a
better place for you to post your query.
Cheers,
Bert
Bert Gunter
2018 May 03
2
adding overall constraint in optim()
Thanks Bert. But everyone on that forum wants to use finance tools rather than general optimization stuff! And I am not optimizing a traditional Markowitz mean-variance problem. Plus, smarter people here. :-)
> On May 3, 2018, at 3:01 PM, Bert Gunter <bgunter.4567 at gmail.com> wrote:
>
> You can't -- at least as I read the docs for ?optim (but I'm pretty
> ignorant
2018 May 04
0
adding overall constraint in optim()
On Thu, May 3, 2018 at 2:03 PM, Michael Ashton
<m.ashton at enduringinvestments.com> wrote:
> Thanks Bert. But everyone on that forum wants to use finance tools rather than general optimization stuff! And I am not optimizing a traditional Markowitz mean-variance problem. Plus, smarter people here. :-)
>
I'm very confused by these statements. Most of the "finance tools"
2003 Nov 14
7
Vector indices and minus sign
Hi,
I got caught out by this behaviour in 1.8.0 and I wondered why this
happens:
I have a list of vectors and was using lapply and grep to remove
matched elements that occur in only a subset of the elements of the
list:
locs <- lapply(locs, function(x){x[- grep("^x", x)]})
The problem is that where the grep finds no matches and hence returns a
vector of length 0, all the
2009 Apr 16
2
error bars in matplot
Hi,
I was trying to get error bars in my matplot. I looked at an earlier thread, and the sample code that I made is:
#------------------
library(plotrix)
mat1 <- matrix(sample(1:30,10),nrow=5,ncol=2)
ses <- matrix(sample(1:3,10,replace=T),nrow=5,ncol=2)
vect <- seq(20,100,20)
rownames(mat1) <- rownames(ses) <- vect
colnames(mat1) <- colnames(ses) <- letters[1:2]
2009 Aug 04
2
can a key of a list be a variable
Hi,
I search a solution to record data in dynamic structures in R.
I have an algorithm that will be executed each step and whose output is an
array of doubles with unknown size.
The solution I found is to use lists
1) I initialise my list
l <- list()
2) and at a step numbered i I conacatain the new tab to the list
vect <- algorithm()
l <<--c( l , list(stepi=vect))
The problem is
2007 Aug 10
2
need help to manipulate function and time interval
Hi R-users,
I have to define a noise level function L and its energy in the various
moment of the day by:
if time is between 18:00:00 and 23:59:59 then L[j] <- L[j]+5 and W <-
10^((L+5)/10)
if time is between 22:00:00 and 05:59:59 ==> L <- L+10 and W <-
10^((L+10)/10)
else
L=L and W = W
Could someone help me to realize this function please? You will find my
following
1999 Nov 30
1
Character2function
If I have several character vectors, for example:
a_c('data.')
b_c('_myfunction(')
c_c('vect.')
d_c(')')
and, j_1
I can build a vector using paste:
x_paste(a,j,b,c,j,d,sep="")
x="data.1_myfunction(vect.1)"
I have n numeric vectors (vect.1...vect.n)
Then, if I could evaluate the string x, I would calculate the
result of my function in
2019 Nov 30
2
Inconsistent behavior for the C AP's R_ParseVector() ?
Hi again,
Beside R_ParseVector()'s possible inconsistent behavior, R's handling of
zero-length named elements does not seem consistent either:
```
> lst <- list()
> lst[[""]] <- 1
> names(lst)
[1] ""
> list("" = 1)
Error: attempt to use zero-length variable name
```
Should the parser be made to accept as valid what is otherwise possible
2019 Dec 14
2
Inconsistent behavior for the C AP's R_ParseVector() ?
Le lun. 9 d?c. 2019 ? 09:57, Tomas Kalibera <tomas.kalibera at gmail.com> a
?crit :
> On 12/9/19 2:54 PM, Laurent Gautier wrote:
>
>
>
> Le lun. 9 d?c. 2019 ? 05:43, Tomas Kalibera <tomas.kalibera at gmail.com> a
> ?crit :
>
>> On 12/7/19 10:32 PM, Laurent Gautier wrote:
>>
>> Thanks for the quick response Tomas.
>>
>> The same error
2001 Oct 30
2
extracting object names as strings
Hi,
I'm looking for a function which returns the name of the argument
object as a string:
>vect <- 1:3
>function(vect)
"vect"
I've looked at 'name', 'names', 'objects', none seem to do exactly what I
want. ls/objects comes close, but I can't figure out how to force it to
give me only one object name.
daver
2019 Dec 07
2
Inconsistent behavior for the C AP's R_ParseVector() ?
Thanks for the quick response Tomas.
The same error is indeed happening when trying to have a zero-length
variable name in an environment. The surprising bit is then "why is this
happening during parsing" (that is why are variables assigned to an
environment) ?
We are otherwise aware that the error is not occurring in the R console,
but can be traced to a call to R_ParseVector() in
2001 Dec 31
2
Extracting/setting elements from/in a matrix/array
Dear all,
I had to extracts/set elements from/in a matrix. Let say I have two
vectors dim1 and dim2 of indices in the respective two dimensions of a
matrix: I want to extract all the corresponding elements. I the case of a
nxn matrix, dim1 <- 1:n and dim2 <- 1:n would extract the diagonal.
I know one way would be to use the functions 'row' and 'col', but the
matrixes I