similar to: Speeding up a loop

Displaying 20 results from an estimated 4000 matches similar to: "Speeding up a loop"

2011 Jul 12
4
qplot and for loops
I have 4 columns and 56 rows of made up data that I want to plot as a series of bar graphs. The idea is to create one bar graph for each of the 4 columns using a for loop. I tried the following command in RStudio and when I type x in the console I get just the 4th graph instead of all four graphs. I did not define what x is before hand. I was not sure what it would be. Any suggestions on how you
2012 Jul 20
0
[External] Re: Speeding up a loop
"Reith, William [USA]" <reith_william@bah.com> wrote on 07/20/2012 09:52:02 AM: > Would this matrix eat up memory making the rest of my program > slower? Each x needs to be multiplied by a matrix and the results > checked against a set of thresholds. Doing them one at a time takes > at least 24 hours right now. > > Optimizing a program is not my thing.
2011 Jun 23
3
trying to import xls or xlsx files
library(xlsReadWrite) mydata<-read.xls("file path", header=TRUE) however if I change xls to csv it works just fine. Any ideas what I'm doing wrong? I have have also using the package gdata with the exact same error. Below is the error that pops up. Error in findPerl(verbose = verbose) : perl executable not found. Use perl= argument to specify the correct path. Error in
2012 Oct 12
3
Autofilling a large matrix in R
I wish to create a matrix of all possible percentages with two decimal place percision. I then want each row to sum to 100%. I started with the code below with the intent to then subset the data based on the row sum. This works great for 2 or 3 columns, but if I try 4 or more columns the number of rows become to large. I would like to find a way to break it down into some kind of for loop, so
2011 Jun 06
2
qplot fill and colour not working as expected
I am just learning to use qplot and can't get the fill/colour to work. Below is the R code for a scatter plot and bar graph. library(ggplot2) x<-c(1,2,3,4,5,6,7) y<-c(1,2,3,2,5,6,3) qplot(x,y, main="Scatter Plot Test", xlab="X Label Test", ylab="Y Label Test", colour="blue")z<-c("van", "van", "van",
2011 May 04
1
Str info. Thanks for helping
It looks from str(SA) that Response IPS1 is a data.frame of class "anova", which probably cannot be coerced to vector. Maybe you can use unlist() instead of as.vector() Or something like SA[["Response IPS1"]]["as.factor(WSD)",] ## to select the first row only, even maybe with unlist() Without a better REPRODUCIBLE example, I cannot tell more (maybe some others
2012 Sep 07
4
Trying to learn how to write a function... can't define a variable??
I am just starting to experiment with writing a function and have run into what seems like a limitation or more likely a lack of understanding on my part. Very Simple Example: I want to define a function that does 1+1=2. z<-1 ADD<-function(x) { x<-x+1 } ADD(z) z output for z is 1 not the expected 2. Now if I were to do print(x+1) instead of x<-x+1 it does return 2, so the
2012 Sep 26
3
Removing duplicates without a for loop
I have several thousand rows of shipment data imported into R as a data frame, with two columns of particular interest, col 1 is the entry date, and col 2 is the tracking number (colname is REQ.NR). Tracking numbers should be unique but on occassion aren't because they get entered more than once. This creates two or more rows of with the same tracking number but different dates. I wrote a for
2012 Jul 23
2
Bug in my code (finding nonzero min)
Can someone verify for me if the for loop below is really calculating the nonzero min for each row of a matrix? I have a bug somewhere in the is section of code. My first guess is how I am find the the nonzero min of each row of my matrix. The overall idea is to make sure I am investing all of my money, i.e. new.set is a set of indicator variables for each stock for a particular portfolio, i.e.
2011 Jun 21
2
qplot/ggplot2 Questions
I took some data from an online poll about which R GUI people used most and I am messing around with it to learn how to use qplot. Specifically I am making a horizontal bar graph and I have two questions. 1. The categories are ordered in rather strange way at least to me. It is not alphabetical or ascending/descending order of votes cast so i had to manually state the order I wanted which is
2012 Aug 22
1
rbind in a loop with " : " elements
Dear Ruser, Below, the deal (you can copy paste): r=3 ; set.seed(1) v <- matrix(c(rnorm(40)),10,4) for (j in 1:4){ for (i in 1:r){ x <- t(v[,j]^(i)*v[,1:4]^((r-(4-1)):r)) print(x) } } How to reach to " x " " row bind " inside or outside (preferred) of the loop. To obtain at the end something like: > x matrix( , 12*4, 10) Any help or
2011 Jan 05
4
Match numeric vector against rows in a matrix?
Two posts in one day is not a good day...and this question seems like it should have an obvious answer: I have a matrix where rows are unique combinations of 1's and 0's: > combs=as.matrix(expand.grid(c(0,1),c(0,1))) > combs Var1 Var2 [1,] 0 0 [2,] 1 0 [3,] 0 1 [4,] 1 1 I want a single function that will give the row index containing an exact match
2012 Nov 18
1
identical matrices
Dear R users, I want to check matrices when i change the order of the rows or/and the order of the columns or/and the combination of them i will give an example what i want  1  -1  1  1      1  1   1  1 -1  -1 -1 -1    -1 -1  -1  -1   1  1    1  1     1 -1    1   1 these 2 matrices are identical because i change the first row and make it third   1  -1  1  1      -1  1   1  1 -1  -1 -1
2012 Aug 26
3
Two selections from Bag A
All, I am looking at an example in Aliaga's Interactive Statistics. Bag A has the following vouchers. BagA <- c(-1000,10,10,10,10,10,10, 10,20,20,20,20,20,20,30, 30,40,40,50,60) Bag B has the following vouchers. BagB <- c(10,20,30,30,40,40,50,50, 50,50,50,50,60,60,60,60, 60,60,60,1000) Two values are selected (from BagA or BagB) without
2008 Dec 11
3
generate combination multiset (set with repetition)
Hi, This has been asked before but not sufficiently answered from what I could find. How do you create combinations with repetitions (multisets) in R? If I have > set <- array(1:3) And I want to choose all combinations of picking 2 numbers, I want to get a print out like [,1] [,2] [1,] 1 1 [2,] 1 2 [3,] 1 3 [4,] 2 2 [5,] 2 3 [6,] 3 3 subsets(set,
2008 Sep 03
1
many correlations
I have one hundred and six independent variable that I would like to preform a correlation analysis on. Is there anyway to only get the values that are abolute value 0.6 or greater. thanks -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is
2012 Aug 31
7
splits with 0s in middle columns
Hi, A column of my df looks like A 10/20/30 40/20 60/10/10/5 80/10 I want to split it such that the last column has the last composition and if there are not enough the middle columns get the 0s. That way my df would look like A1 A2 A3 A4 10 20 0 30 40 0 0 20 60 10 10 5 80 0 0 10 How can I do that ?? [[alternative HTML version deleted]]
2011 Apr 27
2
Writing Macros for RExcel
I have columns of data in Excel 2007, A2:A196, B2:B196...ET2:ET196 that I would like to place into arrays in R. I have been trying to write a macro that would automatically create all of my arrays for me with a array names coming from the cells A1, B1, etc. I can manually create an array using RExcel<Put R Var< Array, but I don't want to manually create all 150 arrays this way. Thanks
2010 Jun 18
25
Erratic behavior on 24T zpool
Well, I''ve searched my brains out and I can''t seem to find a reason for this. I''m getting bad to medium performance with my new test storage device. I''ve got 24 1.5T disks with 2 SSDs configured as a zil log device. I''m using the Areca raid controller, the driver being arcmsr. Quad core AMD with 16 gig of RAM OpenSolaris upgraded to snv_134. The zpool
2011 Aug 02
3
3D Bar Graphs in ggplot2?
Does anyone know how to create a 3D Bargraph using ggplot2/qplot. I don't mean 3D as in x,y,z coordinates. Just a 2D bar graph with a 3D shaped bard. See attached excel file for an example. Before anyone asks I know that 3D looking bars don't add anything except "prettiness". http://r.789695.n4.nabble.com/file/n3713305/Example.xlsx Example.xlsx -- View this message in