Question

Problem 10.3: For each of these computations, say what R function is the most appropriate: 1.Count...

Problem 10.3: For each of these computations, say what R function is the most appropriate:

1.Count the number of cases in a data table.
2.List the names of the variables in a data table.
3.For data tables in an R package, display the documentation (“codebook”) for the data table.
4.Load a package into your R session.
5.Mark a data table as grouped by one or more categorical variables.

Homework Answers

Answer #1

The appropiate R functions for the given computations are as follows:

1. for one group: nrow(data[data$group1 == "A" & data$group2 == "C", ])

for each group: aggregate(x ~ group1 + group2, data = data, FUN = length)

2. To list the names of the variables in a data table:

function name:

object()

#or

ls()

3. For data tables in an R package, display the documentation (“codebook”) for the data table:

  library(codebook)
codebook_data <- codebook::bfi

#with

  codebook_data <- rio::import("https://osf.io/s87kd/download", "csv")

4. To load a package into your R session:

.libPaths() # get library location
library()   # see all packages installed
search()    # see packages currently loaded

5. To mark a data table as grouped by one or more categorical variables

  group_by(data, category) %>%

skim()

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT