Displaying 20 results from an estimated 7000 matches similar to: "add values inside vector"
2009 Jun 15
2
function inside ifelse
Hi,
Could you tell me, if it's possible to create ifelse and put function
inside, for example:
code{
ifelse ((is.na(vek)), call_fun_1(arguments), call_fun_2(arguments))
call_fun_1 <- function(arguments)
{ sth...
}
}
--
View this message in context: http://www.nabble.com/function-inside-ifelse-tp24035739p24035739.html
Sent from the R help mailing list archive at Nabble.com.
2009 Jun 14
3
if + is.na
Hello!
I wont to use a function is.na()
I have two vectors:
> a=c(1,NA,3,3,3)
> b=c(0,0,0,0,0)
and when I use is.na function it's ok:
> is.na(a)
[1] FALSE TRUE FALSE FALSE FALSE
but I would create sth like this:
for i in 1:length(a){
if (wsp[i] == is.na(a)) {b=43}
}
or like this
if(is.na(a)) b=3 else a
[1] 1 NA 3 3 3
but I always get an error:
the condition has
2009 May 29
4
logical vector as a matrix
I have a vector like this:
h <- c(4, 6, NA, 12)
and I create the secound logical vector like this:
g <- c(TRUE, TRUE, FALSE, TRUE)
And my problem is that I would like to get a new "m" vector as a rasult "h"
and "g"( as dot-matrix printer) but with missed "NA" value, for example:
m = (4,6,12)
Do you have any idea?
--
View this message in
2009 May 14
2
I want to avioid unnecessary value
I have a database like this:
"kol1";"kol2";"kol3" ...
"2";"5";"9"
"9";"6";"6"
"4";"6";"5"...
I looking for a kod in R which let mi aviod in column unnecessary value, for
example number "9".
So, if I have:
Kol1
2
9
4
4...
after loop in R I would like to get my
2009 Jun 16
1
ifelse(is.na), with function inside
Hi,
I have a vector a=c(NA, 3, 4, 4, NA, NA, 3) and I would like to use is.na(a)
function to get a vector like this:
wy=(1,2,2,2,1,1,2) - you know, this vector create 1 or 2 depends on value in
vector "a"
This is my short code but something is wrong and I don't know what...
for (i in 1:7){
a=c( NA, 3, 4, 4, NA, NA, 3)
fun1=function(x){
x=1
print(x)
}
fun2=function(x){
2009 Jun 08
4
seq(...) strange logical value
Do you heve any idea why I get after this instruction everywhere false?
> seq (0, 1, by=0.1) == 0.3
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
But after different step it's ok:
> seq(0, 1, by=0.1) == 0.4
[1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
--
View this message in context:
2009 Apr 29
2
library which convert dates
I'm looking for library which let mi convert dates
for example like this:
00-06-05 00:00
00-08-06 00:00
00-08-16 00:00
00-05-23 00:00
00-01-14 00:00
00-10-28 00:00
and as a result I want to get a 3 levels
--
View this message in context: http://www.nabble.com/library-which-convert-dates-tp23295853p23295853.html
Sent from the R help mailing list archive at Nabble.com.
2009 Jun 01
3
Editor R
Do you know any good editor R?
--
View this message in context: http://www.nabble.com/Editor-R-tp23822342p23822342.html
Sent from the R help mailing list archive at Nabble.com.
2009 Aug 23
2
difficult "for"
Hi,
My english isn't brilliant and my problem is very difficult to describe but
I try ;)
My first question is: May I write loop "for" like this or similar - for (i
in sth : sth[length(sth)], k in sth_else : length(sth_else) ) - I'd like
to have two independent conditions in the same loop "for".
My secound question depend on program below. I'd like to write every
2009 Apr 19
1
data$ID -> I always get a NULL
I have database write as .csv file.
When I want to get sth from my database I get NULL, but I know that there is
sth!
For example:
> data$ID
NULL
> data$kod
NULL
but command like below is always recognize by R
> data[2,3]
[1] '082'
In my opinion this problem is also connect with my attempt to create a tree.
I always get errors.
> t.tree0=rpart(ID~.,t.train)
Error in
2010 Jan 06
1
math function - MDS method
Hi,
I need math function which is used in: isoMDS, Sammon and metaMDS method.
Anybody know where I may find it? Any manual or webside?
I would be very happy
Thanks a lot !
--
View this message in context: http://n4.nabble.com/math-function-MDS-method-tp1008294p1008294.html
Sent from the R help mailing list archive at Nabble.com.
2009 May 31
1
Error:non-numeric argument in my function
Hello!
I have a function:
zywnoscCalosc<- function( jedzenie, n1, n2, n3, n4, d1, d2, d3, d4 ) {
ndf <- data.frame(nn1=n1,nn2=n2,nn3=n3,nn4=n4)
ddf <- data.frame(dd1=d1,dd2=d2,dd3=d3,dd4=d4)
for (i in 1:length(n1)){
wekt_n = ndf[i,]
wekt_n_ok = wekt_n[!is.na(wekt_n)]
dl_n = length(wekt_n_ok)
wynik = (1*wekt_n_ok)/(1*dl_n)
}
}
and I get an error like this:
Error in 1 * wekt_n_ok :
2009 Aug 13
1
write result in matrix using loop
Hello,
I want call my function (use my database) and write every result in matrix
"wynik" but I always get an error: Error in wynik[, i] <- dodawanie(wzorzec,
wzorzec1) :
number of items to replace is not a multiple of replacement length
I'll be very happy if sb help me
dodawanie<- function ( wzorzec, wzorzec1){
wynik1<-wzorzec + wzorzec1
wynik2<-wzorzec *
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:
2010 Mar 05
2
install rJava in linux
Hi
I'm a problem with installing "rJava" in Linux
I have got in my system : java-sun, java-sun-tools, java-sun-jre
but if I wont install rJava I got a problem like this:
> install.packages("rJava", dependencies = TRUE)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.mirroring.de/src/contrib/rJava_0.8-2.tar.gz'
Content type
2009 Jun 02
2
What do you think about my function?
Hello,
I want to know what do you think about my function. I know that it isn't
briliant :/ but what do you think? What I should do that my function will be
better? (now is very slow and not ideal, sometimes I also get a mistake!)
########## My function #############################################
dzieci<-transform(dzieci, zywnosc=0)
zywnoscCalosc<- function( jedzenie, sklep, n1, n2,
2010 Apr 16
2
managing data and removing lines
Hi,
I am very new to R and I've been trying to work through the R book to gain a
better idea of the code (which is also completely new to me).
Initially I imputed my data from a text file and that seemed to work ok, but
I'm trying to examine linear relationships between gdist and gair, gdist and
gsub, m6dist and m6air, etc.
This didn't work and I think it might have something to do
2008 Sep 22
1
findInterval(), binary search, log(N) complexity
Dear R users,
the help for findInterval(x,vec) suggests a logarithmic dependence on N
(=length(vec)), which would imply a binary search type algorithm.
However, when I "test" this hypothesis, in the following manner:
set.seed(-3645);
l <- vector();
N.seq <- c(5000, 500000, 1000000, 10000000, 50000000);k <- 1
for (N in N.seq){
tmp <- sort(round(stats::rt(N, df=2), 2));
2008 Nov 21
1
question about shapiro.test()
Hi all!
I tried to perform Shapiro-Wilk test for my sample of 243 values.
> Us
[1] -10.4 -13.1 -12.2 38.1 -18.8 -13.3 -11.7 29.3 49.7 6.8 12.7 16.3
[13] 5.8 -0.7 -29.4 4.1 38.8 -1.4 8.8 15.6 32.9 -5.3 19.1 35.8
[25] 4.0 -1.5 0.6 -4.2 -10.0 -4.0 1.1 48.9 -21.0 -5.3 5.8 -10.8
[37] 21.9 8.2 -3.2 -3.9 -2.3 12.6 -4.7 -8.0 11.8 27.4 -9.5 -20.8
[49]
2016 Aug 04
1
findInterval(all.inside=TRUE) for degenerate 'vec' arguments
What should findInterval(x,vec,all.inside=TRUE) return when length(vec)<=1,
so there are no inside intervals?
R-3.3.0 gives a decreasing map of x->output when length(vec)==1 and -1's
when length(vec)==0. Would '0' in all those cases be better?
> findInterval(x=c(10, 11, 12), vec=11, all.inside=TRUE,
rightmost.closed=FALSE, left.open=FALSE)
[1] 1 0 0
>