Re: [R] where is a value in my list

2009-11-15 Thread Grzes

It's excellent! 
Now, if I have a vector k=c( TRUE, TRUE, FALSE) how I may get lines from
list?
which (list ?? k) ? 



David Winsemius wrote:
> 
> 
> On Nov 15, 2009, at 10:47 AM, Grzes wrote:
> 
>>
>> But it's not what I wont
>>
>> I need get a number of line my list
>> 5 is in: list[[1]][1] and list[[2]][1] so
>> I would like to get a vector k = 1,2
>>
> 
> I am sorry. I do not understand what you want the second solution  
> offered gave you numbers (and they were the numbers that were for  
> "5"'s rather than one that were not for "5"'s as your offered solution.
> 
> If you just want to know which lists contain a 5, but not the position  
> within the list (which was not what you appeared to be asking..):
> 
>  > which(sapply(lista, function(x) any(x == 5)))
> [1] 1 2
> 
> 
> 
>>
>> David Winsemius wrote:
>>>
>>>
>>> On Nov 15, 2009, at 10:01 AM, Grzes wrote:
>>>
>>>>
>>>> I heve got a list:
>>>>
>>>> lista=list()
>>>> a=c(2,4,5,5,6)
>>>> b=c(3,5,4,2)
>>>> c=c(1,1,1,8)
>>>> lista[[1]]=a
>>>> lista[[2]]=b
>>>> lista[[3]]=c
>>>>
>>>>> lista
>>>> [[1]]
>>>> [1] 2 4 5 5 6
>>>>
>>>> [[2]]
>>>> [1] 3 5 4 2
>>>>
>>>> [[3]]
>>>> [1] 1 1 1 8
>>>>
>>>> I would like to know where is number 5 (which line)?
>>>>
>>>> For example I have got a loop:
>>>>
>>>> k= vector(mode = "integer", length = 3)
>>>>
>>>> for(i in 1:3)
>>>> {
>>>> for (j in 1:length(lista[[i]])){
>>>> if ((lista[[i]][j])==5   k[i]= [i])
>>>> }
>>>> }
>>>>
>>>> This loop is wrong but I would like to get in my vector k sth like
>>>> this:
>>>>
>>>> k = lista[[1]][1], lista[[2]][1] ...or sth similar
>>>
>>> I am a bit confused, since clearly lista[[1]][1] does _not_ == 5.  
>>> It's
>>> also unclear what type of output you expect ... character, list,
>>> numeric?
>>>
>>> See if these take you any further to your vaguely expressed goal:
>>>
>>>> lapply(lista, "%in%", 5)
>>> [[1]]
>>> [1] FALSE FALSE  TRUE  TRUE FALSE
>>>
>>> [[2]]
>>> [1] FALSE  TRUE FALSE FALSE
>>>
>>> [[3]]
>>> [1] FALSE FALSE FALSE FALSE
>>>
>>>> lapply(lista, function(x) which(x == 5) )
>>> [[1]]
>>> [1] 3 4
>>>
>>> [[2]]
>>> [1] 2
>>>
>>> [[3]]
>>> integer(0)
>>>
>>>> --
>>>
>>>
>>> David Winsemius, MD
>>> Heritage Laboratories
>>> West Hartford, CT
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://old.nabble.com/where-is-a-value-in-my-list-tp26359843p26360251.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://old.nabble.com/where-is-a-value-in-my-list-tp26359843p26360930.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] where is a value in my list

2009-11-15 Thread Grzes

But it's not what I wont

I need get a number of line my list
5 is in: list[[1]][1] and list[[2]][1] so
I would like to get a vector k = 1,2


David Winsemius wrote:
> 
> 
> On Nov 15, 2009, at 10:01 AM, Grzes wrote:
> 
>>
>> I heve got a list:
>>
>> lista=list()
>> a=c(2,4,5,5,6)
>> b=c(3,5,4,2)
>> c=c(1,1,1,8)
>> lista[[1]]=a
>> lista[[2]]=b
>> lista[[3]]=c
>>
>>> lista
>> [[1]]
>> [1] 2 4 5 5 6
>>
>> [[2]]
>> [1] 3 5 4 2
>>
>> [[3]]
>> [1] 1 1 1 8
>>
>> I would like to know where is number 5 (which line)?
>>
>> For example I have got a loop:
>>
>>  k= vector(mode = "integer", length = 3)
>>
>> for(i in 1:3)
>> {
>> for (j in 1:length(lista[[i]])){
>> if ((lista[[i]][j])==5   k[i]= [i])
>> }
>> }
>>
>> This loop is wrong but I would like to get in my vector k sth like  
>> this:
>>
>> k = lista[[1]][1], lista[[2]][1] ...or sth similar
> 
> I am a bit confused, since clearly lista[[1]][1] does _not_ == 5. It's  
> also unclear what type of output you expect ... character, list,  
> numeric?
> 
> See if these take you any further to your vaguely expressed goal:
> 
>  > lapply(lista, "%in%", 5)
> [[1]]
> [1] FALSE FALSE  TRUE  TRUE FALSE
> 
> [[2]]
> [1] FALSE  TRUE FALSE FALSE
> 
> [[3]]
> [1] FALSE FALSE FALSE FALSE
> 
>  > lapply(lista, function(x) which(x == 5) )
> [[1]]
> [1] 3 4
> 
> [[2]]
> [1] 2
> 
> [[3]]
> integer(0)
> 
>> --
> 
> 
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://old.nabble.com/where-is-a-value-in-my-list-tp26359843p26360251.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] where is a value in my list

2009-11-15 Thread Grzes

I heve got a list: 

lista=list() 
a=c(2,4,5,5,6) 
b=c(3,5,4,2) 
c=c(1,1,1,8) 
lista[[1]]=a 
lista[[2]]=b 
lista[[3]]=c

 > lista 
[[1]] 
[1] 2 4 5 5 6 

[[2]] 
[1] 3 5 4 2 

[[3]] 
[1] 1 1 1 8 

I would like to know where is number 5 (which line)?

For example I have got a loop:

  k= vector(mode = "integer", length = 3)

 for(i in 1:3)
{
 for (j in 1:length(lista[[i]])){
if ((lista[[i]][j])==5   k[i]= [i])
}
}

This loop is wrong but I would like to get in my vector k sth like this:

k = lista[[1]][1], lista[[2]][1] ...or sth similar
-- 
View this message in context: 
http://old.nabble.com/where-is-a-value-in-my-list-tp26359843p26359843.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] write data frame in a list

2009-11-10 Thread Grzes

Thanks jholtman for advice but I need do it using a loop. (Because  my code
is a little more complicated).



jholtman wrote:
> 
> Is this what you want:
> 
>> df=data.frame(x=c(3,6,7),y=c(2,7,4))
>> df
>   x y
> 1 3 2
> 2 6 7
> 3 7 4
>> as.list(df)
> $x
> [1] 3 6 7
> 
> $y
> [1] 2 7 4
> 
> 
> On Tue, Nov 10, 2009 at 6:05 AM, Grzes  wrote:
>>
>> Hi,
>> I have got a data frame:
>>
>> df=data.frame(x=c(3,6,7),y=c(2,7,4))
>>
>> and I would like to write my values from data frame to list using loop,
>> for
>> example:
>>
>> lista=list()
>> for (i in 1: length(?)){
>>        lista[[?]][?] = df [?]
>> }
>> But I havn't got any idea what I should put in places where I put a
>> question
>> mark?
>>
>> As a rusult I would like to get a list like this:
>> list:
>> [[1]]
>> 3,6,7
>> [[2]]
>> 2,7,4
>>
>> I wll be very happy if somebody can help me
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/write-data-frame-in-a-list-tp26281645p26281645.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> 
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem that you are trying to solve?
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://old.nabble.com/write-data-frame-in-a-list-tp26281645p26283178.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] write data frame in a list

2009-11-10 Thread Grzes

Hi,
I have got a data frame:

df=data.frame(x=c(3,6,7),y=c(2,7,4))

and I would like to write my values from data frame to list using loop, for
example:

lista=list()
for (i in 1: length(?)){
lista[[?]][?] = df [?]
}
But I havn't got any idea what I should put in places where I put a question
mark?  

As a rusult I would like to get a list like this:
list:
[[1]]
3,6,7
[[2]]
2,7,4

I wll be very happy if somebody can help me


-- 
View this message in context: 
http://old.nabble.com/write-data-frame-in-a-list-tp26281645p26281645.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Find the first values in vector

2009-11-09 Thread Grzes

Thank You All Very Much  :jumping:

Dimitris Rizopoulos-4 wrote:
> 
> yet another solution is:
> 
> vec <- c(TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, 
> FALSE)
> 
> seq_len(rle(vec)$lengths[1])
> 
> 
> I hope it helps.
> 
> Best,
> Dimitris
> 
> 
> Grzes wrote:
>> 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
> 
> -- 
> Dimitris Rizopoulos
> Assistant Professor
> Department of Biostatistics
> Erasmus University Medical Center
> 
> Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
> Tel: +31/(0)10/7043478
> Fax: +31/(0)10/7043014
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Find-the-first-values-in-vector-tp26271555p26273429.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Java and R

2009-11-09 Thread Grzes

Hello,
I'm looking for any manual about using Java and R for begginers. Do you know
any?
-- 
View this message in context: 
http://old.nabble.com/Java-and-R-tp26275500p26275500.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Find the first values in vector

2009-11-09 Thread Grzes

Thank You All Very Much   :jumping:



baptiste auguie-5 wrote:
> 
> Hi,
> 
> One way would be,
> 
> vec[ cumsum(!vec)==0 ]
> 
> HTH,
> 
> baptiste
> 
> 2009/11/9 Grzes :
>>
>> 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:
>> http://old.nabble.com/Find-the-first-values-in-vector-tp26271555p26271555.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Find-the-first-values-in-vector-tp26271555p26273390.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Find the first values in vector

2009-11-09 Thread Grzes

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: 
http://old.nabble.com/Find-the-first-values-in-vector-tp26271555p26271555.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] "ipredknn" - How may I find values?

2009-10-27 Thread Grzes

I'm sorry David, this is my code once again:

 library(klaR)
 library(ipred)
 library(mlbench)
 data(PimaIndiansDiabetes2)
 dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
 dane[,2]=log(dane[,2])
 dane[,1:2]=scale(dane[,1:2])
 zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)
 
klasyfikatorKNN=ipredknn(diabetes~glucose+insulin,data=dane,subset=zbior.uczacy,k=3)

oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],"class")

df=data.frame(glucose=c(klasyfikatorKNN$learn$X[,1]),insulin=klasyfikatorKNN$learn$X[,2],diabetes=c(klasyfikatorKNN$learn$y))
 df$diabetes=factor(df$diabetes)

drawparti(df$diabetes, df$glucose, df$insulin, method = "sknn", prec = 100,
xlab = NULL, ylab = NULL) 

But in my computer everything is ok. The "drawparti" is in "klaR" package.
Or maybe try like this: 

drawparti(klasyfikatorKNN$learn$y, df$glucose, klasyfikatorKNN$learn$X[,2],
method = "sknn", prec = 100, xlab = NULL, ylab = NULL)

 



David Winsemius wrote:
> 
> 
> On Oct 27, 2009, at 10:18 AM, Grzes wrote:
> 
>>
>> Yes, I want to know which points in my picture are in red or green  
>> area.
>> For example:
>> .glucose..insulin.diabetes
>> 609  0.95177272  1.139969011   - I want to know that it's for
>> example: black point in red area
> 
> red area?
> 
> 
>> 253 -1.05724970 -1.158814331   - it's for example: black  
>> point in
>> green area
> 
> green area?
> 
>> 319 -0.24716002  0.184830541
>> 302  0.69254402  0.132529652
>>
>> If it's impossible plese give me any package or function which can  
>> do it.
> 
> I already asked what was different about your code that was able to do  
> plotting without error on your machine.
> 
> -- 
> David
>>
>>
>> Max Kuhn wrote:
>>>
>>> I think we are having some difficulty understanding what you are
>>> looking for. If you are looking to find which of the training samples
>>> were closest to the prediction sample, I don't think that you can get
>>> it from this function.
>>>
>>> If this is what you want, I use the dist function in the proxy  
>>> package.
>>>
>>> Max
>>>
>>> On Tue, Oct 27, 2009 at 8:46 AM, David Winsemius >> >
>>> wrote:
>>>>
>>>> On Oct 27, 2009, at 6:02 AM, Grzes wrote:
>>>>
>>>>>
>>>>> Hi everybody!
>>>>>
>>>>> I want to find a closer neighbourins observation. This is my code:
>>>>> ##
>>>>> library(klaR)
>>>>> library(ipred)
>>>>> library(mlbench)
>>>>> data(PimaIndiansDiabetes2)
>>>>> dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
>>>>> dane[,2]=log(dane[,2])
>>>>> dane[,1:2]=scale(dane[,1:2])
>>>>> zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)
>>>>>
>>>>>
>>>>> klasyfikatorKNN=ipredknn(diabetes~glucose 
>>>>> +insulin,data=dane,subset=zbior.uczacy,k=3)
>>>>>
>>>>> oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],"class")
>>>>>
>>>>> #data frames with my result from klasyfikatorKNN
>>>>>
>>>>> df=data.frame(glucose=c(klasyfikatorKNN$learn$X[, 
>>>>> 1]),insulin=klasyfikatorKNN$learn$X[,2],diabetes=c(klasyfikatorKNN 
>>>>> $learn$y))
>>>>> #And picture
>>>>> drawparti(as.factor(df$diabetes), df$glucose, df$insulin, method =
>>>>> "sknn",
>>>>> prec = 100, xlab = NULL, ylab = NULL)
>>>>
>>>> I get an error: Error: could not find function "drawparti"
>>>>
>>>>>
>>>>> ##
>>>>> My question is:  How or where may I find correct or wrong values  
>>>>> which
>>>>> were
>>>>> drawn (found,classification) in this picture?
>>>>
>>>> No picture resulted.
>>>>
>>>>> It means I'm looking for  x, y
>>>>> values.
>>>>
>>>> Not sure exactly what you are asking. Does this modification to df  
>>>> and
>>>> fairly obvious the cross table help?
>>>>
>>>>>
>>>>> df=data.frame(glucose=c(klasyfikatorKNN$learn$X[, 
>>>>> 1]),insulin=klasyfikatorKNN$learn$X[, 
>>>>> 2],pred.diabetes=klasyfikatorKNN$learn$y,
>>>&g

Re: [R] "ipredknn" - How may I find values?

2009-10-27 Thread Grzes

Yes, I want to know which points in my picture are in red or green area.
For example:
.glucose..insulin.diabetes
609  0.95177272  1.139969011   - I want to know that it's for
example: black point in red area
253 -1.05724970 -1.158814331   - it's for example: black point in
green area
319 -0.24716002  0.184830541
302  0.69254402  0.132529652

If it's impossible plese give me any package or function which can do it. 


Max Kuhn wrote:
> 
> I think we are having some difficulty understanding what you are
> looking for. If you are looking to find which of the training samples
> were closest to the prediction sample, I don't think that you can get
> it from this function.
> 
> If this is what you want, I use the dist function in the proxy package.
> 
> Max
> 
> On Tue, Oct 27, 2009 at 8:46 AM, David Winsemius 
> wrote:
>>
>> On Oct 27, 2009, at 6:02 AM, Grzes wrote:
>>
>>>
>>> Hi everybody!
>>>
>>> I want to find a closer neighbourins observation. This is my code:
>>> ##
>>> library(klaR)
>>> library(ipred)
>>> library(mlbench)
>>> data(PimaIndiansDiabetes2)
>>> dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
>>> dane[,2]=log(dane[,2])
>>> dane[,1:2]=scale(dane[,1:2])
>>> zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)
>>>
>>>
>>> klasyfikatorKNN=ipredknn(diabetes~glucose+insulin,data=dane,subset=zbior.uczacy,k=3)
>>>
>>> oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],"class")
>>>
>>> #data frames with my result from klasyfikatorKNN
>>>
>>> df=data.frame(glucose=c(klasyfikatorKNN$learn$X[,1]),insulin=klasyfikatorKNN$learn$X[,2],diabetes=c(klasyfikatorKNN$learn$y))
>>> #And picture
>>> drawparti(as.factor(df$diabetes), df$glucose, df$insulin, method =
>>> "sknn",
>>> prec = 100, xlab = NULL, ylab = NULL)
>>
>> I get an error: Error: could not find function "drawparti"
>>
>>>
>>> ##
>>> My question is:  How or where may I find correct or wrong values which
>>> were
>>> drawn (found,classification) in this picture?
>>
>> No picture resulted.
>>
>>> It means I'm looking for  x, y
>>> values.
>>
>> Not sure exactly what you are asking. Does this modification to df and
>> fairly obvious the cross table help?
>>
>>>
>>> df=data.frame(glucose=c(klasyfikatorKNN$learn$X[,1]),insulin=klasyfikatorKNN$learn$X[,2],pred.diabetes=klasyfikatorKNN$learn$y,
>>> trueDiab=dane[,3])
>> Warning message:
>> In data.frame(glucose = c(klasyfikatorKNN$learn$X[, 1]), insulin =
>> klasyfikatorKNN$learn$X[,  :
>>  row names were found from a short variable and have been discarded
>>> with( df, table(pred.diabetes, trueDiab))
>>             trueDiab
>> pred.diabetes neg pos
>>          neg 174  86
>>          pos  88  44
>>
>>
>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/%22ipredknn%22---How-may-I-find-values--tp26074994p26074994.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> 
> -- 
> 
> Max
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/%22ipredknn%22---How-may-I-find-values--tp26074994p26078505.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] "ipredknn" - How may I find values?

2009-10-27 Thread Grzes

Hi everybody!

I want to find a closer neighbourins observation. This is my code:
##
library(klaR)
library(ipred)
library(mlbench)
data(PimaIndiansDiabetes2)
dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
dane[,2]=log(dane[,2])
dane[,1:2]=scale(dane[,1:2])
zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)

klasyfikatorKNN=ipredknn(diabetes~glucose+insulin,data=dane,subset=zbior.uczacy,k=3)

oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],"class")
 
#data frames with my result from klasyfikatorKNN
df=data.frame(glucose=c(klasyfikatorKNN$learn$X[,1]),insulin=klasyfikatorKNN$learn$X[,2],diabetes=c(klasyfikatorKNN$learn$y))
#And picture
drawparti(as.factor(df$diabetes), df$glucose, df$insulin, method = "sknn",
prec = 100, xlab = NULL, ylab = NULL) 

## 
My question is:  How or where may I find correct or wrong values which were
drawn (found,classification) in this picture? It means I'm looking for  x, y
values.


-- 
View this message in context: 
http://www.nabble.com/%22ipredknn%22---How-may-I-find-values--tp26074994p26074994.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] avoid NA in list

2009-09-07 Thread Grzes

Henrique and Peter,  thank you very much for your advices :)
-- 
View this message in context: 
http://www.nabble.com/avoid-NA-in-list-tp25321020p25330422.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] avoid NA in list

2009-09-06 Thread Grzes

Hi!
I Have list, for example:
...
[[22]]
[1]  27  51  69 107 119

[[23]]
[1] NA

[[24]]
[1] 54 57 62

And I would like to avoid NA value. Similar way like I may do it in vector
using na.value() function.
Do you have any idea?
-- 
View this message in context: 
http://www.nabble.com/avoid-NA-in-list-tp25321020p25321020.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Two packages in one method

2009-09-06 Thread Grzes

Hi!
I want to use one method "combinations" from "gtools" package but in my code
I must use also "dprep" method where is method "combinations" too. Mayby I
show you result my help function:

Help on topic 'combinations' was found in the following packages: 

  Package   Library 
  dprep /usr/lib64/R/library 
  gtools/usr/lib64/R/library 

Choose one 

1: Constructing distinct permutations {dprep} 
2: Enumerate the Combinations or Permutations of the Elements of a Vector
{gtools} 


If I want to use "combination" method I use error:

> combinations(3,2,letters[1:3]) 
Error in combinations(3, 2, letters[1:3]) : 
  unused argument(s) (2, letters[1:3])

Do you have any idea?
I try code similar to C++   gtools::combinations but in my opinion it's
wrong way.

If my explanation is't clear to you let me show my all attempts:


> library(gtools) 
> combinations(3,2,letters[1:3]) 
 [,1] [,2] 
[1,] "a"  "b" 
[2,] "a"  "c" 
[3,] "b"  "c" 
> library(dprep) 
Loading required package: MASS 
Loading required package: nnet 
Loading required package: lattice 
Loading required package: class 

Attaching package: 'dprep' 


The following object(s) are masked from package:gtools : 

combinations 

> combinations(3,2,letters[1:3]) 
Error in combinations(3, 2, letters[1:3]) : 
  unused argument(s) (2, letters[1:3]) 

> gtools::combinations  
function (n, r, v = 1:n, set = TRUE, repeats.allowed = FALSE) 
{ 
if (mode(n) != "numeric" || length(n) != 1 || n < 1 || (n%%1) != 
0) 
stop("bad value of n") 
if (mode(r) != "numeric" || length(r) != 1 || r < 1 || (r%%1) != 
0) 
stop("bad value of r") 
if (!is.atomic(v) || length(v) < n) 
stop("v is either non-atomic or too short") 
if ((r > n) & repeats.allowed == FALSE) 
stop("r > n and repeats.allowed=FALSE") 
if (set) { 
v <- unique(sort(v)) 
if (length(v) < n) 
stop("too few different elements") 
} 
v0 <- vector(mode(v), 0) 
if (repeats.allowed) 
sub <- function(n, r, v) { 
if (r == 0) 
v0 
else if (r == 1) 
matrix(v, n, 1) 
else if (n == 1) 
matrix(v, 1, r) 
else rbind(cbind(v[1], Recall(n, r - 1, v)), Recall(n - 
1, r, v[-1])) 
} 
else sub <- function(n, r, v) { 
if (r == 0) 
v0 
else if (r == 1) 
matrix(v, n, 1) 
else if (r == n) 
matrix(v, 1, n) 
else rbind(cbind(v[1], Recall(n - 1, r - 1, v[-1])), 
Recall(n - 1, r, v[-1])) 
} 
sub(n, r, v[1:n]) 
} 
 

> combinations(3,2,letters[1:3])  ### what I should do to 
> start working "combinations"?
Error in combinations(3, 2, letters[1:3]) : 
  unused argument(s) (2, letters[1:3]) 
-- 
View this message in context: 
http://www.nabble.com/Two-packages-in-one-method-tp25319739p25319739.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] about isoMDS method

2009-08-30 Thread Grzes

Yes, I'm using euclidean distances
-- 
View this message in context: 
http://www.nabble.com/about-isoMDS-method-tp25211016p25213217.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] about isoMDS method

2009-08-30 Thread Grzes

Hi,
For example:
I built a half matrix "w" using a daisy(x, metric = c("euclidean")) 
http://www.nabble.com/file/p25211016/1.jpg 

And next I transformed this matrix "w" using isoMDS function, for example
isoMDS(w, k=2) and as result I got:
http://www.nabble.com/file/p25211016/2.jpg 
And now I have a question:

1. If number in matrix  w[2, 1]  (= 0.41538462) match  two points (below) in
matrix created by isoMDS ?
http://www.nabble.com/file/p25211016/3.jpg 

Is this the same point?
-- 
View this message in context: 
http://www.nabble.com/about-isoMDS-method-tp25211016p25211016.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Best R text editors?

2009-08-30 Thread Grzes

Hello,
 
I'm using PLD Linux and in my opinion, if you looking for very easy editor -
Geany!!! It'll be fantastic ;)

-- 
View this message in context: 
http://www.nabble.com/Best-R-text-editors--tp25178744p25210782.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] dificult loop "for"

2009-08-23 Thread Grzes

Hi,
My english isn't briliant and my problem is very dificult to descripe 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 result
in matrix but I also want to call my function "odleg" use vector "e3" -
exactly using values which are inside.

Can anyone please guide me, how to do that? 
Thanks 

## Function 
odleg <- function (Xa,Xb,Ya,Yb){ 
d <- ((Xa-Xb)^2+(Ya-Yb)^2)^(1/2) 
return (d) 
} 

# Database 
ma=matrix(c(0.51139630,-0.12937287, 0.19530080,
0.02273691,-0.43634186,-0.01717149,-0.27597035,-0.41732933,-0.15476464,-0.15692965),nrow
= 5, ncol=2) 

e3<- c(1,2,4) 
for (i in e3[1] : e3[length(e3)]; (k in 1 : length(e3))){ 
for (j in e3[1] : e3[length(e3)]; (l in 1 : length(e3))){ 

me1[k,l] = odleg
(nepitabds$points[i,1],nepitabds$points[j,1],nepitabds$points[i,2],nepitabds$points[j,2])
 
}}
-- 
View this message in context: 
http://www.nabble.com/dificult-loop-%22for%22-tp25107157p25107157.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.