[R] About error in the panel

lily li chocold12 at gmail.com
Sat Mar 11 19:50:32 CET 2017

Hi R users,

I have a problem about using R studio. For example, there is a dataframe
that has many columns. I want to aggregated column X and column Y into
column Z. Column Z does not exist before the aggregation. I use the code
df$Z = df$X + df$Y

However, it does not work in the top left panel in Rstudio, and has the
following warning message:
Error in `$<-.data.frame`(`*tmp*`, "Z", value = numeric(0)) :
  replacement has 0 rows, data has 34333

If I type the same code in the Console panel (bottom left panel), it works.
How to deal with this problem? Thanks.

	[[alternative HTML version deleted]]

More information about the R-help mailing list