search for: elegant

Displaying 20 results from an estimated 3827 matches for "elegant".

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...
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, ------------------------------------------------------------------- Rajarshi Guha...
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 <- as.data.frame(t(t(rawdata)/sens)) Any suggestions? Cheers, TL
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...
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 kronecker(m...
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)...
2007 May 29
1
Modal Window Stealing Elements from Form. Need Elegant Solution.
...DIV into a separate DIV outside the main content. This creates a problem where my elements are suddenly taken out of the form and when I click submit all the options are completely gone. We would like to use the modal since it makes the entire posting process that much nicer but again we need an elegant solution. The none elegant solution would be to write a script that creates hidden form elements based on the form elements'' values in the modal window but again I''d rather not go with bad code. Is it possible to force the modal window to not go out of it''s initial posi...
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 candidate in 2rd year Department of Animal genetics & breeding Room 436,College of Animial Science&Technology, China Agriculture University,Beijing,100193 E-mail: yao.h.1988 at gmai...
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 Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Mai...
2012 Nov 01
3
Start R from bash/bat file and end in interactive mode
...k.R Runs and quits I would have expected the --interactive parameter to do what I want, but it doesn't seem to do anything. What does work is to create a .Rprofile with sourc("rook.R") in it in the directory and then start R (just plain R). However I don't find this a very elegant solution. I could of create the .Rprofile file in the bash script which is somewhat better, but still not very elegant. I end up with the following bash script: #!/bin/bash echo "source(\"rook.R\")" > .Rprofile R Another, not very elegant, possible solution which I have...
2008 Nov 20
2
Elegant way to transform dataframe?
...e minimum value. A constant number of metrics is associated with each possible combination of parameters. I've cobbled together code that performs this using nested loops and far too many variables. The number of metrics has now gone up by an order of magnitude and I'm looking for a more elegant way of doing this. If anyone has a short bit of code that can deal with this, I'd really appreciate having a look. Thanks much, Barry
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 way to write that. If not,...
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, ------------------------------------------------------------------- Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1B...
2006 Jan 26
2
elegant way of re-encoding?
...scoder correctly ;) so, what I'm looking for is a way to re-encode every stream which is sent to the icecast server, as soon as it is started. this could be done with streamtranscoder and a looped bash script around, that looks if there is a source, if so it starts the re-encode. Is there an elegant way, better than a bash script? maybe a plugin for the icecast server itself? or, where to find out more about? kind regards, k
2005 Dec 28
1
making has_and_belongs_to_many save more elegant
...t; "home", :action => "index" else render :action => "new" end end Now I have a couple questions: 1) Is there an easier way to save both the tags and the post at the same time? 2) Do I need to do the push to save the join table or is there a more elegant way or automated way of doing this? 3) Does the fact that I have to check to see if tag already exist change things? Your feedback is greatly appreciated. I find my solution not that elegant and would love to find a new one. This is for my site http:// www.soen.info. Your Friend, John Kop...
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
...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 variable (by.value) that shows up three times. Is there a more elegant solution to this? Thanks! Tim
2006 Feb 28
2
Elegant way to express residual calculation in R?
...55 51 46 52 49 50 58 54 49 54 50" ), header=TRUE)) rownames(X)<- paste("Operator.", 1:nrow(X), sep="") print(X) # I'd like to know if there is a more elegant way to calculate the residuals # than the following, which seems to be rather a kludge. If you care to read # the code you'll see what I mean. machine.adjustment<- colMeans(X) - mean(mean(X)) # length(machine.adjustment)==3 operator.adjustment<- rowMeans(X) - mean(me...
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.