Reputation: 2077
I have the following code that everthing is alright, even the file generated in "C:/Users/User/Desktop/test/4.csv" is correct
d <- data.frame()
for(i in 1:nrow(testresult))
{
b<- pnbd.ConditionalExpectedTransactions(est.params, T.star = testresult [i,8],
x, t.x, T.cal)
m6<- list(testresult[i,1],b)
d <- rbind(d,m6)
write.table(m6,file="C:/Users/User/Desktop/test/4.csv", append=TRUE,sep=",",col.names=FALSE,row.names=FALSE)
}
I need a data frame similar to "C:/Users/User/Desktop/test/4.csv". That's why I added
d <- rbind(d,m6)
to append the new rows to my dataframe. The results for d
is some repeated rows. Hope I am clear. Please ignore line 4 of the code if they are not clear. They are not the issue. the issue is only d <- rbind(d,m6)
Upvotes: 0
Views: 34
Reputation: 1153
Posting as an answer:
Your object m6
is a list
and so cannot be attached to a dataframe using rbind
. It depends on the output from your function pnbd.ConditionalExpectedTransactions
but what you probably want is to create a vector using m6 <- c(testresult[i,1], b)
.
Upvotes: 1