search for: substract

Displaying 20 results from an estimated 99 matches for "substract".

2011 Oct 09
2
Substract "previous" element
Dear all, I have a matrix with data and I want to substract from every value the previous element. Let's assume that my vector(matrix) is c<-(1,2,3,4,5) I want to get remove_previous c<-(0,1,2,3,4). How I can do that efficiently in R? I would like to thank you in advance for your help B.R Alex [[alternative HTML version deleted]]
2011 Mar 21
3
How to substract a valur from dataframe with condition
...1 2011-02 0.00 4.00 2 2011-02 0.00 2.11 3 2011-02 2.00 3.08 4 2011-02 0.06 2.79 5 2011-02 0.00 4.00 6 2011-02 0.00 3.00 7 2011-02 0.08 2.23 Please help, I will really appreciate that. Thanks, Joe -- View this message in context: http://r.789695.n4.nabble.com/How-to-substract-a-valur-from-dataframe-with-condition-tp3394907p3394907.html Sent from the R help mailing list archive at Nabble.com.
2008 Jan 07
2
Efficient way to substract all entries in two vectors from each other
Hi all, I'm to inexperienced to come up with the matrix solution elusively appearing on the horizon for the following problem and would appreciate if you could give me a nudge ... I have two vectors a, and b and need to find the closest match for each value of a in b. How to do that efficiently? Thanks, Joh
2012 Sep 12
3
how to create a substraction matrix (subtract a row of every column from the same row in other columns)
...(This would probably entail just taking a portion of the matrix.) . This is what the result would be difftype value x1x2 x1x3 x1x4 x1x5 x2x3 x2x4 x2x5 x3x4 x3x5 x4x5 Thank you for any help you can give me. -- View this message in context: http://r.789695.n4.nabble.com/how-to-create-a-substraction-matrix-subtract-a-row-of-every-column-from-the-same-row-in-other-column-tp4642949.html Sent from the R help mailing list archive at Nabble.com.
2012 Oct 05
3
loop for column substraction of a matrix
Dear useRs, I have a matrix with 38 columns and 365 rows. what i want to do is the following..... 1. subtracting from each column, first itself and then all the remaining columns. More precisely, from column number 1, i will first subtract itself(column 1) and then the remaining 37 columns. Afterwards i will take column number 2 and do the same. In this way i want to proceed till 38th column.
2006 Mar 06
7
is there a way to let R do smart matrix-vector operation?
Hi all, I want to substract vector B from A's each column... how can R do that smartly without a loop? > A=matrix(c(2:7), 2, 3) > A [,1] [,2] [,3] [1,] 2 4 6 [2,] 3 5 7 > B=matrix(c(1, 2), 2, 1) > B [,1] [1,] 1 [2,] 2 > A-B Error in A - B : non-conformable arrays [[alter...
2013 Oct 03
1
prcomp - surprising structure
...I plot the eigenvectors (called rotation in prcomp) 2,3 and 4 (e.g. plot (rotation[,2]) I see a strange "column" in my data (see attachment). I suggest it is an artefact (but of what?). Suggestion: I used prcomp this way: prcomp (mat), where mat is a matrix with the column means already substracted followed by a normalisation procedure (see below for details). Is that okay? Or does prcomp repeat substraction steps? Originally my approach was driven by the idea to compute a covariation matrix followed by the use of eigen, but the covariation matrix was to huge to handle. So I switched to pr...
2012 Jul 31
1
TimeStamps to seconds
...1   15   25 31.343 I would like to be able to report some simple statistics based on the time differences of two entries. For example to check the time consistency (was my device measuring at same intervals ?) I think the easiest would be to convert the matrix above to pure seconds and then just substract them so something like that ... makeSeconds(roofPart1$TimeStamps[1:5,2])-makeSeconds(roofPart1$TimeStamps[1:5,1]) makeSeconds(roofPart1$TimeStamps[1:5,3])-makeSeconds(roofPart1$TimeStamps[1:5,2]) makeSeconds(roofPart1$TimeStamps[1:5,4])-makeSeconds(roofPart1$TimeStamps[1:5,3]) Do you know whi...
2003 Sep 02
1
convert character to POSIXct
...OSIXct). e.g. starttime<-strptime("1/1/1999 01:01:01",format="%d/%m/%Y %H:%M:%S") endtime<-strptime("1/8/1999 01:01:01",format="%d/%m/%Y %H:%M:%S") > starttime [1] "1999-01-01 01:01:01" > endtime [1] "1999-08-01 01:01:01" If I substract these from each other, endtime-starttime >Time difference of 211.9583 days Which should mean that the default is in day light saving. Next I convert these times into as.POSIXct and substract them as.POSIXct(starttime) [1] "1999-01-01 01:01:01 GMT Standard Time" as.POSIXct(endtime)...
2011 Feb 27
2
substract 2 data.frames
Hi! I have 2 data.frames: "fish" and "popn": >fish xloc yloc id birth size weight energy gonad 20 15 15 54 -60 107.9 63.0 15952.9 8.0 21 15 15 32 -60 105.1 61.4 15538.8 7.8 91 4 43 96 -60 118.9 69.4 17573.2 8.8 71 32 4 64 -60 121.6 71.0 17976.0 9.0 34 2 64 20 -60 116.2 67.9 17173.0 8.6 95 6 20 58 -60 106.5
2008 May 21
3
Converting a 'difftime' to integer - How to???
I want to find the DOY (Day of Year) of some dates. I think to substract the date 1. January from the data to achive this. Something like: > d <- as.Date("2006-03-13") - as.Date("2006-01-01") +1 > d Time difference of 72 days So far so good. But d is a 'difftime' object. How do I get an Integer value from that? I tried severel th...
2010 Apr 23
3
substract start from the end of the vector
Dear group, Here is my df : df <- structure(list(DESCRIPTION = c("PRM HGH GD ALUMINIUM USD 09/07/10 ", "PRM HGH GD ALUMINIUM USD 09/07/10 ", "PRIMARY NICKEL USD 04/06/10 " ), CREATED.DATE = structure(c(18361, 18361, 18325), class = "Date"), QUANITY = c(-1L, 1L, 1L), CLOSING.PRICE = c("2,415.90", "2,415.90",
2019 Mar 01
2
Meaning of `sub nsw`
In the following code. unsigned char x1 = atoi(argv[1]); unsigned char x2 = atoi(argv[2]); printf("%d\n", x1-x2); The substraction of the last command is translated to the following IR code. %18 = load i8, i8* %6, align 1 %19 = zext i8 %18 to i32 %20 = load i8, i8* %7, align 1 %21 = zext i8 %20 to i32 %22 = sub nsw i32 %19, %21 I don't follow the explanation of nsw in langref. Could anybody help explain what nsw means...
2007 May 10
3
Getting the last day of the month.
...- as.Date(ISOdate(substr(x$YearEnd,1,4),substr(x$YearEnd,5,6),1)) But this gives the first day of the month. To get the last day of the month, I tried > as.Date(as.yearmon(x$Date,frac=0)) But I don't get the last day of the month here. (Tried frac=1 too.) I then add a month to the date, substract one day from the resultant date. But this wouldn't work for December. > x$YearEnd [1] 200203 200303 200403 200503 200603 200603 200312 200503 200603 200203 200303 [12] 200403 200503 200512 200612 200203 200303 200403 200503 200603 > > x$Date <- as.Date(ISOdate(substr(x$YearEnd,1,...
2023 Feb 21
2
Problem of intercept?
Dear R-experts, Here below my R code working with quite a few warnings.? x11 and x12 are dichotomous variable (0=no and 1=yes). I substract 1 to ignore intercept. I would like not to ignore intercept. How to modify my R code because if I just remove -1 it does not work? y= c(32,45,65,34,23,43,65,76,87,98,7,867,56,45,65,76,88,34,55,66) x11=c(0,1,1,0,0,1,1,1,0,0,1,0,0,1,0,0,1,1,0,1) x12=c(0,1,0,1,0,1,1,0,1,1,0,0,1,1,1,0,0,1,0,0) ? Data...
2009 Dec 01
4
median for time data
Hi everybody How do I do to calculate the median and average of a colum of time data like this: "8:50:10". I also need to plot the time difference between two colums Thanks a lot -- View this message in context: http://n4.nabble.com/median-for-time-data-tp932287p932287.html Sent from the R help mailing list archive at Nabble.com.
2011 Jan 28
3
sapply puzzlement
Hi, I have this data.frame with two variables in it, > z V1 V2 1 10 8 2 NA 18 3 9 7 4 3 NA 5 NA 10 6 11 12 7 13 9 8 12 11 and a vector of means, > means <- apply(z, 2, function (col) mean(na.omit(col))) > means V1 V2 9.666667 10.714286 My intention was substracting means from z, so instictively I tried > z-means V1 V2 1 0.3333333 -1.6666667 2 NA 7.2857143 3 -0.6666667 -2.6666667 4 -7.7142857 NA 5 NA 0.3333333 6 0.2857143 1.2857143 7 3.3333333 -0.6666667 8 1.2857143 0.2857143 But this is completely wron...
2009 Jul 29
3
Newbie in R: Reading .txt files and storing the 'numbers' in a vector
...ain numbers ('doubles' for those who know c++) ordered into 2 columns as below: coordinate1 value1 coordinate2 value2 coordinate3 value3 ... ... coordinateN valueN I would like to write a small programme in which i would: 1. take all values of file 1 and store them in a vector 2. substract to those all values of file 2 (one by one) and store the result in a new vector 3. Create a sliding window of chosen size and calculate the mathematical average and store these averages in a new vector 4. Plot the different graphes with a bar plot So I wrote a c++ script that does the first pa...
2012 Mar 27
1
[LLVMdev] Compiling integer mod
For the simple C program below I show the output of clang and the output of the VS compiler (I am on windows). Maybe this is obvious to you, but is it really faster to do 2 multiplications, 3 movl instructions, 2 shifts, 1 add, and 1 substract than to do 1 mov, 1 cdq, and 1 idiv? I run into this while trying to understand why my code runs slower with llvm than a comparable program on windows. Thanks for any help, Brent int f(int n) { return (n + 1) % 18; } "clang -O2 -S" produces this code: _f:...
2002 Apr 17
1
zero center a group of variables
*This message was transferred with a trial version of CommuniGate(tm) Pro* A simple question, perhaps to simple, but I am new to R: For a data frame with k variables and n1+n2 observations (two groups) how can i substract the group means for every variable, so both group variables become centered to mean zero? Thanks in advance for your help H?ctor ................................................... H?ctor Villalobos Depto. de Pesquer?as y Biolog?a Marina Instituto Polit?cnico Nacional - Centro Interdisc...