R basic graphics xlim and ylim
Have this assignment cannot figure out You can draw the picture by following these steps:Make a vector years1 containing values 100, 101, ..., 150 and a vector years2 containing values 151, 152, ...,...
View ArticleWhat is an alternative to this eval parse code?
I am inserting some code into someone else's custom R package and I don't have flexibility to write it how I would like. I need to be able to sum up many variables following a similar format that I can...
View ArticleData frame consisting of characters is converted to factors after pdata.frame...
I am using a panel data set:y is my independent variable equal to 0 or 1 --> numericx1 are my individuals --> numericx2 are my time indicators --> numericx3,x4,...,x65 are my independent...
View ArticleBar-chart with dplyr/ggplot with male/female bars side by side
I'm trying to Here's the example : df <- read.table(text = "sex var value m a 1 m a 1 m a 0 m b 0 m b 0 f a 1 f a 0 f b 0 f b 1", header = TRUE, stringsAsFactors = FALSE ) What I'd like to create is...
View Articleleave one out cross validation in R returns a very low accuracy results...
I am trying to compute the accuracy of a decision tree on the seeds dataset (Link to the seeds dataset) over 20 iterations, however, I am getting very low overall accuracy (30%-35%). This is what I've...
View Articleundefined columns selected in plm() function
I had a weird problem in plm() function. Below is the code:library(data.table) library(tidyverse) library(plm) #Data Generation n <- 500 set.seed(75080) z <- rnorm(n) w <- rnorm(n) x <- 5*z...
View ArticleR: How to get rid of default data and values stored in global environment
Every time I open my laptop R, the same data and values (data tables and variables I used in the past) keep on appearing, and it's annoying to rm() them every time I open a new file to work on...
View ArticleMoving objects of pheatmap in r to correct the scale/make it look good
I've read similar questions like Moving color key in R heatmap.2 (function of gplots package) and the handbook but it hasn't worked (/I haven't got it to work). Maybe it is a different command for a...
View ArticleSelecting columns in R dataframe based on values of column in other dataframe
I have two dataframes as u can see below. #Dataframe 1 colname value col1 0.45 col2 -0.2 col3 -0.4 col4 0.1 #Dataframe 2 col1 col2 col3 col4 1 5 9 5 45 29 43 9 34 33 56 3 2 67 76 1 What I want to do is...
View Articlehow to further refine expss table format?
I am trying to improve my table design using expss. My current design is shown below using the following code:library(expss) # bogus example data x<-structure(list(visits= structure(c(17, 2, 23, 1,...
View Articleapplying function to multiple dataframes programatically [duplicate]
This question already has an answer here:Same function over multiple data frames in R 3 answersHow can I apply the same function to multiple data frames in R without having to save the data frames into...
View ArticleCreating one merged variable from multiple separate one
Any help would be greatly appreciated I have a file exported from a PCR plate software. I have already coded the call for all alleles and have now merged them into one data frame.I need to create a new...
View ArticleWarning: 'newdata' has x rows but variables found have >x rows with coxph and...
I have reviewed the other similar questions and I don't believe I have found the answers. I am trying to do Cox regression with two co-variates - sex and disease status. Original data frame looks a bit...
View ArticleGetting specific values for each for loop value
Im using a for loop to perform some estimations with the nardl() function. My specific function is the following:#Estimacion de la boyanza de corto plazo por sector Boyanza_Corto_Plazo <-...
View ArticleRender computed HTML in RMarkdown
I have a function that produces some html and I want RMarkdown to render the html.```{r} outputFromAFunction <- '<span style="background-color: #A6CEE3">A</span>' outputFromAFunction ```...
View ArticleCreating a plot with multiple variables in R [closed]
I am having a hard time finding anything similar to my work. I would like to create multiple plots with similar data as this image. I want my y axis to resemble the numbers, which are D15N, and x axis...
View ArticlePlotting training and test error rates of knn cross-validation in R
I have performed the following cross-validation knn (using the caret package) on the iris dataset. I am now trying to plot the training and test error rates for the result. Here is my attempt but I...
View ArticleFind closest match, then next closest, between groups until a specified...
I'd like to find the closest match (smallest difference) of a variable between two groups, but if the closest match has already been made, move on to the next closest match, until n number of matches...
View ArticleStrange arithmetic result [duplicate]
This question already has an answer here:Is floating point math broken? 31 answers:0.3-0.2-0.1 = -2.775558e-17 # in R3.4 / Python 3.5 While0.4-0.2-0.1-0.1 = 0. I am very confused now. I am aware of...
View ArticleSave ggplot with a function
I would like to create a function to save plots (from ggplot).Here is a data frame:### creating data frame music <- c("Blues", "Hip-hop", "Jazz", "Metal", "Rock") number <- c(8, 7, 4, 6, 11)...
View Article