splitting strings into letters using R snippet node
Hi, I am using the R snippet node to take a column of strings, split them into their component letters, then output the results as a dataframe.
The code I have places is:
tmp ← knime.in # a simple table consisting of 1 column (“Column Header) of 16 strings #
df1 ← as.data.frame(tmp)
df1$‘splt’ ← c(strsplit(df1$
Column Header,split=”")) #adding the split strings as a second column in the df #
knime.out ← df1
This seems to work in R studio, which gives me the output:
df1 Column Header splt 1 IntWC2hA1 I, n, t, , W, C, 2, h, A, 1 2 IntWC2hA2 I, n, t, , W, C, 2, h, A, 2 3 IntWC2hA3 I, n, t, , W, C, 2, h, A, 3 4 IntWC2hA4 I, n, t, , W, C, 2, h, A, 4 5 IntWD2hA1 I, n, t, , W, D, 2, h, A, 1 6 IntWD2hA2 I, n, t, , W, D, 2, h, A, 2 7 IntWD2hA3 I, n, t, , W, D, 2, h, A, 3 8 IntWD2hA4 I, n, t, , W, D, 2, h, A, 4 9 IntWC2hT1 I, n, t, , W, C, 2, h, T, 1 10 IntWC2hT2 I, n, t, , W, C, 2, h, T, 2 11 IntWC2hT3 I, n, t, , W, C, 2, h, T, 3 12 IntWC2hT4 I, n, t, , W, C, 2, h, T, 4 13 IntWD2hT1 I, n, t, , W, D, 2, h, T, 1 14 IntWD2hT2 I, n, t, , W, D, 2, h, T, 2 15 IntWD2hT3 I, n, t, , W, D, 2, h, T, 3 16 IntWD2hT4 I, n, t, , W, D, 2, h, T, 4
However, the R snippet node fails when I run it.
Perhaps I am missing something basic, but does anyone have any ideas of why the node fails?