Displaying 20 results from an estimated 3825 matches for "elegance".
2005 Jul 26
4
elegant solution to transform vector into percentages?
Hi,
I am looking for an elegant way to transform a vector into percentages of values
that meet certain criteria.
store<-c(1,1.4,3,1.1,0.3,0.6,4,5)
# now I want to get the precentages of values
# that fall into the categories <=M , >M & <=N , >N
# let
M <-.8
N <- 1.2
# In my real example I have many more of these cutoff-points
# What I did is:
out <- matrix(NA,1,3)
2008 Mar 02
3
elegant way to minus on each row of a matrix
How to do this in an elegant way formatrix/data frame/zoo?
mat=
1 2 3
4 5 6
7 8 9
vector=
1
2
3
result=
0 1 2
2 3 4
4 5 6
ie
1-1 2-1 3-1
4-2 5-2 6-2
7-3 8-3 9-3
Thanks in advance.
_________________________________________________________________
08
[[alternative HTML version deleted]]
2005 May 26
5
a more elegant approach to getting the majority level
Hi, I have a factor and I would like to find the most frequent level.
I think my current approach is a bit long winded and I was wondering if
there was a more elegant way to do it:
x <- factor(sample(1:0, 5,replace=TRUE))
levels(x)[ which( as.logical((table(x) == max(table(x)))) == TRUE ) ]
(The length of x will always be an odd number, so I wont get a tie in
max())
Thanks,
2008 Mar 22
2
More elegant multiplication or division of a data frame with a vector
Hello,
I am importing some raw voltage multichannel measurements into an R
data frame. I need to scale each column with the respective
sensitivity for that channel. I figured how to do it, but I am curious
if there isn't a more elegant way.
Now I start with something like this:
rawdata <- data.frame(rbind(c(1,2,3), c(4,5,6)))
sens <- c(2,4,6)
and I do this:
data <-
2006 Jan 15
6
Saving one-many associations (elegant solution please)
What is the most elegant way to save new one-many associations?
order = Order.new(:name => "My Order")
order.line_items << LineItem.new(:product_id => 1, :quantity => 2)
order.line_items << LineItem.new(:product_id => 2, :quantity => 5)
order.save
The above - which is by far the most elegant way of putting it - doesn''t
work for me - the line_items
2004 Jul 28
6
elegant matrix creation
Hello everybody.
I am trying to reproduce a particular matrix in an elegant way. If I
have
jj1 <-
structure(c(1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,
3,1,2,3,1,2,3,1,2,3,2,3,1,2,3,1,2,3,1,2,3,
1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,3,1,2,3,1,
2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,
2),.Dim = as.integer(c(9,9)))
[ image(jj1) is good here ] then I can get this with
2012 Mar 16
2
Elegant Code
Hi,
Can anyone help to write a more elegant version of my code? I am sure
this can be put into a loop but I am having trouble creating the
objects b1,b2,b3,...,etc.
b1 <- rigamma(50,1,1)
theta1 <- rgamma(50,0.5,(1/b1))
sim1 <- rpois(50,theta1)
b2 <- rigamma(50,1,1)
theta2 <- rgamma(50,0.5,(1/b2))
sim2 <- rpois(50,theta2)
b3 <- rigamma(50,1,1)
theta3 <-
2007 May 29
1
Modal Window Stealing Elements from Form. Need Elegant Solution.
I''m using Prototype.js with Control.modal to create a modal window on
my IPB Forum which takes all the various topic posting/replying/
editing options and places them into a Modal window.
The inherent nature of this action is to take the contents of whatever
DIV I told Control.Modal to make a modal window out of and place the
entire innerHTML of that DIV into a separate DIV outside the
2013 Jan 07
2
how to aggregate T-test result in an elegant way?
Dear all:
Plan 1:
I want to do serval t-test means for different variables in a loop ,
so I want to add all results to an object then dump() them to an
text. But I don't know how to append T-test result to the object?
I have already plot the barplot and I want to know an elegant way to
report raw result.
Can anybody give me some pieces of advice?
Yao He
?????????????????????????
Master
2010 Jul 29
2
Replace last element in a vector - elegant solution?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi
I have to replace the last element of a vector with 0, but the length of
x is not known at coding time. So I do the following:
x <- 1:10
x
x[length(x)] <- 0
x
it is working nicely, but I am wondering: is there a more elegant
solution( like tail(x, 1) <- 0 , which does not work)?
Thanks,
Rainer
- --
Rainer M. Krug, PhD (Conservation
2012 Nov 01
3
Start R from bash/bat file and end in interactive mode
I have a r-script (rook.R) that starts a Rook server. To present users
from having to start R and type in source("rook.R"), I want to create
a bash script and bat file that starts R and sources the script.
However, to keep the Rook server running R should not close after
running the script and stay in interactive mode. This proves more
difficult than expected.
I tried various
2008 Nov 20
2
Elegant way to transform dataframe?
Hello,
I have a dataframe with columns like:
parameter1 parameter2 metricname value
and I'd like to transform it into a dataframe with columns:
parameter1 parameter2 metric1 metric2 metric3
where the values for each metric would be in the appropriate column. There are often multiple values for a given (parameter1, parameter2, metricname) triple. In this case, I want to use the
2011 Sep 08
2
The elegant way to test if a number is a whole number
Hi,
x <- 0.2*5
is.integer(x)
gives me FALSE because R stores it as a float number, right?
Is there an elegant way to work around that problem? Right now
I'm using
x <- 0.2*5
round(x) == x
which returns TRUE. But more strictly I should use all.equal(),
right?
I somehow just don't like the--pardon--ugliness of those pieces
of code. Maybe there is a beautiful
2003 Nov 10
10
shuffling a vector
Hi,
I'me trying to write a function that will shuffle a vector. At the
moment I'm baically making a vector of randomized indices and then
making a new vector from the original one using these random indices.
However, is there an alternative (more elegant) method to do this? I
tried help.search('shuffle') but it does'nt return anything relevant.
Thanks,
2006 Jan 26
2
elegant way of re-encoding?
hi,
I have a single stream going to my icecast server, encoded in hi-quality
ogg. goal is to serve hi- and low quality ogg and mp3 streams,
re-encoded from the single hi-quality ogg stream.
encoding all from e.g. oddcast simultaniously is not an option.
it would be easier if source-streams would be static and always named
the same .. unfortunately they are not. if so, I could define simple
2005 Dec 28
1
making has_and_belongs_to_many save more elegant
When a user creates a post I also want to save all the tags
associated with it. I do that in the post_controller like this
presently:
def save
@post = Post.new(@params[:post])
@tags = Tag.new(@params[:tags])
@post.user_id = session[:id]
if @post.save
@tags.title.split('','').each do |tag|
present_tag = Tag.find_by_title(tag.strip)
present_tag =
2009 Nov 30
2
Ggplot2: Elegant Graphics for Data Analysis (Use R) (2009 Paperback)
Is this book worth its dollar? If so, why?, if not, why not?
Cheers.
--
View this message in context: http://n4.nabble.com/Ggplot2-Elegant-Graphics-for-Data-Analysis-Use-R-2009-Paperback-tp931702p931702.html
Sent from the R help mailing list archive at Nabble.com.
2008 Aug 18
1
seq: specify *minimum* end value, more elegant solution
Hello,
Using seq, I would like to specify a minumum end value, rather than a maximum end value. For example, rather than
> seq(from=0, to=10, by=4)
[1] 0 4 8
I would like to obtain
[1] 0 4 8 12
I can do that with
> by.value = 4
> seq(from=0,by=by.value,to=ceiling(10 / by.value)*by.value)
[1] 0 4 8 12
That seems like a somewhat clunky solution, though, and requires an additional
2006 Feb 28
2
Elegant way to express residual calculation in R?
Hi All,
I am illustrating a simple, two-way ANOVA using the following data and I'm
having difficulty in expressing the predicted values succinctly in R.
X<- data.frame(read.table(textConnection("
Machine.1 Machine.2 Machine.3
53 61 51
47 55 51
46 52 49
50
2011 Apr 18
3
guitar pro 5.2 runs of out of gdi handles
On both wine 1.3.15 and 1.3.17, guitar pro 5.2 has a tendency to crash
after a while. Wine gives the error message that it ran out of gdi
handles and expect crashes.
Trigger unknown.