An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130319/12245b8b/attachment.pl>
Copying rows in data frames
6 messages · Ista Zahn, Berend Hasselman, arun +1 more
show us the data. On Tue, Mar 19, 2013 at 7:55 AM, Sahana Srinivasan
<sahanasrinivasan.91 at gmail.com> wrote:
Hi,
I'm trying to copy the first row of one data frame to another. This is the
statement I am using :
df2[1,]<-df1[1,];
I have printed them out separately:
df1[1,] = A C D E F
But after copying:
df2[1,] = 96 29 88 122 68
Why isn't it copying? They are both data frames, and "as.character" isn't
working either.
Thanks for your input :)
[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130319/c3ac0edc/attachment.pl>
On 19-03-2013, at 13:06, Sahana Srinivasan <sahanasrinivasan.91 at gmail.com> wrote:
I.. did? Here is the whole thing: Output dataframe, df2: (NA is because I haven't filled those cells in yet, but they will have numeric values) 1462696298812268108381201091254781626868918410126662NANANANANANANANANANANANA NANANANANANANANANA Input dataframe, df1: 1GENEACDEFGHIKLMNPQRSTVWY2amt:Amet_00012902334171612422939635201325342732312
Not good enough. Use dput(head(df1)) and dput(head(df2)) And paste the result in the message. Berend.
Hi, set.seed(25) ?df1<- as.data.frame(matrix(sample(LETTERS[1:10],20,replace=TRUE),ncol=5),stringsAsFactors=FALSE) ?df1 #? V1 V2 V3 V4 V5 #1? E? B? A? J? F #2? G? J? C? F? H #3? B? G? D? G? E #4? I? D? D? B? H ?str(df1) #'data.frame':??? 4 obs. of? 5 variables: # $ V1: chr? "E" "G" "B" "I" # $ V2: chr? "B" "J" "G" "D" # $ V3: chr? "A" "C" "D" "D" # $ V4: chr? "J" "F" "G" "B" # $ V5: chr? "F" "H" "E" "H" ?df2<-as.data.frame(matrix(NA,ncol=5,nrow=3)) ?df2[1,]<-df1[1,] ?df2[1,] #? V1 V2 V3 V4 V5 #1? E? B? A? J? F A.K. ----- Original Message ----- From: Sahana Srinivasan <sahanasrinivasan.91 at gmail.com> To: r-help at r-project.org Cc: Sent: Tuesday, March 19, 2013 7:55 AM Subject: [R] Copying rows in data frames Hi, I'm trying to copy the first row of one data frame to another. This is the statement I am using : df2[1,]<-df1[1,]; I have printed them out separately: df1[1,] = A C D E F But after copying: df2[1,] = 96 29 88 122 68 Why isn't it copying? They are both data frames, and "as.character" isn't working either. Thanks for your input :) ??? [[alternative HTML version deleted]] ______________________________________________ R-help at 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130319/ce553e4f/attachment.pl>