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


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


[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

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


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.


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.


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.


Re: [R] A very simple question

2007-10-23 Thread John Kane
It sound like you have been loading an existing
workspace in 2.5.0 when you started up R each time.  

I don't know much about this but you might want to see
if you have some kind of .Rdata file in the 2.5.0
installation that is doing this. 

Otherwise did you make any changes to your Rprofile in
2.5.O that would have been automatically been loading
Rdata files or sourcing a script file?

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

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