I'm trying this in R
> df <- data.frame(x=c("spam", "spam", "ham"), y=c("some mail", "some other mail", "some third mail"))
> add.string.func <- function(somestr) { paste("prefix-", somestr, "-postfix", sep = "") }
> df[1,]
x y
1 spam some mail
> df[,1]
[1] spam spam ham
Levels: ham spam
> apply(X = df[1,], add.string.func, MARGIN = 1)
1
[1,] "prefix-spam-postfix"
[2,] "prefix-some mail-postfix"
> apply(X = as.matrix(df[,1]), add.string.func, MARGIN = 1)
[1] "prefix-spam-postfix" "prefix-spam-postfix" "prefix-ham-postfix"
> apply(X = df[,1], add.string.func, MARGIN = 1)
Error in apply(X = df[, 1], add.string.func, MARGIN = 1) :
dim(X) must have a positive length ### Why is the dim 0?
> dim(df)
[1] 3 2 # doesn't this means it's 3 rows and 2 columns??
> dim(df)
[1] 3 2
if dim(df)
is 3 2
how come dim[,1]
is NULL?