Open mmonakho opened 2 years ago
When you unlist the words it puts the words into a vector. You can access the object in a vector by placing a bracket after the object's name followed by the address. So word.vector[1] should return the first word in the string
On Tue, Feb 1, 2022 at 5:04 PM mmonakho @.***> wrote:
Struggling with this part.
get_first_word <- function( x ) { split title x into words unlist results select the first word return first word
}
What does # select the first word imply? How do we select it? This is what I got so far.
get_first_word <- function( x ) { word.list <- strsplit(titles, " " ) word.vector <- unlist( word.list ) select the first word return first word
}
— Reply to this email directly, view it on GitHub https://github.com/Watts-College/cpp-527-spr-2022/issues/23, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4EHB5QQVFLBQCK7FD6VYLUZBYJNANCNFSM5NKTB23A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
Does that (word.vector[1]) imply both
and
I tried this:
get_first_word <- function( x ) { word.list <- strsplit(lower.title, " " ) word.vector <- unlist( word.list ) word.vector[1] }
And it returns "a" to me every time...
By every time I mean for any number in brackets here:
get_first_word(d$title[number here])
word.vector is the name of one of your objects that was defined in the function. Based on the code you posted word.vector[1] will be the first word in the list of strings.
You can either save that as a new object and return that object. Or you can just use return(Word.vector[1]).
On Tue, Feb 1, 2022 at 9:51 PM mmonakho @.***> wrote:
By every time I mean for any number in brackets here:
get_first_word(d$title[number here])
— Reply to this email directly, view it on GitHub https://github.com/Watts-College/cpp-527-spr-2022/issues/23#issuecomment-1027575257, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4EHBYXR2IEZPYP6AVEZO3UZCZ6RANCNFSM5NKTB23A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
Struggling with this part.
get_first_word <- function( x ) {
split title x into words
unlist results
select the first word
return first word
}
What does # select the first word imply? How do we select it? This is what I got so far.
get_first_word <- function( x ) { word.list <- strsplit(titles, " " ) word.vector <- unlist( word.list )
select the first word
return first word
}