Thanks for all your help. It works now.
On Tue, May 23, 2017 at 1:34 AM, William Michels via R-help <
r-help@r-project.org> wrote:
> Hi Ivan,
>
> I was just writing a follow-up note as your note came in. While the
> code I posted previously works fine, using which() is unnecessary.
>
> > DF <- re
Hi Ivan,
I was just writing a follow-up note as your note came in. While the
code I posted previously works fine, using which() is unnecessary.
> DF <- read.csv("~/lily.csv")
> DF$product1_1 <- NA
> DF$product1_1 <- DF[DF$month == 1, "product1"]*3.1
Error in `$<-.data.frame`(`*tmp*`, "product1_1"
Hi,
Actually, you don't need to create the column first, nor to use which:
DF[DF$month==1, "product1_1"] = DF[DF$month==1, "product1"] * 3.1
The "[" is a great tool that you need to learn. In this case, you don't
need to combine "[" and $: within the square brackets, the vector before
the comm
Hi Lily,
You're on the right track, but you should define a new column first
(filled with NA values), then specify the precise rows and columns on
both the left and right hand sides of the assignment operator that
will be altered. Luckily, this is pretty easy...just remember to use
which() on the
Hi R users,
I have a question about manipulating the dataframe. I want to create a new
dataframe, and to multiply rows with different seasons for different
constants.
DF
year month day product1 product2 product3
1981 1 1 18 5620
1981 1
5 matches
Mail list logo