similar to: Neat conditional assignment

Displaying 20 results from an estimated 20000 matches similar to: "Neat conditional assignment"

2009 Jan 30
2
reshape with two time variables
I have a data frame in wide format that I'd like to convert to long format. For example, in wide format I have: id A1B1 A1B2 A2B1 A2B2 1 1 400 475 420 510 2 2 390 500 470 472 3 3 428 512 555 610 4 4 703 787 801 822 5 5 611 634 721 705 6 6 543 522 612 788 7 7 411 488 506 623 8 8 654 644 711 795 A is one repeated-measures variable with levels 1 and 2. B is a second repeated-measures variable
2006 May 03
2
Conditional statement style
This is a bit of a nuby question methinks but i''ve had a play/search around and it''s just bugging me now :0) Say I have a conditional statement, testing a variable against a number of values. The first way i did this is like so: if myvar != "" and myvar != 0 and myvar != nil # .. code end This seems a bit messy - is there neater way of doing this? I thought of:
2009 Oct 25
4
Multiple line commands in R scripting
I'm wondering whether there is a character to let R know to expect more input for a command on subsequent lines. Here is an example: test_1.R: x <- c(1,2,3,4) / c(1,2,3,4) x R CMD BATCh test_1.R produces test_1.Rout: > x <- c(1,2,3,4) > / c(1,2,3,4) Error: unexpected '/' in " /" Execution halted test_2.R: x <- c(1,2,3,4) / c(1,2,3,4) x R CMD
2005 Jan 24
2
using eval() with pre-built expression inside function
I'm trying to evaluate a pre-built expression using eval(), e.g. dataset <- data.frame(y = runif(30, 50,100), x = gl(5, 6)) # one like this mf <- expression(model.frame(y~x)) eval(mf, dataset, parent.frame()) # rather than this eval(expression(model.frame(y~x)), dataset, parent.frame()) In the example above there is no problem, the problem comes when I try to do a similar thing
2005 Oct 23
12
Showing a neat error message
Hi All, I''m trying to prevent users from deleting a folder that has contents like this: class Folder < ActiveRecord::Base has_many :myfiles has_many :folders belongs_to :folder validates_uniqueness_of :name, :scope => "folder_id" before_destroy :dont_destroy_folder_with_contents def dont_destroy_folder_with_contents if Folder.find(id) != nil ||
2011 Apr 18
1
Print out data frames into neat images
Hi Group, I often need to print out data frames with results of analysis into a neat little image to copy and paste into documents. I need apply formatting like bold, currency signs, number formats, header shading etc. I currently output the data into csv and format using good old excel. Any suggestions if there are packages to help with such activities (to some level of basic functionality). I
2005 Jan 31
1
A neat "hot seating" mplementation
Has anyone implemented "hot seating" in any neat way? This where people can log in to any phone in the company and have their calls/voicemail come to that particular handset.....
2005 Jan 11
5
Problem starting Shorewall using Bridge configuration
Hi I have recently reconfigured my system to a Bridge based architecture on the basis that I have an ADSL Modem/Router with a Public address on the Wan side and a Private address on the Lan side. I am running a Debian based system kernel 2.6.7 and the Bridging software is installed and working correctly, including startup etc. The problem that I have is in "shorewall start" The
2004 Oct 19
2
Slope of surface
Hi, Is there a neat way of working out the slope of a flat surface in R? Given (x,y,z) co-ordinates of the four corners of a square, is there a function which will allow me to calculate the "mean" slope of the surface in a given direction? Thanks in advance.. Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44
2013 Feb 12
7
Is there a neat R trick for this?
Hello all, given two vectors X and Y I'd like to receive a vector Z which contains, for each element of X, the index of the corresponding element in Y (or NA if that element isn't in Y). Example: x <- c(4,5,6) y <- c(10,1,5,12,4,13,14) z <- findIndexIn(x, y) z [1] 5 3 NA 1st element of z is 5, because the 1st element of x is at the 5th position in y 2nd element of z is 3,
2008 Feb 28
1
Plotting Dendrogram Help Getting Plot to Display Neatly
I have done a cluster analysis doing: 1-clusNorth <-hclust(dist(Artorious)^2, method="ward") 2-clusNorth$labels <-Artorious$Name ## to show the case names and not numbers 3-dend1 <- as.dendrogram(clusNorth) 4-plot(dend1) My Dendrogram is now showing the names of my cases in the dataframe on the x axis 1 OMNICELL INC COM 2 GETTY IMAGES INC
2006 Nov 23
2
Conditional queries
Hi. I''m attempting to return a result set which filters Pages by their active state and their start/end date. Whilst the code I have at the moment is doing this without problem, some of the Page items may not have an end date set and I can''t see a way of conditionally doing the query so these are not excluded. Perhaps showing some code will help explain better;
2010 Oct 05
3
Question about assigning values in a matrix, conditional on column first row; how to do the loop.
Hello, I?m new at programming and I will greatly appreciate if you can help me with this. I have a very large matrix (hundreds of rows and columns), with the first raw filled with different numbers (between 0 and 1). The rest of the matrix is filled with values 0, 1, 2. What I need is to replace the values in the matrix (except the first row will has to remain intact). In each column I have to
2007 Nov 17
2
Getting Annual (Conditional) Averages
Hello, I'm very new to R, and so my question is simple. I have data record with 80 years of daily temperatures in one long string. The dates are also recorded, in YYMMDD format. I'd like to learn an elegant simple way to pull out the annual averages. (Obviously, every 4th year has 366 days.) I know I can set up a formal loop to create annual records and then average. But R
2013 Oct 21
4
Strange behaviour with ActiveRecord has_many collections, Rails 4 compared to Rails 3
Hi All, I have been told to post discussion based topic on here instead of the GitHub Issues. I thought this ''could'' be a bug, but just need some clarification really. The issue I posted is here <https://github.com/rails/rails/issues/12597>, does anyone have any thoughts? Again: https://github.com/rails/rails/issues/12597 Thanks a lot. -- You received this message
2018 Apr 30
1
Overlay line on a bar plot - multiple axis
Hi Miluji, Using Jim's interpretation of your desired graph, you could do it in ggplot2 using your dat DF by: ggplot() + geom_bar(data=dat, aes(x=week,y=count,fill=city),stat="identity",position="dodge") + coord_flip() + geom_line(data=dat, aes(x=week, y=mean_tmin)) There would still need some work to be done to get the weekly mean into a legend, but it is
2006 Dec 24
1
RE: Question regarding Split Access description (Adam Neat)
IMHO, i believe that it would be more realistic to have one router providing load balancing/dead gateway to one/several subnet(s). otherwise, each server/user would have to do their own load balancing for each subnet! that, or you would need 3 routers, one for each subnet and a linux router doing the load balancing in the middle. with 3 routers, the load balancing configurations
2008 May 22
1
plot 7 * 3 matrix on DIN A4 pdf
Hello, I want to plot 21 scatter plots in a 7*3 matrix on a single A4 page (using mfcol). Below is an example, which -by and large- looks very close to the desired result. But I do not get it to fill out the whole page. If I specify the a different page size, the plots still do not fill out the whole page. Anybody an idea what to do? Maybe adjusting indvidiual plot size (if so, how?). Or is there
2010 Oct 01
2
element wise conditional assignment in r
Hi, I am looking for a one-liner code for the following situation say I have a vector r of 0 and 1's, and another vector v of equal length. I want to assign v[i]-1 to v[i] if r[i]=1, for all i. How would I do that using mapply or any other batch processing keywords? thanks. John -- View this message in context:
2010 Mar 16
2
Conditional variable assignment
Hi everyone, Once again I am stuck with a problem I can't seem to figure out. I suppose this learning curve levels off eventually, lol. I am learning on my own with absolutely no background in programming, so if I seem to request help a lot it's not because I am seeking others to do the work for me. I need to assign one of two arrival times to the 'ARRIVE' variable of my