similar to: NOT-SO-SIMPLE function!

Displaying 20 results from an estimated 10000 matches similar to: "NOT-SO-SIMPLE function!"

2008 May 27
4
help with simple function
I have a matrix of frequency counts from 0-160. x<-as.matrix(c(0,1,0,0,1,0,0,0,1,0,0,0,0,1)) I would like to apply a function creating a new column (x[,2])containing values equal to: a) log(x[m,1]) if x[m,1] > 0; and b) for all x[m,1]= 0, log(next x[m,1] > 0 / count of preceding zero values +1) for example, x[1,2] should equal log(x[2,1]/2) = log(1/2) = -0.6931472 whereas x[3,2] should
2015 Mar 10
3
como hacer una operacion con data.table
estimados, siempre habia usado data.frame, pero estoy tratando de aprender a usar data.table porque normalmente tengo que manejar una buena cantidad de datos ahora necesito hacer un calculo simple, para el que antes usaba ciclos FOR, pero quiero aprovechar las ventajas de data.table mi preguna es como podria calcular, por ejemplo, la columna 2 de un data.table llamada DT si el valor de la
2015 Mar 12
2
como hacer una operacion con data.table
Par evitar el warning.... > DT=data.table(col1=1:10) > DT[,col2:=diff(log(c(1,col1)))] > DT col1 col2 1: 1 0.0000000 2: 2 0.6931472 3: 3 0.4054651 4: 4 0.2876821 5: 5 0.2231436 6: 6 0.1823216 7: 7 0.1541507 8: 8 0.1335314 9: 9 0.1177830 10: 10 0.1053605 > ----- Mensaje original ----- De: "Carlos Ortega" <cof en
2010 Jan 18
2
function to set log(0)=0 not working on tables or vectors
There must be a very basic thing I am not getting... I'm working with some entropy functions and the convention is to use log(0)=0. So I wrote a function: llog<-function(x){ if (x ==0) 0 else log(x) } which seems to work fine for individual numbers e.g. >llog(0/2) [1] 0 but if I try whole vectors or tables: p<-c(4,3,1,0) q<-c(2,2,2,2) llog(p/q) I get this: [1] 0.6931472
2007 Jan 18
4
How to optimize this loop ?
Dear R Users, I request your help to optimize a loop. Given a series of observations, I want to know how many consecutive past observations are below the last one. e.g : my_series <- c(3, 4, 10,14,8,3,4,6,9) As the last number (9) is higher than the four preceding numbers (6, 4, 3, 8), this function should return 4. my_series <- c(3, 4, 10,14,8,3,4,11,9) Here, it should return 0, as 9
2011 Oct 12
1
exclude columns with at least three consecutive zeros
Hi everyone, I have a large data set with about 3'000 columns and I would like to exclude all columns which include three or more consecutive zeros (see below example). A further issue is that it should just jump NA values if any. How can I do this? In the below example R should exclude column C and D (since in D jumping the NA leaves three consecutive zeros). I would appreciate
2012 Mar 08
3
Calculating length of consecutive sequences within a vector
Hi all, I have a nx1 logical array of zeros and ones and I want to calculate the individual lengths of all 1-consecutive sequences contained in it. Is there an easy quick way to do this in R? So, if I have a vector such as 111001101000011111110 I would like to get (1) 3, (2) 2, (3) 1, (4) 7 Any help would be appreciated! thanks! Jorge [[alternative HTML version deleted]]
2009 Nov 24
2
linear regression on groups of consecutive rows of a matrix
I want to perform linear regression on groups of consecutive rows--say 5 to 10 such--of two matrices. There are many such potential groups because the matrices have thousands of rows. The matrices are both of the form: > shp[1:5,16:20] SL495B SL004C SL005C SL005A SL017A -2649 1.06 0.56 NA NA NA -2648 0.97 0.57 NA NA NA -2647 0.46 0.30 NA NA
2008 Apr 29
1
Consecutive zeros in a vector
Suppose X is a long vector of integers (typically about 30000 elements). Is there an efficient way to detect whether there are at least N consecutive zeros in X, and if yes, where does this occur? for example, suppose X is: 1 2 3 4 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 4 2 0 1 2 0 0 0 2 2 2 2 2 ... and N is 10. I would like a foo(X, 10) to return something like c(6,19) (start and end positions in X
2012 Feb 13
1
entropy package: how to compute mutual information?
suppose I have two factor vectors: x <- as.factor(c("a","b","a","c","b","c")) y <- as.factor(c("b","a","a","c","c","b")) I can compute their entropies: entropy(table(x)) [1] 1.098612 using library(entropy) but it is not clear how to compute their mutual information
2008 Aug 28
2
sample consecutive integers efficiently
Hi all, I have some rough code to sample consecutive integers with length according to a vector of lengths #sample space (representing positions) pos<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) #sample lengths lengths<-c(2,3,2) From these two vectors I need a vector of sampled positions. the sampling is without replacement, making things tough as the sampled integers need
2010 Mar 12
6
Randomly sampling subsets of dataframe variable
Fellow R users, I am stumped on what would seem to be something fairly simple. I have a dataframe that has a variable named 'WEEK' that takes the numbers 1:26 (26 week time-period) with each number repeated five times consecutively (once for each weekday, Monday through Friday). Ex. 111112222233333.....2626262626. I would like to randomly extract two weekdays per five day week for
2009 Apr 03
10
btrfs for enterprise raid arrays
Dear all, While going through the archived mailing list and crawling along the wiki I didn''t find any clues if there would be any optimizations in Btrfs to make efficient use of functions and features that today exist on enterprise class storage arrays. One exception to that was the ssd option which I think can make a improvement on read and write IO''s however when attached to
2011 Oct 27
1
question R regarding consecutive numbers
Hi everyone Do you know about any possibility in R to check for consecutive numbers in vectors? That is, I do not only want to count the number of observations in total (which can be done table(x)), but I also want to count for instance how many times that vector contains a certain number consecutively. For example in the following vector x the number "1" appears 7 times.
2009 Nov 21
7
consecutive numbering of elements in a matrix
Within a very large matrix composed of a mix of values and NAs, e.g, matrix A: [,1] [,2] [,3] [1,] 1 NA NA [2,] 3 NA NA [3,] 3 10 17 [4,] 4 12 18 [5,] 6 16 19 [6,] 6 22 20 [7,] 5 11 NA I need to be able to consecutively number, in new columns, the non-NA values within each column (i.e. A[1,1] A[3,2] and A[3,3] would all be set to one, and
2008 Oct 06
2
Graphics window BUG
I thought this problem would be resolved when I switched to R version 2.7.0 (for Windows), but no - anytime I plot something that produces more than one page of graphics, the graphics window starts by showing the first page, until such time as I hit enter to show me the next page, at which time it speeds through every consecutive page and freezes on the last one. At this point the last page is
2010 Nov 13
1
truncate integers
Is there any really easy way to truncate integers with several consecutive digits without rounding and without converting from numeric to character (using strsplit, etc.)?? Something along these lines: e.g. = 456 truncfun(e.g., location=1) = 4 truncfun(e.g., location=1:2) = 45 truncfun(e.g., location=2:3) = 56 truncfun(e.g., location=3) = 6 It's one thing using floor(x/100) to get 4 or
2008 Sep 15
1
How to plot a matrix of intervals
Dear R-users, I have some nonstandard data set which I would like to plot but don't know how to do it in R. The data is in a matrix where the rows represent samples and the columns represent locations. The entries of the matrix are 0's and 1's, where 1 represents an event and 0 represents a non-event. e.g. aberrations <- matrix(rbinom(1000, 1, 0.8), nrow=20, ncol=50,
2008 Sep 13
1
How do I set up Steam?
I just set up Ubuntu Hardy Heron on my Compaq Presario C712nr laptop, and I was hoping that someone could help me to set up Steam so that it will fully function. I have previously tried this, yet was unable to get the Steam Community working properly with its chat functions and such. This was a real dealbreaker for me, as Steam Community is my primary social networking service. If anyone could
2009 May 28
1
Unable to load R
Dear all, I have recently installed R on a Red Hat Enterprise Linux (RHEL5) system. But I am unable to load R and it is giving the following error : */usr/local/lib/R/bin/exec/R: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory* I have checked for the presence of the above mention library and found that the library