Re: [R] a very simple question

2012-03-19 Thread David Winsemius


On Mar 18, 2012, at 4:43 PM, Dajiang Liu wrote:



Dear All,
I have a seemingly very simple question, but I just cannot figure  
out the answer. I attempted to run the  
following:a=0.1*(1:9);which(a==0.3);it returns integer(0). But  
obviously, the third element of a is equal to 0.3.
I must have missed something. Can someone kindly explain why? Thanks  
a lot.


It has already been explained on this list ... frequently in FAQt.

Locate the FAQ and search for a question about why R doesn't think two  
numbers are equal. The FAQ should be part of a standard instalL on the  
main help page.




Regards,Dajiang

[[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
Heritage Laboratories
West Hartford, CT

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


Re: [R] a very simple question

2012-03-19 Thread Rainer Schuermann
As to the reasons, David as given you the necessary hints.

In order to get around the issue, here is what I do:

 a - round( 0.1 * ( 1:9 ), 1 )
 a
[1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
 which( a == 0.3 )
[1] 3

Rgds,
Rainer


 Original-Nachricht 
 Datum: Sun, 18 Mar 2012 21:43:54 +
 Von: Dajiang Liu ldjst...@hotmail.com
 An: r-help@r-project.org
 Betreff: [R] a very simple question

 
 Dear All,
 I have a seemingly very simple question, but I just cannot figure out the
 answer. I attempted to run the following:a=0.1*(1:9);which(a==0.3);it
 returns integer(0). But obviously, the third element of a is equal to 0.3. 
 I must have missed something. Can someone kindly explain why? Thanks a
 lot.
 Regards,Dajiang
 
   [[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.

-- 
---

Gentoo Linux with KDE

__
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 very simple question

2012-03-19 Thread Petr Savicky
On Sun, Mar 18, 2012 at 09:43:54PM +, Dajiang Liu wrote:
 
 Dear All,
 I have a seemingly very simple question, but I just cannot figure out the 
 answer. I attempted to run the following:a=0.1*(1:9);which(a==0.3);it returns 
 integer(0). But obviously, the third element of a is equal to 0.3. 
 I must have missed something. Can someone kindly explain why? Thanks a lot.

Hi.

A simple way to detect rounding problems is subtracting
the numbers.

  a = 0.1*(1:4)
  a - 0.3

  [1] -2.00e-01 -1.00e-01  5.551115e-17  1.00e-01

Use rounding to avoid it as suggested by others.

Petr Savicky.

__
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 very simple question

2012-03-19 Thread Dajiang Liu

Thanks a lot for the clarification. I just find it very bizarre that if you run 
a=0.1*(1:9);which(a==0.4) 
it returns the right answer. Anyway, I will pay attention next time. Thanks a 
lot. 

 Date: Mon, 19 Mar 2012 08:59:59 +0100
 From: rainer.schuerm...@gmx.net
 Subject: Re: [R] a very simple question
 To: ldjst...@hotmail.com; r-help@r-project.org
 
 As to the reasons, David as given you the necessary hints.
 
 In order to get around the issue, here is what I do:
 
  a - round( 0.1 * ( 1:9 ), 1 )
  a
 [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
  which( a == 0.3 )
 [1] 3
 
 Rgds,
 Rainer
 
 
  Original-Nachricht 
  Datum: Sun, 18 Mar 2012 21:43:54 +
  Von: Dajiang Liu ldjst...@hotmail.com
  An: r-help@r-project.org
  Betreff: [R] a very simple question
 
  
  Dear All,
  I have a seemingly very simple question, but I just cannot figure out the
  answer. I attempted to run the following:a=0.1*(1:9);which(a==0.3);it
  returns integer(0). But obviously, the third element of a is equal to 0.3. 
  I must have missed something. Can someone kindly explain why? Thanks a
  lot.
  Regards,Dajiang

  [[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.
 
 -- 
 ---
 
 Gentoo Linux with KDE
 
  
[[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] a very simple question

2012-03-19 Thread Berend Hasselman

On 19-03-2012, at 13:47, Dajiang Liu wrote:

 
 Thanks a lot for the clarification. I just find it very bizarre that if you 
 run a=0.1*(1:9);which(a==0.4) 
 it returns the right answer. Anyway, I will pay attention next time. Thanks a 
 lot. 
 


Look at

 a = 0.1*(1:4)
  a - 0.4
[1] -0.3 -0.2 -0.1  0.0
 


Berend

 Date: Mon, 19 Mar 2012 08:59:59 +0100
 From: rainer.schuerm...@gmx.net
 Subject: Re: [R] a very simple question
 To: ldjst...@hotmail.com; r-help@r-project.org
 
 As to the reasons, David as given you the necessary hints.
 
 In order to get around the issue, here is what I do:
 
 a - round( 0.1 * ( 1:9 ), 1 )
 a
 [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
 which( a == 0.3 )
 [1] 3
 
 Rgds,
 Rainer
 
 
  Original-Nachricht 
 Datum: Sun, 18 Mar 2012 21:43:54 +
 Von: Dajiang Liu ldjst...@hotmail.com
 An: r-help@r-project.org
 Betreff: [R] a very simple question
 
 
 Dear All,
 I have a seemingly very simple question, but I just cannot figure out the
 answer. I attempted to run the following:a=0.1*(1:9);which(a==0.3);it
 returns integer(0). But obviously, the third element of a is equal to 0.3. 
 I must have missed something. Can someone kindly explain why? Thanks a
 lot.
 Regards,Dajiang
   
 [[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.
 
 -- 
 ---
 
 Gentoo Linux with KDE
 
 
   [[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] a very simple question

2012-03-19 Thread Ted Harding
On 19-Mar-2012 Dajiang Liu wrote:
 Thanks a lot for the clarification. I just find it very bizarre
 that if you run
 a=0.1*(1:9);which(a==0.4) 
 it returns the right answer. Anyway, I will pay attention next time.
 Thanks a  lot.

The basic explanation is that, for an integer r (0r10), what is
stored in binary representation by R for 0.1*r or for 0.r or
for r/10 is always an approximation to the exact value (with the
possible exception of r=5).

The exact detail of the binary representation may depend on how
it was obtained, by any of several different methods of calculation
which, mathematically, are exactly equivalent but, in the binary
representations stored in the computer, may be slightly different.

Examples:

  0.1*(1:9) - (1:9)/10
  # [1] 0.00e+00 0.00e+00 5.551115e-17 0.00e+00
  # [5] 0.00e+00 1.110223e-16 1.110223e-16 0.00e+00
  # [8] 0.00e+00

  0.1*(1:9) - c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)
  # [1] 0.00e+00 0.00e+00 5.551115e-17 0.00e+00
  # [5] 0.00e+00 1.110223e-16 1.110223e-16 0.00e+00
  # [8] 0.00e+00

  # (1:9)/10 - c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)
  # [1] 0 0 0 0 0 0 0 0 0

  cumsum(rep(0.3,9))/3 - (1:9)/10
  # [1] -1.387779e-17 -2.775558e-17  0.00e+00 -5.551115e-17
  # [5]  0.00e+00  0.00e+00  1.110223e-16 -1.110223e-16
  # [9] -1.110223e-16

and so on ...

The third example suggests that when R is given a decimal
fraction 0.r it recognises that this is equivalent to r/10
and calculates it accordingly, hence the agreement between
(1:9)/10 and c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9). (I would
need to check the source code to verify that statement, however).

The short answer (as has been pointed out) is that you cannot
count on exact agreement, within R (or most other numerical
software), between a value calculated by one numerical method
and the value calculated by another numerical method which is
mathematically equivalent.

Some numerical software will work by storing the expression
given to it not as a number but as a sequence of operations
performed on given digits, only evaluating this at the last
moment along with other similar expressions, working within
the scale (e.g. decimal scale for numbers given like 123.456)
thus obtaining maximum accuracy within the allocated storage.
An example it the arbitrary-precision calculator 'bc'.

Many (most?) hand-held digital calculators work to an internal
decimal representation such as BCD (binary-coded decimal)
where each byte is split into two half-bytes of 4 binary
digits, each capable of storing a number from 0 to 9; then
they can perform exact decimal arithmetic (to within the
precision of storage) for decimal numbers, avoiding the
imprecision resulting from conversion to binary (but may
exhibit similar problems to the above for binary input).

Ted.

-
E-Mail: (Ted Harding) ted.hard...@wlandres.net
Date: 19-Mar-2012  Time: 15:02:03
This message was sent by XFMail

__
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 very simple question

2012-03-19 Thread Petr Savicky
On Mon, Mar 19, 2012 at 12:47:12PM +, Dajiang Liu wrote:
 
 Thanks a lot for the clarification. I just find it very bizarre that if you 
 run a=0.1*(1:9);which(a==0.4) 
 it returns the right answer. Anyway, I will pay attention next time. Thanks a 
 lot. 

Hi.

Yes, these things are bizarre sometimes. Compare

  print(0.1, digits=20)   # [1] 0.1555
  print(4*0.1, digits=20) # [1] 0.4000222
  print(0.4, digits=20)   # [1] 0.4000222

Equality of the last two is the reason for

  which(0.1*(1:9) == 0.4)

  [1] 4

while for 0.3, we get

  print(3*0.1, digits=20) # [1] 0.30004441
  print(0.3, digits=20)   # [1] 0.2999889

See

  http://rwiki.sciviews.org/doku.php?id=misc:r_accuracy

for further hints.

Petr Savicky.

__
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] a very simple question

2012-03-18 Thread Dajiang Liu

Dear All,
I have a seemingly very simple question, but I just cannot figure out the 
answer. I attempted to run the following:a=0.1*(1:9);which(a==0.3);it returns 
integer(0). But obviously, the third element of a is equal to 0.3. 
I must have missed something. Can someone kindly explain why? Thanks a lot.
Regards,Dajiang
  
[[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] A very simple question

2008-05-15 Thread Erin Hodgess
Or

 k - c(1,1,1,2,2,1,1)
 k[!(k==3)]
[1] 1 1 1 2 2 1 1



On Wed, May 14, 2008 at 1:59 PM, Julian Burgos
[EMAIL PROTECTED] wrote:
 Try this:

 k=c(1,1,1,2,2,1,1,1)

 k[(k!=1)]
 [1] 2 2

 k[(k!=2)]
 [1] 1 1 1 1 1 1

 k[(k!=3)]
 [1] 1 1 1 2 2 1 1 1

 Julian


 Shubha Vishwanath Karanth wrote:

 Hi R,


 Suppose

 l=c(1,1,1,2,2,1,1,1)


 k[-which(k==1)]

 [1] 2 2


 k[-which(k==2)]

 [1] 1 1 1 1 1 1


 But,


 k[-which(k==3)]

 numeric(0)


 I do not want this numeric(0), instead the whole k itself should be my
 result... How do I do this?



 Thanks,

 Shubha


 This e-mail may contain confidential and/or privileged i...{{dropped:13}}

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




-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: [EMAIL PROTECTED]

__
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 very simple question

2008-05-15 Thread Patrick Burns

There have been several solutions like:

k[k != 3]

The more general form of this idea is:

k[!(k %in% 3)]

Sticking closer to the original form would be:

out - which(k == 3)
if(length(out)) k[-out] else k


Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and A Guide for the Unwilling S User)

Shubha Vishwanath Karanth wrote:

Hi R,

 


Suppose

l=c(1,1,1,2,2,1,1,1)

 


k[-which(k==1)]

[1] 2 2

 


k[-which(k==2)]

[1] 1 1 1 1 1 1

 


But,

 


k[-which(k==3)]

numeric(0)

 


I do not want this numeric(0), instead the whole k itself should be my
result... How do I do this?

 

 


Thanks,

Shubha

 


This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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] A very simple question

2008-05-14 Thread Shubha Vishwanath Karanth
Hi R,

 

Suppose

l=c(1,1,1,2,2,1,1,1)

 

k[-which(k==1)]

[1] 2 2

 

k[-which(k==2)]

[1] 1 1 1 1 1 1

 

But,

 

k[-which(k==3)]

numeric(0)

 

I do not want this numeric(0), instead the whole k itself should be my
result... How do I do this?

 

 

Thanks,

Shubha

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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 very simple question

2008-05-14 Thread Christos Hatzis
 k - c(1,1,1,2,2,1,1,1)
 k[k != 1]
[1] 2 2
 k[k != 2]
[1] 1 1 1 1 1 1
 k[k != 3]
[1] 1 1 1 2 2 1 1 1
 

-Christos 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Shubha 
 Vishwanath Karanth
 Sent: Wednesday, May 14, 2008 11:16 AM
 To: [EMAIL PROTECTED]
 Subject: [R] A very simple question
 
 Hi R,
 
  
 
 Suppose
 
 l=c(1,1,1,2,2,1,1,1)
 
  
 
 k[-which(k==1)]
 
 [1] 2 2
 
  
 
 k[-which(k==2)]
 
 [1] 1 1 1 1 1 1
 
  
 
 But,
 
  
 
 k[-which(k==3)]
 
 numeric(0)
 
  
 
 I do not want this numeric(0), instead the whole k itself 
 should be my result... How do I do this?
 
  
 
  
 
 Thanks,
 
 Shubha
 
  
 
 This e-mail may contain confidential and/or privileged 
 i...{{dropped:13}}
 
 __
 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 very simple question

2008-05-14 Thread Chuck Cleland

On 5/14/2008 11:16 AM, Shubha Vishwanath Karanth wrote:

Hi R,

 


Suppose

l=c(1,1,1,2,2,1,1,1)

 


k[-which(k==1)]

[1] 2 2

 


k[-which(k==2)]

[1] 1 1 1 1 1 1

 


But,

 


k[-which(k==3)]

numeric(0)

 


I do not want this numeric(0), instead the whole k itself should be my
result... How do I do this?

 

 


Thanks,

Shubha


  Look at the result of which(k==3) to see why your approach does not 
work.  You might try this instead:


k - c(1,1,1,2,2,1,1,1)

k[!(k==1)]

[1] 2 2

k[!(k==2)]

[1] 1 1 1 1 1 1

k[!(k==3)]

[1] 1 1 1 2 2 1 1 1


This e-mail may contain confidential and/or privileged i...{{dropped:13}}

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


--
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
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 very simple question

2008-05-14 Thread Ingmar Visser
l[!l==3]

On 14 May 2008, at 17:16, Shubha Vishwanath Karanth wrote:

 Hi R,



 Suppose

 l=c(1,1,1,2,2,1,1,1)



 k[-which(k==1)]

 [1] 2 2



 k[-which(k==2)]

 [1] 1 1 1 1 1 1



 But,



 k[-which(k==3)]

 numeric(0)



 I do not want this numeric(0), instead the whole k itself should be my
 result... How do I do this?





 Thanks,

 Shubha



 This e-mail may contain confidential and/or privileged i... 
 {{dropped:13}}

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

Ingmar Visser
Department of Psychology, University of Amsterdam
Roetersstraat 15
1018 WB Amsterdam
The Netherlands
t: +31-20-5256723



[[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] A very simple question

2008-05-14 Thread Greg Snow
Use logical subscripts rather than which:

 k - c(1,1,1,2,2,1,1,1)
 k[ k != 1 ]
[1] 2 2
 k[ k != 2 ]
[1] 1 1 1 1 1 1
 k[ k != 3 ]
[1] 1 1 1 2 2 1 1 1

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Shubha
 Vishwanath Karanth
 Sent: Wednesday, May 14, 2008 9:16 AM
 To: [EMAIL PROTECTED]
 Subject: [R] A very simple question

 Hi R,



 Suppose

 l=c(1,1,1,2,2,1,1,1)



 k[-which(k==1)]

 [1] 2 2



 k[-which(k==2)]

 [1] 1 1 1 1 1 1



 But,



 k[-which(k==3)]

 numeric(0)



 I do not want this numeric(0), instead the whole k itself
 should be my result... How do I do this?





 Thanks,

 Shubha



 This e-mail may contain confidential and/or privileged
 i...{{dropped:13}}

 __
 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 very simple question

2008-05-14 Thread Julian Burgos

Try this:

k=c(1,1,1,2,2,1,1,1)

 k[(k!=1)]
[1] 2 2

 k[(k!=2)]
[1] 1 1 1 1 1 1

 k[(k!=3)]
[1] 1 1 1 2 2 1 1 1

Julian


Shubha Vishwanath Karanth wrote:

Hi R,

 


Suppose

l=c(1,1,1,2,2,1,1,1)

 


k[-which(k==1)]

[1] 2 2

 


k[-which(k==2)]

[1] 1 1 1 1 1 1

 


But,

 


k[-which(k==3)]

numeric(0)

 


I do not want this numeric(0), instead the whole k itself should be my
result... How do I do this?

 

 


Thanks,

Shubha

 


This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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] A Very Simple Question

2008-05-13 Thread Yukihiro Ishii
Hi Rusers!

I am ashed of asking such a simple question.

X-matrix(rnorm(24), 4)
X0-apply(X,2,mean)

What I want is a matrix which consists of colums such as X[,1]--X0[1].

X-X0 doesn't work.

Perhaps apply function?

Thanks in advance.

Yukihiro Ishii
2-3-28 Tsurumakiminami, Hadano, 250-0002 Japan
+81463691922

__
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 Very Simple Question

2008-05-13 Thread Chuck Cleland

On 5/13/2008 10:27 AM, Yukihiro Ishii wrote:

Hi Rusers!

I am ashed of asking such a simple question.

X-matrix(rnorm(24), 4)
X0-apply(X,2,mean)

What I want is a matrix which consists of colums such as X[,1]--X0[1].

X-X0 doesn't work.

Perhaps apply function?


scale(X, scale=FALSE)

?scale


Thanks in advance.

Yukihiro Ishii
2-3-28 Tsurumakiminami, Hadano, 250-0002 Japan
+81463691922

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


--
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
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 Very Simple Question

2008-05-13 Thread Greg Snow
?sweep

-Original Message-
From: Yukihiro Ishii [EMAIL PROTECTED]
To: r-help@r-project.org r-help@r-project.org
Sent: 5/13/08 8:30 AM
Subject: [R] A Very Simple Question


Hi Rusers!

I am ashed of asking such a simple question.

X-matrix(rnorm(24), 4)
X0-apply(X,2,mean)

What I want is a matrix which consists of colums such as X[,1]--X0[1].

X-X0 doesn't work.

Perhaps apply function?

Thanks in advance.

Yukihiro Ishii
2-3-28 Tsurumakiminami, Hadano, 250-0002 Japan
+81463691922

__
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 Very Simple Question

2008-05-13 Thread Giovanni Petris

See

?scale

HTH,
Giovanni

 Date: Tue, 13 May 2008 23:27:59 +0900
 From: Yukihiro Ishii [EMAIL PROTECTED]
 Sender: [EMAIL PROTECTED]
 Precedence: list
 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=ybb20050223; d=ybb.ne.jp;
 
 Hi Rusers!
 
 I am ashed of asking such a simple question.
 
 X-matrix(rnorm(24), 4)
 X0-apply(X,2,mean)
 
 What I want is a matrix which consists of colums such as X[,1]--X0[1].
 
 X-X0 doesn't work.
 
 Perhaps apply function?
 
 Thanks in advance.
 
 Yukihiro Ishii
 2-3-28 Tsurumakiminami, Hadano, 250-0002 Japan
 +81463691922
 
 __
 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.
 
 

-- 

Giovanni Petris  [EMAIL PROTECTED]
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

__
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] A very simple question

2007-10-22 Thread David Kaplan
Hi all,

My apologies for a very simple question.  I just downloaded 
R 2.6.0.  I want to bring in all of the objects from 2.5.0 
that I see when I type ls().  I have no idea how to do that.

Thanks in advance.

David


-- 
===
David Kaplan, Ph.D.
Professor
Department of Educational Psychology
University of Wisconsin - Madison
Educational Sciences, Room 1061
1025 W. Johnson Street
Madison, WI 53706

email: [EMAIL PROTECTED]
Web: 
http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm
Phone: 608-262-0836
Fax:   608-262-0843

__
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 very simple question

2007-10-22 Thread Tim Calkins
?save.image
?load

HTH.

tc

On 10/23/07, David Kaplan [EMAIL PROTECTED] wrote:
 Hi all,

 My apologies for a very simple question.  I just downloaded
 R 2.6.0.  I want to bring in all of the objects from 2.5.0
 that I see when I type ls().  I have no idea how to do that.

 Thanks in advance.

 David


 --
 ===
 David Kaplan, Ph.D.
 Professor
 Department of Educational Psychology
 University of Wisconsin - Madison
 Educational Sciences, Room 1061
 1025 W. Johnson Street
 Madison, WI 53706

 email: [EMAIL PROTECTED]
 Web:
 http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm
 Phone: 608-262-0836
 Fax:   608-262-0843

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



-- 
Tim Calkins
0406 753 997

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