tidyr::spread() gives an Error

时间:2017-08-30 20:46:44

标签: r tidyr spread

SOLVED

Please, help to figure out what might be wrong with the following example.

app.use('*/css',express.static('public/css'));
app.use('*/js',express.static('public/js'));
app.use('*/images',express.static('public/images'));

an issue is here:

lloyd = {
  "name": "Lloyd",
  "homework": [90.0, 97.0, 75.0, 92.0],
  "quizzes": [88.0, 40.0, 94.0],
  "tests": [75.0, 90.0]
}
alice = {
  "name": "Alice",
  "homework": [100.0, 92.0, 98.0, 100.0],
  "quizzes": [82.0, 83.0, 91.0],
  "tests": [89.0, 97.0]
}
tyler = {
  "name": "Tyler",
  "homework": [0.0, 87.0, 75.0, 22.0],
  "quizzes": [0.0, 75.0, 78.0],
  "tests": [100.0, 100.0]
}

# Add your function below!
def average(numbers):
  total = sum(numbers)
  total = float(total)
  return total / len(numbers)

def get_average(student):
  homework = average(student["homework"])
  quizzes = average(student["quizzes"])
  tests = average(student["tests"])
  return 0.1 * homework + 0.3 * quizzes + 0.6 * tests

it gives the following error:

Error in matrixToDataFrame(x) : object '_tibble_matrixToDataFrame' not found

I updated packages not so far:

    public static string GenerateFullTypeName(string name, int arity)
    {
        //StringBuilder sb = new StringBuilder();
        StringBuilder sb = cached.Value;
        sb.Clear();

        sb.Append(name);
        if (arity != 0)
        {
            sb.Append("<");
            for (int i = 1; i < arity; i++)
            {
                sb.Append("T"); sb.Append(i.ToString()); sb.Append(", ");
            }
            sb.Append("T"); sb.Append(arity.ToString()); sb.Append(">");
        }

        //return sb.ToString();
        /* Use sb as before */
        return sb.ToString();
    }

    [ThreadStatic]
    private static Lazy<StringBuilder> cached = new Lazy<StringBuilder>(()=> new StringBuilder());

eipi10's Session Info:

library(tidyverse)

(freq <- structure(list(Year_of_diagnosis = c(2004L, 2004L, 2005L, 2005L, 
                                             2006L, 2006L, 2007L, 2007L, 2008L, 2008L, 2009L, 2009L, 2010L, 
                                             2010L, 2011L, 2011L, 2012L, 2012L, 2013L, 2013L, 2014L, 2014L), 
                       Sex = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
                                         2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Female", "Male"), class = "factor"), 
                       n = c(70L, 180L, 70L, 170L, 70L, 180L, 60L, 220L, 80L, 190L, 80L, 230L, 60L, 210L, 70L, 230L,
                             70L, 220L, 70L, 220L, 80L, 230L)), 
                  class = c("tbl_df", "tbl", "data.frame"), .Names = c("Year", "Sex", "n"), row.names = c(NA, -22L)))

Update: [credit to @aosmith] reinstalling tidyr::spread(freq, key = Sex, value = n) in a fresh session helped.

0 个答案:

没有答案