FAQ

# R>r-help>February 2015

## 327 discussions - 1,015 posts

• 17

#### [R] the less-than-minus gotcha

I've got to remember to use more spaces. Here's the basic problem: These are the same: v< 1 v<1 But these are extremely different: v< -1 v<-1 This mistake can get you even inside of a function call ...
 Mike MillerFeb 1, 2015 at 11:09 pmFeb 4, 2015 at 9:33 pm
• 14

#### [R] Substring replacement in string

Dear R-help list, I would like to replace all lower-case letters in a string that are not part of certain fixed expressions. For example, I have the string: "pmin(pmax(pmin(x1, X2), pmin(X3, X4)) == ...
 Alrik ThiemFeb 27, 2015 at 10:19 pmMar 1, 2015 at 9:38 am
• 14

#### [R] ggplot2 shifting bars to only overlap in groups

Hi all, I have four factors for a continuous time variable along with its confidence interval. I would like to produce a publication quality error bar chart that is clear to understand. For now, I ...
 Hörmetjan YiltizFeb 12, 2015 at 2:08 pmFeb 19, 2015 at 6:42 pm
• 10

#### [R] creating a distinct zip file

Hello yet again. I am trying to create a zip file for a friend who has a Windows machine. He needs to access this via the "local zip file" packages option. When I use R CMD INSTALL --compile-both, it ...
 Erin HodgessFeb 20, 2015 at 9:07 pmFeb 21, 2015 at 9:07 pm
• 10

#### [R] Noob question re: writing while loops on one line

Hi list I'm working through some exercises and did a while loop which raised an issue for me: I can write out the while loop so: while(count < 10) { print(count) count <- count + 1 } And this works ...
 Sun ShineFeb 15, 2015 at 10:20 amFeb 15, 2015 at 8:30 pm
• 10

#### [R] Still trying to avoid loops

Given a dataframe: dat<-data.frame(S=factor(c(rep('a',2),rep('b',1),rep('c',3)),levels=c('b','a','c')), D=c(5,1,3,2,3,4)) where S is a subject identifier and D a visit (actually a date in my real ...
 Tom WrightFeb 4, 2015 at 7:34 pmFeb 4, 2015 at 10:24 pm
• 9

#### [R] How many digits are there in left of dot of 0.0001 ?

Dear all, I would like to count how many digits are there on the left of a the dot of a numeric variable a=0.0001 thanks
 CeFeb 26, 2015 at 1:55 amFeb 26, 2015 at 12:17 pm
• 9

#### [R] Numerical stability of eigenvalue and hessian matrix in R

Hi list, I am running the following R code, the answer should be zero. But R gives a very small negative number, what should I do? ##R code library(numDeriv) h_x <- function(x){ a = x[1] b = x[2] c = ...
 C WFeb 18, 2015 at 3:53 amFeb 18, 2015 at 10:20 pm
• 9

#### [R] How to solve this complex equation

Hi! I want to use R to calculate the variable x which is in a complex equation in below: 2 ?[exp(-x/2)*(x^k)/(2^k*k!)]=0.05 k=0 how to solve this equation to get the exact x in R? Thank you very ...
 SsuhanchenFeb 10, 2015 at 1:04 amFeb 11, 2015 at 4:42 pm
• 8

#### [R] Why does R replace all row values with NAs

I know how to get the output I need, but I would benefit from an explanation why R behaves the way it does. # I have a data frame x: x = data.frame(a=1:10,b=2:11,c=c(1,NA,3,NA,5,NA,7,NA,NA,10)) x # I ...
 Dimitri LiakhovitskiFeb 27, 2015 at 2:04 pmMar 1, 2015 at 1:05 pm
• 8

#### [R] Subsetting a list of lists using lapply

Hi Everyone, I'm working on a thorny subsetting problem involving list of lists. I've put a dput of the data here ...
 Aron LindbergFeb 19, 2015 at 7:45 pmFeb 20, 2015 at 8:08 pm
• 8

#### [R] %>%

Hello, Where can I find info about the operator % %? Never used it but when I search for it I gives no result. Thanks, Andr?
 André de BoerFeb 17, 2015 at 7:41 pmFeb 18, 2015 at 11:10 am
• 8

#### [R] how to draw paired mosaic plot?

Hi all: If there are two numeric variable:x,y, and I can get paired scatter plot by function "pairs".But if x and y are character, and I want to get paired mosaic plot,which function should be used ...
 MengFeb 6, 2015 at 11:46 amFeb 8, 2015 at 4:23 pm
• 8

#### [R] FFT Normalization Documentation

Hello everyone, the docpage for the fft function states: ?Description: Performs the Fast Fourier Transform of an array.? and ?Arguments ? inverse: if ?TRUE?, the unnormalized inverse transform is ...
 Eike PetersenFeb 2, 2015 at 1:27 pmFeb 5, 2015 at 4:54 pm
• 7

#### [R] save structure to be accesible later

Dear all,I have a function that returns the following list. At the end I will call my function 1000 times and I want to keep for each of these 1000 "results" (the structure as given below)in an order ...
 AlaiosFeb 5, 2015 at 12:57 pmFeb 12, 2015 at 7:50 pm
• 6

#### [R] Firefox not showing R help.

Firefox recently updated itself on my laptop. Now when I ask for R help --- e.g. ?plot --- I just get my home page. And no help. If I do "?plot" again after Firefox has opened its window, I just get ...
 Rolf TurnerFeb 28, 2015 at 9:10 pmMar 2, 2015 at 8:18 am
• 6

#### [R] integrate with vector arguments

I'm a bit stuck. I have to integrate a series of polynomial functions with vector arguments. v1<-c(1:5) v2<-c(1:5) f1<-function (x) {v1*x+v2*x^2} The problem is that integrate(f1, 0, 1) does not ...
 marKoFeb 26, 2015 at 6:49 pmFeb 27, 2015 at 1:49 pm
• 6

#### [R] Best Mac for R

I am possibly in the market for a new laptop. Predominantly a Windows user, I owned a macbook pro 10 years ago and am considering going that route again. Does the standard advice still hold: Get the ...
 Dan MurphyFeb 25, 2015 at 7:50 pmFeb 26, 2015 at 4:11 pm
• 6

#### [R] Not finding superclass in library

Hello, I have a library that I created that defines a parent class, assayObject. I created other classes that inherit from it, say assayObjectDemo. Each one of those classes I wanted to make in its ...
 Ramiro BarrantesFeb 23, 2015 at 8:35 pmFeb 24, 2015 at 5:09 pm
• 6

#### [R] split dataframe to several dataframes in R

Hi All,I have a dataframe called 'means' as shown below:iris1.csv <- iris iris2.csv <- iris names <- c("iris1.csv", "iris2.csv") dat <- mget(names) lst4 <- lapply(dat, function(x) apply(x[,-5], 2, ...
 Zilefac ElvisFeb 17, 2015 at 3:53 amFeb 17, 2015 at 6:32 pm
• 6

#### [R] problems with packages installation

Dear all I just switched to new version platform i386-w64-mingw32 arch i386 os mingw32 system i386, mingw32 status Under development (unstable) major 3 minor 2.0 year 2015 month 02 day 11 svn rev ...
 PIKAL PetrFeb 12, 2015 at 4:40 pmFeb 16, 2015 at 8:07 am
• 6

#### [R] Unable to use `eval(parse(text))' in nlme::lme

Hi, I would like to run lme() on a number of response variables in a dataframe in an automatic manner. Bu, when I use eval(parse(text=yname)) to denote the LHS of the formula in lme(), I get the ...
 Ravi VaradhanFeb 8, 2015 at 5:46 pmFeb 14, 2015 at 9:29 pm
• 6

#### [R] suggestion for optimal plotting to show significant differences

Dear all I would like to ask for your opinion about possible graphical representation of such data. structure(list(item = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, ...
 PIKAL PetrFeb 6, 2015 at 11:09 amFeb 13, 2015 at 1:35 pm
• 6

#### [R] Rotate array by 90°

Dear aal, Is there a way to rotate array or a cube of matrices by Y axis? MatLab example: A = cat(3,{'a' 'b' 'c';'d' 'e' 'f';'g' 'h' 'i'},{'j' 'k' 'l';'m' 'n' 'o';'p' 'q' 'r'}) A(:,:,1) = 'a' 'b' 'c' ...
 Karim MezhoudFeb 5, 2015 at 9:17 pmFeb 11, 2015 at 2:45 pm
• 6

#### [R] Error: OutOfMemoryError (Java): GC overhead limit exceeded

Hello all, When I met this following error message: Error: OutOfMemoryError (Java): GC overhead limit exceeded I usually use the following options to overcome the memory limit ...
 Yuan, RebeccaFeb 2, 2015 at 1:43 pmFeb 10, 2015 at 8:51 pm
• 6

#### [R] How to enable https for R 3.1.2 on windows 8.1

I run the code below successfully on Mac and Ubuntu successfully. When I run on Windows, I get the results shown. How do I get the code to work on Windows? I've googled extensively with no success ...
 John KalbFeb 1, 2015 at 4:56 pmFeb 2, 2015 at 9:24 pm
• 5

#### [R] Using a text file as a removeWord dictionary in tm_map

Hi list Although this query applies specifically to the tm package, perhaps it's something that others might be able to lend a thought to. Using tm to do some initial text mining, I want to include ...
 Sun ShineFeb 28, 2015 at 1:46 pmMar 3, 2015 at 5:04 pm
• 5

#### [R] Dummy variable in ARIMA

Hi all I have been searching on the web in vain. I want to include a dummy variable in my ARIMA model. Let's say that I want to make an AR(1) model for X including a dummy variable which should be 1 ...
 Mikael Olai MilhøjFeb 26, 2015 at 4:02 pmMar 2, 2015 at 9:49 am
• 5

#### [R] Schedule R function/Code to run at specific time

Is there functionality within R proper, without having to revert to the OS, allowing a function or a portion of an R script to be run at a defined time? My google searches haven't provided much other ...
 Doran, HaroldFeb 26, 2015 at 7:08 pmFeb 27, 2015 at 7:16 am
• 5

#### [R] Extracting Factor Pattern Matrix Similar to Proc Factor

Hello, I am fairly new to R and coming from SAS IML. I am rewriting one of my MC simulations in R and am stuck on extracting a factor pattern matrix as would be done in IML using Proc Factor. I have ...
 Scott ColwellFeb 23, 2015 at 6:15 pmFeb 26, 2015 at 6:29 pm
• 5

#### [R] Replacing 9999 and 999 values with NA

Hello All, I have a data frame of two columns for wind. The first column is for wind speed and the second wind direction. I'm trying to replace the 9999 values in the first column and the 999 values ...
 Alexandra CatenaFeb 20, 2015 at 6:55 pmFeb 23, 2015 at 8:34 pm
• 5

#### [R] Split a dataframe by rownames and/or colnames

Dear List, Consider this example df <- data.frame(matrix(rnorm(9*9), ncol=9)) names(df) <- c("c_1", "d_1", "e_1", "a_p", "b_p", "c_p", "1_o1", "2_o1", "3_o1") row.names(df) <- names(df) indx <- ...
 Tim Richter-HeitmannFeb 20, 2015 at 5:33 pmFeb 23, 2015 at 4:56 pm
• 5

#### [R] irregular sequence of events

Dear all I know I am missing something obvious but after few hours of trials I ask for some help. I have some sequence of values (days) x <- 1:30 and an indication of event start and end day ...
 PIKAL PetrFeb 20, 2015 at 2:27 pmFeb 23, 2015 at 10:17 am
• 5

#### [R] AR1 covariance structure for lme object and R/SAS differences in model output

Dear R users, We are working on a data set in which we have measured repeatedly a physiological response variable (y) every 20 min for 12 h (time variable; 'x') in subjects ('id') beloning to one of ...
 AnordFeb 11, 2015 at 3:57 pmFeb 17, 2015 at 3:06 pm
• 5

#### [R] list of list

Dear friends - this is simple I know but I can figure it out without your help. I have for each of 2195 instances 10 variables measured at specific times from 6 to several hundred, so if I just take ...
 Troels RingFeb 16, 2015 at 4:43 pmFeb 16, 2015 at 7:17 pm
• 5

#### [R] Plot residuals against standard normal distribution

Hi, I'm having trouble trying to plot the density of the residuals against the standard normal distribution N(0,1). (I'm trying to see if my residuals are well-behaved). I know hwo to calculate the ...
 Mikael Olai MilhøjFeb 2, 2015 at 10:42 pmFeb 7, 2015 at 9:43 pm
• 5

#### [R] Interpreting a Logit regression result

Call: glm(formula = Div ~ PRFD, family = binomial(link = "logit"), data = divs) Deviance Residuals: Min 1Q Median 3Q Max -1.6765 -0.2626 0.7502 0.7502 2.6017 Coefficients: Estimate Std. Error z value ...
 Mohamed FarahFeb 6, 2015 at 7:42 amFeb 6, 2015 at 9:42 pm
• 5

Hi All, I need to loop through and download the past 10 years of met data to a temporary directory. I then need to unzip it and place it into another directory. year = (2005:2015) for (i in year) ...
 Alexandra CatenaFeb 4, 2015 at 10:24 pmFeb 5, 2015 at 9:18 pm
• 5

#### [R] rgl::writeWebGL( , prefix = , )

Dear all, I am using writeWebGL to create an HTML page containing an interactive 3D plot. It works fine with the default prefix="" but fails when I specify a prefix "for different scenes displayed on ...
 Keith JewellFeb 3, 2015 at 2:43 pmFeb 3, 2015 at 5:42 pm
• 5

#### [R] save program results and graphs to one file

Dear group, I have many plots and numeric results in my R program, kindly how can I save them all sequently on one file. thanks in advance RAI [[alternative HTML version deleted]]
 Ragia IbrahimFeb 1, 2015 at 8:05 pmFeb 2, 2015 at 11:16 am
• 4

#### [R] Summing certain values within columns that satisfy a certain condition

Hi, Supposed I had a data frame like so: A B C D 0 1 0 7 0 2 0 7 0 3 0 7 0 4 0 7 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 5 0 5 1 5 0 4 1 5 0 8 4 7 0 0 3 0 0 0 3 4 0 0 3 4 0 0 0 5 0 2 0 6 0 0 4 0 0 0 4 ...
 Kate IgnatiusFeb 26, 2015 at 8:23 pmFeb 27, 2015 at 4:07 pm
• 4

#### [R] Save a list of list and search for values

Dear all,in my code I am using the mix() function that returns results in a list. The result looks like List of 10 ?$parameters? :'data.frame':?? 2 obs. of? 3 variables: ? ..$ pi?? : num [1:2] 0.77 ...
 AlaiosFeb 26, 2015 at 2:27 pmFeb 27, 2015 at 1:09 pm
• 4

#### [R] aggregating variables (sum within groups)

Hello everybody! I have a (probabely very easy) problem. Even though I was looking in several r-books I could not find a suitable function to this problem, that's why I hope that someone here could ...
 David StuderFeb 26, 2015 at 12:02 pmFeb 26, 2015 at 4:47 pm
• 4

#### [R] Processing key_column, begin_date, end_date in R

Hi, I am trying to process a large dataset in R. The dataset contains the following three columns: key_column - a unique key identifier begin_date - the start date of the active period end_date - the ...
 Matt GrossFeb 25, 2015 at 9:18 pmFeb 26, 2015 at 3:23 pm
• 4

#### [R] Replace the value with 1 and 0

Hi everyone, I have this kind of rainfall dataset: ?? Year Month Day Amount 1? 1950???? 1?? 1??? 0.0 2? 1950???? 1?? 2?? 35.5 3? 1950???? 1?? 3?? 17.8 4? 1950???? 1?? 4?? 24.5 5? 1950???? 1?? 5?? ...
 Smart hendsomeFeb 25, 2015 at 10:54 pmFeb 26, 2015 at 8:59 am
• 4

#### [R] Getting Rmarkdown to generate custom LaTEX environment

Hi all, I was struggling trying to make my Rmarkdown document to generate \begin{figure*} instead of \begin{figure} So that the figure spans on two columns (I'm using a custom template). in my ...
 Huan TruongFeb 25, 2015 at 2:28 amFeb 25, 2015 at 7:07 pm
• 4

#### [R] HELP asin transformation

Dear all, I attempted to transform my data using "asin" but a WARNING message appears: dat1$Abu.tr<-asin(sqrt(dat1$Abundance/100)) Warning message: In asin(sqrt(dat1\$Abundance/100)) : NaNs produced ...
 CHIRIBOGA XavierFeb 22, 2015 at 6:28 pmFeb 25, 2015 at 7:51 am
• 4

#### [R] How do I access a specific element of a multi-dimensional list

Dear list, Let's say I have setup the following list: a = c(2, 3, 5) b = c("aa", "bb", "cc") c = c(TRUE, FALSE, TRUE) x = list(a, b, c) I want to access the first second dimension element of each ...
 Knut HansenFeb 20, 2015 at 12:18 pmFeb 23, 2015 at 12:47 pm
• 4

#### [R] multiple parameter optimization with optim()

I am trying to generalize a working piece of code for a single parameter to a multiple parameter problem. Reproducible code is below. The parameters to be estimated are a, b, and c. The estimation ...
 Doran, HaroldFeb 17, 2015 at 11:03 pmFeb 21, 2015 at 11:33 pm
• 4

#### [R] Raster Help

Hello everyone, I need a little help with some R syntax to complete what (I think) is a fairly straightforward task- hopefully someone can assist! I have a raster map of the UK which is split into ...
 Simon TarrFeb 19, 2015 at 4:44 pmFeb 20, 2015 at 4:10 pm