I'd have to say that I've just started working with R half an hour ago, running R scripts from SQL Server, so I'm what they call a complete noob.
I'm trying to merge two R vectors into a data frame, but my problem is that the vectors have varying lengths.
I'm not sure if this can be done, although i don't necessarily see why not?
My R script is:
n <- c(2, 3, 5, 6);
s = c("aa", "bb", "cc");
df = data.frame(n, s);
And the error that I'm getting is:
Error in data.frame(n, s) : arguments imply differing number of rows: 4, 3 Calls: source -> withVisible -> eval -> eval -> data.frame
Error in ScaleR. Check the output for more information. Error in eval(expr, envir, enclos) : Error in ScaleR. Check the output for more information. Calls: source -> withVisible -> eval -> eval -> .Call Execution halted
Esentially what I'm imagining doing is generating a result set similar to a LEFT JOIN
.
2 aa
3 bb
5 cc
6 NULL
I'm asking myself if I should specify a "replace NULL" values in the R data frame, but I'm not sure if this is a solution.