Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread Mike C
I was using OS X native R editor. I would imagine that editor is as simple and native as it gets. But, if it's truly native, why would Gmail think of my code chunk so differently. I'm just throwing it out there! I can always remove format in Gmail after pasting as a precaution. :) On Fri,

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread Jeff Newmiller
I am pretty sure it is not RStudio that is converting it to html... it is Gmail... but many email programs seem to do this these days so that people can send Wingdings symbols to their lolz pals, with no thought of the damage done to computer code examples. -- Sent from my phone. Please

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
Thanks for letting me know. That line does look familiar. It's interesting how I simply copy and paste from R editor can result in HTML format. On Fri, Feb 24, 2017 at 9:16 PM, Jeff Newmiller wrote: > There is a little button near the bottom of the Gmail editing box

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread Jeff Newmiller
There is a little button near the bottom of the Gmail editing box that switches to plain text. We can immediately tell because of the [[alternative HTML version deleted]] line when we receive it, and sometimes it loses all of the line breaks or has extra asterisks mixed in. You can look in the

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
I suppose for loop will suffice. I simply copy & paste the code from R editor. From my email, it looks plain. Is there a way to tell? On Fri, Feb 24, 2017 at 8:50 PM, Jeff Newmiller wrote: > The apply function is one of many alienate ways to write a loop. It is not >

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread Jeff Newmiller
The apply function is one of many alienate ways to write a loop. It is not appreciably more efficient in cpu time than a for loop. Your example creates the numbers in the loop... does your actual data get created in a loop? If so then your original code should be perfectly serviceable. If not

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
In theory, I am generating from group 5 groups of random numbers, each group has 3 samples. Isn't apply() the replacement of loops? On Fri, Feb 24, 2017 at 8:23 PM, Jeff Newmiller wrote: > What is wrong with > > dat <- matrix(rnorm(15), nrow=5, ncol = 3) > > ? > > And

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread Jeff Newmiller
What is wrong with dat <- matrix(rnorm(15), nrow=5, ncol = 3) ? And what is this "no loop drama" you refer to? I use loops frequently to loop around large memory gobbling chunks of code. -- Sent from my phone. Please excuse my brevity. On February 24, 2017 5:02:46 PM PST, C W

[R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
Dear R, I wanted to simulate a 5 by 3 matrix which fills up by either rows or columns? I started with the following filling the matrix by rows, dat <- matrix(NA, nrow=5, ncol = 3) for(i in 1:5){ dat[i, ] <- rnorm(3) } But, R is known for no loop drama. Any suggestions? Thanks!