Hello folks,
This is my first project I whant to create function which ask user to enter some data and after that bind it to my df(df has more columns when vector x has in function). This function don´t give me an error but still not add data to my df. Hope you understand my question
function(){
q <- readline("input1")
w <- readline("input2:")
e <- readline("input3:")
r <- readline("input4:")
t <- readline("input5:")
y <- readline("input6:")
u <- readline("input7:")
i <- readline("input8:")
o <- readline("input9:")
p <- readline("input10:")
a <- readline("input11:")
s <- readline("input12:")
d <- readline("input13:")
x <- c(q,w,e,r,t,y,u,i,o,p,a,s,d)
df <- rbind(df,x)
You have to set the function to return a value. As written, it makes a new version of df but that version disappears when the function finishes executing. Try this
addRow <- function(){
q <- readline("input1")
w <- readline("input2:")
e <- readline("input3:")
r <- readline("input4:")
t <- readline("input5:")
y <- readline("input6:")
u <- readline("input7:")
i <- readline("input8:")
o <- readline("input9:")
p <- readline("input10:")
a <- readline("input11:")
s <- readline("input12:")
d <- readline("input13:")
x <- c(q,w,e,r,t,y,u,i,o,p,a,s,d)
rbind(df,x)
}
df <- addRow()