Re: [R] About error in the panel

2017-03-11 Thread William Dunlap via R-help
You will get this error if 'df' does not have columns named "X" and
"Y", so df$X or df$Y is NULL.  E.g.,
  > df <- data.frame(One=1:3, Two=11:13)
  > df$Three <- df$One + df$noSuchColumn
  Error in `$<-.data.frame`(`*tmp*`, "Three", value = numeric(0)) :
replacement has 0 rows, data has 3

What does names(df) show in the different panels?

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Sat, Mar 11, 2017 at 10:50 AM, lily li  wrote:
> 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
> below:
> 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]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] About error in the panel

2017-03-11 Thread Jeff Newmiller
Copy one statement at a time into a new R session.  When you get an error you 
will know what you need to look at more closely. RStudio makes this easy with 
the Start New R Session menu option and using Ctrl-Enter in the editor.
-- 
Sent from my phone. Please excuse my brevity.

On March 11, 2017 11:53:41 AM PST, lily li  wrote:
>I think this is the problem. How to solve then?
>
>On Sat, Mar 11, 2017 at 12:18 PM, Bert Gunter 
>wrote:
>
>> Typo, should be:
>>
>> 3. A guess: You are sourcing the entire script in the editor panel
>> into R, and there is something screwed up there.
>>
>> -- Bert
>>
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming
>along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Sat, Mar 11, 2017 at 11:14 AM, lily li 
>wrote:
>> > Thanks for your reply. I thought anything about R questions can be
>posted
>> > here.
>> >
>> > About your third point, what does it mean? I did the same thing
>before
>> for
>> > other scripts, but this one does not work. Thanks again.
>> >
>> > On Sat, Mar 11, 2017 at 12:12 PM, Bert Gunter
>
>> > wrote:
>> >>
>> >> 1. Not reproducible, hence impossible to say.
>> >>
>> >> 2. This is r-help. RStudio is totally separate and its own support
>page.
>> >>
>> >> 3. A guess: Use are sourcing the entire script in the editor panel
>> >> into R, and there is something screwed up there.
>> >>
>> >> Cheers,
>> >> Bert
>> >>
>> >>
>> >> Bert Gunter
>> >>
>> >> "The trouble with having an open mind is that people keep coming
>along
>> >> and sticking things into it."
>> >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> >>
>> >>
>> >> On Sat, Mar 11, 2017 at 10:50 AM, lily li 
>wrote:
>> >> > 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
>> >> > below:
>> >> > 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]]
>> >> >
>> >> > __
>> >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more,
>see
>> >> > 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.
>> >
>> >
>>
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] About error in the panel

2017-03-11 Thread lily li
I think this is the problem. How to solve then?

On Sat, Mar 11, 2017 at 12:18 PM, Bert Gunter 
wrote:

> Typo, should be:
>
> 3. A guess: You are sourcing the entire script in the editor panel
> into R, and there is something screwed up there.
>
> -- Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Sat, Mar 11, 2017 at 11:14 AM, lily li  wrote:
> > Thanks for your reply. I thought anything about R questions can be posted
> > here.
> >
> > About your third point, what does it mean? I did the same thing before
> for
> > other scripts, but this one does not work. Thanks again.
> >
> > On Sat, Mar 11, 2017 at 12:12 PM, Bert Gunter 
> > wrote:
> >>
> >> 1. Not reproducible, hence impossible to say.
> >>
> >> 2. This is r-help. RStudio is totally separate and its own support page.
> >>
> >> 3. A guess: Use are sourcing the entire script in the editor panel
> >> into R, and there is something screwed up there.
> >>
> >> Cheers,
> >> Bert
> >>
> >>
> >> Bert Gunter
> >>
> >> "The trouble with having an open mind is that people keep coming along
> >> and sticking things into it."
> >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >>
> >>
> >> On Sat, Mar 11, 2017 at 10:50 AM, lily li  wrote:
> >> > 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
> >> > below:
> >> > 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]]
> >> >
> >> > __
> >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> > 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.
> >
> >
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] About error in the panel

2017-03-11 Thread Bert Gunter
Typo, should be:

3. A guess: You are sourcing the entire script in the editor panel
into R, and there is something screwed up there.

-- Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sat, Mar 11, 2017 at 11:14 AM, lily li  wrote:
> Thanks for your reply. I thought anything about R questions can be posted
> here.
>
> About your third point, what does it mean? I did the same thing before for
> other scripts, but this one does not work. Thanks again.
>
> On Sat, Mar 11, 2017 at 12:12 PM, Bert Gunter 
> wrote:
>>
>> 1. Not reproducible, hence impossible to say.
>>
>> 2. This is r-help. RStudio is totally separate and its own support page.
>>
>> 3. A guess: Use are sourcing the entire script in the editor panel
>> into R, and there is something screwed up there.
>>
>> Cheers,
>> Bert
>>
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Sat, Mar 11, 2017 at 10:50 AM, lily li  wrote:
>> > 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
>> > below:
>> > 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]]
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > 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.
>
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] About error in the panel

2017-03-11 Thread lily li
Thanks for your reply. I thought anything about R questions can be posted
here.

About your third point, what does it mean? I did the same thing before for
other scripts, but this one does not work. Thanks again.

On Sat, Mar 11, 2017 at 12:12 PM, Bert Gunter 
wrote:

> 1. Not reproducible, hence impossible to say.
>
> 2. This is r-help. RStudio is totally separate and its own support page.
>
> 3. A guess: Use are sourcing the entire script in the editor panel
> into R, and there is something screwed up there.
>
> Cheers,
> Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Sat, Mar 11, 2017 at 10:50 AM, lily li  wrote:
> > 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
> > below:
> > 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]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] About error in the panel

2017-03-11 Thread Bert Gunter
1. Not reproducible, hence impossible to say.

2. This is r-help. RStudio is totally separate and its own support page.

3. A guess: Use are sourcing the entire script in the editor panel
into R, and there is something screwed up there.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sat, Mar 11, 2017 at 10:50 AM, lily li  wrote:
> 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
> below:
> 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]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] About error in the panel

2017-03-11 Thread lily li
More specifically,  it shows the following when I typed traceback():

3: stop(sprintf(ngettext(N, "replacement has %d row, data has %d",
   "replacement has %d rows, data has %d"), N, nrows), domain = NA)
2: `$<-.data.frame`(`*tmp*`, "Z", value = numeric(0))
1: `$<-`(`*tmp*`, "Z", value = numeric(0))

I don't know what is the problem, as it works in the Console panel but not
in the top left panel. Thanks for your help.

On Sat, Mar 11, 2017 at 11:50 AM, lily li  wrote:

> 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
> below:
> 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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] About error in the panel

2017-03-11 Thread lily li
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
below:
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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.