Hi,
Please check your dput().
By using your dput() output, I am getting:
$patient_id
[1] 2 2 2 2 3 3 3 3

$responsed_at
[1] 14755 14797 14835 14883 14755 14789 14826 14857

$number
[1] 1 2 3 4 1 2 3 4

$score
[1] 1 1 2 3 1 5 4 5

$.Names
[1] "patient_id"   "responsed_at" "number"       "scores"      

$row.names
[1] NA -8

$class
[1] "data.frame"

It looks like the image from shared also showed the same output.  I am not 
using RStudio.  So, I don't know what is wrong.


#the dput should be:dat1<- structure(list(patient_id = c(2,2,2,2,3,3,3,3),

               responsed_at = 
c(14755,14797,14835,14883,14755,14789,14826,14857),
               number = c(1,2,3,4,1,2,3,4), score=c(1,1,2,3,1,5,4,5)),  
               .Names = c("patient_id","responsed_at", "number", 
"scores"),row.names=c(NA,-8L),class = "data.frame")
dat1
#  patient_id responsed_at number scores
#1          2        14755      1      1
#2          2        14797      2      1
#3          2        14835      3      2
#4          2        14883      4      3
#5          3        14755      1      1
#6          3        14789      2      5
#7          3        14826      3      4
#8          3        14857      4      5


library(zoo)
dat1$responsed_at<-as.Date(dat1$responsed_at)
 dat1
#  patient_id responsed_at number scores
#1          2   2010-05-26      1      1
#2          2   2010-07-07      2      1
#3          2   2010-08-14      3      2
#4          2   2010-10-01      4      3
#5          3   2010-05-26      1      1
#6          3   2010-06-29      2      5
#7          3   2010-08-05      3      4
#8          3   2010-09-05      4      5
 str(dat1)
#'data.frame':    8 obs. of  4 variables:
# $ patient_id  : num  2 2 2 2 3 3 3 3
# $ responsed_at: Date, format: "2010-05-26" "2010-07-07" ...
# $ number      : num  1 2 3 4 1 2 3 4
# $ scores      : num  1 1 2 3 1 5 4 5
A.K.




________________________________
 From: GUANGUAN LUO <guanguan...@gmail.com>
To: arun <smartpink...@yahoo.com> 
Sent: Tuesday, April 16, 2013 10:49 AM
Subject: Re: how to change the date into an interval of date?
 


hi,
 dput(head(data,8))
structure(list(patient_id = c(2,2,2,2,3,3,3,3), 
               responsed_at = 
c(14755,14797,14835,14883,14755,14789,14826,14857), 
               number = c(1,2,3,4,1,2,3,4), score=c(1,1,2,3,1,5,4,5),  
               .Names = c("patient_id", 
  "responsed_at", "number", "scores"),  class = "data.frame"))

like this? 
i use R studio, there are 4 windows , window of results is the output. 


2013/4/16 arun <smartpink...@yahoo.com>

HI,
>Please dput() your dataset as in my previous reply.  This is image and it is 
>twice or thrice the work for me to convert it to readable form.
>
>http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
>
>
>Also,  you didn't answer to my question:
>"I didn't understand which one is "window of results" and which is "my 
>tables"."
>
>
>
>
>
>________________________________
> From: GUANGUAN LUO <guanguan...@gmail.com>
>To: smartpink...@yahoo.com 
>Sent: Tuesday, April 16, 2013 10:10 AM
>Subject: Re: how to change the date into an interval of date?
> 
>
>
>  
>patient_id
>number
>response_id
>session_id
>responsed_at
>login
>clinique_basdai.fatigue
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>1 2 1 77 2 14755 3002 4 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>2 2 2 1258 61 14797 3002 5 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>3 2 3 2743 307 14835 3002 5 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>4 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> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>26 3 7 8341 1100 14961 3005 3 
> 
>
>Hello, this is my table, and i want to work with a format "yyyy-mm-dd", but 
>you see the column "responsed_at" are the grand numbers.
>I want to change these into normal format.
>I don't know whether it owe to the wrong format that i  can not merge two 
>tables together.
>Thank you so much.
>
>Guanguan
>
>
>2013/4/16 <smartpink...@yahoo.com>
>
>
>>Hi,
>>I didn't understand which one is "window of results" and which is "my 
>>tables".  According to your post, it looks like one of them is in the correct 
>>date format.  So, you wanted to work on the dataset with the incorrect date 
>>format?
>>Please dput(head(dataset,20)).  By using these images, it takes so much time 
>>to type the data as in your image and it won't give much details regarding 
>>the structure of your dataset.
>>A.K.
>>
>>
>>
>><quote author='mimorsa'>
>>Hello AK,
>> Thank you so much for your help.
>>I've tried your method to my tables, and I think I had not expressed clearly
>>my problems.
>>Sorry to trouble you so much.
>>
>>In reality, my table is like this:
>>
>>
>>
>>
>>My problems are as following:
>>1. The format of date is such the numbers like  "14755" etc. , I have tried
>>dat$responsed_at <- as.Date ( dat$responsed_at,format="%Y-%m-%d")
>>
>>but it looks like doesn't work . In the window of result, the format of date
>>is such like "2010-02-02", but in my tables, the format of date has not
>>changed.
>>
>>PS: and i have told you a wrong thing, now my date format should still be
>>"%Y-%m-%d". No need to change into "%d-%m-%Y"
>>
>>2. How can i merge the two dataframe into one?
>>as you have mentioned in your reponse, your code is
>>res<-merge(datNew,dat2,all=TRUE,by="responsed_at")
>>I've tried that, but the error is :
>>
>>Error in charToDate(x) :
>>  character string is not in a standard unambiguous format
>>
>>I think that is also the problem of the format of date, isn't that?
>>
>>3. because for the patient concerned,in the original database, there are
>>only the number of connection, which i  want is to see if  the patient had
>>responsed the questionnaire every month. So the 'id' should be conserved
>>too.
>>
>>Thank you so much.
>></quote>
>>Quoted from:
>>http://r.789695.n4.nabble.com/how-to-change-the-date-into-an-interval-of-date-tp4664071p4664339.html
>>
>>
>>_____________________________________
>>Sent from http://r.789695.n4.nabble.com
>>
>>
>
>
>

______________________________________________
R-help@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.

Reply via email to