Sunday, 15 February 2015

Calculate length of character array in a list in R -



Calculate length of character array in a list in R -

i tried separate words of sentence different elements of array this:

words_from_sentence <- strsplit("i going out brother", " ")

i want length of array of words , want access each word index number of array. however, end getting single list of length 1. please advise.

typeof(words_from_sentence)

list

length(words_from_sentence)

1

length(words_from_sentence[1])

1

you need utilize double bracket indexing when trying grab element list.

length(words_from_sentence[[1]])

r

No comments:

Post a Comment