similar to: Summing with NA

Displaying 20 results from an estimated 20000 matches similar to: "Summing with NA"

2010 Mar 23
2
Create NA
Hi, How can I create an NA? for example, i have this program but it has errors > x=scan() 1: 1 2 3 4 5 6: Read 5 items > "na"*x Error in "na" * x : non-numeric argument to binary operator what should I multiply x so that I will get an NA? And I really need to multiply that with my x vector. I need this output: (na,na,na,na,na) Thank you for your time and help!=) --
2010 Mar 23
3
If else statements
Hi everyone! May I request again for your help? I need to make some codes using if else statements... Can I do an "if-else statement" inside an "if-else statement"? Is this the correct form of writing it? Thank you.=) Example: for (v in 1:6) { for (i in 2:200) { if (v==1) (if max(x*v-y*v)>1 break()) if (v==2) (if max(x*v-y*v)>1.8 break()) if (v==3) (if
2010 Mar 20
3
How to count the number of occurence?
Hi, may I ask for your help... What is the R code if I want to count the number of times that "2" appeared in the following R output > k [1] 1 1 1 1 1 1 3 1 2 1 1 1 1 1 1 1 1 3 2 1 1 4 1 1 1 1 1 5 1 1 Thank you for your help. :-) -- View this message in context: http://n4.nabble.com/How-to-count-the-number-of-occurence-tp1661733p1661733.html Sent from the R help mailing list
2010 Dec 08
5
Summing up Non-numeric column
Dear All If I have the following dataset V1 V2 x y y x z b a c b j d l c o How do I use R command to get the total number of different letter in column "V1" column "V1" has 7 different letters. Thank you -- View this message in context: http://r.789695.n4.nabble.com/Summing-up-Non-numeric-column-tp3077710p3077710.html Sent from the R help mailing list archive
2005 Dec 05
1
data frames, na.omit, and sums
Dear R-helpers, New to R, I'm in the middle of a project that I'm using to force me learn R. I'm running into some behavior that I don't understand, and I need some advice. In the last week I've gotten some great advice from the list on visualizing my data, and I was hoping people could help me get over another barrier I've encountered to my progress. Before I
2008 Sep 23
1
Summing up columns with NA elements in a data frame
Hi all, When I try to sum a few columns in a data frame (which has NA?s randomly distributed as elements), I am not able to get the summing operation to ignore the NA?s. Let me explain with the following code : ################################? a<-structure(list(a1 = c(NA, 2, 3, NA, 5, 6, NA, 8, 9, NA), a2 = c(NA, + 4, 5, 5, NA, 7, 8, 8, NA, 10), a3 = c(2, NA, 6, 8, NA, 12, 14, + NA, 18, 20)),
2015 Jun 01
2
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
I'm observing that base::sum(x, na.rm=FALSE) for typeof(x) == "double" is much more time consuming when there are missing values versus when there are not. I'm observing this on both Window and Linux, but it's quite surprising to me. Currently, my main suspect is settings in on how R was built. The second suspect is my brain. I hope that someone can clarify the below
2008 Jul 28
1
Interpolating a line and then summing there values for a diurnal oxygen curve (zoo object)
#I would like to interpolate a straight line between 06/08/06 04:16:00 - 06/08/06 20:31:00 with values and then sum them. This is an estimate of ecosystem #respiration and I will be using this in a larger context(48 days of these diurnal curves), but for right now I am just trying to figure out how to do it for this one #day example. I have some other code for Ecosystem (stream) Metabolism that
2015 Jun 01
0
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
This is a great example how you cannot figure it out after spending two hours troubleshooting, but a few minutes after you post to R-devel, it's just jumps to you (is there a word for this other than "impatient"?); Let me answer my own question. The discrepancy between my sum2() code and the internal code for base::sum() is that the latter uses LDOUBLE = long double (on some system
2013 Apr 04
2
summing vectors/matrices
Hi All, I have a large dataset I need to re-structure. It looks something like this: YearAreaQBinFD20001150200011101200011152320001120122000112512000215120002110 6200021151120002120132000212532000125020001210120001215232000122012200012251 20002251200022103200022151220002220132000222532001…2011 And I need to create different vectors (Bin, FD) summing by year and/or by area; For example, I need
2013 Apr 04
3
summing vectors
Hi All, Year Area Q Bin FD I have a large dataset I need to re-structure. It looks something like this: 2000 1 1 5 0 2000 1 1 10 1 2000 1 1 15 23 2000 1 1 20 12 2000 1 1 25 1 2000 2 1 5 1 2000 2 1 10 3 2000 2 1 15 15 2000 2 1 20 11 2000 2 1 25 3 2000 1 2 5 0 2000 1 2 10 1 2000 1 2 15 23 2000 1 2 20 12 2000 1 2 25 1 2000 2 2 5 1 2000 2 2 10 3 2000 2 2 15 15 2000 2 2 20 11
2010 May 12
3
summing items within a row
Hello, I am trying to figure out how to do a sum of items within a row. For example, I have a data frame something like this: A1 B1 ... A2 B2 ... 1 1 4 1 4 2 2 5 2 5 3 3 6 3 6 What I want, is for each row, to get A1 + A2, B1 + B2, etc. which would, perhaps, give me a vector something like this c(2, 8, ... 4, 10 ... 6, 12). Does anyone know of a simple
2008 Mar 06
2
replace NA with 9999 in zoo object
This is the same set of data that I have been working with for those in the know. it is a matrix of ~174 columns and ~70,000 rows. I have it as a zoo object, but I could read it in as just a matrix as long as the date time stamp won't be corrupted. here is an example of what a column would look like: 1/1/06 12:00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,6 ,7, NA #read in with the
2008 Jul 19
2
extracting colnames to label plots in a function
#this is my little function that I would like to use the column names of the x and y arguments in the function. I would like it to read # site1-site2 how would I do this diff.temp <- function(x, y ,use="pairwise.complete.obs") { na.method <- pmatch(use, c("all.obs", "complete.obs", "pairwise.complete.obs")) par(mfrow=c(2,1))
2010 Nov 13
1
Summing functions of lists
Hi I'm trying to sum functions of lists with different lengths. Here is a simplified example of the problem: r=list(1:3,1:5,1:2) r [[1]] [1] 1 2 3 [[2]] [1] 1 2 3 4 5 [[3]] [1] 1 2 x=function(i,j) sum(j*r[[i]]) # x is a function of two parameters: i & j y=function(j) # y is the sum of x over i + {
2008 Jul 18
1
finding "chuncks" of data that have no NA s
I have a data frame that is 122 columns and 70000ish rows it is a zoo object, but could be easily converted or read in as something else. It is multiparameter multistation water quality data - there are a lot of NA s. I would like to find "chuncks" of data that are free of NA s to do some analysis. All of the data is numeric. Is there a way besides graphing to find these NA less
2011 Dec 19
2
Summing x1 to x6
Suppose I have the following: x1<-as.vector(rnorm(10)) x2<-as.vector(rnorm(10)) x3<-as.vector(rnorm(10)) x4<-as.vector(rnorm(10)) x5<-as.vector(rnorm(10)) x6<-as.vector(rnorm(10)) x7<-as.vector(rnorm(10)) x8<-as.vector(rnorm(10)) x9<-as.vector(rnorm(10)) x10<-as.vector(rnorm(10)) I would like the mean of x1 to x6 for each vector position. I would do something else
2010 Oct 27
1
return NA instead zero when summing over an empty range?
Dear R users, the colSums function from the base package returns zero if there are no values in a range to be summed over (after removing missing values with na.rm = TRUE). Is there some way to make it return NA in that case just like colMeans does? Or any other function or some good way to achieve that? Any ideas are be welcome. Regards, Martin Ivanov
2011 Nov 17
1
Exclude NA while summing
Dear R users, I am new to R and have some query. I am having a dataset with binary output 0's and ones. But along with it it has NA's too. I want to sum all the rows and get the sum total for each column. But whenever there is a NA in an row the sum of the row is returned as NA so I am not able to sum up the values. *row.sums.m <- apply(dummy.curr.res.m,1,sum)* It would be helpful
2010 Jan 25
1
summing a large, partitioned data frame
Dear R community, I'm trying to develop a fast way of summing specific rows of a large data frame. Here is an example of the kind of data frames I'm dealing with: > refls H K L M/ISYM BATCH I SIGI 43247 1 0 5 21 79 61.44117 2.20553 1040 1 0 5 257 6 15.16316 0.54431 2324 1 0 5 257 5 46.76152 1.67858 31515 1 0 5 259 60 57.97305