FAQ

# R>r-help>July 2010

## 1,016 discussions - 3,393 posts

• 21

#### [R] Not nice behaviour of nlminb (windows 32 bit, version 2.11.1)

nlminb( obj = function(x) x, start=1, lower=-Inf, upper=Inf ) $par [1] 0$objective [1] 0 $convergence [1] 0$message [1] "absolute function convergence (6)" $iterations [1] 1$evaluations function ...
 Matthew KilleyaJul 9, 2010 at 2:37 pmJul 12, 2010 at 1:05 am
• 19

#### [R] Visualization of coefficients

Dear all, I try to show a subset of coefficients in my presentation. It seems that a "standard" table is not a good way to go. I found figure 9 (page 9) in this file ( ...
 WincentJul 2, 2010 at 6:10 amJul 7, 2010 at 9:21 pm
• 15

#### [R] how to generate a random data from a empirical distribition

hi, this is more a statistical question than a R question. but I do want to know how to implement this in R. I have 10,000 data points. Is there any way to generate a empirical probablity ...
 Xin weiJul 26, 2010 at 6:36 pmJul 28, 2010 at 7:42 pm
• 14

#### [R] [R-pkgs] New package "list" for analyzing list survey experiments

Dear all, Kosuke Imai and I announce the new package "list," which is now available on CRAN. list: Multivariate Statistical Analysis for the Item Count Technique List allows researchers to conduct ...
 Graeme BlairJul 11, 2010 at 4:32 pmJul 15, 2010 at 4:20 pm
• 13

#### [R] newton.method

Hi, Is this method broken in R? I am using it to find roots of the following function: f(x) = 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) + 2.5*exp(-1.5*x) - 100 It is giving an answer of ...
 SammynyJul 29, 2010 at 8:32 amAug 2, 2010 at 3:26 pm
• 13

#### [R] Continuing on with a loop when there's a failure

Hi R sages, Here is my latest problem. Consider the following toy example: x <- read.table(textConnection("y1 y2 y3 x1 x2 indv.1 bagels donuts bagels 4 6 indv.2 donuts donuts donuts 5 1 indv.3 donuts ...
 Josh BJul 12, 2010 at 10:18 pmJul 19, 2010 at 9:00 am
• 12

#### [R] levene.test

I am trying to use Levene's test (of package car), but I do not understand quite well how to use it. '?levene.test' does not unfortunately provide any example. My data are in a data frame and ...
 MartanairJul 14, 2010 at 8:37 amJul 14, 2010 at 2:49 pm
• 12

#### [R] package installation for Windows 7

Neither biocLite nor the GUI menus can install packages on my system. Here is relevant output: platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 11.1 year 2010 ...
 Dave BickelJul 8, 2010 at 11:15 amJul 11, 2010 at 12:38 am
• 11

#### [R] creation package

Dear r-help, I create a package. When I installed this package (I use this command : R CMD check namepackage),I find an error: * checking whether package 'namepackage' can be installed ... ERROR ...
 Anderson nuelJul 30, 2010 at 1:44 pmAug 26, 2010 at 9:20 pm
• 11

#### [R] (no subject)

Hi all, I want to add the red color under the standard normal curve to the right of 1.96. Can anyone give me a hand? Please see the code below. Thank you. x <- seq(-4, 4, length=100) hx <- dnorm(x) ...
 Li liJul 12, 2010 at 3:22 amJul 30, 2010 at 5:48 pm
• 11

#### [R] Double Integration

Dear R helpers I am working on the Bi-variate Normal distribution probabilities. I need to double integrate the following function (actually simplified form of bivariate normal distribution) f(x, y) ...
 Sarah SanchezJul 1, 2010 at 12:30 pmJul 4, 2010 at 10:10 pm
• 10

#### [R] save plot

I made a plot, but after I made a second plot, the previous plot was gone. How can I save all the plots in a file (I do not manually copy and paste them one by one)? Thanks. Linda
 Linda.sJul 16, 2010 at 3:17 pmAug 4, 2010 at 12:33 pm
• 10

#### [R] reading dates in Excel into R

I am reading dates in Excel2007 into R. Here are the functions I used: library(RODBC) channel<-odbcConnectExcel2007("myfile.xlsx") tmp<-sqlFetch(channel,"1",as.is=T) The dates in myfile.xlsx are all ...
 Hongying LiJul 29, 2010 at 5:32 pmAug 3, 2010 at 6:41 am
• 10

Hello! I have a data set similar to the data set "monthly" in the example below ...
 Dimitri LiakhovitskiJul 23, 2010 at 4:36 pmJul 23, 2010 at 6:17 pm
• 10

#### [R] The opposite of "lag"

Hello! I have a data frame A (below) with a grouping factor (group). I take my DV and create the new, lagged DV by applying the function lag.it (below). It works fine. A <- ...
 Dimitri LiakhovitskiJul 21, 2010 at 2:14 pmJul 21, 2010 at 5:26 pm
• 10

#### [R] in continuation with the earlier R puzzle

When I just run a for loop it works. But if I am going to run a for loop every time for large vectors I might as well use C or any other language. The reason R is powerful is becasue it can handle ...
 RaghuJul 12, 2010 at 2:09 pmJul 13, 2010 at 11:41 am
• 10

#### [R] Adding two files into one and vlookup

I have two files with dates and prices in each. The number of rows in each of them will differ. How do I create a new file which contains data from both these files? Cbind and merge are not helpful ...
 RaghuJul 6, 2010 at 10:18 pmJul 8, 2010 at 1:12 pm
• 10

#### [R] forcing a zero level in contr.sum

I need to use contr.sum and observe that some levels are not statistically different from the overall mean of zero. What is the proper way of forcing the zero estimate? It seems the column ...
 Bond, StephenJul 7, 2010 at 7:13 pmJul 8, 2010 at 1:02 pm
• 10

#### [R] plotmath vector problem; full program enclosed

Here's another example of my plotmath whipping boy, the Normal distribution. A colleague asks for a Normal plotted above a series of axes that represent various other distributions (T, etc). I want ...
 Paul JohnsonJul 6, 2010 at 2:54 pmJul 7, 2010 at 7:20 pm
• 10

#### [R] left end or right end

Dear all, I am a biologist. I have two sets of distance P(start1, end1) and Q(start2, end2). The distance will be like this. P ------------------------ Q ---------------------------------------- I ...
 Ravikumar sukumarJul 1, 2010 at 11:53 amJul 1, 2010 at 6:27 pm
• 9

#### [R] Zoo - bug ???

Hi folks, I am confused whether the following is a bug or it is fine Here is the explanation a <- zoo(c(NA,1:9),1:10) Now If I do rollapply(a,FUN=mean,width=3,align="right") I get 3 4 5 6 7 8 9 10 NA ...
 Sayan dasguptaJul 13, 2010 at 11:43 amNov 30, 2010 at 9:39 pm
• 9

Hello to all! I am new with R and I need your help. I'm trying to read a file which contests are similar to this: A B C T Lengths 1 4.0 0.0015258789 18 c(1,2,3) 1 1.0 0.0017166138 24 c(1,1,4) So all ...
 BalpoJul 16, 2010 at 2:51 pmOct 23, 2010 at 5:56 am
• 9

#### [R] Sweave: infelicities with lattice graphics

In a paper I'm writing using Sweave, I make use of lattice graphics, but don't want to explicitly show (or explain) in the article text the print() wrapper I need in code chunks for the graphs to ...
 Michael FriendlyJul 15, 2010 at 8:51 pmSep 12, 2010 at 6:39 pm
• 9

#### [R] How to deal with more than 6GB dataset using R?

&nbsp;Hi there, Sorry to bother those who are not interested in this problem. I'm dealing with a large data set, more than 6 GB file, and doing regression test with those data. I was wondering are ...
 Babyfoxlove1Jul 23, 2010 at 4:10 pmJul 30, 2010 at 4:13 am
• 9

#### [R] [Rd] R CMD build wiped my computer

Hi Martin, I think this is the most likely reason given that the name in the DESCRIPTION file does NOT have a version number. Even so, it is very easy to misname a file and then delete it/change its ...
 Jarrod HadfieldJul 28, 2010 at 10:55 amJul 28, 2010 at 10:20 pm
• 9

#### [R] Trouble retrieving the second largest value from each row of a data.frame

I have a data frame with a couple million lines and want to retrieve the largest and second largest values in each row, along with the label of the column these values are in. For example row 1 ...
 MpwardJul 24, 2010 at 1:20 amJul 25, 2010 at 1:48 am
• 9

#### [R] converting a time to nearest half-hour

Hi folks, I've got a POSIXct datum as follows: [1] "2010-07-23 11:29:59 BST" I want to convert this to the nearest half-hour, i.e., to "2010-07-23 11:30:00 BST" (If the time were "11:59:ss", I want ...
 Murali MenonJul 23, 2010 at 3:20 pmJul 23, 2010 at 4:48 pm
• 9

#### [R] Matrix Size

hi - i just started using R as i am trying to figure out how perform a linear regression on a huge matrix. i am sure this topic has passed through the email list before but could not find anything in ...
 Paul sJul 14, 2010 at 9:23 pmJul 15, 2010 at 4:09 pm
• 9

#### [R] F# vs. R

Hello, everyone F# is now public. Compiled code should run? faster than R. Anyone has opinion on F# vs. R? Just curious Best, S -- ------- Kniven sk?rpes bara mot stenen.
 Sergey GoriatchevJul 7, 2010 at 3:31 pmJul 11, 2010 at 6:31 pm
• 9

#### [R] can't open file

I have a text file log2.log encoded Ansi in Windows. When I execute: out <- read.zoo(readLines(con <- file("log2.log", encoding="UCS-2LE")),FUN = as.chron) have errors: Error en file(file, "rt") : no ...
 Sebastian KrukJul 7, 2010 at 1:16 pmJul 8, 2010 at 12:56 pm
• 9

#### [R] how to define a function in R

1. how to write a R script? 2.How to write a SAS like macro/generic process to process multiple files by using the same funstion in R? Thanks in advance -- View this message in context ...
 Jd6688Jul 6, 2010 at 10:48 pmJul 8, 2010 at 6:29 am
• 8

#### [R] Syntax Highlightning and Editor for Linux

Hello to the community . First post :) I would like to ask you which text editor do you use in Linux and how did you setup the syntax highlightning? one more question is it possible to debug any ...
 AlaiosJul 23, 2010 at 12:08 pmJul 23, 2010 at 4:12 pm
• 8

#### [R] how to force a table to be square?

Hi guys, I hope you can help me with this. Here is the problem: I have some data (myData) that looks similar to this: [,1] [,2] [,3] [,4] [1,] "A" "A" "B" "B" [2,] "B" "B" "B" "B" [3,] "C" "C" "C" ...
 LiatJul 22, 2010 at 2:00 pmJul 22, 2010 at 4:57 pm
• 8

#### [R] how to collapse categories or re-categorize variables?

I am sure this is a very basic question: I have 600,000 categorical variables in a data.frame - each of which is classified as "0", "1", or "2" What I would like to do is collapse "1" and "2" and ...
 CCJul 16, 2010 at 5:18 pmJul 20, 2010 at 10:18 pm
• 8

#### [R] Help with Reshaping from Wide to Long

I am trying to reshape data that are in the wide format into the long format. The design is a repeated-measures design, which combined 3 levels of shape (circle, square, triangle) with 3 levels of ...
 JlwoodardJul 17, 2010 at 3:42 pmJul 20, 2010 at 7:45 pm
• 8

#### [R] Plot error

Hi guys, I am a newbie to R, so apologies in advance. I created this simple table in excel, saved in tab delimited .txt: name value_1 value_2 1 bill 1 4 2 ben 2 2 3 jane 3 1 and i get this error ...
 James PlattJul 17, 2010 at 2:50 pmJul 18, 2010 at 2:24 pm
• 8

#### [R] Want to exclude a column when using sample function

For example: When I take a sample of 5 from 10 columns, I want to exclude from the sample column 1 from being chosen. How do I do this? -- View this message in context ...
 Addi WeiJul 13, 2010 at 9:00 pmJul 14, 2010 at 6:19 pm
• 8

#### [R] Fast string comparison

What is the fastest way to compare two strings in R? Ralf
 Ralf BJul 11, 2010 at 12:08 pmJul 13, 2010 at 3:37 pm
• 7

#### [R] metafor and meta-analysis at arm-level

Hi, I have been looking for an R package which allowed to do meta-analysis (both pairwise and network/mixed-treatment) at arm-level rather than at trial-level, the latter being the common way in ...
 Angelo FranchiniJul 2, 2010 at 12:07 pmAug 9, 2010 at 8:34 am
• 7

#### [R] how to get higher derivatives with "deriv"

Dear ExpeRts, I have trouble implementing a function which computes the k-th derivative of a specified function f and returns it as a function. I tried to adapt what I found under ?deriv but could ...
 Marius HofertJul 29, 2010 at 4:03 pmAug 1, 2010 at 10:20 pm
• 7

#### [R] how to code it??

Hi I have say a large vector of 3500 digits. Initially the digits are 0s and 1s. I need to check for a rule to change some of the 0s to -1s in this vector. But once I change a 0 to -1 then I need to ...
 RaghuJul 28, 2010 at 6:10 pmJul 29, 2010 at 4:28 am
• 7

#### [R] Sweave and scan()

I am introducing the scan() function to my class. Consider the following file (Scanexamp.Rnw ) \documentclass[12pt]{article} \begin{document} << = height = scan() 64 62 66 65 62 69 72 72 70 part = ...
 Murray JorgensenJul 27, 2010 at 3:54 amJul 28, 2010 at 11:32 pm
• 7

#### [R] Optimization problem with nonlinear constraint

Dear all, I'm looking for a way to solve a simple optimization problem with a nonlinear constraint. An example would be max x s.t. y = x * T ^(x-1) where y and T are known values. optim() and ...
 Uli KleinwechterJul 26, 2010 at 2:16 pmJul 28, 2010 at 3:49 pm
• 7

#### [R] Checking package licences including dependencies?

I only recently discovered options("available_packages_filters" = list(add = TRUE, "license/FOSS")) [cf. help("available.packages", package="utils") in R 2.10.0 or later] which goes nicely with my ...
 Allan EngelhardtJul 27, 2010 at 11:17 amJul 27, 2010 at 3:58 pm
• 7

#### [R] Plot of a subset of a data.frame()

Hello, my data.frame is sort of a collection of process values, i.e. huge run-chart. It consists of a time-stamp in the first column (date as string), factors in the following columns (used for ...
 Steffen UhligJul 26, 2010 at 11:38 amJul 27, 2010 at 10:33 am
• 7

#### [R] Bug on r-bc?

Dear All, The following code should return 1, but it returns 0: source("http://r-bc.googlecode.com/svn/trunk/R/bc.R") bc("9 % 2") Do you confirm this bug? Paul
 Paul SmithJul 26, 2010 at 5:44 pmJul 27, 2010 at 9:51 am
• 7

#### [R] legend in R plot

Hi all, I am have some difficulty with the legend function. I need to add a legend to describe the different line types in a plot. The legend box is small. It did not include sufficient length of ...
 Li liJul 22, 2010 at 4:06 amJul 23, 2010 at 1:38 pm
• 7

#### [R] , how to express bar(zeta) in main title in boxplot

Hi everyone, I am plotting a boxplot with main title as main = bquote(paste(.(ts.ind[s]), ": ", bar(zeta), " Boxplot from 2001 to 2009", sep = "")) but it doesn't work. The program said they cannot ...
 Marcus LiuJul 22, 2010 at 5:44 pmJul 22, 2010 at 10:39 pm
• 7

#### [R] Sweave special characters problem

Dear all, I use Sweave to create my reports. Unfortunately my script crashes whenever I my R code contains special characters like umlauts. Is there a way to to escape special characters in ...
 Bunny, lautloscrew.comJul 22, 2010 at 12:19 pmJul 22, 2010 at 9:07 pm
• 7

#### [R] best way to apply a list of functions to a dataset ?

Assuming I have a matrix of data (or under some restrictions that will become obvious, possibly a data frame), I want to be able to apply a list of functions (initially producing a single number from ...
 Glen BarnettJul 20, 2010 at 5:51 amJul 21, 2010 at 3:00 pm