Using apply() and only base R, how do I write a function that takes a matrix...
The function takes these inputs:A 200x1000 matrix (200 individuals, 1000 experiments)A vector of length 200 with group assignments 0 ("control") and 1 ("treatment")Performs t-tests on the data in each...
View ArticleError in cor(x, use = use) : supply both 'x' and 'y' or a matrix-like 'x'
I am using the psych package,following code I tried:library(psych)str(price_per_d)Least_appealing <-subset(zdf_base, select=c("price_per_h", "price_per_d", "mileage", "one_way_option",...
View Articleno method for coercing this S4 class to a vector for utilization of mclust
I'm trying to use the mclust method on an .FCS format file (which is a flow cytometry format file) and I read this file into R as flowFrame object. install.packages("openCyto") # since the old version...
View ArticleRandom lines on geom_tile plot
I'm trying to make a heatmap geom_tile plot of a large number of sequential scans. This is what I have right now:The thick horizontal lines are genuine missing observations which need to remain as...
View ArticleLooking for advice on how to work with json files that sort data in atypical...
I'm working with a json file in R that seems to have a somewhat odd format for a class assignment in both R and Python:{"data": [ { "British Columbia": "BC", "BC": "4.63" }, { "Alberta": "AB", "AB":...
View ArticleR Markdown won't knit even though my code chunks work
For some reason, my code chunks work but when I try to knit the file, I have an "object not found" error. Here's the chunk which causes the error:library(ggplot2)library(tidyverse)library(dplyr)chart2...
View ArticleHow to access the entire source code of a function that has...
I am trying to extend the functionality of the RQuantLib package and need to access the entire code behind the DiscountCurve function.The result I get is:library(RQuantLib)DiscountCurvefunction...
View ArticleIs there a way to print an empty vector as 'zero' in R?
I am creating a monthly report to summarise the field sites where certain data were collected, since the last month. I am currently using R Markdown and knitting to a word.docx.Each field site has a...
View ArticleR Markdown HTML output - Hide a section of the document of an HTML RMarkdown...
I'm trying to knit an HTML document from RMarkdown, and hide the section from both the Table of Contents (ToC) and body of the output (HTML file), while while still knitting (executing) all of the code...
View ArticleUnderstanding `purrr::pmap` with a dataframe inside `mutate` in R
I want to make the sum of the first 3 columns with pmap.library(tidyverse)mtcars %>% mutate(new = pmap(select(., 1:3), ~ sum(.))) # FAILSmtcars %>% mutate(new = pmap(., ~ sum(.[1:3]))) # FAILS...
View ArticleWhy are keyword searches acting like name searches in google places API?
I am working on a public health project where I'm scraping an entire state for tobacco vaping shops. I've been experimenting using the google places API webservice, specifically the Nearby and Text...
View ArticleHow to plot a 3 set proportional Venn/Euler diagram?
I have a set of microarray data, and I would like to represent it according to the attached figure (done with PowerPoint). I have tried the various packages available for R (VennDiagram, venneuler,...
View ArticleIs it possible to create a proportional triple Venn Diagram
I am trying to create a proportional Venn Diagram with three groups. I searched the web and tried with 3 different packages: Venndiagram, venneuler and eulerr. However, with none it seems that it...
View ArticleAvoiding Memory Aliasing Errors in R
How does pointer/reference aliasing work in R? If I assign a vector or data frame to a new variable (y <- x) and modify y, R automatically duplicates the data in memory so x stays unchanged. Are...
View ArticleUse = instead of
I love the package but I was wondering how I could change one rule from the tidyverse style: I'd like to keep "=" instead of "<-" for assignment.I've read that note:...
View ArticleAvoid `zoo:na.fill(x, "extend")` error: need at least two non-NA values to...
When trying to extend and linearly interpolate a time series with zoo::na.fill(x, "extend"), an error is thrown whenever one of the columns or groups only has one value. How can I avoid this...
View ArticleHow to smooth only certain edges of a sf polygon
I'm trying to smooth the edges of polygons created from species occurrence points.When a species has a small number of occurrence records, e.g. five occurrences distributed over a large area, the...
View ArticleHow to mutate multiply imputed data for estimateNetwork() in R? (mice, bootnet)
I am trying to conduct an MGM network analysis using the bootnet package. I have a dataset of categorical vars and items that constitute survey scales (e.g., summing columns 1-8 produces a total score...
View ArticleIssue with bbmle package and optimx in R returning par as all NAs
I am having an issue with using the optimx with the bbmle package. The model will run on my personal computer, but will not return viable results on a linux computer. Both are running the same code, on...
View ArticleError in singlefold(obs, k) : insufficient records:2, with k=5 / unused...
This is the code I use:competition <- ENMevaluate(occ = occ_coord, env = env, bg.coords = bg_coord, method = "randomkfold", RMvalues=seq(0.5, 5, 0.5), fc = c("L", "LQ", "H", "LQH"),...
View Article