Creating data frame from summary(); Error in dimnames(x) <- dnx : 'dimnames' applied to non-array

Advertisements For the love of me, I don’t understand why this does not work: x = c(3, 5, 3, 100, 5, -9, 10, 24) x_summary <- summary(x) x_names <- names(x_summary) x_summary <- unname(x_summary) xdf <- data.frame(Statistics = x_names, Value = x_summary) I thought the named vector from using summary() was the issue at first. But… Read More Creating data frame from summary(); Error in dimnames(x) <- dnx : 'dimnames' applied to non-array

Efficiently create summary table with min, max, mean, SE and sample size by category

Advertisements I have a dataset that shows the walking speed of different age classes, measured in two different periods. Here is a reproducible example: Period<-rep(c(1,2),times=c(9,18)) Class<-rep(c("child","teen","adult","toddler","child","teen","adult"),times=c(2,3,4,3,4,5,6)) Speed<-c(2,3,3,4,5,5,4,4,6,1,0.7,0.3,1,2,3,2,2,5,5,4,2,3,5,4,6,5,4) data<-data.frame(Period,Class,Speed) Period Class Speed 1 1 child 2.0 2 1 child 3.0 3 1 teen 3.0 4 1 teen 4.0 5 1 teen 5.0 6 1 adult 5.0… Read More Efficiently create summary table with min, max, mean, SE and sample size by category

work with quoted variable names in a R summarize ifelse statement (programming in dplyr)

Advertisements I am assigning variable names programmatically in a custom function I am building in R. This is working fine. However if I then want to access that same variable in an ifelse() statement, it doesnt work. Basically, How can I translate this code: library(tidyverse) df %>% group_by(ID) %>% summarise( first_adopted_test_1 = ifelse(never_adopted , "never… Read More work with quoted variable names in a R summarize ifelse statement (programming in dplyr)

Parse over large JSON array of Objects from Facebook

Advertisements This is the JSON array: { "id": "", "name": "", "posts": { "data": [ { "likes": { "data": [ ], "paging": { "cursors": { "before": "QVFIUnpFd2IwMlhuOWI3dJqelFNNEZAPWDlqeENTNkg1N2RqMm9zQXBreVV6bE9KNXJzX29LeXlMZAzhNT2x3TEhlcGk3OG1Bd3ZABRmpyTXhnNDZAWV2hR", "after": "QVFIUl9Vbm14cld0dm41OTFtKYmgtelBKall2bnBINjBQMXBiNkNCMUM0d21lQXptOXRvbklkU0pHbV9yejNBVG9Jb2hqQTFoem1mdm9zMnJn" }, "next": "" }, "summary": { "total_count": 84, "can_like": true, "has_liked": false } }, "comments": { "data": [ { "created_time": "2022-05-25T18:22:19+0000", "message": "", "id": "" },… Read More Parse over large JSON array of Objects from Facebook

How to use dplyr to return the grouped sum of all numeric columns when there are NA values?

Advertisements I’m was attempting to sum all numeric columns using dplyr’s group_by and summarise functions as below. I didn’t understand the error returned from the summarise function and cannot seem to find a similar example on stack overflow … however after two members pointed out my error in making the example data I found that… Read More How to use dplyr to return the grouped sum of all numeric columns when there are NA values?

Why is this requests get not working with this url

Advertisements If i run this Python code my program just hangs up. (I don`t get any error.) import requests url = "https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/generative/dcgan.ipynb&quot; r = requests.get(url) But this works perfectly fine as expected. import requests url = "https://stackoverflow.com&quot; r = requests.get(url) Using curl to get the github file worked also fine. curl https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/generative/dcgan.ipynb So can you… Read More Why is this requests get not working with this url

How do I use the means of the columns of a matrix as prediction values in a linear regression in R?

Advertisements Problem Statement: Some near infrared spectra on 60 samples of gasoline and corresponding octane numbers can be found by data(gasoline, package="pls"). Compute the mean value for each frequency and predict the response for the best model using the five different methods from Question 4. Note: This is Exercise 11.5 in Linear Models with R,… Read More How do I use the means of the columns of a matrix as prediction values in a linear regression in R?

Python BeautifulSoup failure to get data from a div with a certain class

Advertisements I am working on a program that will scrape metacritic for info on the movie from my library and display it but in certain parts like grabbing the rating always returns nothing what am I doing wrong? from bs4 import BeautifulSoup import requests import os def ratingsGet(headers, movie): movie = movie.lower().replace(" ","-") detail_link="https://www.metacritic.com/movie/&quot; +… Read More Python BeautifulSoup failure to get data from a div with a certain class