[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Looking for help with a very basic R assignment. I'm taking

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 2
Thread images: 1

File: R_logo.svg.png (190KB, 2000x1550px) Image search: [Google]
R_logo.svg.png
190KB, 2000x1550px
Looking for help with a very basic R assignment. I'm taking a course for complete novices. I'm not quite sure about how to get R to spit out the mode (#3), I can't find any command for it online or in my textbook.

1. Create a list with four elements - two character, one numeric and one logical
2. Extract the logical element
3. What are the mode and class of the results of #11

This is what I have so far:
x = c('Hello', 'Hi', 400, 5 > 1)

x[4]

mode(x)???
class(x)


Thanks. I know this is super basic stuff, no bully pls.
>>
>>375287
>x = c('Hello', 'Hi', 400, 5 > 1)
This doesn't quite work (if you type mode(x) you'll see that x is a character vector) because the 'c' function will assume you want a character vector and try to coerce the non-character elements into strings. You want

x = list('Hello', 'Hi', 400, 5 > 1)
mode(x)

>x[4]
Since x is a list instead of a vector, you'll need to double up on square brackets to extract elements, i.e.

x[[4]]

(x[4] will return a list containing the single element TRUE, instead of the element itself. To verify this, type "str(x[[4]])" and "str(x[4])" without quotes.)

>mode(x)???
>class(x)
That's correct, unless your assignment is interpreting "mode" in the statistical sense (most common element) instead of the R sense (the type of x, in programming lingo).
Thread posts: 2
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.