Re: [R] setting attributes

2010-11-05 Thread Johannes Huesing
David Winsemius dwinsem...@comcast.net [Fri, Nov 05, 2010 at 05:18:23AM CET]:
[...]
 If you were trying for something else, then please explain in plain
 English rather than simply showing code that throws an error.
 

Well, code never hurts. But it should be accompanied with a hint towards
what it is meant to do.

-- 
Johannes Hüsing   There is something fascinating about science. 
  One gets such wholesale returns of conjecture 
mailto:johan...@huesing.name  from such a trifling investment of fact.  
  
http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi)

__
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] setting attributes

2010-11-04 Thread Stephen Liu
Hi folks,

An Introduction to R

3.3 Getting and setting attributes
http://cran.r-project.org/doc/manuals/R-intro.html#Vectors-and-assignment

 z - 0:9
 z
 [1] 0 1 2 3 4 5 6 7 8 9

 attr(z, dim) - c(10,10)
Error in attr(z, dim) - c(10, 10) : 
  dims [product 100] do not match the length of object [10]

Please help me to understand what mistake I committed?  TIA

B.R.
Stephen L



__
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] setting attributes

2010-11-04 Thread David Winsemius


On Nov 5, 2010, at 12:05 AM, Stephen Liu wrote:


Hi folks,

An Introduction to R

3.3 Getting and setting attributes
http://cran.r-project.org/doc/manuals/R-intro.html#Vectors-and-assignment


z - 0:9
z

[1] 0 1 2 3 4 5 6 7 8 9


attr(z, dim) - c(10,10)

Error in attr(z, dim) - c(10, 10) :
 dims [product 100] do not match the length of object [10]

Please help me to understand what mistake I committed?  TIA


If you want a 10 x 10 matrix then:

zm - matrix(z, 10, 10)  # positional arguments to nrow and ncol.

If you were trying for something else, then please explain in plain  
English rather than simply showing code that throws an error.


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] setting attributes

2010-11-04 Thread Stephen Liu
Hi David,

I'm learning R following the tutorial mentioned, nothing else.  I got an error 
running the code.  Please help.

B.R.
Stephen L




- Original Message 
From: David Winsemius dwinsem...@comcast.net
To: Stephen Liu sati...@yahoo.com
Cc: r-help@r-project.org
Sent: Fri, November 5, 2010 12:18:23 PM
Subject: Re: [R] setting attributes


On Nov 5, 2010, at 12:05 AM, Stephen Liu wrote:

 Hi folks,

 An Introduction to R

 3.3 Getting and setting attributes
 http://cran.r-project.org/doc/manuals/R-intro.html#Vectors-and-assignment

 z - 0:9
 z
 [1] 0 1 2 3 4 5 6 7 8 9

 attr(z, dim) - c(10,10)
 Error in attr(z, dim) - c(10, 10) :
  dims [product 100] do not match the length of object [10]

 Please help me to understand what mistake I committed?  TIA

If you want a 10 x 10 matrix then:

zm - matrix(z, 10, 10)  # positional arguments to nrow and ncol.

If you were trying for something else, then please explain in plain  
English rather than simply showing code that throws an error.

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] setting attributes

2010-11-04 Thread Michael Sumner
David did help already, but if you want literally what the
Introduction uses then you'll need a vector with as many elements as
the final matrix (in David's example recyling applies to give 100
elements from the original 10).

 z - rep(0:9, each = 10)
attr(z, dim) - c(10,10)

That's simply a different route to the one shown by David, where the
repetition of z values is made explicit.

Cheers, Mike.

On Fri, Nov 5, 2010 at 3:32 PM, Stephen Liu sati...@yahoo.com wrote:
 Hi David,

 I'm learning R following the tutorial mentioned, nothing else.  I got an error
 running the code.  Please help.

 B.R.
 Stephen L




 - Original Message 
 From: David Winsemius dwinsem...@comcast.net
 To: Stephen Liu sati...@yahoo.com
 Cc: r-help@r-project.org
 Sent: Fri, November 5, 2010 12:18:23 PM
 Subject: Re: [R] setting attributes


 On Nov 5, 2010, at 12:05 AM, Stephen Liu wrote:

 Hi folks,

 An Introduction to R

 3.3 Getting and setting attributes
 http://cran.r-project.org/doc/manuals/R-intro.html#Vectors-and-assignment

 z - 0:9
 z
 [1] 0 1 2 3 4 5 6 7 8 9

 attr(z, dim) - c(10,10)
 Error in attr(z, dim) - c(10, 10) :
  dims [product 100] do not match the length of object [10]

 Please help me to understand what mistake I committed?  TIA

 If you want a 10 x 10 matrix then:

 zm - matrix(z, 10, 10)  # positional arguments to nrow and ncol.

 If you were trying for something else, then please explain in plain
 English rather than simply showing code that throws an error.

 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.




-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@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.


Re: [R] setting attributes (SOLVED)

2010-11-04 Thread Stephen Liu
Hi Mike,

I got it done.  Thanks

Your advice:-

 z - rep(0:9, each = 10)
 z
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]012345678 9
 [2,]012345678 9
 [3,]012345678 9
 [4,]012345678 9
 [5,]012345678 9
 [6,]012345678 9
 [7,]012345678 9
 [8,]012345678 9
 [9,]012345678 9
[10,]012345678 9

 attr(z, dim) - c(10,10)

 attr
function (x, which, exact = FALSE)  .Primitive(attr)

 attr(z, dim)
[1] 10 10


David's advice:-

 z - 0:9
 z - matrix(z, 10, 10) 
 z
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]000000000 0
 [2,]111111111 1
 [3,]222222222 2
 [4,]333333333 3
 [5,]444444444 4
 [6,]555555555 5
 [7,]666666666 6
 [8,]777777777 7
 [9,]888888888 8
[10,]999999999 9

 attr(z, dim) - c(10,10)
 attr(z, dim)
[1] 10 10

 attr
function (x, which, exact = FALSE)  .Primitive(attr)


The learning curve of R is rather steep at start.


B.R.
Stephen L




- Original Message 
From: Michael Sumner mdsum...@gmail.com
To: Stephen Liu sati...@yahoo.com
Cc: r-help@r-project.org
Sent: Fri, November 5, 2010 12:44:08 PM
Subject: Re: [R] setting attributes

David did help already, but if you want literally what the
Introduction uses then you'll need a vector with as many elements as
the final matrix (in David's example recyling applies to give 100
elements from the original 10).

z - rep(0:9, each = 10)
attr(z, dim) - c(10,10)

That's simply a different route to the one shown by David, where the
repetition of z values is made explicit.

Cheers, Mike.

On Fri, Nov 5, 2010 at 3:32 PM, Stephen Liu sati...@yahoo.com wrote:
 Hi David,

 I'm learning R following the tutorial mentioned, nothing else.  I got an error
 running the code.  Please help.

 B.R.
 Stephen L




 - Original Message 
 From: David Winsemius dwinsem...@comcast.net
 To: Stephen Liu sati...@yahoo.com
 Cc: r-help@r-project.org
 Sent: Fri, November 5, 2010 12:18:23 PM
 Subject: Re: [R] setting attributes


 On Nov 5, 2010, at 12:05 AM, Stephen Liu wrote:

 Hi folks,

 An Introduction to R

 3.3 Getting and setting attributes
 http://cran.r-project.org/doc/manuals/R-intro.html#Vectors-and-assignment

 z - 0:9
 z
 [1] 0 1 2 3 4 5 6 7 8 9

 attr(z, dim) - c(10,10)
 Error in attr(z, dim) - c(10, 10) :
  dims [product 100] do not match the length of object [10]

 Please help me to understand what mistake I committed?  TIA

 If you want a 10 x 10 matrix then:

 zm - matrix(z, 10, 10)  # positional arguments to nrow and ncol.

 If you were trying for something else, then please explain in plain
 English rather than simply showing code that throws an error.

 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.




-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@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.


Re: [R] setting attributes (SOLVED)

2010-11-04 Thread Erik Iverson



The learning curve of R is rather steep at start.


Yes, it can be. I think the general advice would be
to get a good Intro to R book if you're just starting
out.

That's certainly my advice.

Or, get a book on some methods you're interested
in that uses R (the Springer useR! series is
really useful for this.)

--Erik

__
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] setting attributes (SOLVED)

2010-11-04 Thread Stephen Liu
From: Erik Iverson er...@ccbr.umn.edu

To: r-help@r-project.org
Sent: Fri, November 5, 2010 1:09:19 PM
Subject: Re: [R] setting attributes (SOLVED)

 The learning curve of R is rather steep at start.

Yes, it can be. I think the general advice would be
to get a good Intro to R book if you're just starting
out.

That's certainly my advice.

Or, get a book on some methods you're interested
in that uses R (the Springer useR! series is
really useful for this.)


Hi Erik,

Thanks for your advice.  I found useR;

Use R
http://www.springer.com/series/6991


Actually I have a good collection of tutorials and technical documentation on 
R.  I found it difficult going through all in a short span.  Particularly I 
have 
to practice the examples.

How to use R
http://en.wikiversity.org/wiki/How_to_use_R

is good link.

B.R.
Stephen L






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