Displaying 20 results from an estimated 40000 matches similar to: "How to capture NA values"
2012 Mar 07
3
GPS handling libraries or (String manipulation)
Dear all,
I would like to ask you if R has a library that can work with different GPS formats
For example
I have a string of this format
N50° 47.513 E006° 03.985
and I would like to convert to GPS decimal format.
that means for example converting the part N50° 47.513
to 50 + 47/60 + 513/3600.
Is it possible to do that with R?
What is the name of such a library?
I would like to thank you in
2012 Mar 03
4
Sliding a Window in R
Dear all,
I am having a vector of around 300.000 elements and I Want to slide fast a window from the first element until the last-Windowsize
what I have so far is the following for statement:
for (i in 1:(length(data[,1]) - windowSize)) {
out[i] <- mean(data[i:(i + windowSize - 1), ])
elements[i]<-length(i:(i + windowSize - 1))
}
but this of course takes ages to
2009 Nov 09
6
Find the first values in vector
Hi !
I have a vector:
vec= TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE TRUE TRUE FALSE
and I'm looking for a method which let me get only the first values equal
TRUE from this vector. It means that I want to get a vector:
vec_out = TRUE TRUE TRUE TRUE
or posictions values = TRUE: vec_out = 1,2,3,4
--
View this message in context:
2012 Sep 11
2
Sort or Permutate
Dear all,
I am having a struct that contains on the first column file names and on the second column a number which is a "rating" of the file on first column
A small subset looks like that
small
[,1]
[1,]
2007 Oct 11
2
Identifying and characterizing strings of NA in a vector
Dear R users,
I was wondering if someone could suggest a few lines of code for my problem.
I want to count the number and the length of strings of NA in a vector.
For example:
vec <- c(1, 2, 1, NA, NA, 1, 2, NA, NA, NA, 3, 4, NA, NA)
has 2 strings of NA's of length 2 and 1 string of NA' of length 3.
I can easily count the number of NA's per vector, but I am having a hard
time
2011 Jan 10
2
From vector to a step function
Greetings R members.
I have a few vectors that denote the 'steps' of different step functions
v1=c(3,4,5,1,2,3,4,5)
v2=c(5,6,2,4,7,3,2,5)
v3=c(1,2,4,7,3,1,3,5)
Here v1,v2,v3 are considered as the steps for the f1,f2,f3 step functions.
For example f1 looks like that (step size is always same and fixed)
f1= 3 (x>=-3,x<-2)
f1= 4 (x>=-2,x<-1)
f1= 5 (x>=-1,x<0)
f1= 1
2013 Feb 16
2
Handling NA values
Hello again,
I have a question on who sum() handle the NA values.
> sum(c(NA, 1), na.rm = TRUE)
[1] 1
I understand this. However could not agree with following:
> sum(c(NA, NA), na.rm = TRUE)
[1] 0
Where this '0' is coming from? Should not it be NA itself?
Thanks and regards,
2013 Apr 17
2
On matrix calculation
Hello again,
Let say I have a matrix:
Mat <- matrix(1:12, 4, 3)
And a vector:
Vec <- 5:8
Now I want to do following:
Each element of row-i in 'Mat' will be divided by i-th element of Vec
Is there any direct way to doing that?
Thanks for your help
2006 Dec 18
5
Replacing values
Hi all,
I have to recode some values in a dataset. for example changing all zeros to
"." or 999 would be also ok. does anybody know how to do this? thanks in
advance. lars
--
View this message in context: http://www.nabble.com/-R--Replacing-values-tf2841687.html#a7934402
Sent from the R help mailing list archive at Nabble.com.
2012 Mar 24
2
Compare similarit of two vector of not same length
Dear all,
this is not strictly R question. I have two vectors of different length (this is in the order of 10%). I am trying to see if still one can compare these two for similarity.
IF the vectors were of the same length I would just take the difference of the two and plot a pdf of it.
One way I am thinking is prorbably to find the longer length and short it in some way to get to the length of
2009 Dec 11
4
extracting vectors from lists of lists
Good evening
I often have as output from simulations a list of various values, vectors
and matrices.
Supposing that I then run said simulation several times, I often want to
extract a particular result from each simulation for plotting and,
ideally, put it in a matrix.
A simple example
v1 <- 1:5
v2 <- 6:10
other1 <- "stuff"
other2 <- "stuff"
set1 <-
2009 Dec 05
4
paste adjacent elements matching string
Hi all,
I would like to combine elements of a vector:
vec <- c("astring", "b", "cstring", "d", "e")
> vec
[1] "astring" "b" "cstring" "d" "e"
such that for every element that contains "string" at the end, it is
combined with the next element, so that I get this:
2013 Oct 29
1
TelosB external modules, guide
Hi all,
I would like to ask your help regarding connecting external modules to telosb. I have found that tiny os offers many possibilities for that as
ADC,
GPIOs, SPI, UART, I2C
I have never learned anything regarding those. Can someone please let me know if there is any simple
guide on these "interfaces" to show with a primitive example how to start with?
I would like to thank you
2012 Mar 24
2
expand.grid (the half!)
Dear all,
I am using expand.grid for calculating all the possible values between four pairs.
I would like to ask you if it is possible to filter the result out, so to keep all unique pairs. In my algorithm the input c(1,2) produces the same results as the c(2,1)
so for example in the following code below
> expand.grid(c(1,2,3),c(1,2,3))
Var1 Var2
1 1 1
2 2 1
3 3 1
4
2009 Jul 05
6
another matrix problem
I want a function that takes an input vector, the number of columns
and returns a matrix as follows.
x<- 1:5
foo(x, nc=3)
1 5 4
2 1 5
3 2 1
4 3 2
5 4 3
Thanks again for any help.
Bill
2008 Jul 02
1
set values in data.frame to NA conditional on another data.frame
Hello List,
Is there a faster way to set values in one data.frame equal to NA
conditional on the corresponding value in another data.frame? Currently
I am using:
> b[is.na(a)] <- NA
where 'a' and 'b' are data.frames of equal size/dimensions, and 'a'
contains NAs but 'b' does not. This is extremely slow as is, as my
data.frames are about 6000 columns by
2007 Nov 23
4
PCA with NA
Dear all,
(Mac OS X 10.4.11, R 2.6.0)
I have a quantitative dataset with a lot of Na?s in it. So many, that
it is not possible to delete all rows with NA?s and also not
possible, to delete all variables with NA?s.
Is there a function for a principal component analysis, that can deal
with so many NA?s.
Thanks in advance
Birgit
Birgit Lemcke
Institut f?r Systematische Botanik
2010 Feb 17
3
Extending data frame with longer columns
Hi,
I am a beginner in R and have only read a few chapters in the R book,
I was not able to find a solution for this simple problem.
I have an empty data frame:
a=data.frame(name="test")
which I would like to extend in a for-loop (with data extracted from a
database). Ideally I would like to extend the data frame like this:
a["new_1"] = 1:10
a["new_1"] = 1:12
2009 Dec 01
3
Using two (...) in a function
Hello R-Helpers,
I am not sure if it is a very simple question but I would like to use two
(...) in a function, for example,
this is a script where I would like to input the variable names (in one of
the (...)) and the variances associated to those variables which are not
calculated in the script because there is a specific software to calculate
it (the other (...))
data <- function
2010 Apr 29
2
Split a vector by NA's - is there a better solution then a loop ?
Hi all,
I would like to have a function like this:
split.vec.by.NA <- function(x)
That takes a vector like this:
x <- c(2,1,2,NA,1,1,2,NA,4,5,2,3)
And returns a list of length of 3, each element of the list is the relevant
segmented vector, like this:
$`1`
[1] 2 1 2
$`2`
[1] 1 1 2
$`3`
[1] 4 5 2 3
I found how to do it with a loop, but wondered if there is some smarter
(vectorized) way