similar to: Two statement logical dealing with NAs

Displaying 20 results from an estimated 30000 matches similar to: "Two statement logical dealing with NAs"

2012 Apr 27
6
Returning the coef from two coordinates
Thank you to everyone in this forum that has been helping me with the basic R skills while I learn to apply them. I would like to take the coefficient of two coordinates. One of them comes from two different columns in a table: >A x y a 1 3 b 2 2 c 3 1 the other is set and for this question I'll just call it (1,1) I've been trying to find a way to return the
2012 Oct 15
2
Chopping a two column data frame by rows into a three dimensional array.
If I have a two column data frame like: > dat <- cbind("x"=c(1:100),"y"=c(100:1)) How can I create an array that splits every ten rows of that data frame into a third dimension of an array so that: > newarray[,,1] ,,1 x y 1 100 2 99 3 98 ... ... 10 91 ,,2 x y 11 90 12 89 ... ... ... Thanks. [[alternative HTML version deleted]]
2012 Nov 11
2
Cropping a matrix by rows
Hello r-help, I've been banging my head against the computer in an attempt to learn how to divide my matrix into segments by rows. I want to be able to return each segment as a newly named object. I've tried looking at the apply functions and creating a for loop but brain no work. Here's the basic starting objects that I believe would be needed to separate the matrix. mat <-
2012 Feb 26
2
Dealing with NAs in C
Hi. I am currently converting a lot of R code to C in order to make it more efficient. A lot of the data involves NAs. As the data is mainly integers > 0, I am just setting all NAs to 0 then sending it to the C code then resetting them to NAs again after the C program is done, to be compatible with the rest of the R code. Is there a more efficient way to deal with NAs in C? I have used
2008 Sep 05
1
dealing with NAs in time series
Certain timeseries I have had outliers, which I removed by assigning NA to their positions. Now acf() refuses to go to work. What's the right way to remove outliers from ts objects, and what are teh standard ways to interpolate NAs in them? Cheers, Alexy
2006 Jan 10
6
Can we cache user home pages?
Hi Railers, I am trying to create a simple application like a guest book which has users and uses sessions to keep track of which users are logged on. The user''s page is constructed after doing some SQL queries and the user clicks on another link and hits the back button I dont want to regenerate the whole page (which is what happens now) .So I want to use some kind of caching mechanism.
2011 Dec 18
2
Dealing with NAs
Hi I am trying to estimate parameter values with mlogit. I attach a part of my data. My code is x=mlogit.data(y,choice="voittaja",shape="long",id.var="id",alt.var="numero") summary(mlogit(voittaja ~ Ie-1 , data=x, na.action=na.pass)) But i get Error in if (abs(x - oldx) < ftol) { : missing value where TRUE/FALSE needed Because there is Na
2012 May 23
3
applying cbind (or any function) across all components in a list
#If I have two lists as follows a1<- array(1:6, dim=c(2,3)) a2<- array(7:12, dim=c(2,3)) l1<- list(a1,a2) a3<- array(1:4, dim=c(2,2)) a4<- array(5:8, dim=c(2,2)) l2<- list(a3,a4) #how can I create a new list with the mean across all arrays within the list, so all components are included? As an example for [[1]]; cbind((l1[[1]][,1]+l2[[1]][,1])/2,
2008 Dec 11
3
Logical "in" test
OK, this should be trivial but I'm not finding it. I want to compress the test, if (i==7 | i==10 | i==30 | i==50) {} into something like if (i in c(7,10,30,50)) {} so I can build a "excludes" vector excludes <- c(7,10,30,50) and test if (i in excludes) {} However, I'm not finding a clue on how to accomplish this, if it can be done. Would someone with more R
2012 Jun 14
1
Can someone recommend a package for SNP cluster analysis of Fluidigm microarrays?
I know that there are quite a few packages out that there for cluster analysis. The problem that I am facing is finding a package that will not incorporate all my samples into clusters but just the samples that fit a threshold (that I have not set yet and may need help finding the right level) for genotyping. It should be able to "no call" samples outside the clusters. It also needs to
2006 Jul 03
5
How do I code this conditional statement in Ruby
Hi, I am a COBOL programmer and I am busy teaching myself Rails and Ruby. In COBOL I can code this conditional If x = 1 next sentence else .......................... The "next sentence" statement enables me to get out of the conditional. How would I code the same thing in Ruby? In C you could use break but I understand that Ruby has no break statement. Regards, Paul
2012 Jan 28
3
logical subsetting, indexes and NAs
Dear All, just a quick example: > x = 1:25 > x[12] = NA > x [1] 1 2 3 4 5 6 7 8 9 10 11 NA 13 14 15 16 17 18 19 20 21 22 23 24 25 > y = x[x<10] > y [1] 1 2 3 4 5 6 7 8 9 NA Is there any way of NOT getting NA for y = x[x<10]? Similarly > y = x[x<15] > y [1] 1 2 3 4 5 6 7 8 9 10 11 NA 13 14 How do I get rid of the NA (not post
2005 May 11
3
display two pie-charts
Hey, i'd like to compose a clock-like looking plot composed out of two circles, each showing the length of a period (to compare them). first, to do so, it looked the easiest by using pie(), just puting multiple pie-charts over each other. the problem is that once the second pie is drawn, it replaces the first one. does anybody know how to add a second, smaller pie over an existing one,
2000 Nov 25
2
assigning to data frames with whole columns of NAs
I suppose this could be described as a feature (it seems to be similar in S-Plus), but it looks to me more like a bug. Why can't the assignment below to a row of "emptyframe" (or "anotherframe") be made? This with R --vanilla (version info below). Regards -- David David Firth Phone +44 1865 278544 Nuffield College Fax +44 1865
2011 Aug 05
2
summing columns with NAs present
Hello! I have a data frame with some NAs. test<-data.frame(a=c(1,2,NA),b=c(10,NA,20)) I need to sum up values in 2 variables. However: test$a+test$b procudes NAs in rows that have NAs. How could I sum up columns while ignoring NAs (the way the function sum(..., na.rm=T) works? Thank you! -- Dimitri Liakhovitski marketfusionanalytics.com
2011 Feb 25
1
combining two columns into one column despite NAs
I am trying to combine two columns in a data frame into one column. Some values in either column are missing, but not in the same row for the two different columns. Additionally, when both columns in a row contain data, the data are identical. I want a new column with the identical data or the data from the column with observed data. For example: I have >data id x y
2011 Jan 17
2
Finding NAs in DF
Hi, What is an efficient way to take this DF data.frame(A=c(1,2,NA,NA),B=c(1,NA,NA,4)) and get c(NA,"TWO","BOTH","ONE") as the result, where NA corresponds to a row without "NA"s, TWO indicates NA in the second and ONE in the first column. Thanks for any pointers. Joh
2007 Sep 04
2
For loop with if else statement
Hi, I try to make a simple for loop with a if else statement (First example - Below) and extend it to a more complex loop (Second example). However, my results #First example: x=c(1,2) t=for(i in 1:length(x)){ if (x==1){a=x+1}else if (x==2){a=x} } Returned from R: Warning messages: 1: the condition has length > 1 and only the first element will be used in: if (x == 1) { 2: the condition has
2009 Jun 12
3
replacing zeros by NAs
something like ... > x<-c(1,2,3,0,5,6,0) > is.na(x[x==0])<-T > x [1] 1 2 3 NA 5 6 NA ~~~~~~~~~~~~~~~~ Robert Kinley ~~~~~~~~~~~~~~~~ [[alternative HTML version deleted]]
2008 Jul 24
2
NAs - NAs are not allowed in subscripted assignments
Dear List, I ran into some trouble handling missing values. Assume 2 vectors (numeric) including NAs a <- c(rep(seq(1,4),4),NA,NA) b <- c(sample(1:2,14,replace=T),NA,NA,1,2) I want to replace the values of vector a that are smaller than 2 and larger than 3 into NAs only in case vector b equals 1 a[b==1][a[b==1]<2 | a[b==1]>3] <- NA The following error accurse: NAs are not