[R] Why does `[<-.matrix` not exist in base R

2019-11-23 Thread David Disabato
Whenever going from working with a data.frame to a matrix, I get annoyed that I cannot assign and subset at the same time with matrices - like I can with data.frames. For example, if I want to add a new column to a data.frame, I can do something like `myDataFrame[, "newColumn"] <- NA`. However, w

[R] Printing standard notation and scientific notation in the same column of a dataframe

2018-09-27 Thread David Disabato
Hi R-help, I was wondering if it was possible for a column of a dataframe to print some numbers in standard notation and some in scientific notation. Say my column of data (i.e., dat$x) has numbers between 0 and 1 with a few numbers very close to 0. When using the "scipen" argument in "options," R

Re: [R] For loop with multiple iteration indexes

2018-09-10 Thread David Disabato
x[i] ], y = dat[, y[i] ]) } print(r) On Mon, Sep 10, 2018 at 11:30 AM Berry, Charles wrote: > I have a sense of deja vu: > > https://www.mail-archive.com/r-help@r-project.org/msg250494.html > > There is some good advice there. > > > On Sep 9, 2018, at 3:49 PM, David D

[R] For loop with multiple iteration indexes

2018-09-09 Thread David Disabato
Hi R-help, I am trying to create a for loop with multiple iteration indexes. I don't want to use two different for loops nested together because I don't need the full matrix of the two indexes, just the diagonal elements (e.g., i[1] & j[1] and i[2] & j[2], but not i[1] & j[2]). Is there a way to s