[R] a question about data manipulation in R

John Kane jrkrideau at inbox.com
Tue Sep 15 03:26:42 CEST 2015


Please do not send email in HTML. The R-help mailer removes any HTML code and the result is a mess. Your results were readable but still a terrible mess.

Also please reply to the R-help list not just to me. Your chances of getting an answer are much better if you reply to the list.

Anyway here are your two data.frames. It should be very easy to do what you want but I am completely blank for the moment. We'll let someone else have a go at this

input <- structure(list(V1 = c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,

4L), V2 = c(33313L, 45534L, 34533L, 54321L,43322L, 34462L, 40023L, 44412L, 11115L, 26L,

2236L, 3L, 12343L, 12334L, 94845L)), .Names = c("V1", "V2"), class ="data.frame",

row.names = c(NA, -15L))

output <- structure(list(V1 = c(33313L, 45534L, 34533L, NA, NA), V2 =c(54321L, 43322L,

34462L, 40023L, NA), V3 = c(44412L, 11115L, 26L, NA, NA), V4 = c(2236L, 3L, 12343L,

12334L, 94845L)), .Names =c("V1", "V2", "V3", "V4"), class ="data.frame", row.names =

c(NA, -5L)) 

John Kane

Kingston ON Canada


John Kane
Kingston ON Canada

-----Original Message-----
From: zkarimi1985 at yahoo.com
Sent: Mon, 14 Sep 2015 17:37:44 +0000 (UTC)
To: jrkrideau at inbox.com
Subject: Re: [R] a question about data manipulation in R

Dear John,

Thank you for your response.

my last item was 432. I Put my input and output file in duput() and this is the result:

> dput(input)

structure(list(V1 = c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 

4L, 4L, 4L, 4L, 4L), V2 = c(33313L, 45534L, 34533L, 54321L, 43322L, 

34462L, 40023L, 44412L, 11115L, 26L, 2236L, 3L, 12343L, 12334L, 

94845L)), .Names = c("V1", "V2"), class = "data.frame", row.names = c(NA, 

-15L))

> dput(output)

structure(list(V1 = c(33313L, 45534L, 34533L, NA, NA), V2 = c(54321L, 

43322L, 34462L, 40023L, NA), V3 = c(44412L, 11115L, 26L, NA, 

NA), V4 = c(2236L, 3L, 12343L, 12334L, 94845L)), .Names = c("V1", 

"V2", "V3", "V4"), class = "data.frame", row.names = c(NA, -5L

))

my problem is that I do not know how to write a code in R to reach from the described input to the output that I need. I am beginner in R and I try to learn. I should mention that My real input data is very large and this is only small example similar to the real data. can you please show me how to write a script in R to reach to the output I need?

kind regards,

Zahra

  On Sunday, 13 September 2015, 14:07, John Kane <jrkrideau at inbox.com> wrote:

You are in the right place but the question in not very clear. Have a look at the links below for some suggestions on how to ask a question on R-help.

I think we need the data in dput() format. See ?dput or the discussion of dput() in the links.

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example [http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example]and http://adv-r.had.co.nz/Reproducibility.html [http://adv-r.had.co.nz/Reproducibility.html]

Did you intend that the last item in the data set be  432I where that last character is an I (��  not a one 1?

John Kane
Kingston ON Canada

> -----Original Message-----
> From: r-help at r-project.org
> Sent: Sun, 13 Sep 2015 05:12:07 +0000 (UTC)
> To: r-help at r-project.org
> Subject: [R] a question about data manipulation in R
> 
> Hello,
> I have a data like this:1 2331 3331 4551 3452 5432 4332 3442 4003 4443
> 1113 0003 432I want to change it to this new dataset:c1    c2     c3233
> 543  444333  433  111455  344  000345  400  432
>  How can I do this in R? Please if this not the correct place to ask  my
> queston.. then could you please guid me , where should I ask my
> question?kind regards,Zahra

> 
>     [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.

[http://mysecurelogon.com/password-manager]

____________________________________________________________
Send your photos by email in seconds...
TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if3
Works in all emails, instant messengers, blogs, forums and social networks.



More information about the R-help mailing list