[R] coxme adequacy check

2015-10-28 Thread Cacique Samurai
Hello all!

I´m fitting a mixed effects cox model with coxme function of coxme
package. I want to konw what is the best way to check the model
adequacy, once that function cox.zph does not work for coxme objects.

Thanks in advanced,

Raoni

-- 
Raoni Rosa Rodrigues
Research Associate of Fish Transposition Center CTPeixes
Universidade Federal de Minas Gerais - UFMG
Brasil
rodrigues.ra...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Neuralnet package in R gives wrong output

2015-10-28 Thread John Kane
No attachements. R-help is very picky about attachements.

 I'd suggest supplying the data using dput() . See ?dput for more information

It is probably best to just copy and paste the code into your email. If this is 
no practical try sending a plain text file with a .txt extension

John Kane
Kingston ON Canada


> -Original Message-
> From: mar.sap...@gmail.com
> Sent: Tue, 27 Oct 2015 18:34:12 +0100
> To: r-help@r-project.org
> Subject: [R] Neuralnet package in R gives wrong output
> 
> I'm trying to generate prediction of the column "dubina" using this
> algorithm made in R's "neuralnet" package. But I keep getting
> non-reliable
> neural-net output. I have tried changing the number of hidden layers,
> normalizing and denormalizing data. Is there a mistake in the algorithm,
> maybe because of the activation function being logistic, not sigmoid?
> 
> The algorithm and the dataset are added as attachments but are added as
> attachments.
> 
> I'd be very grateful if you'd help me.
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.


Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Failed to read UTF-16LE file on Windows

2015-10-28 Thread Wush Wu
Dear all,

Here is an answer I found.

```
library(stringi)
src <- readBin("orglist-100.CSV", "raw", file.info("orglist-100.CSV")$size)
src2 <- stri_encode(src, "UTF-16LE", "UTF-8")
con <- textConnection(src2)
answer <- read.table(con, header = TRUE, sep = ",")
```

Hope it will help someone in the future.

Wush


2015-10-27 21:24 GMT+08:00 Wush Wu :

> Dear all,
>
> I tried to run the following code on 3 different OS:
>
> ```
> download.file("
> https://raw.githubusercontent.com/wush978/DataScienceAndR/course/RBasic-07-Loading-Dataset/orglist-100.CSV";,
> destfile = "orglist-100.CSV")
> con <- file("orglist-100.CSV", encoding = "UTF-16LE")
> src <- readLines(con)
> length(src) # should be 100
> ```
>
> On ubuntu and OS X, R correctly read 100 lines from the file. However, the
> windows will only read the first line with the following warning message:
>
> ```
> Warning message:
> In readLines(file("orglist-100.CSV", encoding = "UTF-16LE")) :
>   incomplete final line found on 'orglist-100.CSV'
> ```
>
> Is there any recommended way to read a local UTF-16LE file on windows?
>
> Thanks,
> Wush
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] coxme adequacy check

2015-10-28 Thread Therneau, Terry M., Ph.D.



On 10/28/2015 06:00 AM, r-help-requ...@r-project.org wrote:

Hello all!

I?m fitting a mixed effects cox model with coxme function of coxme package.
I want to konw what is the best way to check the model adequacy, once that
function cox.zph that does not work for coxme objects.

Thanks in advanced,

Raoni


No one has done the theory work to see if the method used by coxme extends to random 
effects models.  I suspect that it does, but that is a long way from a proof.  So at this 
point I don't have a good suggestion, even though I have been thinking about the problem.


Terry Therneau

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Extract entries from matrix

2015-10-28 Thread Jorge I Velez
Dear all,

I thought I would better send an image illustrating that the problem is
(hope the file gets through).  In the picture, the matrix "m" is given by

## input
m <- structure(c(0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 2, 2,
2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0,
0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
5), .Dim = c(12L, 5L))

We start from the entry [1,1] and select all values in the diagonal until
we find the first zero. That is, we select the values in purple.  Because
the first zero is found in [4,4], the next matrix begins in the 4th row.
The values of interest would be 1, 2, 3, 4, 5 (light blue).  The last value
in this resulting vector is entry m[8,5], which is located at the maximum
number of columns of m. Hence, the next matrix to work with starts at row 9
and the values of interest are 1, 2 (in orange).

The output vector would then be of the same length as the number of rows in
"m", and would contain the elements previously selected.

Any ideas on how to proceed?

Thank you very much in advance.

Best regards,
Jorge Velez.-



On Tue, Oct 27, 2015 at 4:38 PM, Jorge I Velez 
wrote:

> Thank you all for your solutions and comments.
>
> As Dr. Carlson mentioned, we leave rows 1 to 3 out as they are all zeroes.
> Then, the entries I need to select from m are
>
> 
> entry value
> 
> 4,1  ---> 1
> 5,2  ---> 2
> 6,3  ---> 3
> 7,1  ---> 1
> 8,2  ---> 2
> 9,3  ---> 3
> 10,4  ---> 4
> 11,5  ---> 5
> 12,1  ---> 1
>
> Note that the entry [7,4] is zero, so we start from the first column in
> the 7th row and then select entry [7,1] instead.  That's what I meant by  "...
> the idea is to extract the diagonal elements until a zero is found."  I
> should have said *entries* instead of  _diagonal elements_. I am sorry Dr.
> Turner for the confusion.
>
> Starting with m
>
> R> m
> #   [,1] [,2] [,3] [,4] [,5]
> # [1,]00000
> # [2,]00000
> # [3,]00000
> # [4,]12300
> # [5,]12300
> # [6,]12300
> # [7,]12300
> # [8,]12300
> # [9,]12340
> #[10,]12340
> #[11,]12345
> #[12,]12345
>
> the first submatrix to work with is
>
> # [4,]12300
> # [5,]12300
> # [6,]12300
>
> from which the elements of interest are 1, 2, 3.  Note that the 7th row of
> m is not included here because m[7, 5] = 0.
>
> Further, the second submatrix is
>
> # [7,]12300
> # [8,]12300
> # [9,]12340
> #[10,]12340
> #[11,]12345
>
> and the corresponding elements are 1, 2, 3, 4, 5.
>
> And the last matrix is
>
> #[12,]12345
>
> from which the position [12,1] is selected.
>
> So, the resulting entries from this process are 1, 2, 3, 1, 2, 3, 4, 5, 1.
>
> Thank you in advance for any additional insight you may provide.
>
> Regards,
> Jorge Velez.-
>
>
>
> On Tue, Oct 27, 2015 at 4:06 PM, David L Carlson 
> wrote:
>
>> I don't see how you are getting the result you provide.
>>
>> > m
>>   [,1] [,2] [,3] [,4] [,5]
>>  [1,]00000
>>  [2,]00000
>>  [3,]00000
>>  [4,]12300
>>  [5,]12300
>>  [6,]12300
>>  [7,]12300
>>  [8,]12300
>>  [9,]12340
>> [10,]12340
>> [11,]12345
>> [12,]12345
>> > t(sapply(1:8, function(x) diag(m[x:12, ])))
>>  [,1] [,2] [,3] [,4] [,5]
>> [1,]00000
>> [2,]00300
>> [3,]02300
>> [4,]12300
>> [5,]12300
>> [6,]12340
>> [7,]12345
>> [8,]12345
>>
>> These are all of the diagonals from the 1st through 8th rows. The first 3
>> begin with 0 so we leave them out, but then we have 4th: 1, 2, 3; 5th: 1,
>> 2, 3; 6th: 1, 2, 3, 4, etc so you must have some additional rule in mind to
>> get your answer.
>>
>> -
>> David L Carlson
>> Department of Anthropology
>> Texas A&M University
>> College Station, TX 77840-4352
>>
>>
>>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jorge I
>> Velez
>> Sent: Tuesday, October 27, 2015 2:44 PM
>> To: jim holtman
>> Cc: R-help
>> Subject: Re: [R] Extract entries from matrix
>>
>> Dear Jim,
>>
>> Thank you very much for your quick reply.
>>
>> I am sorry for the confusion it may have caused, but I messed up the
>> indexes in my example.  I would like, from the following matrix "m"
>>
>> ## input
>> m <- structure(c(0L, 0L, 0L, 1L, 1

Re: [R] Extract entries from matrix

2015-10-28 Thread Boris Steipe
Your code does not produce the matrix in your image.
The first three rows contain all-zeros and the last row is missing.
The following line fixes that:

m <- rbind(m[-(1:3), ], 1:5)

Given that matrix, the following code produces the output
you have illustrated. It's so trivial however that I suspect
something must be missing in your problem description.



v <- numeric(nrow(m))
j <- 1
for (i in 1:nrow(m)) {
if (j > ncol(m) || m[i,j] == 0) {
j <- 1
}
v[i] <- m[i,j]
j <- j+1
}

v

Note that this puts 0 in the output if
there is a zero in your first column and
the "diagonal". Your example didn't have that.



B.


On Oct 28, 2015, at 1:17 PM, Jorge I Velez  wrote:

> Dear all,
> 
> I thought I would better send an image illustrating that the problem is
> (hope the file gets through).  In the picture, the matrix "m" is given by
> 
> ## input
> m <- structure(c(0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 2, 2,
> 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0,
> 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
> 5), .Dim = c(12L, 5L))
> 
> We start from the entry [1,1] and select all values in the diagonal until
> we find the first zero. That is, we select the values in purple.  Because
> the first zero is found in [4,4], the next matrix begins in the 4th row.
> The values of interest would be 1, 2, 3, 4, 5 (light blue).  The last value
> in this resulting vector is entry m[8,5], which is located at the maximum
> number of columns of m. Hence, the next matrix to work with starts at row 9
> and the values of interest are 1, 2 (in orange).
> 
> The output vector would then be of the same length as the number of rows in
> "m", and would contain the elements previously selected.
> 
> Any ideas on how to proceed?
> 
> Thank you very much in advance.
> 
> Best regards,
> Jorge Velez.-
> 
> 
> 
> On Tue, Oct 27, 2015 at 4:38 PM, Jorge I Velez 
> wrote:
> 
>> Thank you all for your solutions and comments.
>> 
>> As Dr. Carlson mentioned, we leave rows 1 to 3 out as they are all zeroes.
>> Then, the entries I need to select from m are
>> 
>> 
>> entry value
>> 
>> 4,1  ---> 1
>> 5,2  ---> 2
>> 6,3  ---> 3
>> 7,1  ---> 1
>> 8,2  ---> 2
>> 9,3  ---> 3
>> 10,4  ---> 4
>> 11,5  ---> 5
>> 12,1  ---> 1
>> 
>> Note that the entry [7,4] is zero, so we start from the first column in
>> the 7th row and then select entry [7,1] instead.  That's what I meant by  
>> "...
>> the idea is to extract the diagonal elements until a zero is found."  I
>> should have said *entries* instead of  _diagonal elements_. I am sorry Dr.
>> Turner for the confusion.
>> 
>> Starting with m
>> 
>> R> m
>> #   [,1] [,2] [,3] [,4] [,5]
>> # [1,]00000
>> # [2,]00000
>> # [3,]00000
>> # [4,]12300
>> # [5,]12300
>> # [6,]12300
>> # [7,]12300
>> # [8,]12300
>> # [9,]12340
>> #[10,]12340
>> #[11,]12345
>> #[12,]12345
>> 
>> the first submatrix to work with is
>> 
>> # [4,]12300
>> # [5,]12300
>> # [6,]12300
>> 
>> from which the elements of interest are 1, 2, 3.  Note that the 7th row of
>> m is not included here because m[7, 5] = 0.
>> 
>> Further, the second submatrix is
>> 
>> # [7,]12300
>> # [8,]12300
>> # [9,]12340
>> #[10,]12340
>> #[11,]12345
>> 
>> and the corresponding elements are 1, 2, 3, 4, 5.
>> 
>> And the last matrix is
>> 
>> #[12,]12345
>> 
>> from which the position [12,1] is selected.
>> 
>> So, the resulting entries from this process are 1, 2, 3, 1, 2, 3, 4, 5, 1.
>> 
>> Thank you in advance for any additional insight you may provide.
>> 
>> Regards,
>> Jorge Velez.-
>> 
>> 
>> 
>> On Tue, Oct 27, 2015 at 4:06 PM, David L Carlson 
>> wrote:
>> 
>>> I don't see how you are getting the result you provide.
>>> 
 m
>>>  [,1] [,2] [,3] [,4] [,5]
>>> [1,]00000
>>> [2,]00000
>>> [3,]00000
>>> [4,]12300
>>> [5,]12300
>>> [6,]12300
>>> [7,]12300
>>> [8,]12300
>>> [9,]12340
>>> [10,]12340
>>> [11,]12345
>>> [12,]12345
 t(sapply(1:8, function(x) diag(m[x:12, ])))
>>> [,1] [,2] [,3] [,4] [,5]
>>> [1,]00000
>>> [2,]00300
>>> [3,]02300
>>> [4,]12300
>>> [5,]12300
>>> [6,]12340
>>> [7,]12345
>>> [8,]12345
>>> 
>>> These are all of the diago

[R] rbind - names in dataframe. Beginner Question

2015-10-28 Thread Dagmar Cimiotti

Hello,
It must be very easy.

I have data like this:
myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert", 
"Bert","Bert", "Duck"), Hunger=c(1,1,1,2,2,1,3) )

myframe
bighunger <- subset (myframe, myframe$Hunger>=2 &myframe$Hunger <3 )
bighunger
verybighunger <- subset(myframe,myframe$Hunger>=3)
verybighunger
hungry <- rbind (bighunger=bighunger,very=verybighunger)
hungry

BUT I want a result like this:
myframesresult <- data.frame(Hunger=c("bighunger","bighunger","very"), 
ID=c("Bert", "Bert", "duck"), Hunger=c(2,2,3))

myframesresult

Where is my mistake?
Very many thanks in advance!!
Dagmar

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] rbind - names in dataframe. Beginner Question

2015-10-28 Thread Sarah Goslee
If I'm reading this correctly, you want to add a column to your
dataframe with a name corresponding to the value in the Hunger column.

myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert",
"Bert","Bert", "Duck"), Hunger=c(1,1,1,2,2,1,3) )

myframe$Hungertype <- c("none", "bighunger", "verybighunger")[myframe$Hunger]

 ID HungerHungertype
1 Ernie  1  none
2 Ernie  1  none
3 Ernie  1  none
4  Bert  2 bighunger
5  Bert  2 bighunger
6  Bert  1  none
7  Duck  3 verybighunger

Then you can subset it to remove low values, sort it, etc.

On Wed, Oct 28, 2015 at 8:20 AM, Dagmar Cimiotti  wrote:
> Hello,
> It must be very easy.
>
> I have data like this:
> myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert",
> "Bert","Bert", "Duck"), Hunger=c(1,1,1,2,2,1,3) )
> myframe
> bighunger <- subset (myframe, myframe$Hunger>=2 &myframe$Hunger <3 )
> bighunger
> verybighunger <- subset(myframe,myframe$Hunger>=3)
> verybighunger
> hungry <- rbind (bighunger=bighunger,very=verybighunger)
> hungry
>
> BUT I want a result like this:
> myframesresult <- data.frame(Hunger=c("bighunger","bighunger","very"),
> ID=c("Bert", "Bert", "duck"), Hunger=c(2,2,3))
> myframesresult
>
> Where is my mistake?
> Very many thanks in advance!!
> Dagmar

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] problem with formula argument to randomForest

2015-10-28 Thread Ed Komp


The randomForest function generates an error whenever
I supply it with a formula using the function, I() to inhibit interpretation.
When I do so, I always get an error like this one:
 Error in unique(c("AsIs", oldClass(x))) : object 'Age' not found

Is this because of:
1.  a restriction for the randomForest function that I have not seen documented;
2.  a deficiency / error in randomForest; or
3.  an error in my calling sequence?

I am including a very simple example to demonstrate the problem.
Simply using   I()  generates the error.
This is not a meaningful use of I(), but is very simple.
My Interest is for  I(  / ) .

I also demonstrate that the usage of I() in a formula works just fine
for another discrimination function, lda.

The sample code is included after my signature, along with line-by-line output.

Thanks in advance !

Ed Komp
ITTC Lab, University of Kansas

===
> library(rpart)
> library(MASS)
> library(randomForest)
randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.
> formula <- as.formula('Kyphosis ~ Age + Number + Start')
> formula
Kyphosis ~ Age + Number + Start
> formulaWithI <- as.formula('Kyphosis ~ I(Age) + Number + Start')
> formulaWithI
Kyphosis ~ I(Age) + Number + Start
> fit <- randomForest(formula,   data=kyphosis)
> fitWithI <- randomForest(formulaWithI,   data=kyphosis)
Error in unique(c("AsIs", oldClass(x))) : object 'Age' not found
>
> fit <- lda(formula, data = kyphosis)
> fitWithI <- lda(formula, data = kyphosis)
> fitWithI
Call:
lda(formula, data = kyphosis)

Prior probabilities of groups:
   absent   present
0.7901235 0.2098765

Group means:
 Age   Number Start
absent  79.89062 3.75 12.609375
present 97.82353 5.176471  7.294118

Coefficients of linear discriminants:
LD1
Age 0.005910971
Number  0.291501797
Start  -0.170496626
>
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] randomForest_4.6-12 MASS_7.3-44 rpart_4.1-10

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Distribution hist

2015-10-28 Thread Adams, Jean
Something like this might help you get started.

Simulation <-
  c(10403, NA, NA, NA, NA, 11178, NA, NA, NA, NA, 11521, NA, NA,
  NA, NA, 11385, NA, NA, NA, NA, 10102, NA, NA, NA, NA, 10544.013,
  10339.925, 9912.695, 9928.198, 9932.112, 9008.05, 9437.174, 10406.784,
  10832.123, 11095.868, 10955.094, 10804.075, 9002.848, 11276.038,
  10503.487, 11899.525, 10085.509, 9109.918, 8953.339, 10135.833,
  11047.832, 14353.462, 8804.653, 11942.829, 7722.255, 9732.114,
  8413.027, 10213.796, 10091.471, 12317.169)

yl <- c(0, 2)
par(mfrow=c(1, 2), oma=c(0, 0, 2, 0))
matplot(Simulation, type="l", ylim=yl)
fhist <- hist(Simulation, plot=FALSE)
with(fhist, plot(counts, mids, ylim=yl, type="o"))
mtext("Dim Mo Simulation 2 years", outer=TRUE, side=3)


Jean

On Tue, Oct 27, 2015 at 3:17 PM, bgnumis bgnum  wrote:

> Hi all,
>
> I have this data on "sim" variable
>
>  10403.000NANANANA
>  11178.000NANANANA
>  11521.000NANANANA
>  11385.000NANANANA
> 10102.000NANANANA
>  10544.013 10339.925  9912.695  9928.198  9932.112
>   9008.050  9437.174 10406.784 10832.123 11095.868
>  10955.094 10804.075  9002.848 11276.038 10503.487
>  11899.525 10085.509  9109.918  8953.339 10135.833
>  11047.832 14353.462  8804.653 11942.829  7722.255
>   9732.114  8413.027 10213.796 10091.471 12317.169
>
> I want to use matplot on a left plot and a "distribution line" on a right
> plot.
>
> My idea is the same size from the ylim (max and min) on the left plot will
> be the same on the right plot (but I cannot get the same size so thar the
> right plot show the distribution of the matplot on the left.
>
> I tried this but canot (some suggest me using rect() for the boundaries of
> the second plot but I cannot achive what I want.
>
> I dont care if is it a hist or line plot but something similar a
> distribution shape (or like a bell)
>
>
> Can anyone try to help me?
>
> par(mar=c(10,6,6,6))
> matplot(Simulation,type="l",ylim=c(0,2))
>
>
> title(" Dim Mo Simulation 2 years",font=4)
> fhist<-hist(Simulation,plot=FALSE)
>
> par(mar=c(6,0,6,6))
> barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray")
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Lattice Package in R: Is it possible to develop an interactive “scatterplot/network”?

2015-10-28 Thread Luck Buttered
I am developing an interactive scatterplot so that when the user rolls over
a data point, a label is displayed. However, I would also like to add edges
between certain data points.

I am successful at developing the interactive scatterplot using several
libraries, including grid, gridSVG, lattice, and adegraphics. Below is a
MWE:

##

library(grid)
library(gridSVG)
library(lattice)
library(adegraphics)

x = rnorm(10)
y = rnorm(10)
dat = data.frame(label = letters[1:10], x, y)

customPanel2 <- function(x, y, ...) {
  for (j in 1:nrow(dat)) {
grid.circle(x[j], y[j], r = unit(.5, "mm"),
default.unit = "native",
name = paste("point", j, sep = "."))
  }}

xyplot(y ~ x, panel = customPanel2, xlab = "x variable", ylab=NULL,
scales=list(tck = c(1,0), y=list(at=NULL)))
for (i in 1:nrow(dat)) {
  grid.text(as.character(dat$label)[i], x = 0.1, y = 0.01, just =
c("left", "bottom"), name = paste("label", i, sep = "."), gp =
gpar(fontface = "bold.italic"))}
for (i in 1:nrow(dat)) {
  grid.garnish(paste("point", i, sep = "."), onmouseover =
paste('highlight("', i, '.1.1")', sep = ""), onmouseout =
paste('dim("', i, '.1.1")', sep = ""))
  grid.garnish(paste("label", i, sep = "."), visibility = "hidden")}

grid.script(filename = "aqm.js", inline = TRUE)
grid.export("interactiveScat.svg")

##

The resulting .svg file accomplishes everything I am aiming for - except
that I also wish to add certain non-interactive edges. I tried to do this
by incorporating the adeg.panel.edges method from the adegraphics library
after defining the edges and the coordinates to be mapped. So, basically my
MWE stays the exact same, except the xplot(...) function from before is
replaced with:

edges = matrix(c(1, 2, 3, 2, 4, 1, 3, 4), byrow = TRUE, ncol = 2)
coords <- matrix(c(x[1], y[1], x[2], y[2], x[3], y[3], x[4], y[4]),
byrow = TRUE, ncol = 2)

xyplot(y ~ x, panel = function(customPanel2){adeg.panel.edges(edges,
coords, lty = 1:4, cex = 5)}, xlab = "x variable", ylab=NULL,
scales=list(tck = c(1,0), y=list(at=NULL)))

It seems that this simply erases the interactive scatterplot made from the
original xyplot, and simply outputs the static edge and coordinate image.

I tried to follow the example as seen in (
http://finzi.psych.upenn.edu/library/adegraphics/html/adeg.panel.nb.html):

edges <- matrix(c(1, 2, 3, 2, 4, 1, 3, 4), byrow = TRUE, ncol = 2)
coords <- matrix(c(0, 1, 1, 0, 0, -1, -1, 0), byrow = TRUE, ncol = 2)
xyplot(coords[,2] ~ coords[,1],
  panel = function(...){adeg.panel.edges(edges, coords, lty = 1:4, cex = 5)})


I am a bit at a loss as to how to troubleshoot this problem. I suspect it
is a misuse of the ellipses function(...) in xyplot.

I read the xyplot help manual, and note that they state:

"It is useful to know in this context that all arguments passed to a
high-level Lattice function (such as xyplot) that are not recognized by it
are passed through to the panel function. It is thus generally good
practice when defining panel functions to allow a ... argument."

I feel I did define my panel function customPanel(...) using ellipses in my
MWE:

customPanel2 <- function(x, y, ...)

Any suggestions are greatly appreciated!

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.