similar to: help me avoid nested for() loops!

Displaying 20 results from an estimated 6000 matches similar to: "help me avoid nested for() loops!"

2011 Mar 08
4
minimum distance between line segments
Dear R helpers, I think that this may be a bit of a math question as the more I consider it, the harder it seems. I am trying to come up with a way to work out the minimum distance between line segments. For instance, consider 20 random line segments: x1 <- runif(20) y1 <- runif(20) x2 <- runif(20) y2 <- runif(20) plot(x1, y1, type = "n") segments(x1, y1, x2, y2)
2001 May 16
2
Strange formatting
I've never noticed this before, though it's probably not new. In 1.2.3 for Windows, if I print a short vector the formatting is different than if I print a long one, whether or not they fit on one line. The short/long split appears to be between 9 and 10 elements: > 1:9 [1] 1 2 3 4 5 6 7 8 9 > 1:10 [1] 1 2 3 4 5 6 7 8 9 10 > sqrt(1:9) [1] 1.000000 1.414214
2011 Feb 16
2
distance between consecutive points
Dear R users, I have two coloumns of data, say x and y, referring to a list of points in 2D space. I am trying to develop a code that will give me the distances (using Pythagoras) between consecutive points (xi,yi) and (xi+1,yi+1). So far I have come up with the following: for (i in 1:length(x)) d<-sqrt((x[i+1]-x[i])^2+(y[i+1]-y[i])^2) For example, if I use the two points (note, I have
2012 May 14
3
How to apply a function to a multidimensional array based on its indices
Hello. I have a 4 dimensional array and I want to fill in the slots with values which are a function of the inputs. Through searching the forums here I found that the function "outer" is helpful for 2x2 matrices but cannot be applied to general multidimensional arrays. Is there anything which can achieve, more efficiently than the following code, the job I want? K <-
2018 Mar 15
3
stats 'dist' euclidean distance calculation
Hello, I am working with a matrix of multilocus genotypes for ~180 individual snail samples, with substantial missing data. I am trying to calculate the pairwise genetic distance between individuals using the stats package 'dist' function, using euclidean distance. I took a subset of this dataset (3 samples x 3 loci) to test how euclidean distance is calculated: 3x3 subset used
2004 Aug 30
3
Multiple lapply get-around
I am faced with a situation wherein I have to use multiple lapply's. The pseudo-code could be approximated to something as below: For each X from i=1 to n For each Y based on j=1 to m For each F from 1 to f Do some calculation based on Fij Store Xi,Yj = Fij End For F End for Y End for X Is there anyway to optimize the processing logic further? I *guess* using the multiple lapply
2005 Aug 18
4
Driver for Powerware 3105 (USB)
I ordered some Powerware 3105 devices for Linux workstations. These devices only have an USB interface. I understood too late that support for Powerware devices is only available for the serial interface. Since the protocols over serial and USB seem to be identical, it was not too difficult to modify the bcmxcp driver to support USB. The new and changed files can be found here:
2009 May 13
4
matching period with perl regular expression
Hello, I have several strings where I am trying to eliminate the period and everything after the period, using a regular expression. However, I am having trouble getting this to work. > x = "wa.w" > gsub(x, "\..*", "", perl=TRUE) [1] "" Warning messages: 1: '\.' is an unrecognized escape in a character string 2: unrecognized escape removed
2007 Aug 16
1
Question on output of vectors from a for loop into a matrix
Hello R-help, I am a recent convert to R from SAS and I am having some difficulty with output of a for loop into a matrix. I have searched the help manuals and the archives, but I can't get my code to work. It is probably a syntax error that I am not spotting. I am trying to make a distance matrix by extracting the distances from each point to all others in a vector (the for loop). I can
2009 Jan 30
1
problem using identify() after plot()
I can't seem to use the point-and-click identify() function properly. I'm running R 2.5.1 (I know, I need to get around to upgrading) under Win XP. The problem is, when I click on a point on the graph, I get an error, "no point within 0.25 inches." But in some areas, I can click where there is no visible point anywhere close, and an identify() label will pop up. The troublesome
2006 Mar 12
5
AR - Migrations - how to use a varchar as primary key instead of int ?
Hi I''d like to have a varchar primary key named id instead of the default int id. Does anyone knows how to specify this from migrations ? Should I also specify something in the model class ? thanks! Thibaut -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060312/797bca4b/attachment.html
2004 Sep 22
3
loops: pasting indexes in variables names
I cannot figure out how, using R, I can paste indexes or characters to the variable names which are used within loops. I will explain this with a simple example: Immagine I have a huge series of variables, each one taken two times, say x1 x2 y1 y2 z1 z2..... Now, immagine that I want to compute a variable from the difference of each couple, say dx=x1-x2, dy=y1-y2, dz=z1-z2... In Stata, for
2010 Aug 09
5
Drawing problem in Wine 1.3.0
Hi, I'm having a problem with black boxes and black widgets appearing in Wine programs. See these two screenshots[0], [1] for examples. One program is a Windows application, but the other is Winecfg. Any clues what is wrong here? This is Wine 1.3.0 compiled on Debian squeeze. Thanks, Andrew Barr [0] http://img843.imageshack.us/img843/5373/screenshotho.png [1]
2008 Sep 09
2
isolate elements in vector that match one of many possible values
Hi all, I want to get the index numbers of all elements of a vector which match any of a long series of possible values. Say x <- c(1,2,3,4) and I want to know which values are equal to 1, 2 or 4. I could do which(x == 1 | x==2 | x==4) [1] 1 2 4 This gets really ugly though, when the list of values of interest is really long. Is there a nicer way to do this? Something akin to the MySQL
2010 Oct 06
3
Assigning value to a vector from within a function
Hi all, I am having trouble assigning a value within a vector using a variable defined within a function. I suspect this has something to do with namespaces but I cannot figure it out. Please reply directly to me if you can help. ###begin code #simple vector test<-c(4,5,6) #simple function to get a value from a vector #works just like I would expect, has no problem indexing using the local
2005 Oct 09
3
bcmxcp - Powerware 9125
I'm currently testing the bcmxcp driver for NUT, and it causes me some trouble. And when scanning the archives it seems like the 3110 USB problem reported recently. The bcmxcp daemon stops running, and the logs shows the following: Oct 6 14:22:32 host.dom.tld bcmxcp[82628]: Communications with UPS lost: Receive error (data): got -1 bytes instead of 28!!! Oct 6 14:22:33 host.dom.tld
2005 Mar 19
2
System-wide multiuser Wine installation
Hi. I was wondering if it is possible to do a Wine installation and installation of Windows applications where the applications are accessible to all users (or better yet, users in a certain group like "win32" or "wine")? I read in the most recent edition (March 18, 2005) of the Wine Weekly News that the global registry functionality had been removed. Is this necessary to have
2006 Feb 09
3
Rail in teaching environments
Newbie question (just joined the list) Is anyone running Ruby on Rails in a teaching environment? Regards John John Colby BA, MBCS, PGCertE Lecturer, Department of Computing, The Business School Room F316, Galton Building, University of Central England, Franchise Street, Perry Barr, Birmingham B42 2SU Tel: +44 (0) 121 331 6937, Fax +44 (0) 121 331 6281, Mobile: 07795 215 912
2008 May 29
6
SoundBlaster 16 removal impending
(Reply directly, as I''m not subscribed here.) As you may have seen, ARC recently approved my case to remove the ancient sbpro driver Solaris. I''m intent on doing that, because it really helps with our OSS integration effort, which I''m now leading. The problem is, will this impact qemu? I''m not sure of the answer. I *think* qemu emulates an older ESS1370
2008 May 29
6
SoundBlaster 16 removal impending
(Reply directly, as I''m not subscribed here.) As you may have seen, ARC recently approved my case to remove the ancient sbpro driver Solaris. I''m intent on doing that, because it really helps with our OSS integration effort, which I''m now leading. The problem is, will this impact qemu? I''m not sure of the answer. I *think* qemu emulates an older ESS1370