Re: [R] dimnames in an array(I'll be grateful if this message will be passed to all list users)

2012-08-27 Thread William Dunlap
   res3 = Profile.LS(fhn, data=data2, times=times, pars=pars,
   coefs=coefs, lambda=lambda, out.meth='nls',
   control.in=control.in, control.out=control.out)

  #Rather than parameter estimates, as with the single replicate 
analysis, this produces the error:

   Error in as.array.default(Y) : attempt to set an attribute on 
NULL

This happens for me when I omit the basisvals argument to Profile.LS().
Profile.LS ought to catch this directly.

Profile.LS also produces a slew of warnings while running the example in its
help file.  E.g.,
  Warning in dim(weights[whichrows, ]) == dim(diffs) :
  longer object length is not a multiple of shorter object length

You may want to correspond with maintainer of the CollocInfer package:
  R maintainer(CollocInfer)
  [1] Giles Hooker gj...@cornell.edu

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

From: aleksandr shfets [mailto:a_shf...@mail.ru]
Sent: Wednesday, August 22, 2012 1:52 AM
To: William Dunlap
Cc: R. Michael Weylandt; r-help@r-project.org
Subject: Re[2]: [R] dimnames in an array(I'll be grateful if this message will 
be passed to all list users)

Hi,
Thank you for the suggestions.
I've attached the code in the text file test; to run this one needs the 
CollocInfer package(available under R 2.14, now I think if you have 2.14 on 
your system you can download CollocInfer from CRAN).

I've tried the 'error' options you suggest; using the syntax  
dimnames(data2)[1:2] does seem to give an improvement of the attributes of 
the array,

But even with the attributes seeming to be in as good order as they might 
be(i.e., each boxcar, [[1]],[[2]],[[3]] contains the correct number of names), 
rerunning the analysis with the revised array returns the same error.


traceback() gives
4: `colnames-`(`*tmp*`, value = c(V, R))
3: objective(.par, ...)
2: nlminb(coefs, SplineCoefsErr, gradient = SplineCoefsDC, hessian = Hessian,
   control = control.in, times = times, data = data, lik = lik,
   proc = proc, pars = pars)
1: inneropt(coefs = DEfd2$coefs, times = times, data = data2, lik = lik,
   proc = proc, pars = spars, in.meth = nlminb, control.in = control.out)

To my (untrained) eye, this points again to some kind of mismatch between the 
array 'data2' and its dimnames.

Again I'll be grateful if anyone can see what the problem is.

regards,

A
(recover() also is unfruitful)



Fri, 17 Aug 2012 15:28:19 + от William Dunlap 
wdun...@tibco.commailto:wdun...@tibco.com:
Have you showed us how to reproduce your original problem?
Have you showed us the output of traceback() after encountering
the error? Have you tried setting options(error=recover) before
encountering the error and then using recover() to look at the dimensions
and dimnames of the array that caused the problem?

This error message
  Error in `colnames-`(`*tmp*`, value = c(V, R)) :
  length of 'dimnames' [2] not equal to array extent
comes from a nested replacement operation. One such such case is
 mat - matrix(1:6,nrow=2,ncol=3)
 colnames(mat)[1:2] - c(V, R)
where the nested replacement gets expanded into
 tmp - colnames(mat) # tmp becomes NULL
 tmp[1:2] - c(V, R) # tmp becomes c(V,R), length is 2
 colnames(tmp) - tmp # error: 2 colnames for 3 columns
(R uses `*tmp*` where I used tmp - the former is for internal use only.)

There are lots of other possibilities, but you need to at least show the
output of traceback() to pin it down.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: 
 r-help-boun...@r-project.orgsentmsg?composeTo=r%2dhelp%2dbounces@r%2dproject.org
  
 [mailto:r-help-boun...@r-project.org]mailto:[mailto:r-help-boun...@r-project.org]
  On Behalf
 Of aleksandr shfets
 Sent: Friday, August 17, 2012 6:25 AM
 To: R. Michael Weylandt
 Cc: r-help@r-project.orgsentmsg?composeTo=r%2dhelp@r%2dproject.org
 Subject: Re: [R] dimnames in an array(I'll be grateful if this message will 
 be passed to all
 list users)


 Michael,
 Thank you for suggestions;
 it seems to me that there's a fundamental lacuna with respect to names of a 
 three
 dimensional array:
 that is, rownames fits dimension 1, colnames fits another dimension(that is, 
 3, if I read it
 correctly),
 but there is no specific name for the third dimension. I've tried setnames 
 thinking that
 this would be appropriate
 for naming the sets, but there is no such R function.

 On the other hand you're right, the suggestion
  dimnames(data11a)[[2]]=c(V,R)

 doesn't ameliorate the analysis: while now dimnames(data11a)[[2]]

 comes out as
 [2]

 returning to the original analysis the same error comes up, that is, that the 
 length of
 dimnames[2] doesn't agree with thee.
 'array extent' -- that is, even though the boxcar contents are two in number, 
 it evaluates
 the analysis on the basis of the
 dimnames(data11a)[2] value.

 I'm using colloc infer (available under R 2.14) and trying to do

Re: [R] dimnames in an array(I'll be grateful if this message will be passed to all list users)

2012-08-22 Thread aleksandr shfets
Hi,
Thank you for the suggestions.
I've attached the code in the text file test; to run this one needs the 
CollocInfer package(available under R 2.14, now I think if you have 2.14 on 
your system you can download CollocInfer from CRAN).

I've tried the 'error' options you suggest; using the syntax  
dimnames(data2)[1:2] does seem to give an improvement of the attributes of 
the array,

But even with the attributes seeming to be in as good order as they might 
be(i.e., each boxcar, [[1]],[[2]],[[3]] contains the correct number of names), 
rerunning the analysis with the revised array returns the same error.


traceback() gives
4: `colnames-`(`*tmp*`, value = c(V, R))
3: objective(.par, ...)
2: nlminb(coefs, SplineCoefsErr, gradient = SplineCoefsDC, hessian = Hessian, 
   control = control.in, times = times, data = data, lik = lik, 
   proc = proc, pars = pars)
1: inneropt(coefs = DEfd2$coefs, times = times, data = data2, lik = lik, 
   proc = proc, pars = spars, in.meth = nlminb, control.in = control.out)

To my (untrained) eye, this points again to some kind of mismatch between the 
array 'data2' and its dimnames.

Again I'll be grateful if anyone can see what the problem is.

regards,

A
(recover() also is unfruitful)



Fri, 17 Aug 2012 15:28:19 + от William Dunlap wdun...@tibco.com:
   








Have you showed us how to reproduce your original problem?

Have you showed us the output of traceback() after encountering

the error?  Have you tried setting options(error=recover) before

encountering the error and then using recover() to look at the dimensions

and dimnames of the array that caused the problem?


This error message

Error in `colnames-`(`*tmp*`, value = c(V, R)) :

length of 'dimnames' [2] not equal to array extent

comes from a nested replacement operation.  One such such case is

 mat - matrix(1:6,nrow=2,ncol=3)

 colnames(mat)[1:2] - c(V, R)

where the nested replacement gets expanded into

 tmp - colnames(mat) # tmp becomes NULL

 tmp[1:2] - c(V, R) # tmp becomes c(V,R), length is 2

 colnames(tmp) - tmp # error: 2 colnames for 3 columns

(R uses `*tmp*` where I used tmp - the former is for internal use only.)


There are lots of other possibilities, but you need to at least show the

output of traceback() to pin it down.


Bill Dunlap

Spotfire, TIBCO Software

wdunlap tibco.com



 -Original Message-

 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf

 Of aleksandr shfets

 Sent: Friday, August 17, 2012 6:25 AM

 To: R. Michael Weylandt

 Cc: r-help@r-project.org

 Subject: Re: [R] dimnames in an array(I'll be grateful if this message will 
 be passed to all

 list users)

 

 

 Michael,

 Thank you for suggestions;

 it seems to me that there's a fundamental lacuna with respect to names of a 
 three

 dimensional array:

 that is, rownames fits dimension 1, colnames fits another dimension(that is, 
 3, if I read it

 correctly),

 but there is no specific name for the third dimension. I've tried setnames 
 thinking that

 this would be appropriate

 for naming the sets, but there is no such R function.

 

 On the other hand you're right, the suggestion

  dimnames(data11a)[[2]]=c(V,R)

 

 doesn't ameliorate the analysis: while now dimnames(data11a)[[2]]

 

 comes out as

 [2]

 

 returning to the original analysis the same error comes up, that is, that the 
 length of

 dimnames[2] doesn't agree with thee.

 'array extent' -- that is, even though the boxcar contents are two in number, 
 it evaluates

 the analysis on the basis of the

 dimnames(data11a)[2] value.

 

 I'm using colloc infer (available under R 2.14) and trying to do the 
 FHN(FitzHugh Nagumo)

 analysis in section 9.1 of the manual; it's very complex work, but I doubt 
 the program is

 in error.

 

 It seems to me in any case that, if R demands that the length of 'dimnames[2] 
 must be

 equal to the array extent, then there must be a way to make the length of the 
 names

 equal to the extent of the array, am I right?

 Otherwise R would be inconsistent with itself, like Nomad on Startrek, and 
 I've never

 seen a case where it was thus.

 

 This is again why I ask if others with extensive experience with dimnames of 
 an array

 have seen anything similar.

 Certainly someone might know what is the significance of the dimnames of the 
 array,

 how much can the length of them be altered for use generally?

 

 regards,

 A

 Thu, 16 Aug 2012 00:00:35 -0400 от R. Michael Weylandt

 michael.weyla...@gmail.com:

 

 

 

 

 

 

 

 

 

 On Wed, Aug 15, 2012 at 3:57 AM, aleksandr shfets a_shf...@mail.ru wrote:

 

  Hi Michael,

 

  Thanks for help on double brackets: I wasn't aware of this use of them.

 

 

 

  I went back to readjust my array so the dimnames(data11a)[[2]] would have

 

  two

Re: [R] dimnames in an array(I'll be grateful if this message will be passed to all list users)

2012-08-17 Thread aleksandr shfets

Michael,
Thank you for suggestions; 
it seems to me that there's a fundamental lacuna with respect to names of a 
three dimensional array:
that is, rownames fits dimension 1, colnames fits another dimension(that is, 3, 
if I read it correctly),
but there is no specific name for the third dimension. I've tried setnames 
thinking that this would be appropriate 
for naming the sets, but there is no such R function.

On the other hand you're right, the suggestion
             dimnames(data11a)[[2]]=c(V,R)

doesn't ameliorate the analysis: while now dimnames(data11a)[[2]]

comes out as 
[2]

returning to the original analysis the same error comes up, that is, that the 
length of dimnames[2] doesn't agree with thee.
'array extent' -- that is, even though the boxcar contents are two in number, 
it evaluates the analysis on the basis of the 
dimnames(data11a)[2] value.

I'm using colloc infer (available under R 2.14) and trying to do the 
FHN(FitzHugh Nagumo) analysis in section 9.1 of the manual; it's very complex 
work, but I doubt the program is in error.

It seems to me in any case that, if R demands that the length of 'dimnames[2] 
must be equal to the array extent, then there must be a way to make the length 
of the names equal to the extent of the array, am I right?
Otherwise R would be inconsistent with itself, like Nomad on Startrek, and I've 
never seen a case where it was thus.

This is again why I ask if others with extensive experience with dimnames of an 
array have seen anything similar.
Certainly someone might know what is the significance of the dimnames of the 
array, how much can the length of them be altered for use generally?

regards,
A
Thu, 16 Aug 2012 00:00:35 -0400 от R. Michael Weylandt 
michael.weyla...@gmail.com:
   








On Wed, Aug 15, 2012 at 3:57 AM, aleksandr shfets a_shf...@mail.ru wrote:

 Hi Michael,

 Thanks for help on double brackets: I wasn't aware of this use of them.



 I went back to readjust my array so the dimnames(data11a)[[2]] would have

 two elements, and remade the array to include the new dimnames:



 dimnames(data11a)[[2]]=c(V,R)



 so that inside the second car of the train would

 be two items?


Yes.




 There seems to be no way to define dimnames(data11a)[2] to be two elements

 rather than one[as you say we have no way to combine the elements of the

 train except using the train].


You could do this:


dimnames(data11a)[2] - list(c(V,R))


but I'm not sure that's any clearer. To keep the metaphor rolling (get

it!), list() puts your stuff in a boxcar so now you can put it

directly on the train.


 So having tried to do what I can to make the

 middle element of the list to two rather than one, I rerun the analysis with

 the same result.



 if I read the thing right, regardless of how I define the inside of the

 boxcar, the analysis that I referred to



  res11a = inneropt(coefs, times=times, data=data11a,

 lik=lik,

  proc=proc, pars=spars, in.meth='nlminb',

 control.in=control.out)




Where is this inneropt function from? It could be an error in that. If

it's from a package, give me the name and I'll take a look at it and

you can also contact the maintainer: get contact info using the

maintainer() function.


Also, some of the advice here will probably be helpful  in seeking follow-up:

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example


Cheers,

Michael


 still won't look at the 'contents' of the car, but gives the same message:



   Error in `colnames-`(`*tmp*`, value = c(V, R)) :

   length of 'dimnames' [2] not equal to array extent





 I've tried a couple of other things like, after defining the second boxcar

 as:



   dimnames(data11a)[[2]]=c(V,R)





 then





dimnames(data11a)[2]=list(dimnames(data11a)[[2]])





 but this last generates an error.



 Somehow I think that that the clue to the thing is in the error message:

 what I see[ with my untrained eye] is that there should be some way to

 reconcile the three-- colnames, dimnames and the array- to a greater degree

 than their present agreement.

 Am I right?

 regards,

 Russell



 Tue, 14 Aug 2012 01:27:50 -0400 от R. Michael Weylandt

 michael.weyla...@gmail.com:



 On Mon, Aug 13, 2012 at 5:10 AM, aleksandr russell sss...@gmail.com wrote:

 Hello,



 I'm hoping someone with a wide experience with R may be able to see

 what the program is trying to tell me.



 I've got an array:



 y1=rnorm(41,0.2)

 y2=rnorm(41,0.2)

 y3=rbind(y1,y2)







 data11-array(0,c(41,2,2))

 data11[,1,]=y3

 data11[,2,]=y3

 rownames(data11)-rownames(data11, do.NULL = FALSE, prefix = Obs.)

 colnames=c(V,R)

 varnames=c(one,two)

 dimnames(data11)-list(rownames(data11), varnames, colnames)







 data11a-as.array(data11, dimnames=dimnames(data11))



 

Re: [R] dimnames in an array(I'll be grateful if this message will be passed to all list users)

2012-08-17 Thread William Dunlap
Have you showed us how to reproduce your original problem?
Have you showed us the output of traceback() after encountering
the error?  Have you tried setting options(error=recover) before
encountering the error and then using recover() to look at the dimensions
and dimnames of the array that caused the problem?

This error message
Error in `colnames-`(`*tmp*`, value = c(V, R)) :
length of 'dimnames' [2] not equal to array extent
comes from a nested replacement operation.  One such such case is
 mat - matrix(1:6,nrow=2,ncol=3)
 colnames(mat)[1:2] - c(V, R)
where the nested replacement gets expanded into
 tmp - colnames(mat) # tmp becomes NULL
 tmp[1:2] - c(V, R) # tmp becomes c(V,R), length is 2
 colnames(tmp) - tmp # error: 2 colnames for 3 columns
(R uses `*tmp*` where I used tmp - the former is for internal use only.)

There are lots of other possibilities, but you need to at least show the
output of traceback() to pin it down.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of aleksandr shfets
 Sent: Friday, August 17, 2012 6:25 AM
 To: R. Michael Weylandt
 Cc: r-help@r-project.org
 Subject: Re: [R] dimnames in an array(I'll be grateful if this message will 
 be passed to all
 list users)
 
 
 Michael,
 Thank you for suggestions;
 it seems to me that there's a fundamental lacuna with respect to names of a 
 three
 dimensional array:
 that is, rownames fits dimension 1, colnames fits another dimension(that is, 
 3, if I read it
 correctly),
 but there is no specific name for the third dimension. I've tried setnames 
 thinking that
 this would be appropriate
 for naming the sets, but there is no such R function.
 
 On the other hand you're right, the suggestion
  dimnames(data11a)[[2]]=c(V,R)
 
 doesn't ameliorate the analysis: while now dimnames(data11a)[[2]]
 
 comes out as
 [2]
 
 returning to the original analysis the same error comes up, that is, that the 
 length of
 dimnames[2] doesn't agree with thee.
 'array extent' -- that is, even though the boxcar contents are two in number, 
 it evaluates
 the analysis on the basis of the
 dimnames(data11a)[2] value.
 
 I'm using colloc infer (available under R 2.14) and trying to do the 
 FHN(FitzHugh Nagumo)
 analysis in section 9.1 of the manual; it's very complex work, but I doubt 
 the program is
 in error.
 
 It seems to me in any case that, if R demands that the length of 'dimnames[2] 
 must be
 equal to the array extent, then there must be a way to make the length of the 
 names
 equal to the extent of the array, am I right?
 Otherwise R would be inconsistent with itself, like Nomad on Startrek, and 
 I've never
 seen a case where it was thus.
 
 This is again why I ask if others with extensive experience with dimnames of 
 an array
 have seen anything similar.
 Certainly someone might know what is the significance of the dimnames of the 
 array,
 how much can the length of them be altered for use generally?
 
 regards,
 A
 Thu, 16 Aug 2012 00:00:35 -0400 от R. Michael Weylandt
 michael.weyla...@gmail.com:
 
 
 
 
 
 
 
 
 
 On Wed, Aug 15, 2012 at 3:57 AM, aleksandr shfets a_shf...@mail.ru wrote:
 
  Hi Michael,
 
  Thanks for help on double brackets: I wasn't aware of this use of them.
 
 
 
  I went back to readjust my array so the dimnames(data11a)[[2]] would have
 
  two elements, and remade the array to include the new dimnames:
 
 
 
  dimnames(data11a)[[2]]=c(V,R)
 
 
 
  so that inside the second car of the train would
 
  be two items?
 
 
 Yes.
 
 
 
 
  There seems to be no way to define dimnames(data11a)[2] to be two elements
 
  rather than one[as you say we have no way to combine the elements of the
 
  train except using the train].
 
 
 You could do this:
 
 
 dimnames(data11a)[2] - list(c(V,R))
 
 
 but I'm not sure that's any clearer. To keep the metaphor rolling (get
 
 it!), list() puts your stuff in a boxcar so now you can put it
 
 directly on the train.
 
 
  So having tried to do what I can to make the
 
  middle element of the list to two rather than one, I rerun the analysis with
 
  the same result.
 
 
 
  if I read the thing right, regardless of how I define the inside of the
 
  boxcar, the analysis that I referred to
 
 
 
   res11a = inneropt(coefs, times=times, data=data11a,
 
  lik=lik,
 
   proc=proc, pars=spars, in.meth='nlminb',
 
  control.in=control.out)
 
 
 
 
 Where is this inneropt function from? It could be an error in that. If
 
 it's from a package, give me the name and I'll take a look at it and
 
 you can also contact the maintainer: get contact info using the
 
 maintainer() function.
 
 
 Also, some of the advice here will probably be helpful  in seeking follow-up:
 
 http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-
 example
 
 
 Cheers

Re: [R] dimnames in an array(I'll be grateful if this message will be passed to all list users)

2012-08-17 Thread R. Michael Weylandt michael.weyla...@gmail.com


On Aug 17, 2012, at 9:25 AM, aleksandr shfets a_shf...@mail.ru wrote:

 
 Michael,
 Thank you for suggestions; 
 it seems to me that there's a fundamental lacuna with respect to names of a 
 three dimensional array:

A lacuna in the English language, not in R: though perhaps Prof Ripley's 
employer's dictionary's editors could help us out ;-) 

[that might be the closest I've ever gotten to chained pointers in a natural 
language]

 that is, rownames fits dimension 1, colnames fits another dimension(that is, 
 3, if I read it correctly),
 but there is no specific name for the third dimension. I've tried setnames 
 thinking that this would be appropriate 
 for naming the sets, but there is no such R function.
 
 On the other hand you're right, the suggestion
  dimnames(data11a)[[2]]=c(V,R)
 
 doesn't ameliorate the analysis: while now dimnames(data11a)[[2]]
 
 comes out as 
 [2]
 
 returning to the original analysis the same error comes up, that is, that the 
 length of dimnames[2] doesn't agree with thee.

I don't believe I made any prescriptions about length(dimnames[2]) so I have no 
idea what you mean here about it not agreeing with me.

Also, there's almost no chance that's valid syntax: it should throw a 'closure 
not subsettable' error unless you over-wrote the name of a very important 
function (which you should not do).

 And I believe I told you that you want double brackets here. 

 'array extent' -- that is, even though the boxcar contents are two in number, 
 it evaluates the analysis on the basis of the 
 dimnames(data11a)[2] value.

No! Double brackets. 

 
 I'm using colloc infer (available under R 2.14) and trying to do the 
 FHN(FitzHugh Nagumo) analysis in section 9.1 of the manual; it's very complex 
 work, but I doubt the program is in error.

I'm travelling currently so I can't track this down (no wifi) but I'll try 
later. In the meanwhile, see Bill Dunlap's suggestions. 

 
 It seems to me in any case that, if R demands that the length of 'dimnames[2] 
 must be equal to the array extent, then there must be a way to make the 
 length of the names equal to the extent of the array, am I right?

Again -- your code (dimnames[2]) looks like nonsense -- I think you've 
overwritten a function that you shouldn't have. 

 Otherwise R would be inconsistent with itself, like Nomad on Startrek, and 
 I've never seen a case where it was thus.

Really? Never thought about the S3 naming conventions then

 
 This is again why I ask if others with extensive experience with dimnames of 
 an array have seen anything similar.
 Certainly someone might know what is the significance of the dimnames of the 
 array, how much can the length of them be altered for use generally?

Dimnames must have lengths which correspond to the dimensions of the underlying 
array -- that is 

dim(a) == sapply(dimnames(a) length)

Nothing else really makes sense. The only way to change the lengths of the 
dimnames is to reshape the array. 

Michael

 
 regards,
 A
 Thu, 16 Aug 2012 00:00:35 -0400 от R. Michael Weylandt 
 michael.weyla...@gmail.com:
 On Wed, Aug 15, 2012 at 3:57 AM, aleksandr shfets a_shf...@mail.ru wrote:
  Hi Michael,
  Thanks for help on double brackets: I wasn't aware of this use of them.
 
  I went back to readjust my array so the dimnames(data11a)[[2]] would have
  two elements, and remade the array to include the new dimnames:
 
  dimnames(data11a)[[2]]=c(V,R)
 
  so that inside the second car of the train would
  be two items?
 
 Yes.
 
 
  There seems to be no way to define dimnames(data11a)[2] to be two elements
  rather than one[as you say we have no way to combine the elements of the
  train except using the train].
 
 You could do this:
 
 dimnames(data11a)[2] - list(c(V,R))
 
 but I'm not sure that's any clearer. To keep the metaphor rolling (get
 it!), list() puts your stuff in a boxcar so now you can put it
 directly on the train.
 
  So having tried to do what I can to make the
  middle element of the list to two rather than one, I rerun the analysis with
  the same result.
 
  if I read the thing right, regardless of how I define the inside of the
  boxcar, the analysis that I referred to
 
  res11a = inneropt(coefs, times=times, data=data11a,
  lik=lik,
  proc=proc, pars=spars, in.meth='nlminb',
  control.in=control.out)
 
 
 Where is this inneropt function from? It could be an error in that. If
 it's from a package, give me the name and I'll take a look at it and
 you can also contact the maintainer: get contact info using the
 maintainer() function.
 
 Also, some of the advice here will probably be helpful in seeking follow-up:
 
 http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
 
 Cheers,
 Michael
 
  still won't look at the 'contents' of the car, but gives the same message:
 
  Error in `colnames-`(`*tmp*`, value = c(V, R)) :
  length of 'dimnames' [2] not equal to array extent
 
 
  I've tried a couple of other things like, after 

Re: [R] dimnames in an array(I'll be grateful if this message will be passed to all list users)

2012-08-15 Thread aleksandr shfets
Hi Michael,
Thanks for help on double brackets: I wasn't aware of this use of them.

I went back to readjust my array so the dimnames(data11a)[[2]] would have two 
elements, and remade the array to include the new dimnames:

dimnames(data11a)[[2]]=c(V,R)

so that inside the second car of the train would 
be two items?

There seems to be no way to define dimnames(data11a)[2] to be two elements 
rather than one[as you say we have no way to combine the elements of the train 
except using the train]. So having tried to do what I can to make the middle 
element of the list to two rather than one, I rerun the analysis with the same 
result.

if I read the thing right, regardless of how I define the inside of the 
boxcar, the analysis that I referred to 

                 res11a = inneropt(coefs, times=times, data=data11a, 
lik=lik,
                 proc=proc, pars=spars, in.meth='nlminb', 
control.in=control.out) 

still won't look at the 'contents' of the car, but gives the same message:

                  Error in `colnames-`(`*tmp*`, value = c(V, R)) 
: 
                  length of 'dimnames' [2] not equal to array extent
I've tried a couple of other things like, after defining the second boxcar as:

                  dimnames(data11a)[[2]]=c(V,R)


then


                   dimnames(data11a)[2]=list(dimnames(data11a)[[2]])


but this last generates an error.

Somehow I think that that the clue to the thing is in the error message: what I 
see[ with my untrained eye] is that there should be some way to reconcile the 
three-- colnames, dimnames and the array- to a greater degree than their 
present agreement.
Am I right?
regards,
Russell 

Tue, 14 Aug 2012 01:27:50 -0400 от R. Michael Weylandt 
michael.weyla...@gmail.com:
   
On Mon, Aug 13, 2012 at 5:10 AM, aleksandr russell sss...@gmail.com wrote:

 Hello,



 I'm hoping someone with a wide experience with R may be able to see

 what the program is trying to tell me.



 I've got an array:



 y1=rnorm(41,0.2)

 y2=rnorm(41,0.2)

 y3=rbind(y1,y2)







 data11-array(0,c(41,2,2))

 data11[,1,]=y3

 data11[,2,]=y3

 rownames(data11)-rownames(data11, do.NULL = FALSE, prefix = Obs.)

 colnames=c(V,R)

 varnames=c(one,two)

 dimnames(data11)-list(rownames(data11), varnames, colnames)







 data11a-as.array(data11, dimnames=dimnames(data11))


# No effect here

 identical(data11, data11a) # TRUE




 The analysis that I would like to do with R(CollocInfer) runs as

 follows(I print for the sake of introduction here though to run this

 line of code requires extensive setup)



 res11a = inneropt(coefs, times=times, data=data11a, lik=lik,

 proc=proc, pars=spars, in.meth='nlminb', control.in=control.out)







 The response I get is



 Error in 'colnames-'('*tmp*', value = c(V,R)) :

length of 'dimnames' [2] not equal to array extent







 It seems to me that there is a fundamental match of 'dimnames' with

 the array that is being referred to.



 I have learned that the normal length of dimnames for an array is one

 for each element in the list: thus as I've set up the array, the

 length(dimnames(data11a)[2]) gives me



 [1]


I believe you are looking for


length(dimnames(data11a)[[2]]) # 2


Look into the difference between `[` and `[[` for subsetting a list.

See ?Extract for the gorey details, but I like my little train

metaphor:


If the list x, is a train: x[2] is the sub-train consisting only

of the second car, while x[[2]] is the contents of that second car.

Hence we can do x[1:3] to give a well defined train, but not x[[1:3]]

because we have no way to combine the elements of the first three cars

other than using a train.


Cheers,

Michael




 I would like to ask :Is it not evident from R's response that there is

 some other possibility for the dimnames[2] of the array?



 If so, what is it?



 regards,

 A



 __

 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.


[[alternative HTML version deleted]]

__
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] dimnames in an array(I'll be grateful if this message will be passed to all list users)

2012-08-15 Thread R. Michael Weylandt
On Wed, Aug 15, 2012 at 3:57 AM, aleksandr shfets a_shf...@mail.ru wrote:
 Hi Michael,
 Thanks for help on double brackets: I wasn't aware of this use of them.

 I went back to readjust my array so the dimnames(data11a)[[2]] would have
 two elements, and remade the array to include the new dimnames:

 dimnames(data11a)[[2]]=c(V,R)

 so that inside the second car of the train would
 be two items?

Yes.


 There seems to be no way to define dimnames(data11a)[2] to be two elements
 rather than one[as you say we have no way to combine the elements of the
 train except using the train].

You could do this:

dimnames(data11a)[2] - list(c(V,R))

but I'm not sure that's any clearer. To keep the metaphor rolling (get
it!), list() puts your stuff in a boxcar so now you can put it
directly on the train.

 So having tried to do what I can to make the
 middle element of the list to two rather than one, I rerun the analysis with
 the same result.

 if I read the thing right, regardless of how I define the inside of the
 boxcar, the analysis that I referred to

  res11a = inneropt(coefs, times=times, data=data11a,
 lik=lik,
  proc=proc, pars=spars, in.meth='nlminb',
 control.in=control.out)


Where is this inneropt function from? It could be an error in that. If
it's from a package, give me the name and I'll take a look at it and
you can also contact the maintainer: get contact info using the
maintainer() function.

Also, some of the advice here will probably be helpful  in seeking follow-up:

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Cheers,
Michael

 still won't look at the 'contents' of the car, but gives the same message:

   Error in `colnames-`(`*tmp*`, value = c(V, R)) :
   length of 'dimnames' [2] not equal to array extent


 I've tried a couple of other things like, after defining the second boxcar
 as:

   dimnames(data11a)[[2]]=c(V,R)


 then


dimnames(data11a)[2]=list(dimnames(data11a)[[2]])


 but this last generates an error.

 Somehow I think that that the clue to the thing is in the error message:
 what I see[ with my untrained eye] is that there should be some way to
 reconcile the three-- colnames, dimnames and the array- to a greater degree
 than their present agreement.
 Am I right?
 regards,
 Russell

 Tue, 14 Aug 2012 01:27:50 -0400 от R. Michael Weylandt
 michael.weyla...@gmail.com:

 On Mon, Aug 13, 2012 at 5:10 AM, aleksandr russell sss...@gmail.com wrote:
 Hello,

 I'm hoping someone with a wide experience with R may be able to see
 what the program is trying to tell me.

 I've got an array:

 y1=rnorm(41,0.2)
 y2=rnorm(41,0.2)
 y3=rbind(y1,y2)



 data11-array(0,c(41,2,2))
 data11[,1,]=y3
 data11[,2,]=y3
 rownames(data11)-rownames(data11, do.NULL = FALSE, prefix = Obs.)
 colnames=c(V,R)
 varnames=c(one,two)
 dimnames(data11)-list(rownames(data11), varnames, colnames)



 data11a-as.array(data11, dimnames=dimnames(data11))

 # No effect here
  identical(data11, data11a) # TRUE


 The analysis that I would like to do with R(CollocInfer) runs as
 follows(I print for the sake of introduction here though to run this
 line of code requires extensive setup)

 res11a = inneropt(coefs, times=times, data=data11a, lik=lik,
 proc=proc, pars=spars, in.meth='nlminb', control.in=control.out)



 The response I get is

 Error in 'colnames-'('*tmp*', value = c(V,R)) :
 length of 'dimnames' [2] not equal to array extent



 It seems to me that there is a fundamental match of 'dimnames' with
 the array that is being referred to.

 I have learned that the normal length of dimnames for an array is one
 for each element in the list: thus as I've set up the array, the
 length(dimnames(data11a)[2]) gives me

 [1]

 I believe you are looking for

 length(dimnames(data11a)[[2]]) # 2

 Look into the difference between `[` and `[[` for subsetting a list.
 See ?Extract for the gorey details, but I like my little train
 metaphor:

 If the list x, is a train: x[2] is the sub-train consisting only
 of the second car, while x[[2]] is the contents of that second car.
 Hence we can do x[1:3] to give a well defined train, but not x[[1:3]]
 because we have no way to combine the elements of the first three cars
 other than using a train.

 Cheers,
 Michael


 I would like to ask :Is it not evident from R's response that there is
 some other possibility for the dimnames[2] of the array?

 If so, what is it?

 regards,
 A

 __
 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 

[R] dimnames in an array(I'll be grateful if this message will be passed to all list users)

2012-08-13 Thread aleksandr russell
Hello,

I'm hoping someone with a wide experience with R may be able to see
what the program is trying to tell me.

I've got an array:

y1=rnorm(41,0.2)
y2=rnorm(41,0.2)
y3=rbind(y1,y2)



data11-array(0,c(41,2,2))
data11[,1,]=y3
data11[,2,]=y3
rownames(data11)-rownames(data11, do.NULL = FALSE, prefix = Obs.)
colnames=c(V,R)
varnames=c(one,two)
dimnames(data11)-list(rownames(data11), varnames, colnames)



data11a-as.array(data11, dimnames=dimnames(data11))

The analysis that I would like to do with R(CollocInfer) runs as
follows(I print for the sake of introduction here though to run this
line of code requires extensive setup)

res11a = inneropt(coefs, times=times, data=data11a, lik=lik,
proc=proc, pars=spars, in.meth='nlminb', control.in=control.out)



The response I get is

Error in 'colnames-'('*tmp*', value = c(V,R)) :
   length of 'dimnames' [2] not equal to array extent



It seems to me that there is a fundamental match of 'dimnames' with
the array that is being referred to.

I have learned that the normal length of dimnames for an array is one
for each element in the list: thus as I've set up the array, the
length(dimnames(data11a)[2]) gives me

[1]

I would like to ask :Is it not evident from R's response that there is
some other possibility for the dimnames[2] of the array?

If so, what is it?

regards,
A

__
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] dimnames in an array(I'll be grateful if this message will be passed to all list users)

2012-08-13 Thread R. Michael Weylandt
On Mon, Aug 13, 2012 at 5:10 AM, aleksandr russell sss...@gmail.com wrote:
 Hello,

 I'm hoping someone with a wide experience with R may be able to see
 what the program is trying to tell me.

 I've got an array:

 y1=rnorm(41,0.2)
 y2=rnorm(41,0.2)
 y3=rbind(y1,y2)



 data11-array(0,c(41,2,2))
 data11[,1,]=y3
 data11[,2,]=y3
 rownames(data11)-rownames(data11, do.NULL = FALSE, prefix = Obs.)
 colnames=c(V,R)
 varnames=c(one,two)
 dimnames(data11)-list(rownames(data11), varnames, colnames)



 data11a-as.array(data11, dimnames=dimnames(data11))

# No effect here
 identical(data11, data11a) # TRUE


 The analysis that I would like to do with R(CollocInfer) runs as
 follows(I print for the sake of introduction here though to run this
 line of code requires extensive setup)

 res11a = inneropt(coefs, times=times, data=data11a, lik=lik,
 proc=proc, pars=spars, in.meth='nlminb', control.in=control.out)



 The response I get is

 Error in 'colnames-'('*tmp*', value = c(V,R)) :
length of 'dimnames' [2] not equal to array extent



 It seems to me that there is a fundamental match of 'dimnames' with
 the array that is being referred to.

 I have learned that the normal length of dimnames for an array is one
 for each element in the list: thus as I've set up the array, the
 length(dimnames(data11a)[2]) gives me

 [1]

I believe you are looking for

length(dimnames(data11a)[[2]]) # 2

Look into the difference between `[` and `[[` for subsetting a list.
See ?Extract for the gorey details, but I like my little train
metaphor:

If the list x, is a train: x[2] is the sub-train consisting only
of the second car, while x[[2]] is the contents of that second car.
Hence we can do x[1:3] to give a well defined train, but not x[[1:3]]
because we have no way to combine the elements of the first three cars
other than using a train.

Cheers,
Michael


 I would like to ask :Is it not evident from R's response that there is
 some other possibility for the dimnames[2] of the array?

 If so, what is it?

 regards,
 A

 __
 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.


[R] dimnames in array

2012-08-08 Thread aleksandr russell
Hello,

I'm working with an array; I'm trying to make it so that an array of
dim(42,2,2) has names whose length corresponds to that of the array,
and am hoping someone with experience with this can see what I'm not
doing correctly:




data11 = array(0,c(41,2,2))

y = lsoda(x0,times,fhn$fn.ode,pars)#This is make.fhn() from colloc
infer package#
  y = y[,2:3]

data11-array(0,c(41,2,2))


 m8-cbind(.29,1:41)
m9-as.array(m8,dim=c(41,2))

  data11[,1,] = y+m9
   data11[,2,] = y+m9

rownames(data2, do.NULL = FALSE, prefix=row)
varnames=c(V,R)
colnames(data6)=c(one,two)
colnames(data10)=colnames(data6)
 dimnames(data11)=list(rownames(data2),varnames,colnames(data10))
 data11a-as.array(data11,dimnames=dimnames(data11))
 attributes(data11a)

#so this seems to print out the array attributes as they
should be: two sets of two columns each, and the first column of
each set is called 'v' and the second 'r'- no problem#

now the analysis from colloc infer(I've put it in below*)
takes this array but will not complete the analysis, saying

Error in `colnames-`(`*tmp*`, value = c(V, R)) :
  length of 'dimnames' [2] not equal to array extent

When I type in

length(dimnames(data11a)[2])

I get the answer:

[1] 1

which seems odd when

dimnames(data11a)[2]

gives

[[1]]
[1] V R

I would like to ask How can I get the names of the second dimension
of the array(data11a) to have length 2 ?

It seems to me that the analysis will run if I can make this array
have the correct length dimnames

I thank you for your help.




*
  fd.data11a = data11a
  DEfd11a = Data2fd(fd.data11a, times, bbasis,
  fdnames=list(NULL,NULL,varnames))


 
profile11a.obj=LS.setup(pars,DEfd11a$coefs,fhn,basisvals=bbasis,lambda,fd.obj=NULL,
  more=NULL,data=data11a,weights=NULL,times=times,quadrature=NULL,eps=1e-6,
  posproc=FALSE,poslik=FALSE,discrete=FALSE,names=NULL,sparse=FALSE)
 lik = profile11a.obj$lik
 proc = profile11a.obj$proc
 qwts = rep(1/length(knots),length(knots))
  qwts = qwts %*% t(lambda)
  weights = array(1,dim(data11a))
  likmore = make.id()
  likmore$weights = weights
  lik = make.SSElik()
  lik$more = likmore
  lik$bvals = eval.basis(times,bbasis)
  procmore = make.fhn()
  procmore$weights = qwts
  procmore$qpts = qpts
  procmore$names = varnames
  procmore$parnames = parnames
  proc = make.SSEproc()
  proc$more = procmore
  proc$bvals = list(bvals = eval.basis(procmore$qpts,bbasis,0),
  dbvals = eval.basis(procmore$qpts,bbasis,1))
 res11a = inneropt(coefs, times=times, data=data11a, lik=lik, proc=proc,
  pars=spars, in.meth='nlminb', control.in=control.out)

__
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] dimnames in array

2012-08-08 Thread David Winsemius


On Aug 8, 2012, at 3:19 AM, aleksandr russell wrote:


Hello,

I'm working with an array; I'm trying to make it so that an array of
dim(42,2,2) has names whose length corresponds to that of the array,
and am hoping someone with experience with this can see what I'm not
doing correctly:




data11 = array(0,c(41,2,2))

y = lsoda(x0,times,fhn$fn.ode,pars)#This is make.fhn() from colloc
infer package#



 y = y[,2:3]

data11-array(0,c(41,2,2))


m8-cbind(.29,1:41)
   m9-as.array(m8,dim=c(41,2))

 data11[,1,] = y+m9
  data11[,2,] = y+m9


I didn't run that code since your difficulties did not seem to have  
anything to do with the values inside the array but only with the  
dimension labeling.


rownames(data2, do.NULL = FALSE, prefix=row)


What is 'data2'?


varnames=c(V,R)
colnames(data6)=c(one,two)


Ditto... what is 'data6'?


colnames(data10)=colnames(data6)
dimnames(data11)=list(rownames(data2),varnames,colnames(data10))
data11a-as.array(data11,dimnames=dimnames(data11))
attributes(data11a)

#so this seems to print out the array attributes as they
should be:


For which object?


two sets of two columns each, and the first column of
each set is called 'v' and the second 'r'- no problem#


The data11 object had three dimenstions.



now the analysis from colloc infer(I've put it in below*)
takes this array but will not complete the analysis, saying

Error in `colnames-`(`*tmp*`, value = c(V, R)) :
 length of 'dimnames' [2] not equal to array extent


Here's one way to label a 41 x 2 x 2 array:

 dimnames(data11)- c(list(X=paste0(X,1:41)), list(Y=paste0(Y, 
1:2)), list(Z=paste0(Z,1:2)) )

 attributes(data11)
$dim
[1] 41  2  2

$dimnames
$dimnames$X
 [1] X1  X2  X3  X4  X5  X6  X7  X8  X9  X10  
X11 X12 X13 X14 X15 X16 X17 X18 X19
[20] X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30  
X31 X32 X33 X34 X35 X36 X37 X38

[39] X39 X40 X41

$dimnames$Y
[1] Y1 Y2

$dimnames$Z
[1] Z1 Z2


When I type in

length(dimnames(data11a)[2])

I get the answer:

[1] 1

which seems odd when

dimnames(data11a)[2]

gives

[[1]]
[1] V R


It is a one element list whose single element is a 2 element vector.



I would like to ask How can I get the names of the second dimension
of the array(data11a) to have length 2 ?

It seems to me that the analysis will run if I can make this array
have the correct length dimnames

I thank you for your help.




*
 fd.data11a = data11a
 DEfd11a = Data2fd(fd.data11a, times, bbasis,
 fdnames=list(NULL,NULL,varnames))


profile11a.obj=LS.setup(pars,DEfd11a 
$coefs,fhn,basisvals=bbasis,lambda,fd.obj=NULL,
  
more 
=NULL,data=data11a,weights=NULL,times=times,quadrature=NULL,eps=1e-6,

 posproc=FALSE,poslik=FALSE,discrete=FALSE,names=NULL,sparse=FALSE)
lik = profile11a.obj$lik
proc = profile11a.obj$proc
qwts = rep(1/length(knots),length(knots))
 qwts = qwts %*% t(lambda)
 weights = array(1,dim(data11a))
 likmore = make.id()
 likmore$weights = weights
 lik = make.SSElik()
 lik$more = likmore
 lik$bvals = eval.basis(times,bbasis)
 procmore = make.fhn()
 procmore$weights = qwts
 procmore$qpts = qpts
 procmore$names = varnames
 procmore$parnames = parnames
 proc = make.SSEproc()
 proc$more = procmore
 proc$bvals = list(bvals = eval.basis(procmore$qpts,bbasis,0),
 dbvals = eval.basis(procmore$qpts,bbasis,1))
res11a = inneropt(coefs, times=times, data=data11a, lik=lik,  
proc=proc,

 pars=spars, in.meth='nlminb', control.in=control.out)



--
David Winsemius, MD
Alameda, CA, USA

__
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] dimnames in array

2012-08-08 Thread aleksandr russell
Hi again,

Thanks for your suggestion.
I think I can clarify the thing by looking at the bare bones:

data11 = array(0,c(41,2,2))

m8-cbind(.29,1:41)
m9-as.array(m8,dim=c(41,2))
data11[,1,]=m9
data11[,2,]=m9

varnames=c(V,R)
colnames(data11)=c(one,two)
dimnames(data11)=list(rownames(data11),varnames,colnames(data11))
data11a-as.array(data11,dimnames=dimnames(data11))


Just running the above, some artificial data, I come out with
an array that seems to be have the right attributes: typing
attributes(data11a) I get dimnames for each dimension.

The problem  is that [package 'colloc infer' says]
(and I quote):
Error in `colnames-`(`*tmp*`, value = c(V, R)) :
  length of 'dimnames' [2] not equal to array extent

It seems that the names for the second dimension of the array must
have length of 2 -- rather than the present 1 for the analysis to
work.

Again, typing

length(dimnames(data11a)[2])
I get

[1] 1

I've tried your suggestion for the dimnames but I'm getting an  error
could not find function paste0
Maybe you're using R later than 2.41?

thanks,
Alexander

On Wed, Aug 8, 2012 at 10:52 AM, David Winsemius dwinsem...@comcast.net wrote:

 On Aug 8, 2012, at 3:19 AM, aleksandr russell wrote:

 Hello,

 I'm working with an array; I'm trying to make it so that an array of
 dim(42,2,2) has names whose length corresponds to that of the array,
 and am hoping someone with experience with this can see what I'm not
 doing correctly:




 data11 = array(0,c(41,2,2))

 y = lsoda(x0,times,fhn$fn.ode,pars)#This is make.fhn() from colloc
 infer package#


  y = y[,2:3]

 data11-array(0,c(41,2,2))


 m8-cbind(.29,1:41)
m9-as.array(m8,dim=c(41,2))

  data11[,1,] = y+m9
   data11[,2,] = y+m9


 I didn't run that code since your difficulties did not seem to have anything
 to do with the values inside the array but only with the dimension labeling.


 rownames(data2, do.NULL = FALSE, prefix=row)


 What is 'data2'?


 varnames=c(V,R)
 colnames(data6)=c(one,two)


 Ditto... what is 'data6'?


 colnames(data10)=colnames(data6)
 dimnames(data11)=list(rownames(data2),varnames,colnames(data10))
 data11a-as.array(data11,dimnames=dimnames(data11))
 attributes(data11a)

 #so this seems to print out the array attributes as they
 should be:


 For which object?


 two sets of two columns each, and the first column of
 each set is called 'v' and the second 'r'- no problem#


 The data11 object had three dimenstions.



 now the analysis from colloc infer(I've put it in below*)
 takes this array but will not complete the analysis, saying

 Error in `colnames-`(`*tmp*`, value = c(V, R)) :
  length of 'dimnames' [2] not equal to array extent


 Here's one way to label a 41 x 2 x 2 array:

 dimnames(data11)- c(list(X=paste0(X,1:41)), list(Y=paste0(Y,1:2)),
 list(Z=paste0(Z,1:2)) )
 attributes(data11)
 $dim
 [1] 41  2  2

 $dimnames
 $dimnames$X
  [1] X1  X2  X3  X4  X5  X6  X7  X8  X9  X10 X11 X12
 X13 X14 X15 X16 X17 X18 X19
 [20] X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31
 X32 X33 X34 X35 X36 X37 X38
 [39] X39 X40 X41

 $dimnames$Y
 [1] Y1 Y2

 $dimnames$Z
 [1] Z1 Z2


 When I type in

 length(dimnames(data11a)[2])

 I get the answer:

 [1] 1

 which seems odd when

 dimnames(data11a)[2]

 gives

 [[1]]
 [1] V R


 It is a one element list whose single element is a 2 element vector.



 I would like to ask How can I get the names of the second dimension
 of the array(data11a) to have length 2 ?

 It seems to me that the analysis will run if I can make this array
 have the correct length dimnames

 I thank you for your help.

 


 *
  fd.data11a = data11a
  DEfd11a = Data2fd(fd.data11a, times, bbasis,
  fdnames=list(NULL,NULL,varnames))



 profile11a.obj=LS.setup(pars,DEfd11a$coefs,fhn,basisvals=bbasis,lambda,fd.obj=NULL,
  more=NULL,data=data11a,weights=NULL,times=times,quadrature=NULL,eps=1e-6,
  posproc=FALSE,poslik=FALSE,discrete=FALSE,names=NULL,sparse=FALSE)
 lik = profile11a.obj$lik
 proc = profile11a.obj$proc
 qwts = rep(1/length(knots),length(knots))
  qwts = qwts %*% t(lambda)
  weights = array(1,dim(data11a))
  likmore = make.id()
  likmore$weights = weights
  lik = make.SSElik()
  lik$more = likmore
  lik$bvals = eval.basis(times,bbasis)
  procmore = make.fhn()
  procmore$weights = qwts
  procmore$qpts = qpts
  procmore$names = varnames
  procmore$parnames = parnames
  proc = make.SSEproc()
  proc$more = procmore
  proc$bvals = list(bvals = eval.basis(procmore$qpts,bbasis,0),
  dbvals = eval.basis(procmore$qpts,bbasis,1))
 res11a = inneropt(coefs, times=times, data=data11a, lik=lik, proc=proc,
  pars=spars, in.meth='nlminb', control.in=control.out)



 --
 David Winsemius, MD
 Alameda, CA, USA


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

Re: [R] dimnames in array

2012-08-08 Thread David Winsemius


On Aug 8, 2012, at 8:43 AM, aleksandr russell wrote:


Hi again,

Thanks for your suggestion.
I think I can clarify the thing by looking at the bare bones:

data11 = array(0,c(41,2,2))

m8-cbind(.29,1:41)
m9-as.array(m8,dim=c(41,2))
data11[,1,]=m9
data11[,2,]=m9

varnames=c(V,R)
colnames(data11)=c(one,two)


colnames(data11)=c(one,two); str(data11)
 num [1:41, 1:2, 1:2] 0.29 0.29 0.29 0.29 0.29 0.29 0.29 0.29 0.29  
0.29 ...

 - attr(*, dimnames)=List of 3
  ..$ : NULL
  ..$ : chr [1:2] one two
  ..$ : NULL


dimnames(data11)=list(rownames(data11),varnames,colnames(data11))
data11a-as.array(data11,dimnames=dimnames(data11))


 str(data11)
 num [1:41, 1:2, 1:2] 0.29 0.29 0.29 0.29 0.29 0.29 0.29 0.29 0.29  
0.29 ...

 - attr(*, dimnames)=List of 3
  ..$ : NULL
  ..$ : chr [1:2] V R
  ..$ : chr [1:2] one two

Dimnames is a list with three lists.





Just running the above, some artificial data, I come out with
an array that seems to be have the right attributes: typing
attributes(data11a) I get dimnames for each dimension.

The problem  is that [package 'colloc infer' says]
(and I quote):
Error in `colnames-`(`*tmp*`, value = c(V, R)) :
 length of 'dimnames' [2] not equal to array extent


You are not offering code and data that would help understand the  
problem.


It seems that the names for the second dimension of the array must
have length of 2 -- rather than the present 1 for the analysis to
work.

Again, typing

length(dimnames(data11a)[2])
I get

[1] 1

I've tried your suggestion for the dimnames but I'm getting an  error
could not find function paste0
Maybe you're using R later than 2.41?


Yes. R 2.15.1 has added paste0() which is basically paste(... , sep=).

--



thanks,
Alexander

On Wed, Aug 8, 2012 at 10:52 AM, David Winsemius dwinsem...@comcast.net 
 wrote:


On Aug 8, 2012, at 3:19 AM, aleksandr russell wrote:


Hello,

I'm working with an array; I'm trying to make it so that an array of
dim(42,2,2) has names whose length corresponds to that of the array,
and am hoping someone with experience with this can see what I'm not
doing correctly:




data11 = array(0,c(41,2,2))

y = lsoda(x0,times,fhn$fn.ode,pars)#This is make.fhn() from colloc
infer package#




y = y[,2:3]

data11-array(0,c(41,2,2))


m8-cbind(.29,1:41)
  m9-as.array(m8,dim=c(41,2))

data11[,1,] = y+m9
 data11[,2,] = y+m9



I didn't run that code since your difficulties did not seem to have  
anything
to do with the values inside the array but only with the dimension  
labeling.




rownames(data2, do.NULL = FALSE, prefix=row)



What is 'data2'?



varnames=c(V,R)
colnames(data6)=c(one,two)



Ditto... what is 'data6'?



colnames(data10)=colnames(data6)
dimnames(data11)=list(rownames(data2),varnames,colnames(data10))
data11a-as.array(data11,dimnames=dimnames(data11))
attributes(data11a)

#so this seems to print out the array attributes as they
should be:



For which object?



two sets of two columns each, and the first column of
each set is called 'v' and the second 'r'- no problem#



The data11 object had three dimenstions.




now the analysis from colloc infer(I've put it in below*)
takes this array but will not complete the analysis, saying

   Error in `colnames-`(`*tmp*`, value = c(V, R)) :
length of 'dimnames' [2] not equal to array extent



Here's one way to label a 41 x 2 x 2 array:

dimnames(data11)- c(list(X=paste0(X,1:41)), list(Y=paste0(Y, 
1:2)),

list(Z=paste0(Z,1:2)) )
attributes(data11)

$dim
[1] 41  2  2

$dimnames
$dimnames$X
[1] X1  X2  X3  X4  X5  X6  X7  X8  X9  X10  
X11 X12

X13 X14 X15 X16 X17 X18 X19
[20] X20 X21 X22 X23 X24 X25 X26 X27 X28 X29  
X30 X31

X32 X33 X34 X35 X36 X37 X38
[39] X39 X40 X41

$dimnames$Y
[1] Y1 Y2

$dimnames$Z
[1] Z1 Z2



When I type in

   length(dimnames(data11a)[2])

I get the answer:

   [1] 1

which seems odd when

   dimnames(data11a)[2]

gives

   [[1]]
   [1] V R



It is a one element list whose single element is a 2 element vector.




I would like to ask How can I get the names of the second dimension
of the array(data11a) to have length 2 ?

It seems to me that the analysis will run if I can make this array
have the correct length dimnames

I thank you for your help.




*





David Winsemius, MD
Alameda, CA, USA

__
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] dimnames

2010-08-20 Thread Jimmy Söderly
Thanks Joshua, David and Peter.

2010/8/18 Peter Dalgaard pda...@gmail.com

 On 08/18/2010 06:20 PM, Joshua Wiley wrote:
  matrix(1:4, nrow = 4, ncol = 1, dimnames = list(NULL, true value))
 

 or even

 cbind(true value=1:4)


 --
 Peter Dalgaard
 Center for Statistics, Copenhagen Business School
 Phone: (+45)38153501
 Email: pd@cbs.dk  Priv: pda...@gmail.com


[[alternative HTML version deleted]]

__
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] dimnames

2010-08-20 Thread Gene Leynes
It seems like a disastrous proposition to name anything try, because try
is a key function used for error handling.  Many functions use it
internally, and I don't think you'd want to risk fouling up those
mechanics!  Even if it works, it's confusing to see that function being used
as a variable name.

On Wed, Aug 18, 2010 at 10:58 AM, Jimmy Söderly jimmy.sode...@gmail.comwrote:

 Hi everybody,

 I wanted to name a column vector (a variable).

 This is what I did :

 try-matrix(1:4,nrow=4,ncol=1)
 attr(try,dimnames)-list(NULL,true value)

 Is it OK ?

 Thanks for your help,
 Jimmy

[[alternative HTML version deleted]]

 __
 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.


[[alternative HTML version deleted]]

__
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] dimnames

2010-08-18 Thread Jimmy Söderly
Hi everybody,

I wanted to name a column vector (a variable).

This is what I did :

try-matrix(1:4,nrow=4,ncol=1)
attr(try,dimnames)-list(NULL,true value)

Is it OK ?

Thanks for your help,
Jimmy

[[alternative HTML version deleted]]

__
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] dimnames

2010-08-18 Thread Joshua Wiley
On Wed, Aug 18, 2010 at 8:58 AM, Jimmy Söderly jimmy.sode...@gmail.com wrote:
 Hi everybody,

 I wanted to name a column vector (a variable).

 This is what I did :

 try-matrix(1:4,nrow=4,ncol=1)
 attr(try,dimnames)-list(NULL,true value)

 Is it OK ?

Sure.  You can also do:

dimnames(try) - list(NULL,true value)

or if you are creating the matrix, directly with:

try - matrix(1:4, nrow = 4, ncol = 1, dimnames = list(NULL, true value)


 Thanks for your help,
 Jimmy

        [[alternative HTML version deleted]]

 __
 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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] dimnames

2010-08-18 Thread David Winsemius


On Aug 18, 2010, at 11:58 AM, Jimmy Söderly wrote:


Hi everybody,

I wanted to name a column vector (a variable).

This is what I did :

try-matrix(1:4,nrow=4,ncol=1)


(try is a bad name for an object because it is a useful function  
name.)



attr(try,dimnames)-list(NULL,true value)

Is it OK ?


Single column matrices get automatically converted to vectors unless  
you use drop=FALSE. Furthermore naming vectors with strings that  
contain spaces is possible but unwise , because you will forever be  
needing to stick quotes around what would otherwise not need the quotes





Thanks for your help,
Jimmy

[[alternative HTML version deleted]]

__
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
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.


Re: [R] dimnames

2010-08-18 Thread David Winsemius


On Aug 18, 2010, at 12:38 PM, David Winsemius wrote:



On Aug 18, 2010, at 11:58 AM, Jimmy Söderly wrote:


Hi everybody,

I wanted to name a column vector (a variable).

This is what I did :

try-matrix(1:4,nrow=4,ncol=1)


(try is a bad name for an object because it is a useful function  
name.)



attr(try,dimnames)-list(NULL,true value)

Is it OK ?


Single column matrices get automatically converted to vectors unless  
you use drop=FALSE.


The above sentence actually only a problem when you access single  
column vectors with [,  so wouldn't really apply to this question.  
Sorry for that misdirection on that point. The other comments still  
hold.



Furthermore naming vectors with strings that contain spaces is  
possible but unwise , because you will forever be needing to stick  
quotes around what would otherwise not need the quotes





Thanks for your help,
Jimmy



David Winsemius, MD
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.


Re: [R] dimnames

2010-08-18 Thread Peter Dalgaard
On 08/18/2010 06:20 PM, Joshua Wiley wrote:
 matrix(1:4, nrow = 4, ncol = 1, dimnames = list(NULL, true value))
 

or even

cbind(true value=1:4)


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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] dimnames(x) - dn error

2010-06-24 Thread Ayesha Khan
Hi ,
I want to assign names to the rows in my matrix so that when I use the
'agnes'  function from R cluster package , the dendogram that is produced
represents the rows of the matrix. This way I would know what elements in
the matrix are clustered together. But when I do the following,
rownames(distF) - paste(A,dim(distF)[1])

it gives the following error;
Error in dimnames(x) - dn :
  length of 'dimnames' [1] not equal to array extent

What am I doing wrong? Any help is most appreciated

-- 
Ayesha Khan

MS Bioengineering
Dept. of Bioengineering
Rice University, TX

[[alternative HTML version deleted]]

__
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] dimnames(x) - dn error

2010-06-24 Thread Joshua Wiley
Hello Ayesha,

What would you like the rownames to be?  Your problem is that
dim(distF)[1] will return the length of the 1st dimension; this is a
single number.  This code shows what happens and gives you some
alternatives.

temp.data - matrix(1:9, ncol=3)
temp.data
dim(temp.data)[1]

## Possible Alternative 1
## closest to what you had
rownames(temp.data) - paste(A, 1:dim(distF)[1])
rownames(temp.data)

## Possible Alternative 2
## no space
rownames(temp.data) - paste(A, 1:dim(distF)[1])
rownames(temp.data)

## Possible Alternative 3
##letters vary
rownames(temp.data) - paste(LETTERS[1:dim(distF)[1]], 1, sep=)
rownames(temp.data)

Cheers,

Josh



On Thu, Jun 24, 2010 at 6:13 PM, Ayesha Khan
ayesha.diamond...@gmail.com wrote:
 Hi ,
 I want to assign names to the rows in my matrix so that when I use the
 'agnes'  function from R cluster package , the dendogram that is produced
 represents the rows of the matrix. This way I would know what elements in
 the matrix are clustered together. But when I do the following,
 rownames(distF) - paste(A,dim(distF)[1])

 it gives the following error;
 Error in dimnames(x) - dn :
  length of 'dimnames' [1] not equal to array extent

 What am I doing wrong? Any help is most appreciated

 --
 Ayesha Khan

 MS Bioengineering
 Dept. of Bioengineering
 Rice University, TX

        [[alternative HTML version deleted]]

 __
 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.




-- 
Joshua Wiley
Ph.D. Student
Health Psychology
University of California, Los Angeles

__
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] Dimnames of array inside loop

2010-06-23 Thread M.Ribeiro

any clue??

hello R-helpers,

I have an array

acuracia - array(NA, dim = c(1, 1, A, B, C))

which is first defined and in the example above with dimensions 1x1xAxBxC.
My array is then filled using 3 loops (I am not well familiar yet with
lapply or sapply functions so I am still a loop-user):

for (i in 1:A){
for (j in 1:B){
for (k in 1:C){
acuracia[,,i,j,k] - correlacao / (sqrt(ac))
}
}
}


then I want to put names using dimnames but filling the names each at a time
after each iteration:

My first idea was to try

acuracia - array(NA, dim = c(1, 1, A,B,C),dimnames = list(acc,NULL,
paste(rep., i, sep =  ), paste(variable: , j), paste(mark.val = ,
k))

but it did not work.
Can anybody help?
Thank you very much 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Dimnames-of-array-inside-loop-tp1594215p2265736.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] Dimnames of array inside loop

2010-06-23 Thread David Winsemius


On Jun 23, 2010, at 11:17 AM, M.Ribeiro wrote:



any clue??

hello R-helpers,

I have an array

acuracia - array(NA, dim = c(1, 1, A, B, C))

which is first defined and in the example above with dimensions  
1x1xAxBxC.

My array is then filled using 3 loops (I am not well familiar yet with
lapply or sapply functions so I am still a loop-user):

for (i in 1:A){
for (j in 1:B){
for (k in 1:C){
acuracia[,,i,j,k] - correlacao / (sqrt(ac))
}
}
}



I'm not sure what structure correlacao has, but wonder if you couldn't  
have done:


acuracia[,,1:i,1:j,1:k] - correlacao / (sqrt(ac))  # no loop needed?


then I want to put names using dimnames but filling the names each  
at a time

after each iteration:

My first idea was to try

acuracia - array(NA, dim = c(1, 1, A,B,C),dimnames = list(acc,NULL,
paste(rep., i, sep =  ), paste(variable: , j), paste(mark.val  
= ,

k))


It is possible, but seems unwise to use   as your separator in  
dimnames or variable names or to include colons in dimnames, since you  
generally would interpret those as having special syntactic  
significance. Try instead:


acuracia - array(NA, dim = c(1, 1, A,B,C), dimnames = list(acc,NULL,
paste(rep., 1:i, sep = ), paste(variable., 1:j),  
paste(mark.val., 1:k, sep=))


You may want to acquaint yourself with the proper care and handling of  
arrays that have some of there dimensions = 1. Indexing will drop  
dimension if you fail to use drop=FALSE:


tt - array(,dim=c(1,1,3,3))

 tt[,,,1]
[1] NA NA NA




but it did not work.


You should report the full error codes rather than saying did not  
work.


-- David.

__
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] Dimnames of array inside loop

2010-03-18 Thread Márcio Resende

I read the post
http://n4.nabble.com/Error-setting-rowname-if-rowname-currently-NULL-td794579.html#a794579
where it says that the problem is that 
dimnames(acuracia) is Null -equivalent to rownames(fred) is NULL (in the
post)
Then I tried to define all the dimnames first as random names to be then
replaced in the loop
but it did not work either?

Does anyone have a clue?
Thanks a lot

-- 
View this message in context: 
http://n4.nabble.com/Dimnames-of-array-inside-loop-tp1594215p1598069.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] Dimnames of array inside loop

2010-03-15 Thread Márcio Resende

hello R-helpers,

I have an array

acuracia - array(NA, dim = c(1, 1, A, B, C))

which is first defined and in the example above with dimensions 1x1xAxBxC.
My array is then filled using 3 loops (I am not well familiar yet with
lapply or sapply functions so I am still a loop-user):

for (i in 1:A){
for (j in 1:B){
for (k in 1:C){
acuracia[,,i,j,k] - correlacao / (sqrt(ac))
}
}
}


then I want to put names using dimnames but filling the names each at a time
after each iteration:

My first idea was to try

acuracia - array(NA, dim = c(1, 1, A,B,C),dimnames = list(acc,NULL,
paste(rep., i, sep =  ), paste(variable: , j), paste(mark.val = ,
k))

but it did not work.
Can anybody help?
Thank you very much

-- 
View this message in context: 
http://n4.nabble.com/Dimnames-of-array-inside-loop-tp1594215p1594215.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] dimnames in class by object

2009-08-27 Thread utkarshsinghal

Hi All,

 d = data.frame(a=1:10,b=1:10)
 by1 = rep(c(a,b),5)
 by(d, by1, function(z) z[,,drop=F])
by1: a
 a b
1 1 1
3 3 3
5 5 5
7 7 7
9 9 9

by1: b
   a  b
2   2  2
4   4  4
6   6  6
8   8  8
10 10 10


 by(d, by1, function(z) z[,1,drop=F])
[1] 1 3 5 7 9

[1]  2  4  6  8 10

Can somebody explain why are the dimnames (i.e. by1: a   by1: b) not 
there this time.



Many Thanks
Utkarsh

__
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] dimnames does not match array extent

2009-05-23 Thread Penner, Johannes
Dear R help-list,

I am trying to calculate Monmoniers algorithm. I have 3 data sets: coordinates 
(coord), distance matrix (comdist) and geographical distance matrix (geodist). 
I consistently get the error  dimnames does not match array extent. However, 
when I use the function structure I get the following results:

 str(coord)
'data.frame':   114 obs. of  3 variables:
 $ sites : Factor w/ 114 levels beni.bl,beni.pen,..: 1 2 3 4 5 6 7 8 9 10 
...
 $ xcoord: num  2.16 1.35 9.01 9.72 9.83 ...
 $ ycoord: num  6.92 11.02 5.24 4.81 5 ...
 str(comdist)
Class 'dist'  atomic [1:6441] 0.00 2.74e-05 5.58e-01 3.65e-01 6.03e-03 ...
  ..- attr(*, Labels)= chr [1:114] beni.bl beni.pen came.kor came.kup 
...
  ..- attr(*, Size)= int 114
  ..- attr(*, call)= language as.dist.default(m = com, diag = TRUE, upper = 
TRUE)
  ..- attr(*, Diag)= logi TRUE
  ..- attr(*, Upper)= logi TRUE
 str(geodist)
Class 'dist'  atomic [1:6441] 4.18 7.05 7.84 7.91 8.02 ...
  ..- attr(*, Labels)= chr [1:114] beni.bl beni.pen came.kor came.kup 
...
  ..- attr(*, Size)= int 114
  ..- attr(*, call)= language as.dist.default(m = geo, diag = TRUE, upper = 
TRUE)
  ..- attr(*, Diag)= logi TRUE
  ..- attr(*, Upper)= logi TRUE

The label names are exactly identical. Any hint what causes the error and how 
to avoid it?

Any help is highly appreciated!

best wishes
Johannes

[[alternative HTML version deleted]]

__
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] dimnames do not match array extent

2009-05-11 Thread Penner, Johannes
Dear adegenet users,

I am trying to calculate geographical barriers using monmonier.
However, I consistently get the error dimnames do not match array
extent.

- import of the distance matrix: read.table
- conversion 1: as.dist(data, diag=TRUE, upper =TRUE)
- conversion 2: as.matrix(data)

- is.numeric(data) are answered for the geographic and the species
distances are answered TRUE
- is.matrix(data) is also answered TRUE for both

The network is calculated but when setting the threshold I always get
the above error.

However, I checked the names and numbers of rows and columns now several
times in Excel and I can find no differences... What would be the R way?
Or is there a simple way to adopt the names from a master file?

Trying to get around the problem I calculated everything without any
row- or column names. I than get the error dimnames do not match array
extent when using optimize.monmonier

Any solution or suggestions are highly appreciated.

Thanks in advance and best regards
Johannes

__
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] dimnames in pkg ipred

2009-01-23 Thread Häring, Tim (LWF)
I think I solved the problem =)
My dataset is an .arff file. So I read my data into R via read.arff.
I tried the following:
Export the dataframe to an txt-file and import it once again in R via 
read.table.
With the new dataset if works fine. Maybe the error comes from the 
variable-names. I attached a txt-file containing the str(traindat.bin) output 
from the data.frame, which I import via read.arff

Cheers,
TIM


-Ursprüngliche Nachricht-
Von: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Gesendet: Friday, January 23, 2009 11:03 AM
An: Häring, Tim (LWF)
Betreff: Re: AW: [R] dimnames in pkg ipred



Häring, Tim (LWF) wrote:
 OK, the information I send to the list were rather sparse. Sorry for that!
 I just tried the command with the recent Version of R and ipred. The error 
 message is the same.
 I want to create a classification model. My data consist of 5414 observations 
 and 98 variables whereof 33 are numeric, the remainder are binary nominal 
 (factor) variables. My output SOIL_UNIT is a factor variable with 82 levels.
 
 I hope this are enough information to understand the problem.

What does str(traindat.bin) tell you? Is it a data.frame?
Can you reduce the data.frame in a way (less variables and observations) 
so that you can send the rest by e-mail and we can see the error?

Uwe Ligges


 Cheers,
 TIM
 
 
 
 -Ursprüngliche Nachricht-
 Von: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
 Gesendet: Thursday, January 22, 2009 6:49 PM
 An: Häring, Tim (LWF)
 Cc: r-help@r-project.org
 Betreff: Re: [R] dimnames in pkg ipred
 
 
 
 Häring, Tim (LWF) wrote:
 Hello List,

  

 I`m trying to make prediction using a bagged tree with the package ipred. I 
 tried to follow the manual but I`m getting an error message. Also browsing 
 through the list-archive I didn`t find any hint. 

 Maybe someone can help me?

  

 selbag - bagging(SOIL_UNIT ~., data=traindat.bin, coob=TRUE)

 Error in dimnames(X) - list(dn[[1L]], unlist(collabs, use.names = FALSE)) : 

   length of 'dimnames' [2] not equal to array extent

  

 I´m using R 2.7.2 on Win XP and the latest version of ipred.
 
 
 Please do read the posting guide.
 
 - We do not have traindat.bin, hence cannot reproduce your problem
 - Does it happen with recent versions of R and ipred?
 
 Best,
 Uwe Ligges
 
 
 
 
  

 Thanks a lot.

 TIM

  

 ---
  

 Dipl.-Geogr. Tim Häring

 Sachgebiet Standort und Bodenschutz (SG 2.1)

 Bayerische Landesanstalt für Wald und Forstwirtschaft

 Am Hochanger 11

 D-85354 Freising



 Tel.: +49-(0)8161/71-4769

 E-Mail: tim.haer...@lwf.bayern.de

 http://www.lwf.bayern.de






  [[alternative HTML version deleted]]



 

 __
 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.
 str(traindat.bin)
'data.frame':   5414 obs. of  98 variables:
 $ SOIL_UNIT : Factor w/ 82 levels 
17b,19a,19b,..: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Allgaeuschichten: Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Anmooriger_Boden: Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Aptychenschichten   : Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Bachschuttkegel : Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Baustein-Schichten  : Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Baustein-Schichten_Nagelfluh: Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Bergschlipf : Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Bergsturz   : Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Bunte_Hornsteinschichten: Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Bunte_Mergel: Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Bunter_Liaskalk : Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Cenoman : Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Cenoman_Breccie : Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Cenoman_Kalksandstein   : Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Cenoman_Mergel  : Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Deutenhausener_Schichten: Factor w/ 2 levels 
f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Gewaesser

Re: [R] dimnames in pkg ipred

2009-01-23 Thread David Winsemius
I can well imagine that having all those variable names with = in  
them could create a problem.


 str(traindat.bin)
'data.frame':   5414 obs. of  98 variables:
 $ SOIL_UNIT : Factor w/ 82  
levels 17b,19a,19b,..: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Allgaeuschichten: Factor w/ 2  
levels f,t: 1 1 1 1 1 1 1 1 1 1 ...
 $ GEOL_UNIT=Anmooriger_Boden: Factor w/ 2  
levels f,t: 1 1 1 1 1 1 1 1 1 1 ...


Perhaps read.table does a more thorough job of checking variable names  
than does read.arff?


--
David Winsemius

On Jan 23, 2009, at 5:23 AM, Häring, Tim (LWF) wrote:


I think I solved the problem =)
My dataset is an .arff file. So I read my data into R via read.arff.
I tried the following:
Export the dataframe to an txt-file and import it once again in R  
via read.table.
With the new dataset if works fine. Maybe the error comes from the  
variable-names. I attached a txt-file containing the  
str(traindat.bin) output from the data.frame, which I import via  
read.arff


Cheers,
TIM


-Ursprüngliche Nachricht-
Von: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de]
Gesendet: Friday, January 23, 2009 11:03 AM
An: Häring, Tim (LWF)
Betreff: Re: AW: [R] dimnames in pkg ipred



Häring, Tim (LWF) wrote:
OK, the information I send to the list were rather sparse. Sorry  
for that!
I just tried the command with the recent Version of R and ipred.  
The error message is the same.
I want to create a classification model. My data consist of 5414  
observations and 98 variables whereof 33 are numeric, the remainder  
are binary nominal (factor) variables. My output SOIL_UNIT is a  
factor variable with 82 levels.


I hope this are enough information to understand the problem.


What does str(traindat.bin) tell you? Is it a data.frame?
Can you reduce the data.frame in a way (less variables and  
observations)

so that you can send the rest by e-mail and we can see the error?

Uwe Ligges



Cheers,
TIM



-Ursprüngliche Nachricht-
Von: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de]
Gesendet: Thursday, January 22, 2009 6:49 PM
An: Häring, Tim (LWF)
Cc: r-help@r-project.org
Betreff: Re: [R] dimnames in pkg ipred



Häring, Tim (LWF) wrote:

Hello List,



I`m trying to make prediction using a bagged tree with the package  
ipred. I tried to follow the manual but I`m getting an error  
message. Also browsing through the list-archive I didn`t find any  
hint.


Maybe someone can help me?



selbag - bagging(SOIL_UNIT ~., data=traindat.bin, coob=TRUE)

Error in dimnames(X) - list(dn[[1L]], unlist(collabs, use.names =  
FALSE)) :


 length of 'dimnames' [2] not equal to array extent



I´m using R 2.7.2 on Win XP and the latest version of ipred.



Please do read the posting guide.

- We do not have traindat.bin, hence cannot reproduce your problem
- Does it happen with recent versions of R and ipred?

Best,
Uwe Ligges







Thanks a lot.

TIM



---

Dipl.-Geogr. Tim Häring

Sachgebiet Standort und Bodenschutz (SG 2.1)

Bayerische Landesanstalt für Wald und Forstwirtschaft

Am Hochanger 11

D-85354 Freising



Tel.: +49-(0)8161/71-4769

E-Mail: tim.haer...@lwf.bayern.de

http://www.lwf.bayern.de






[[alternative HTML version deleted]]





__
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.

str_traindat.bin.txt__
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.


[R] dimnames in pkg ipred

2009-01-22 Thread Häring, Tim (LWF)
Hello List,

 

I`m trying to make prediction using a bagged tree with the package ipred. I 
tried to follow the manual but I`m getting an error message. Also browsing 
through the list-archive I didn`t find any hint. 

Maybe someone can help me?

 

selbag - bagging(SOIL_UNIT ~., data=traindat.bin, coob=TRUE)

Error in dimnames(X) - list(dn[[1L]], unlist(collabs, use.names = FALSE)) : 

  length of 'dimnames' [2] not equal to array extent

 

I´m using R 2.7.2 on Win XP and the latest version of ipred.

 

Thanks a lot.

TIM

 

--- 

Dipl.-Geogr. Tim Häring

Sachgebiet Standort und Bodenschutz (SG 2.1)

Bayerische Landesanstalt für Wald und Forstwirtschaft

Am Hochanger 11

D-85354 Freising



Tel.: +49-(0)8161/71-4769

E-Mail: tim.haer...@lwf.bayern.de

http://www.lwf.bayern.de






[[alternative HTML version deleted]]

__
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] dimnames in pkg ipred

2009-01-22 Thread Uwe Ligges



Häring, Tim (LWF) wrote:

Hello List,

 

I`m trying to make prediction using a bagged tree with the package ipred. I tried to follow the manual but I`m getting an error message. Also browsing through the list-archive I didn`t find any hint. 


Maybe someone can help me?

 


selbag - bagging(SOIL_UNIT ~., data=traindat.bin, coob=TRUE)

Error in dimnames(X) - list(dn[[1L]], unlist(collabs, use.names = FALSE)) : 


  length of 'dimnames' [2] not equal to array extent

 


I´m using R 2.7.2 on Win XP and the latest version of ipred.



Please do read the posting guide.

- We do not have traindat.bin, hence cannot reproduce your problem
- Does it happen with recent versions of R and ipred?

Best,
Uwe Ligges




 


Thanks a lot.

TIM

 

--- 


Dipl.-Geogr. Tim Häring

Sachgebiet Standort und Bodenschutz (SG 2.1)

Bayerische Landesanstalt für Wald und Forstwirtschaft

Am Hochanger 11

D-85354 Freising



Tel.: +49-(0)8161/71-4769

E-Mail: tim.haer...@lwf.bayern.de

http://www.lwf.bayern.de






[[alternative HTML version deleted]]





__
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.


Re: [R] dimnames in pkg ipred

2009-01-22 Thread Häring, Tim (LWF)
OK, the information I send to the list were rather sparse. Sorry for that!
I just tried the command with the recent Version of R and ipred. The error 
message is the same.
I want to create a classification model. My data consist of 5414 observations 
and 98 variables whereof 33 are numeric, the remainder are binary nominal 
(factor) variables. My output SOIL_UNIT is a factor variable with 82 levels.

I hope this are enough information to understand the problem.

Cheers,
TIM



-Ursprüngliche Nachricht-
Von: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Gesendet: Thursday, January 22, 2009 6:49 PM
An: Häring, Tim (LWF)
Cc: r-help@r-project.org
Betreff: Re: [R] dimnames in pkg ipred



Häring, Tim (LWF) wrote:
 Hello List,
 
  
 
 I`m trying to make prediction using a bagged tree with the package ipred. I 
 tried to follow the manual but I`m getting an error message. Also browsing 
 through the list-archive I didn`t find any hint. 
 
 Maybe someone can help me?
 
  
 
 selbag - bagging(SOIL_UNIT ~., data=traindat.bin, coob=TRUE)
 
 Error in dimnames(X) - list(dn[[1L]], unlist(collabs, use.names = FALSE)) : 
 
   length of 'dimnames' [2] not equal to array extent
 
  
 
 I´m using R 2.7.2 on Win XP and the latest version of ipred.


Please do read the posting guide.

- We do not have traindat.bin, hence cannot reproduce your problem
- Does it happen with recent versions of R and ipred?

Best,
Uwe Ligges




  
 
 Thanks a lot.
 
 TIM
 
  
 
 ---
  
 
 Dipl.-Geogr. Tim Häring
 
 Sachgebiet Standort und Bodenschutz (SG 2.1)
 
 Bayerische Landesanstalt für Wald und Forstwirtschaft
 
 Am Hochanger 11
 
 D-85354 Freising
 
 
 
 Tel.: +49-(0)8161/71-4769
 
 E-Mail: tim.haer...@lwf.bayern.de
 
 http://www.lwf.bayern.de
 
 
 
 
 
 
   [[alternative HTML version deleted]]
 
 
 
 
 
 __
 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.


[[alternative HTML version deleted]]

__
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] dimnames in pkg ipred

2009-01-22 Thread Dieter Menne
Häring, Tim (LWF Tim.Haering at lwf.bayern.de writes:

 
 OK, the information I send to the list were rather sparse. Sorry for that!
 I just tried the command with the recent Version of R and ipred. The error
message is the same.
 I want to create a classification model. My data consist of 5414 observations
and 98 variables whereof 33
 are numeric, the remainder are binary nominal (factor) variables. My output
SOIL_UNIT is a factor
 variable with 82 levels.

No. You should either create a set of dummy data of a similar size that 
reproduces the problem, or post the data set on a web site:

ge = read.table(http://www.menne-biomed.de/gastempt/gastempt.csv;,
  sep=,,header=TRUE)

And the code should be complete so that someone can run it with copy/paste.

Dieter

__
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] dimnames

2008-02-14 Thread John Kane
?write.table  and look at the row.names arguement
which is what they are called in this instance.

write.table(XX, file=XX.txt,quote=FALSE,sep=\t,
row.names=FALSE)


--- Roberto Olivares Hernandez [EMAIL PROTECTED] wrote:

 Hi,
 
 I used the write.table function to save data in txt
 file, and this is the output:
 
 
 V1  V2  V3  V4
 1   YAL005C  21  14  11
 2   YAL007C   2   1   4
 3   YAL012W   8  16   3
 4   YAL016W  24  23  23
 5   YAL019W   3   3   2
 6   YAL020C   2   4   2
 7   YAL021C   7   5   5
 8   YAL022C   3   1   2
 
 
 but I  need to remove the dimnames  (first column)
 
 I tried to use dimnames function to remove it and
 then save it, but still, the output is the same
 
 These are the command lines,
 
 XX #matrix
 dimnames(XX)-NULL
 write.table(XX,XX.txt,quote=FALSE,sep=\t)
 
 
 
 Thanks in advance
 Roberto
 
 
 
   [[alternative HTML version deleted]]
 
 __
 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.
 



[[elided Yahoo spam]]

__
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] dimnames

2008-02-13 Thread Roberto Olivares Hernandez
Hi,

I used the write.table function to save data in txt file, and this is the 
output:


V1  V2  V3  V4
1   YAL005C  21  14  11
2   YAL007C   2   1   4
3   YAL012W   8  16   3
4   YAL016W  24  23  23
5   YAL019W   3   3   2
6   YAL020C   2   4   2
7   YAL021C   7   5   5
8   YAL022C   3   1   2


but I  need to remove the dimnames  (first column)

I tried to use dimnames function to remove it and then save it, but still, the 
output is the same

These are the command lines,

XX #matrix
dimnames(XX)-NULL
write.table(XX,XX.txt,quote=FALSE,sep=\t)



Thanks in advance
Roberto



[[alternative HTML version deleted]]

__
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] dimnames

2008-02-13 Thread Henrique Dallazuanna
Try this:

write.table(XX,XX.txt,quote=FALSE,sep=\t, row.names = FALSE)

On 13/02/2008, Roberto Olivares Hernandez [EMAIL PROTECTED] wrote:
 Hi,

 I used the write.table function to save data in txt file, and this is the 
 output:


 V1  V2  V3  V4
 1   YAL005C  21  14  11
 2   YAL007C   2   1   4
 3   YAL012W   8  16   3
 4   YAL016W  24  23  23
 5   YAL019W   3   3   2
 6   YAL020C   2   4   2
 7   YAL021C   7   5   5
 8   YAL022C   3   1   2


 but I  need to remove the dimnames  (first column)

 I tried to use dimnames function to remove it and then save it, but still, 
 the output is the same

 These are the command lines,

 XX #matrix
 dimnames(XX)-NULL
 write.table(XX,XX.txt,quote=FALSE,sep=\t, row.names = FALSE)



 Thanks in advance
 Roberto



 [[alternative HTML version deleted]]

 __
 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.



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] dimnames

2008-02-13 Thread Eleni Christodoulou
What if you just removed the first column from your matrix:
XX-XX[,2:length(XX[1,]))

so you have a new matrix without the first column and save this second one
to a file?

Regards,
Eleni

On Feb 13, 2008 3:06 PM, Roberto Olivares Hernandez [EMAIL PROTECTED] wrote:

 Hi,

 I used the write.table function to save data in txt file, and this is the
 output:


 V1  V2  V3  V4
 1   YAL005C  21  14  11
 2   YAL007C   2   1   4
 3   YAL012W   8  16   3
 4   YAL016W  24  23  23
 5   YAL019W   3   3   2
 6   YAL020C   2   4   2
 7   YAL021C   7   5   5
 8   YAL022C   3   1   2


 but I  need to remove the dimnames  (first column)

 I tried to use dimnames function to remove it and then save it, but still,
 the output is the same

 These are the command lines,

 XX #matrix
 dimnames(XX)-NULL
 write.table(XX,XX.txt,quote=FALSE,sep=\t)



 Thanks in advance
 Roberto



[[alternative HTML version deleted]]

 __
 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.


[[alternative HTML version deleted]]

__
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.