Basic misunderstanding, or problem with my installation?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Basic misunderstanding, or problem with my installation?

David Parkhurst-2
I've just uninstalled and then reinstalled R on my windows 7 machine.
To test my understanding of data frames, I'm trying the following code.
(I plan to do other things with it, if it would only work.)
Here's the code, which seems pretty basic to me:
ls()
nums ← c(1,2,3,4,5)
ltrs ← c(“a”,”b”,”c”,”d”,”e”)
df1 ← data.frame(nums,ltrs)

Here's what happens when I try to run it:
 > ls()
character(0)
 > nums ← c(1,2,3,4,5)
Error: unexpected input in "nums \"
 > ltrs ← c(“a”,”b”,”c”,”d”,”e”)
Error: unexpected input in "ltrs \"
 > df1 ← data.frame(nums,ltrs)
Error: unexpected input in "df1 \"
 >

Am I really misunderstanding the basics, or is there something
wrong with my installation?
David

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Basic misunderstanding, or problem with my installation?

Gabor Grothendieck
On Tue, Dec 31, 2013 at 6:53 PM, David Parkhurst <[hidden email]> wrote:

> I've just uninstalled and then reinstalled R on my windows 7 machine.
> To test my understanding of data frames, I'm trying the following code.
> (I plan to do other things with it, if it would only work.)
> Here's the code, which seems pretty basic to me:
> ls()
> nums ← c(1,2,3,4,5)
> ltrs ← c(“a”,”b”,”c”,”d”,”e”)
> df1 ← data.frame(nums,ltrs)
>
> Here's what happens when I try to run it:
>> ls()
> character(0)
>> nums ← c(1,2,3,4,5)
> Error: unexpected input in "nums \"
>> ltrs ← c(“a”,”b”,”c”,”d”,”e”)
> Error: unexpected input in "ltrs \"
>> df1 ← data.frame(nums,ltrs)
> Error: unexpected input in "df1 \"
>>
>
> Am I really misunderstanding the basics, or is there something
> wrong with my installation?


The assignment operator is TWO characters: a less than sign
immediately followed by a minus sign.  Try copying and pasting this:

x <- 3
x

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Basic misunderstanding, or problem with my installation?

Sarah Goslee
In reply to this post by David Parkhurst-2
Hi David,

Your code is showing up here with an arrow symbols. If it's an actual cut
and paste, that's your problem: assignment in R is the two-character <- and
not an arrow symbol.

Otherwise your code looks fine.

Sarah

On Tuesday, December 31, 2013, David Parkhurst wrote:

> I've just uninstalled and then reinstalled R on my windows 7 machine.
> To test my understanding of data frames, I'm trying the following code.
> (I plan to do other things with it, if it would only work.)
> Here's the code, which seems pretty basic to me:
> ls()
> nums ← c(1,2,3,4,5)
> ltrs ← c(“a”,”b”,”c”,”d”,”e”)
> df1 ← data.frame(nums,ltrs)
>
> Here's what happens when I try to run it:
> > ls()
> character(0)
> > nums ← c(1,2,3,4,5)
> Error: unexpected input in "nums \"
> > ltrs ← c(“a”,”b”,”c”,”d”,”e”)
> Error: unexpected input in "ltrs \"
> > df1 ← data.frame(nums,ltrs)
> Error: unexpected input in "df1 \"
> >
>
> Am I really misunderstanding the basics, or is there something
> wrong with my installation?
> David
>
> ______________________________________________
> [hidden email] 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.
>

--
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Basic misunderstanding, or problem with my installation?

Nordlund, Dan (DSHS/RDA)
> -----Original Message-----
> From: [hidden email] [mailto:r-help-bounces@r-
> project.org] On Behalf Of Sarah Goslee
> Sent: Tuesday, December 31, 2013 4:55 PM
> To: David Parkhurst
> Cc: [hidden email]
> Subject: Re: [R] Basic misunderstanding, or problem with my
> installation?
>
> Hi David,
>
> Your code is showing up here with an arrow symbols. If it's an actual
> cut
> and paste, that's your problem: assignment in R is the two-character <-
> and
> not an arrow symbol.
>
> Otherwise your code looks fine.
>
> Sarah
>
> On Tuesday, December 31, 2013, David Parkhurst wrote:
>
> > I've just uninstalled and then reinstalled R on my windows 7 machine.
> > To test my understanding of data frames, I'm trying the following
> code.
> > (I plan to do other things with it, if it would only work.)
> > Here's the code, which seems pretty basic to me:
> > ls()
> > nums ← c(1,2,3,4,5)
> > ltrs ← c(“a”,”b”,”c”,”d”,”e”)
> > df1 ← data.frame(nums,ltrs)
> >
> > Here's what happens when I try to run it:
> > > ls()
> > character(0)
> > > nums ← c(1,2,3,4,5)
> > Error: unexpected input in "nums \"
> > > ltrs ← c(“a”,”b”,”c”,”d”,”e”)
> > Error: unexpected input in "ltrs \"
> > > df1 ← data.frame(nums,ltrs)
> > Error: unexpected input in "df1 \"
> > >
> >
> > Am I really misunderstanding the basics, or is there something
> > wrong with my installation?
> > David
> >
> > ______________________________________________
> > [hidden email] 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.
> >
>

And after you get your assignment operator straightened out, you may need to change the quote marks in your character vector.  It looks like they may be "smart quotes" from a word processor, rather than the plain single or double quote marks that R will accept.

Dan

Daniel J. Nordlund, PhD
Research and Data Analysis Division
Services & Enterprise Support Administration
Washington State Department of Social and Health Services


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Basic misunderstanding, or problem with my installation?

David Parkhurst-2
In reply to this post by Sarah Goslee
Thanks to the three people who saw what I missed.  I typed my
code in Libre Office as "<" followed by "-", and that program
converted those two characters into a single left arrow symbol.
I copied the commands from Libre into R without noticing that
that had happened.  Wierd.

On 12/31/2013 7:54 PM, Sarah Goslee wrote:

> Hi David,
>
> Your code is showing up here with an arrow symbols. If it's an actual
> cut and paste, that's your problem: assignment in R is the two-character
> <- and not an arrow symbol.Â
>
> Otherwise your code looks fine.
>
> Sarah
>
> On Tuesday, December 31, 2013, David Parkhurst wrote:
>
>     I've just uninstalled and then reinstalled R on my windows 7 machine.
>     To test my understanding of data frames, I'm trying the following code.
>     (I plan to do other things with it, if it would only work.)
>     Here's the code, which seems pretty basic to me:
>     ls()
>     nums â†� c(1,2,3,4,5)
>     ltrs â†� c(“aâ€�,â€�bâ€�,â€�câ€�,â€�dâ€�,â€�eâ€�)
>     df1 â†� data.frame(nums,ltrs)
>
>     Here's what happens when I try to run it:
>      > ls()
>     character(0)
>      > nums â†� c(1,2,3,4,5)
>     Error: unexpected input in "nums \"
>      > ltrs â†� c(“aâ€�,â€�bâ€�,â€�câ€�,â€�dâ€�,â€�eâ€�)
>     Error: unexpected input in "ltrs \"
>      > df1 â†� data.frame(nums,ltrs)
>     Error: unexpected input in "df1 \"
>      >
>
>     Am I really misunderstanding the basics, or is there something
>     wrong with my installation?
>     David
>
>     ________________________________________________
>     R-help@r-project.org mailing list
>     https://stat.ethz.ch/mailman/__listinfo/r-help
>     <https://stat.ethz.ch/mailman/listinfo/r-help>
>     PLEASE do read the posting guide
>     http://www.R-project.org/__posting-guide.html
>     <http://www.R-project.org/posting-guide.html>
>     and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Sarah Goslee
> http://www.stringpage.com
> http://www.sarahgoslee.com
> http://www.functionaldiversity.org

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Basic misunderstanding, or problem with my installation?

barry rowlingson
In reply to this post by Sarah Goslee
On Wed, Jan 1, 2014 at 4:36 AM, David Parkhurst <[hidden email]> wrote:
> Thanks to the three people who saw what I missed.  I typed my
> code in Libre Office as "<" followed by "-", and that program
> converted those two characters into a single left arrow symbol.
> I copied the commands from Libre into R without noticing that
> that had happened.  Wierd.

 You should probably install "R Studio" and use that! You'll get
syntax highlighting, bracket matching, and no magic conversion of
arrows!

www.rstudio.com

Barry

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Basic misunderstanding, or problem with my installation?

JohnDee
In reply to this post by Gabor Grothendieck
On Tue, 31 Dec 2013 19:51:06 -0500
Gabor Grothendieck <[hidden email]> wrote:

...
>
> The assignment operator is TWO characters: a less than sign
> immediately followed by a minus sign.  Try copying and pasting this:
>
> x <- 3
> x
>

Actually, you can use the = sign as well.

X = 3

works the same as

X <- 3

and uses two fewer keystrokes if you're lazy enough to care about such
things -like me.

______________________________________________
[hidden email] 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.