dput(treat)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

dput(treat)

R help mailing list-2

I got advice here that I didn't understand! Can I ask to explain me the meaning of this procedure: first get the structure, and then assign it back. For what? Thanks!  (Great thanks to Moderator/Admin!)

You should learn to post in plain text and use dput to present your data structures. At your console do this
dput(treat)
# and this will appear. Copy it to your plain-text message:
structure(list(ID = 1:5, start = c(0L, 0L, 0L, 0L, 0L), stop = c(66L,
18L, 43L, 47L, 26L), censor = c(0L, 0L, 1L, 1L, 0L), sex = c(2L,
1L, 2L, 2L, 1L), age = c(1L, 2L, 3L, 3L, 4L), stage = c(3L, 4L,
3L, NA, 3L), treatment = c(1L, 2L, 1L, 2L, NA)), .Names = c("ID",
"start", "stop", "censor", "sex", "age", "stage", "treatment"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5"
)):
Then we can just do this:
 treat <- structure(list(ID = 1:5, start = c(0L, 0L, 0L, 0L, 0L), stop = c(66L,
18L, 43L, 47L, 26L), censor = c(0L, 0L, 1L, 1L, 0L), sex = c(2L,
1L, 2L, 2L, 1L), age = c(1L, 2L, 3L, 3L, 4L), stage = c(3L, 4L,
3L, NA, 3L), treatment = c(1L, 2L, 1L, 2L, NA)), .Names = c("ID",
"start", "stop", "censor", "sex", "age", "stage", "treatment"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5"
))

        [[alternative HTML version deleted]]

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

Re: dput(treat)

Michael Dewey-3
Dear Ted

Comments in line

On 11/10/2017 11:59, Ted Beginner (RStudio) via R-help wrote:
>
> I got advice here that I didn't understand! Can I ask to explain me the meaning of this procedure: first get the structure, and then assign it back. For what? Thanks!  (Great thanks to Moderator/Admin!)
>
> You should learn to post in plain text and use dput to present your data structures. At your console do this

So this is what you do to display your data-frame in a plain text way.

> dput(treat)
> # and this will appear. Copy it to your plain-text message:
> structure(list(ID = 1:5, start = c(0L, 0L, 0L, 0L, 0L), stop = c(66L,
> 18L, 43L, 47L, 26L), censor = c(0L, 0L, 1L, 1L, 0L), sex = c(2L,
> 1L, 2L, 2L, 1L), age = c(1L, 2L, 3L, 3L, 4L), stage = c(3L, 4L,
> 3L, NA, 3L), treatment = c(1L, 2L, 1L, 2L, NA)), .Names = c("ID",
> "start", "stop", "censor", "sex", "age", "stage", "treatment"
> ), class = "data.frame", row.names = c("1", "2", "3", "4", "5"
> )):

Then this is what we, the readers, do to read in your data-frame so we
are sure we have exactly the same as you had.

> Then we can just do this:
>   treat <- structure(list(ID = 1:5, start = c(0L, 0L, 0L, 0L, 0L), stop = c(66L,
> 18L, 43L, 47L, 26L), censor = c(0L, 0L, 1L, 1L, 0L), sex = c(2L,
> 1L, 2L, 2L, 1L), age = c(1L, 2L, 3L, 3L, 4L), stage = c(3L, 4L,
> 3L, NA, 3L), treatment = c(1L, 2L, 1L, 2L, NA)), .Names = c("ID",
> "start", "stop", "censor", "sex", "age", "stage", "treatment"
> ), class = "data.frame", row.names = c("1", "2", "3", "4", "5"
> ))
>

If you carry on posting in HTML it is possible that your e-mails will
get scrambled so it would be best to post in plain text. It does not
seem to have had a bad effect this time.

> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com
>

--
Michael
http://www.dewey.myzen.co.uk/home.html

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

Re: dput(treat)

Rui Barradas
In reply to this post by R help mailing list-2
Hello,

The best way to post data is to use dput. The moderator/admin (?) did
NOT say that you should "first get the structure, and then assign it
back", they gave you an example of the use of dput and then what us,
when reading your post would do with that output.

They wrote that "Then we can just do this".

We can simply assign that output to a variable and create an exact copy
of what you have in your R session, that's why dput is so usefull.

When you post data, always post the output of dput. If it's a large
dataset, such as a data.frame with many rows, you can post a small
subset with

dput(head(df, 20))  # or 30 or 50

This will only give the structure of the first 20 (or 30 or 50) rows.


Hope this helps,

Rui Barradas

Em 11-10-2017 11:59, Ted Beginner (RStudio) via R-help escreveu:

>
> I got advice here that I didn't understand! Can I ask to explain me the meaning of this procedure: first get the structure, and then assign it back. For what? Thanks!  (Great thanks to Moderator/Admin!)
>
> You should learn to post in plain text and use dput to present your data structures. At your console do this
> dput(treat)
> # and this will appear. Copy it to your plain-text message:
> structure(list(ID = 1:5, start = c(0L, 0L, 0L, 0L, 0L), stop = c(66L,
> 18L, 43L, 47L, 26L), censor = c(0L, 0L, 1L, 1L, 0L), sex = c(2L,
> 1L, 2L, 2L, 1L), age = c(1L, 2L, 3L, 3L, 4L), stage = c(3L, 4L,
> 3L, NA, 3L), treatment = c(1L, 2L, 1L, 2L, NA)), .Names = c("ID",
> "start", "stop", "censor", "sex", "age", "stage", "treatment"
> ), class = "data.frame", row.names = c("1", "2", "3", "4", "5"
> )):
> Then we can just do this:
>   treat <- structure(list(ID = 1:5, start = c(0L, 0L, 0L, 0L, 0L), stop = c(66L,
> 18L, 43L, 47L, 26L), censor = c(0L, 0L, 1L, 1L, 0L), sex = c(2L,
> 1L, 2L, 2L, 1L), age = c(1L, 2L, 3L, 3L, 4L), stage = c(3L, 4L,
> 3L, NA, 3L), treatment = c(1L, 2L, 1L, 2L, NA)), .Names = c("ID",
> "start", "stop", "censor", "sex", "age", "stage", "treatment"
> ), class = "data.frame", row.names = c("1", "2", "3", "4", "5"
> ))
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

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

Re: dput(treat)

roslinazairimah zakaria
In reply to this post by R help mailing list-2
Hi,

If you have a data, run dput(data), then in the console you will see the
output.  Copy the output and place it in your email.

HTH.

On Wed, Oct 11, 2017 at 6:59 PM, Ted Beginner (RStudio) via R-help <
[hidden email]> wrote:

>
> I got advice here that I didn't understand! Can I ask to explain me the
> meaning of this procedure: first get the structure, and then assign it
> back. For what? Thanks!  (Great thanks to Moderator/Admin!)
>
> You should learn to post in plain text and use dput to present your data
> structures. At your console do this
> dput(treat)
> # and this will appear. Copy it to your plain-text message:
> structure(list(ID = 1:5, start = c(0L, 0L, 0L, 0L, 0L), stop = c(66L,
> 18L, 43L, 47L, 26L), censor = c(0L, 0L, 1L, 1L, 0L), sex = c(2L,
> 1L, 2L, 2L, 1L), age = c(1L, 2L, 3L, 3L, 4L), stage = c(3L, 4L,
> 3L, NA, 3L), treatment = c(1L, 2L, 1L, 2L, NA)), .Names = c("ID",
> "start", "stop", "censor", "sex", "age", "stage", "treatment"
> ), class = "data.frame", row.names = c("1", "2", "3", "4", "5"
> )):
> Then we can just do this:
>  treat <- structure(list(ID = 1:5, start = c(0L, 0L, 0L, 0L, 0L), stop =
> c(66L,
> 18L, 43L, 47L, 26L), censor = c(0L, 0L, 1L, 1L, 0L), sex = c(2L,
> 1L, 2L, 2L, 1L), age = c(1L, 2L, 3L, 3L, 4L), stage = c(3L, 4L,
> 3L, NA, 3L), treatment = c(1L, 2L, 1L, 2L, NA)), .Names = c("ID",
> "start", "stop", "censor", "sex", "age", "stage", "treatment"
> ), class = "data.frame", row.names = c("1", "2", "3", "4", "5"
> ))
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.




--
*Roslinazairimah Zakaria*
*Tel: +609-5492370; Fax. No.+609-5492766*

*Email: [hidden email] <[hidden email]>;
[hidden email] <[hidden email]>*
Faculty of Industrial Sciences & Technology
University Malaysia Pahang
Lebuhraya Tun Razak, 26300 Gambang, Pahang, Malaysia

        [[alternative HTML version deleted]]

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