0

I need to add and run the current coding using for loop..

df<-data.frame("hi","bye")
names(df)<-c("hello","goodbye")

de<-data.frame("hola","ciao")
names(de)<-c("hello","goodbye")

newdf <- rbind(df, de)
2
  • What happens when you run that code? Is there an error? Commented Aug 5, 2017 at 14:45
  • I really don't understand the question, there's nothing to be done, your code adds (rbind) one df to the other. Commented Aug 5, 2017 at 15:24

1 Answer 1

1

I really can't figure out why, anyway just run the following

newdf = data.frame(hello=character(), goodbye=character()); # create the empty data.frame

# add each df row (one by one)
for(i in 1:NROW(df)) {
    newdf[i, ] = df[i, ];
}

# add each de row (one by one)
for(i in 1:NROW(df)) {
    newdf[i+NROW(df), ] = de[i, ];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.