Newest r Questions

Q&A for professional and enthusiast programmers

Change legend font size using the function vertical.image.legend from aqfig package

I made a plot using the function plot and then I included a legend with a color scale using the vertical.image.legend function from the aqfig package. The question is, does anyone know how to ...

Change width of points in geom_pointrange

I'm just starting to learn ggplot2 and got stuck trying to change the width of the points using geom_pointrange My data: Pop Beta SE Size lo hi name 2 std1 -1.9590 0....

Adding first row by group for longitudinal data frame?

Here is the data frame looking like: subject_ID cd4_time0 other_time cd4_other_time 1 12 0.5 462 1 12 1.0 140 1 12 ...

dplyr with order() produces wrong order [duplicate]

Given the following data.frame, i want to have the order of 'numbers' for each group. df group numbers 1 A -0.80097537 2 B -0.69498701 3 C 0.55627105 4 D -0.05810593 5 ...

dependencies in shiny objects

In my app, the user needs to pick a folder, and in that folder he needs to pick a file (the suffix of the file name is '.seg') This code is working- library(shiny) ui <- shinyUI(fluidPage( # ...

reading CSV,XLX and Xlxs file with text between the data

I have a monthly figures in excel sheet but every week comes with total and below each week there is a summary of the weekly figures I added a screen shoot of an example. I want to read this file ...

RStudio MacOS X missing “Knit with parameters” option for parametrized report

I have a .Rmd file, with the following yaml header: --- title: "Untitled" output: html_document: default html_notebook: params: input: file label: "Input data file": value: data.txt --- ...

How to perform a power analysis for the following binomial Glmm?

I would appreciate some guidance on performing a power analysis for the following. I have preliminary data on my experiment and I would like to run a power analysis to to determine what sample size is ...

Expression evaluation, objects from string… still not clear

I've read many topic on how to create objects from strings or evaluate expressions, with assign(), get(), as.name() or eval(substitute()), but some things are not completely clear to me. In my ...

RMarkdown dynamic hyperlinks

I have been lately busy writing an RMarkdown document that would render a pdf report with information about genetic variants. However, the readers for whom the reports are intended asked whether I ...

Plotting time data on R: Data disappears from plot the second I add limits to x or y axes

I want to plot the time I go to sleep every day versus the date. I'm new to working with date values but I've looked up a bunch on plotting dates and times and have managed to at least plot numerical ...

unexpected failure of grouping in data.table [on hold]

Im not sure why my grouping in data table fails in the code below. client_id <- c("A", "A", "B", "B", "B", "B", "B", "A", "A", "B", "B") value <- c(10, 35, 20, 30, 50, 40, 30, 40, 30, 40, ...

forex forecasting using neural networks in R [on hold]

am new user with basics using R. Having closing daily currency exchange data I want to use neural networks(MLP) using R in forecasting please help on data preparation and coding

Writing a user defined function as a regression model

I have been trying to write a function that is in the form of a regression model such as (Y~X1+X2|Z1,Z2). I have been doing is by using the function np::npscoefbw from the package as a guide (this ...

RMA normalization of Affymetrix 1ST arrays using oligo

I am having 1000 affymetrix 1.0ST arrays of 6 different tissues. I am trying to do RMA normalization for the entire set using oligo::rma(celfiles, target='core'). Its been running for almost a week ...

which package can nicely display R code chunk in Latex without compiling it?

I am trying to figure out the way of displaying R code chunk in latex where prevent compiling the code. Yes, I looked into some post in SO and there is a simple way to do that, such as: \begin{...

Hot decking imputation with the VIM package

I try to use hot deck imputation in my data frame "knowledge.bind". All variables in it are logical operators. `knowledge.hd <- hotdeck(knowledge.bind, variable = "sec.bal", ord_var = c("soli"...

How can I plot legend symbols and labels on a different row in R?

I'm trying to plot a legend in base R with the symbols horizontally and the corresponding labels underneath the symbols on the next row. The legend will be plotted in the margins (not included in ...

How to cast aggregated values over a range in R and fill missing range values with zero

How to cast aggregated values over a range in R and fill missing range values with zero. df <- data.frame (year = sample(c(2014:2016), 100, replace=T), month = sample(c(1:5,8:12),...

Include reactive text in a R markdown shiny documents

I am a little lost and am unable to add a reactive test (te) in the shiny output of an R markdown document. A minimal example based on an R studio example is paste below. Many thanks in advance! Jean-...

Calculate the number of samples with alterations each gene listed in a vector

I'm an R newby and wondering if people could offer me a little bit of advice as to how I can process some data I have. I have a data frame containing a list of samples with observed changes in genes (...

pattern search on vectors in R

is there any better and faster way of achieving the below ? Basically , I am looking(searching) for a pattern in a Data frame. The below works for me. But I can't scale it. Time complexity is really ...

Text mining by row in a data frame

I have this data frame: > str(final) 'data.frame': 112 obs. of 3 variables: $ FAO_CountryName: chr Algeria Egypt Libya Morocco ... $ FAO_CountryURL : chr "http://www.fao.org/giews/...

Multiple loop Syntax Error

I cannot figure out what's going wrong with my loop and it is already too complicated for my current level. I have already tried applybut obviously I do something wrong, so I didn't use it at all. ...

R: Solving for variable Vector / Optimzing Standard Deviation in R

I have a Problem by solving for weights. What I like to do is to finde an optimizer that changes a vector of weights in a way that the standard deviation of column sums of a specific Matrix is 0. The ...

using gregexpr()

I'm trying to use gregexpr() to search through a data.frame. Is there a way to view the results of the gregexpr() search in a data.frame as well? As of now it outputs to a variable. If I could view ...

How do I find the coefficient of correlation between these tables?

So, I have two tables which look like the following Note that the numbers are the ratings for movies by users. I want to find out the correlation of user d in table 2 with each user (a,b,c) in table ...

R code to fine difference in distribution

R code needed: I have 3 columns in my dataset : Price, Slab, NoSlab. How to find the difference in the distribution of price between houses with Slab and NoSlab by using relevant statistics and ...

Valuation of a Vanilla Interest Rate Swap using the “RQuantLib” Package

I am modelling a Vanilla Interest Rate Swap using the "RQuantLib" Package. I am following the example given in the Cran Paper "RQuantLib". For the Fixed Leg of the Interest Rate Swap, the given R code ...

Collapsing data frame by ID while duplicating other columns in R (“self-outer join”) [duplicate]

I am trying to collapse a data frame, grouping the rows by a categorical variable CAT, but instead of summarizing the rest of the data I would like to have a copy of each of the remaining columns, ie, ...

JRI: obtain error messages from the R engine

I am using JRI to execute a number of computations using the R engine. As pointed in various tutorials out there in the web I am using the eval method of the Rengine class, e.g.: engine.eval("meanVal=...

Align footnote in htmlTable in R

I am trying to create a table using htmlTable package in R and I find it difficult to align the footnote to the left bottom bottom of the table. Below is the relevant code: library(htmlTable) # ...

Loops for Regression

I am working on Global Financial Development Database(Available on Google). Attached is a screenshot of the data. Column("Indicator Code") is categorized into 6 factors: Access(GFDD.AI.XX), Efficiency(...

Break x-axis in plot R

I want to get a broken x-axis. I want to make a plot with points between 0 and 59)but also with abline for specific x values (4, 21.3 and 268). Something like this: x <- c(21, 59, 4, 5, 5, 5, 5, ...

Function with dplyr and multiple statements

I am having trouble using several dplyr functions in one function, despite using the function variants. Example library(dplyr) # Data: mydf <- data.frame( var1 = factor(rep(1:24, each = ...

How to connect python to R?

i want to use the pattern.nlp package to perform sentiment analysis on dutch text. But i get an error: 1: In pyConnectionCheck() : R isn't connected to Python! How do i connect python to r?

Check for server with RSelenium: no such file or directory to load external entity

I'm trying to use RSelenium in my work computer and I obtain the following when I check for server: > checkForServer() No such file or directoryfailed to load external entity "http://selenium-...

Fitted Values in UCM

How can we view the fitted values for the UCM function in R? I have tried below code to make the model. model_h_fcast <- ucm(hourly_2~0, data = hourly_2, irregular = TRUE, ...

write.table R failing

I'm running a small script, it works ok, but whenver I try to write the data frame the number of rows that I get (32933) as output is different from thw one I'm expecting (18285). datsort <- read....

R why “==” operation doesn't return the same as %in% [duplicate]

I have something strange when comparing two vectors: individuals=c("A","C","X","Z") m=c("A", "B", "C", "D", "E", "F", "X", "Z") individuals == m it return: TRUE FALSE FALSE FALSE FALSE FALSE TRUE ...

how to decrease the running time of Boruta package

I have 67 variable and 5000 obsevations.I want to know which are all important variables.Im using Boruta ,I takes lot of time,even my R hangs,I think this is one of the drawback of Boruta or any other ...

Finding all Combinations of match places with google geolocation Api

I have one data set like this: > head(base_1[,c("logradouro","nomemun_x")]) logradouro nomemun_x 1 RODOVIA BR-419 KM 236 Anastácio 2 RUA CASTRO ALVES, 1130 São ...

How to obtain profile confidence intervals of the difference in probability of success between two groups from a logit model (glmer)?

I am struggling to transform the log odds ratio profile confidence intervals obtained from a logit model into probabilities. I would like to know how to calculate the confidence intervals of the ...

Read a csv file which contains an arrow symbol

df <- read.table("sample.csv", fill = TRUE, sep=";", quote ="",header=F) This is the command I am using to read a csv file which has semicolon as a separator and -> (arrow) symbols in between. ...

How to speed up row level operation with dplyr

I have a large dataset that I try to manipulate using dplyr. My data wrangling task requires row level string manipulation. I am using the default rowwise() function, and the code is working. ...

How to get R shiny font rendering right on Linux?

I copied the "Table of fonts" example from http://www.cookbook-r.com/Graphs/Fonts/ into a minimal shiny application. I run the shiny code on a Linux Debian server. Unlike in the example, fonts don't ...

naive Bayes classification error 'non-numeric argument to mathematical function'

I have a problem setting up my text classification using naive bayes. First I have 3 text files, two templates with good/bad words, one testing file. My TermDocumentMatrix is created and I also have a ...

Reshape size-frequency table to long format in R

This is essentially a data reshaping question. I have size-frequency data that looks something like this: have.this <- data.frame(Pond = c(1,1,1,2,2,2), Size = c(1,2,3,1,...

How to query OSM with Hive and/or R - OSM2Hive

I would like to use the OSM data stored in Hive to get some info. I have 3 Hive tables (nodes, ways, relations) created using OSM2Hive project (https://github.com/PanierAvide/OSM2Hive). Note: I have ...

Filtering row with too many max and min in R

My dataset is like below. a_metric b_metric c_metric tl_metric mpr 1 1.0079123 0.4121975 1.0510727 0.5280035 -0.03690215 2 -0.3479917 -0.3185338 -0.3652249 -0.1644014 0.01175352 ...
Translating... 0%