[R] Error in rep in matrix - Windows 8- R 3.2.1

David Winsemius dwinsemius at comcast.net
Sat Aug 8 23:17:18 CEST 2015


On Aug 8, 2015, at 1:44 PM, Nikita Dinger wrote:

> y <- matrix(rep(10,4),2,2)
>> y
>     [,1] [,2]
> [1,]   10   10
> [2,]   10   10
> 
> 
> 
> I expected an output of
>> y
>     [,1] [,2]
> [1,]   10   4
> [2,]   10   4
> 

When you get something you don't expect, you should start by examining the arguments. Type this at your console:

rep(10,4)

It should then be obvious that you need to read the help page for `rep`.

-- 
David.
> 
> 
> Thanks and Regards.
> 
> 	[[alternative HTML version deleted]]

And do read the Posting guide.

> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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
Alameda, CA, USA



More information about the R-help mailing list