The Wayback Machine - https://web.archive.org/web/20201005003227/https://github.com/datacarpentry/r-socialsci/issues/65
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data types and structures #65

Open
cmrfoley opened this issue Jun 12, 2018 · 6 comments
Open

data types and structures #65

cmrfoley opened this issue Jun 12, 2018 · 6 comments

Comments

@cmrfoley
Copy link

@cmrfoley cmrfoley commented Jun 12, 2018

The discussion of data types and data structures in "Vectors and data types" could be clarified. Perhaps even defining these terms before using them would help. Also note that the first sentence of the section reads "A vector is the most common and basic data type in R, and is pretty much the workhorse of R." perhaps this should be changed to "basic data structure"

@juanfung
Copy link
Contributor

@juanfung juanfung commented Feb 4, 2019

Agreed this discussion could be improved. Perhaps an abridged version of the discussion here: https://swcarpentry.github.io/r-novice-inflammation/13-supp-data-structures/, with a link to the complete discussion there?

Maybe mentioning the atomic vector types (character, numeric, etc.) plus some of the many "data structures" (list, data frame, etc.) would help clarify?

@ErinBecker I'm tagging you because I'm not sure who to tag lol

@sjopierce
Copy link

@sjopierce sjopierce commented Apr 5, 2019

It seems that this define the different vector data types but it’s sequenced to be discussed after the examples showing how to use functions to assign parameters to vectors and inspect the content. These definitions are essential concepts to be familiar with to understand what’s going on in the examples presented. I would move this up in the episode sequence so it’s discussed right after introducing the concept of what a vector is.

Perhaps something like this:

A vector is most common and basic data structure in R, and is pretty much the workhorse of R. There are 6 atomic vector types and each vector contains only a single data type.

  • character: “a”, “dc”
  • numeric: 1, 525, 3.14
  • integer: 3L ( the L indicates to R that it’s an integer)
  • logical: True, False
  • complex: 1+4i (complex numbers with real and imaginary parts)

Additionally, the lesson doesn’t explicitly state what vector is being used in the examples until near the end of the episode. So students can correlate the concept of the demonstrated vector the type should be stated at the beginning rather than at the end when comes across more as an afterthought.

"For example, we can assign a series of values to a vector using the c() function by creating a numeric vector of household members...."

Finally, under Objectives vectors are mentioned two different times but it's not included in the list of terms that students should be able to define as they relate to R. All other terms listed are later mentioned in other objectives. So change the first objective from:

Define the following terms as they relate to R: object, assign, call, function, arguments, options

to

Define the following terms as they relate to R: object, assign, call, function, arguments, vectors, options.

@allisonrobertsTN
Copy link

@allisonrobertsTN allisonrobertsTN commented Sep 17, 2020

The vector discussion seems fairly flushed out now, but I think a couple things should be clarified about data types. Users coming from other languages (like Java or C++) might appreciate the clarification that in R, there's no real distinction between character data and string data. You can use 'single quotes' or "double quotes" to indicate a string. Further, if you want to include a string that contains quotation marks or a possessive single comma (a common desire for people parsing text and doing text analysis), you merely need to encapsulate the string inside the other type of quotation marks.

To make things less confusing, I would suggest editing the "Vectors and data types" section to be two separate parts: "Data Types" and then "Vectors." It would be much easier to understand vectors if there's an overview first discussing the different data types. For example "character" is used but not defined in the beginning of the vector example. The data types part could look something like the below. Note that I stole a few pieces from the "Vector" discussion and moved them up here, to clarify things.

Basic Data Types in R
R can store many different types of data inside an object. The most basic of these, often called "building blocks" are:

  • Logical values (T or F, TRUE or FALSE), which is the "boolean" data type
  • String variables, indicated by either single or double quotes
    • Note that, in R, there is no real distinction between character and string variables--the terms are used interchangeably
    • To store a string with quotes or possessive marks inside, use the opposite type of quotation mark: "Barry's dog is old." for example, or 'Matilda said, "Whoopsie daisy!" after dropping her toast.'
  • Numeric variables, which store any number and are the "double" data type
  • Integer variables, which store integers and are indicated with an L: 12L

When we want to store several of these data pieces inside the same object, we can use more complex data types, like a vector.

Vectors
etc etc.

@juanfung
Copy link
Contributor

@juanfung juanfung commented Sep 18, 2020

@allisonrobertsTN Thank you! Those are really great points. I don't have a background in languages that distinguish single and double quotes. Def worth including.

Would you be interested in creating a PR to incorporate your suggestions? That way you can get credit for your ideas!

@allisonrobertsTN
Copy link

@allisonrobertsTN allisonrobertsTN commented Sep 18, 2020

Thank you! I'm glad they were helpful. I can definitely draft a PR! I'm still pretty new to using Github and the Carpentries, but I can probably figure it out.

@juanfung
Copy link
Contributor

@juanfung juanfung commented Sep 18, 2020

Awesome! Well if you need guidance, don't hesitate to reach out 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.