[R] Array help
Joshua Wiley
jwiley.psych at gmail.com
Mon Nov 29 04:43:45 CET 2010
Hi B,
What you need to do is pass a vector with the indices you want to
extract. So, you have 1:7 (which expands to 1, 2, 3, ... 7) and 12:34
(which again expands). How would you combine two sets of numbers?
c(), the combine or concatenate function. Putting this in action:
mya <- array(1:510, dim = c(34, 5, 3))
mya[c(1:7, 12:34), , ]
Do note that the row numbers will update unless they were explicitly
named. So they will be numbered 1:30, not 1:7 and 12:34.
Cheers,
Josh
On Sun, Nov 28, 2010 at 6:36 PM, bfhancock <brianfhancock at gmail.com> wrote:
>
> Hi! I am learning R and have a question that is probably fairly simple for
> those of you much more learned than I.
>
> I am messing with Arrays and am doing some simple stuff to get the hang of
> them. I will have a seperate array already pulled up and it will have
> columns and rows. I figured out that I can seperate these out with commands
> like "array_name"[,1,1]. Now, I have an array where I want to make a single
> array from a two ranges in the original array. from 1:7 and 12:34. I know
> if i just did it with 1:7 it is just "array_name"[1:7,,] and that is it.
> But i wanted 12:34 in there as well. I assumed at first that it would just
> be "array_name"[1:7 & 12:34,,] but was wrong. Can anyone help me with this?
> Thanks so much!
>
> -B
> --
> View this message in context: http://r.789695.n4.nabble.com/Array-help-tp3062992p3062992.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
More information about the R-help
mailing list