Re: [R] A potential bug for paste() ?

2009-05-07 Thread Sarah Goslee
It probably has less to do with paste() than with Theoph, but since
we have no idea what that might be, it's hard to tell.

See the bit about reproducible example, please.

Sarah

On Thu, May 7, 2009 at 10:38 AM, Jun Shen jun.shen...@gmail.com wrote:
 Hi, everyone,

 Try the following command to see if you get TRUE or FALSE. I get FALSE on a
 unix platform but TRUE on Windows. Any comment?

 all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]]))


-- 
Sarah Goslee
http://www.functionaldiversity.org

__
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] A potential bug for paste() ?

2009-05-07 Thread Gavin Simpson
On Thu, 2009-05-07 at 09:38 -0500, Jun Shen wrote:
 Hi, everyone,
 
 Try the following command to see if you get TRUE or FALSE. I get FALSE on a
 unix platform but TRUE on Windows. Any comment?
 
 all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]]))

And what is Theoph? Please do read the posting guide and provide a
reproducible example.

Is Theoph a list?

 a - list(A = rnorm(10), B = rnorm(10))
 paste(a[1], a[2])
[1] c(0.511810414967963, 0.165995305876871, 1.22637694512945,
-0.496453787173788, 0.325876407556065, 1.97392856823209,
-0.228962880984580, -0.172306887133861, -0.881280038259407,
-0.216958955239245) c(-0.281058662811336, 0.918418337792562,
-1.44005513590710, 0.22857441100305, 0.840138552938062,
0.0555436312146647, -0.602645008995437, -0.158866265592772,
0.959478898002479, -0.892389972305427)
 paste(a[[1]], a[[2]])
 [1] 0.511810414967963 -0.281058662811336 
 [2] 0.165995305876871 0.918418337792562  
 [3] 1.22637694512945 -1.44005513590710   
 [4] -0.496453787173788 0.22857441100305  
 [5] 0.325876407556065 0.840138552938062  
 [6] 1.97392856823209 0.0555436312146647  
 [7] -0.228962880984580 -0.602645008995437
 [8] -0.172306887133861 -0.158866265592772
 [9] -0.881280038259407 0.959478898002479 
[10] -0.216958955239245 -0.892389972305427
 typeof(a[[1]])
[1] double
 typeof(a[1])
[1] list

If it is, note that [ and [[ do not return the same thing for a list and
as such it is not surprising that they are not equal, pasted or
otherwise.

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
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] A potential bug for paste() ?

2009-05-07 Thread Douglas Bates
On Thu, May 7, 2009 at 9:56 AM, Sarah Goslee sarah.gos...@gmail.com wrote:
 It probably has less to do with paste() than with Theoph, but since
 we have no idea what that might be, it's hard to tell.

 See the bit about reproducible example, please.

Well, actually Theoph is one of the datasets in the (required)
datasets package.  It happens to be data from a pharmacokinetics
experiment so it is natural that PK/PD scientist would think of it.

 find(Theoph)
[1] package:datasets
 str(Theoph)
Classes ‘nfnGroupedData’, ‘nfGroupedData’, ‘groupedData’ and
'data.frame':   132 obs. of  5 variables:
 $ Subject: Ord.factor w/ 12 levels 67811..: 11 11 11 11
11 11 11 11 11 11 ...
 $ Wt : num  79.6 79.6 79.6 79.6 79.6 79.6 79.6 79.6 79.6 79.6 ...
 $ Dose   : num  4.02 4.02 4.02 4.02 4.02 4.02 4.02 4.02 4.02 4.02 ...
 $ Time   : num  0 0.25 0.57 1.12 2.02 ...
 $ conc   : num  0.74 2.84 6.57 10.5 9.66 8.58 8.36 7.47 6.89 5.94 ...
 - attr(*, formula)=Class 'formula' length 3 conc ~ Time | Subject
  .. ..- attr(*, .Environment)=environment: R_EmptyEnv
 - attr(*, labels)=List of 2
  ..$ x: chr Time since drug administration
  ..$ y: chr Theophylline concentration in serum
 - attr(*, units)=List of 2
  ..$ x: chr (hr)
  ..$ y: chr (mg/l)

 On Thu, May 7, 2009 at 10:38 AM, Jun Shen jun.shen...@gmail.com wrote:
 Hi, everyone,

 Try the following command to see if you get TRUE or FALSE. I get FALSE on a
 unix platform but TRUE on Windows. Any comment?

 all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]]))

There is a difference between Theoph[1] and Theoph[[1]].  The Theoph
object is a data frame.  Whenever you use the single bracket extractor
you will get another data frame.

 str(Theoph[1])
Classes ‘nfnGroupedData’, ‘nfGroupedData’, ‘groupedData’ and
'data.frame':   132 obs. of  1 variable:
 $ Subject: Ord.factor w/ 12 levels 67811..: 11 11 11 11
11 11 11 11 11 11 ...

A data frame is a special type of a list and, in general, this applies
to any list - single bracket extraction applied to a list always
produces a list, even if it is a list of one element.

The double bracket extractor returns the element of the list, not a sublist.

 str(Theoph[[1]])
 Ord.factor w/ 12 levels 67811..: 11 11 11 11 11 11 11 11 11 11 ...

I think of the distinction as being like the difference between an
element of a set (the [[ operator) and a subset of size one (the [
operator).

__
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] A potential bug for paste() ?

2009-05-07 Thread Phil Spector
Theoph is in the datasets package, so it should be 
available in all versions of R:



class(Theoph)

[1] nfnGroupedData nfGroupedData  groupedDatadata.frame

The key to what's happening is that there are some methods
for groupedData objects in the nlme library, which I suspect
the original poster had loaded in Windows, but not Unix.

Here's what I see on a Linux system:


all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]]))

[1] FALSE

library(nlme)
all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]]))

[1] TRUE

So if nlme is loaded, the following methods are available for 
groupedData objects:



methods(class='groupedData')

 [1] as.data.frame.groupedData* asTable.groupedData*
 [3] collapse.groupedData*  formula.groupedData*
 [5] [.groupedData* isBalanced.groupedData*
 [7] lme.groupedData*   lmList.groupedData*
 [9] print.groupedData* update.groupedData*

Thus subscripting for these objects is performed differently when
the nlme package is loaded.
   - Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Thu, 7 May 2009, Gavin Simpson wrote:


On Thu, 2009-05-07 at 09:38 -0500, Jun Shen wrote:

Hi, everyone,

Try the following command to see if you get TRUE or FALSE. I get FALSE on a
unix platform but TRUE on Windows. Any comment?

all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]]))


And what is Theoph? Please do read the posting guide and provide a
reproducible example.

Is Theoph a list?


a - list(A = rnorm(10), B = rnorm(10))
paste(a[1], a[2])

[1] c(0.511810414967963, 0.165995305876871, 1.22637694512945,
-0.496453787173788, 0.325876407556065, 1.97392856823209,
-0.228962880984580, -0.172306887133861, -0.881280038259407,
-0.216958955239245) c(-0.281058662811336, 0.918418337792562,
-1.44005513590710, 0.22857441100305, 0.840138552938062,
0.0555436312146647, -0.602645008995437, -0.158866265592772,
0.959478898002479, -0.892389972305427)

paste(a[[1]], a[[2]])

[1] 0.511810414967963 -0.281058662811336
[2] 0.165995305876871 0.918418337792562
[3] 1.22637694512945 -1.44005513590710
[4] -0.496453787173788 0.22857441100305
[5] 0.325876407556065 0.840138552938062
[6] 1.97392856823209 0.0555436312146647
[7] -0.228962880984580 -0.602645008995437
[8] -0.172306887133861 -0.158866265592772
[9] -0.881280038259407 0.959478898002479
[10] -0.216958955239245 -0.892389972305427

typeof(a[[1]])

[1] double

typeof(a[1])

[1] list

If it is, note that [ and [[ do not return the same thing for a list and
as such it is not surprising that they are not equal, pasted or
otherwise.

G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
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] A potential bug for paste() ?

2009-05-07 Thread Jun Shen
Thanks for everyone's attention on this issue!

On Thu, May 7, 2009 at 11:20 AM, Phil Spector spec...@stat.berkeley.eduwrote:

 Theoph is in the datasets package, so it should be available in all
 versions of R:

  class(Theoph)

 [1] nfnGroupedData nfGroupedData  groupedDatadata.frame

 The key to what's happening is that there are some methods
 for groupedData objects in the nlme library, which I suspect
 the original poster had loaded in Windows, but not Unix.

 Here's what I see on a Linux system:

  all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]]))

 [1] FALSE

 library(nlme)
 all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]]))

 [1] TRUE

 So if nlme is loaded, the following methods are available for groupedData
 objects:

  methods(class='groupedData')

  [1] as.data.frame.groupedData* asTable.groupedData*
  [3] collapse.groupedData*  formula.groupedData*
  [5] [.groupedData* isBalanced.groupedData*
  [7] lme.groupedData*   lmList.groupedData*
  [9] print.groupedData* update.groupedData*

 Thus subscripting for these objects is performed differently when
 the nlme package is loaded.
   - Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu



 On Thu, 7 May 2009, Gavin Simpson wrote:

  On Thu, 2009-05-07 at 09:38 -0500, Jun Shen wrote:

 Hi, everyone,

 Try the following command to see if you get TRUE or FALSE. I get FALSE on
 a
 unix platform but TRUE on Windows. Any comment?

 all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]]))


 And what is Theoph? Please do read the posting guide and provide a
 reproducible example.

 Is Theoph a list?

  a - list(A = rnorm(10), B = rnorm(10))
 paste(a[1], a[2])

 [1] c(0.511810414967963, 0.165995305876871, 1.22637694512945,
 -0.496453787173788, 0.325876407556065, 1.97392856823209,
 -0.228962880984580, -0.172306887133861, -0.881280038259407,
 -0.216958955239245) c(-0.281058662811336, 0.918418337792562,
 -1.44005513590710, 0.22857441100305, 0.840138552938062,
 0.0555436312146647, -0.602645008995437, -0.158866265592772,
 0.959478898002479, -0.892389972305427)

 paste(a[[1]], a[[2]])

 [1] 0.511810414967963 -0.281058662811336
 [2] 0.165995305876871 0.918418337792562
 [3] 1.22637694512945 -1.44005513590710
 [4] -0.496453787173788 0.22857441100305
 [5] 0.325876407556065 0.840138552938062
 [6] 1.97392856823209 0.0555436312146647
 [7] -0.228962880984580 -0.602645008995437
 [8] -0.172306887133861 -0.158866265592772
 [9] -0.881280038259407 0.959478898002479
 [10] -0.216958955239245 -0.892389972305427

 typeof(a[[1]])

 [1] double

 typeof(a[1])

 [1] list

 If it is, note that [ and [[ do not return the same thing for a list and
 as such it is not surprising that they are not equal, pasted or
 otherwise.

 G
 --
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] 
 http://www.ucl.ac.uk/~ucfagls/http://www.ucl.ac.uk/%7Eucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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




-- 
Jun Shen PhD
PK/PD Scientist
BioPharma Services
Millipore Corporation
15 Research Park Dr.
St Charles, MO 63304
Direct: 636-720-1589

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