[R] Basic question -loading data

703 views
Skip to first unread message

Dinuk Jayasuriya

unread,
Aug 15, 2012, 12:28:42 AM8/15/12
to r-h...@r-project.org
Hi all,

New user here - I include the following command in the prompt

read.csv("document.csv", header = TRUE )

and the output shows up.

But when I include the following command

summary(data)

I get the following message "Error in object[[i]] : object of type 'closure' is not subsettable"

Can someone please advise why R is not reading my data?

Thanks

[[alternative HTML version deleted]]

______________________________________________
R-h...@r-project.org 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.

Jeff Newmiller

unread,
Aug 15, 2012, 3:27:23 AM8/15/12
to Dinuk Jayasuriya, r-h...@r-project.org
"data" is the name of a base function in R. Functions are objects of type "closure". You can find out more about this function by reading the help. If you create your own object named "data" then your object will "hide" the base function and you won't be able to use it when you want to. Type

?data

You used the read.csv function alright, but you did not assign the function return value to a variable, so it just printed it and threw it away.

Try

dta <- read.csv("document.csv", header = TRUE )
str(dta)
summary(dta)

If you don't know whether some variable name you want to use is already "taken", you can just type the name alone at the R prompt:

data

if it gives a not-found error then you should be safe to use it. A couple of tempting names you should also avoid are

c (commonly used function for making vectors. Tempting because it comes after "a" and "b")
t (the transpose function for matrices. Tempting for naming time variables.)
df (density of the f distribution. Tempting because data frames are very often used object classes.)
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdne...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.

Dinuk Jayasuriya

unread,
Aug 15, 2012, 3:59:53 AM8/15/12
to Jeff Newmiller, r-h...@r-project.org
Hi Jeff,

Thank you - your comment was much appreciated.

I'm now running an ordered probit regression and get the following error:

Error in family$linkfun(mustart) : Value 1.125 out of range (0, 1)

I can't decipher (after looking at other posts on google!) why this error occurs - is it something wrong with my dataset?

If anyone can advise that would be very helpful.

Thanks,
Dinuk

R. Michael Weylandt

unread,
Aug 15, 2012, 11:56:01 PM8/15/12
to Dinuk Jayasuriya, r-h...@r-project.org
On Wed, Aug 15, 2012 at 3:59 AM, Dinuk Jayasuriya
<Dinuk.Ja...@anu.edu.au> wrote:
> Hi Jeff,
>
> Thank you - your comment was much appreciated.
>
> I'm now running an ordered probit regression and get the following error:
>
> Error in family$linkfun(mustart) : Value 1.125 out of range (0, 1)

Error message suggests you are trying to predict a probability of
112.5% with your model, but it's hard to say why exactly you're
getting this message without a reproducible example:

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Note also that this is a pretty different question than how this
thread started, so follow up should begin a new thread.

Michael

John

unread,
Aug 16, 2012, 12:14:12 AM8/16/12
to r-h...@r-project.org
On Wed, 15 Aug 2012 17:59:53 +1000
Dinuk Jayasuriya <Dinuk.Ja...@anu.edu.au> wrote:

> Hi Jeff,
>
> Thank you - your comment was much appreciated.
>
> I'm now running an ordered probit regression and get the following
> error:
>
> Error in family$linkfun(mustart) : Value 1.125 out of range (0, 1)
>
> I can't decipher (after looking at other posts on google!) why this
> error occurs - is it something wrong with my dataset?
>
> If anyone can advise that would be very helpful.
>
> Thanks,
> Dinuk

You need to supply considerably more information before you can expect
much help. A subset of the data would help, since otherwise people are
guessing. Also, if you look at the example here:

http://www.ats.ucla.edu/stat/R/dae/probit.htm

you may find some useful pointers.

JWDougherty

Dinuk Jayasuriya

unread,
Aug 16, 2012, 3:03:11 AM8/16/12
to John, rhelp
John/Michael, thanks for your comments.

I get the following error when I run my code (the code is attached as is a section of the data set):
Error in family$linkfun(mustart) : Value 1.125 out of range (0, 1)

If anyone can please provide assistance that would be much appreciated - I'm not sure if it's something wrong with my dataset or a bug in the program "list"

Many thanks,
Dinuk

David Winsemius

unread,
Aug 16, 2012, 1:07:10 PM8/16/12
to Dinuk Jayasuriya, rhelp

On Aug 16, 2012, at 12:03 AM, Dinuk Jayasuriya wrote:

> John/Michael, thanks for your comments.
>
> I get the following error when I run my code (the code is attached
> as is a section of the data set):

No, it's not (anymore at least). It needs to be a mime-text formated
file at the time it hits the R mail-server, and typically those need
to be constructed with extension ".txt" although details may vary
among OSes.

--
David.
David Winsemius, MD
Alameda, CA, USA
Reply all
Reply to author
Forward
0 new messages