Displaying 20 results from an estimated 246 matches for "inelegant".
2013 Feb 14
3
list of matrices --> array
..._list[[2]] <- matrix(20:1, ncol = 5)
now, knowing that these matrices are identical in dimension, i'd like
to unfold the list to a 2x4x5 (or some other permutation of the dim
sizes) array.
i know i can initialize the array, then loop through my_list to fill
the array, but somehow this seems inelegant.
i also know i can vectorize the matrices and unlist the list, then
build the array from that single vector, but this also seems inelegant
(and an easy place to introduce errors/bugs).
i can't seem to find any built-in that handles this already... but
maybe i just haven't looked hard enoug...
2003 Apr 02
19
Combining the components of a character vector
...", "Sally")
I want to combine it into a single string: "Bob loves Sally" .
paste(x) yields:
paste(x)
[1] "Bob" "loves" "Sally"
The following function combines the character vector into a string in the
way that I want, but it seems somewhat inelegant.
paste.vector <- function(x, ...) {
output <- NULL
for (i in 1:length(x)) output <- paste(output, x[i], ...)
output } #end of function definition
paste.vector(x)
[1] " Bob loves Sally"
Is there a more natural (no loop) way to do this in R?
John Miyamoto
------------------...
2002 Dec 12
4
sum a list of vectors
...#39;t find a way to sum a list of vectors of same length or list of matrices of the same dimension and was curious if something like that exists in R. do.call("+",list) doesn't work because "+" accepts only two arguments, I can obviously use loops but this is quite slow and inelegant.
Thanks,
Tsvetan
2008 Jan 20
3
Bugs through R in Mac
Hello,
I recently changed from Win XP to Mac OS X (10.5.1).
Is there a way to run Bugs (in any version) in R (R version 2.6.0
(2007-10-03)) on this platform?
Fredrik
2008 Sep 14
3
Using R from Java
Hello,
I am interesting in using R from a web application, for basic statistics and
plots. The server is Java-based (tomcat).
The simplest solution is a system call that generates the text or the image,
then the servlet forwards the output. This can be done from any language,
but it is quite inelegant and slow for the initialization time.
Is there any package or approach for accessing R from a Java servlet you can
suggest?
Thanks in advance for any suggestion.
Regards,
-Marzio
--
http://marzio.sala.googlepages.com
[[alternative HTML version deleted]]
2003 Aug 20
5
Interlacing two vectors
I want to interlace two vectors. This I can do:
> x <- 1:4
> z <- x+0.5
> as.vector(t(cbind(x,z)))
[1] 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5
but this seems rather inelegant. Any suggestions?
Murray
--
Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at waikato.ac.nz Fax 7 838 4155
Phone +64 7 838 4773 wk +64 7 849 6486 home M...
2003 Mar 31
4
Convert char vector to numeric table
...5 4.2"
" 19.1 2.2 4.1"
and so on. To get that into a 3 col numeric table, I first just used:
writeLines(data,"tempfile")
read.table("tempfile",col.names=c("A","B","C"))
Works fine, but writing to a temporary file seems ... inelegant? And read.table() doesn't take a char vector as a file or connection argument. The following works but it seems like a lot of code:
data <- sub(" +","",data) # remove leading blanks for strsplit
data <- strsplit(data," +") # strsplit returns a list...
2011 Mar 29
3
passing arguments via "..."
...of you who know R better than I do have already spotted that
"is.null(breaks)" just won't work. Neither does "exists" or "missing".
I can think of ways to do this involving new arguments with new names --
like "histbreaks" or something -- but that seems inelegant.
Is there a way to do what I am trying to do here?
Thanks.
2007 Jan 11
1
Matching on multiple columns
...o exclude about 10000 rows from 108000 rows of data based on
several unique combinations of identifiers in two columns. Only
merge() seems to be able to do that. Merge would allow me to
positively select but it would not allow me to deselect (or exclude).
Look at how I got around the problem.
It is inelegant. Have a missed a more direct function?
x<-seq(from=1,to=10)
y <-rep(1:2,5)
data<-data.frame(cbind(x,y))
x<-seq(from=1,to=10)
y <-rep(1:5,2)
data1<-data.frame(cbind(x,y))
newdata<-rbind(data,data1)
newdata[10,2] <- 3
exclude<-newdata[18:20,]
#This is a simulation of real...
2006 Nov 04
8
alternatives to script/runner?
...eory, but is
too slow to keep up with a large number of events in succession; I''m
suspecting that the bottleneck is that script/runner has a huge
startup cost.
One thing I thought of was to queue inotify events, and call
script/runner once a minute to clear the queue, but that seems a bit
inelegant - ideally, what I''d like to do is have a persistent process
that is aware of my rails models, and which I can just keep sending
events to and have it process them as they come in. Any thoughts on
strategies to accomplish this?
martin
2005 Jan 05
4
output from table() in matrix form
...it isn't
quite right because the default bins are 1:20 and I don't want the
zeroes.
The following is a little clunky:
R> x <- rbind(1:20,tabulate(c(1,1,1,1,2,20)))
R> x[,x[2,]>0]
[,1] [,2] [,3]
[1,] 1 2 20
[2,] 4 1 1
Is there a better way? It seems inelegant to coerce a character
vector back to integers,
but OTOH it's wasteful to have 20 bins when I only need 3. My real
application would have
maybe a dozen distinct (prime) integers in the range 2 up to about 1e4.
--
Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
European...
1999 Aug 02
2
zero replacement
...ometimes it's the simple things that are particularly frustrating,
especially late at night....
Can anyone suggest a simple means for replacing all of the zero values in a
matrix with NANs? I ended up writing an awk script to massage the input file,
which works, of course, but is rather an inelegant blunt instrument. I'd
prefer an R operation. I'm certain that I'm missing something obvious here....
--Mike
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Michael A. Camann mac24 at axe.humboldt.edu
Assistant Professor of Zoology Voice: 707-826-367...
2008 Apr 14
2
Plotting with exact axis limits
...ow I
would like to make a plot with the origin exactly on the bottom left.
Through trial and error, I have discovered that this padding is
approximately 3.8% of the axis length. That is,
plot( runif(100), ylim=c(.038,1), xlim=c(3.8,100))
gives the desired result. However, this seems like a rather inelegant hack.
Is there a "correct" way to do this?
Thank you!
Enrico
[[alternative HTML version deleted]]
2005 Apr 02
2
An exercise in the use of 'substitute'
...39;t been able to work out a clever way of using
substitute to get the first part. I would like to be able to call, e.g.
with(fm, xyplot(resid(.) ~ carb))
and get a plot of resid(fm) ~ Formaldehyde$carb
It is possible to do the first part by deparsing, substituting, and
parsing but that's inelegant. Can anyone suggest a more elegant method?
BTW, the example of an lm model is just for illustration. The actual
use I have in mind is for lme (now lmer) models. The plot method for
the lme class in the nlme package does something very similar to this.
2009 Mar 10
2
1.4.23 + Realtime Queues/Agents NOT via SIP
...t;In
Use" detection of making members of a Queue available or unavailable.
I've not yet figured out the best way to handle this. Currently I've got a
macro that is executed upon answer that Pauses the Queue Member, and
another hook in the hangup to Unpause the Queue Member. It's inelegant and
needs additional help with a cron job connected to Asterisk Manager to make
sure the paused status is appropriate.
I am making an outbound call to the PSTN, and I could dial it via SIP, but
in my tests, because this is not a device, Asterisk cannot determine if it
is on-hook or off-hook, and t...
2010 Feb 05
2
[LLVMdev] Basic block with two return instructions
Fair enough. In that case, is there an elegant way to test whether a
basic block already has a terminator instruction?
(I can think of several ways to do it in the front-end, but all of
them are fairly inelegant. The problem I'm trying to solve is things
like 'a return instruction needs to be added to the end of a function,
if and only if the programmer didn't already end the function with an
explicit return statement', 'if the programmer did write an explicit
return statement everythin...
2017 Sep 28
3
building random matrices from vectors of random parameters
...to construct separate
matrices, with each matrix in the series using the 'next random
parameter value'. While the following works (for generating, say, 5 such
random matrices)
replicate(5,matrix(c(0,rnorm(1,0.8,0.1)*rnorm(1,1.2,0.1),rnorm(1,0.5,0.1),rnorm(1,0.8,0.1)),2,2,byrow=T))
its inelegant, and a real pain if the matrix gets large (say, 20 x 20).
I'm wondering if there is an easier way. I tried
> sa <- rnorm(5,0.8,0.1)
> so <- rnorm(5,0.5,0.1)
> m <- rnorm(5,1.2,0.1)
matrix(c(0,sa*m,so,sa),2,2,byrow=T)
but that only returns a single matrix, not 5 matrices...
2010 Jul 16
2
aggregate(...) with multiple functions
...2.
if i wanted to apply mean() to both columns, i would call:
aggregate(x, list(f), mean)
but to get the mean of col1 and the median of col2, i have to write
separate tapply calls, then wrap back into a data frame:
data.frame(tapply(x$col1, f, mean), tapply(x$col2, f, mean))
this is a somewhat inelegant solution for data frames with potentially
many columns.
what i would like is for aggregate to take a list of functions for
columns, something like:
aggregate(x, list(f), list(mean, median))
i'm just curious how others get around this limitation in aggregate().
do most simply make the indivi...
2007 Jan 14
3
ListCtrl help
...dgets book (which I
have access to online through safari)
I also don''t understand what I should be returning if the ListCtrl
requests more rows than I have data for... right now I''m returning "
" and ending up with blank lines in my table, but that seems rather
inelegant.
I''ll post / send some sample code for sorting / displaying from a
separate data source once I have it working and maybe you can add it
to the samples library.... I''d expect that being able to quickly whip
up a cross platform data viewer is a popular reason to use wxRuby....
2007 Mar 16
1
cumsum over varying column lengths
...urnsFromInception <- matrix(nrow = 1, ncol =
NCOL(historicalInceptionDates))
for (i in 1 : NCOL(historicalReturns))
{
cumReturn <- cumsum(historicalReturns[startOffset[1, i] : n, i])
returnsFromInception[1, i] <- cumReturn[length(cumReturn)]
}
This works for me, but seems rather inelegant, and I don't like having to
use a matrix for returnsFromInception and startOffset, where vectors would
work.
Thanks for your help.
Murali
_________________________________________________________________
It?s tax season, make sure to follow these few simple tips