FAQ

# R>r-help>August 2012

## 696 discussions - 2,744 posts

• 22

#### [R] predict.lm(...,type="terms") question

Hello all, How do I actually use the output of predict.lm(..., type="terms") to predict new term values from new response values? I'm a chromatographer trying to use R (2.15.1) for one of the most ...
 John ThadenAug 28, 2012 at 10:30 pmSep 2, 2012 at 6:25 pm
• 20

Hi R-Helpers, I don't think I need to post a dataset for this question but if I do, I can. Anyway, I am having a lot of trouble with the ifelse command. Here is my code: vn$PM.DIST_flag <- ifelse( ...  Jennifer SabatierAug 24, 2012 at 8:22 pmAug 25, 2012 at 2:35 am • 18 #### [R] test if elements of a character vector contain letters Dear all I'm pretty sure that I'm approaching the problem in a wrong way. Suppose the following character vector: [1] "a10" "b7" "c2" "d3" "e6" "f1" "g5" "h8" "i9" "j4" "k" "l" "m" "n" [15] "o" "p" ...  Liviu AndronicAug 6, 2012 at 4:25 pmAug 8, 2012 at 8:56 am • 18 #### [R] apply function over same column of all objects in a list Hello. Please forgive me if this problem has already been posted (and solved) by someone else ... I can't find it anywhere though it seems so very basic. Here it is: I have a list comprised of ...  GailAug 1, 2012 at 1:43 pmAug 3, 2012 at 7:14 am • 17 #### [R] pass by reference Hi all, I want to do the following: data<-data.frame(col1=c(1,2,3,4,5)) getcol2<-function(data){ data$col2[data$col1<=2]="L" } getcol2(data) Unfortunately in the above col2 does not appear in the ...  Sachinthaka AbeywardanaAug 14, 2012 at 1:08 amAug 15, 2012 at 10:37 am • 16 #### [R] variable scope At the end of a for loop its variables are still present: for (i in 1:10) { x <- vector(length0000000) } ls() will print "i" and "x". this means that at the end of the for loop body I have to write ...  Sam SteingoldAug 28, 2012 at 6:29 pmAug 29, 2012 at 7:09 pm • 14 #### [R] apply --> data.frame Is there a way for an apply-type function to return a data frame? the closest thing I think of is foo <- as.data.frame(sapply(...)) names(foo) <- c(....) is there a more "elegant" way? Thanks! -- Sam ...  Sam SteingoldAug 30, 2012 at 12:56 pmAug 31, 2012 at 8:03 pm • 14 #### [R] Opinion: Why I find factors convenient to use Folks: Over the years, many people -- including some who I would consider real expeRts -- have criticized factors and advocated the use (sometimes exclusively) of character vectors instead. I would ...  Bert GunterAug 17, 2012 at 5:32 pmAug 20, 2012 at 3:41 pm • 14 #### [R] How to link two R packages together Hi, I have built two R packages. One of them (PKG1) needs to use the functions of the other package (PKG2). So I need to link these two packages together, so that the functions of PKG2 can be ...  Xuan zhaoAug 1, 2012 at 10:27 pmAug 2, 2012 at 2:57 pm • 13 #### [R] define subset argument for function lm as variable? Hi I want to do a series of linear models, and would like to define the input arguments for lm() as variables. I managed easily to define the formula arguments in a variable, but I also would like to ...  Rainer M KrugAug 21, 2012 at 2:44 pmAug 29, 2012 at 1:50 pm • 12 #### [R] [ncdf4] error converting GEIA data to netCDF summary: I can successfully ncvar_put(...) data to a file, but when I try to ncvar_get(...) the same data, I get How to fix or debug? details: R code @ https://github.com/TomRoche/GEIA_to_NetCDF ...  Tom RocheAug 28, 2012 at 3:31 amAug 29, 2012 at 2:44 am • 11 #### [R] write.matrix.csr data conversion 0 1 5194394 23487$ cut -d' ' -f1 f | sort | uniq -c 23487 2 5194394 1 i.e., 0 is written as 1 and 1 is written as 2. why? is there a way to disable this? -- Sam Steingold (http://sds.podval.org/) on ...
 Sam SteingoldAug 27, 2012 at 6:47 pmNov 6, 2012 at 8:21 pm
• 11

#### [R] What makes R different from other programming languages?

My intention is to give a presentation about R programming language for software developers. I would like to ask, what are the things that make R different from other programming languages? What are ...
 Johannes raraAug 20, 2012 at 6:02 pmAug 22, 2012 at 8:46 pm
• 11

#### [R] merging and obtaining the nearest value

Dear R-help ? would like to know if there is a short solution in R for this merging problem... Let say I have a dataset A as: TYPE DATE A 2 A 5 A 20 B 10 B 2 (there can be duplicates for the same ...
 FrancescoAug 19, 2012 at 10:10 amAug 20, 2012 at 11:37 am
• 11

#### [R] Get the filename from the given path

Hi, Here i have a file path, for eg : - FPath <- "D:\\MyFolder\\MyFile.txt" HOW IS POSSIBLE TO GET THE FILE NAME FROM THIS GIVEN PATH ? - thanks in advance Antony. -- View this message in context ...
 RantonyAug 17, 2012 at 9:28 amAug 18, 2012 at 1:45 pm
• 11

#### [R] debug vs regular mode

Dear all, I had a R segmentation fault, and then invoked debug mode and ran step by step. When I reached "terms(Y~X1*X2*...*X16)", I would then have "segmentation" fault. However, if I just ran this ...
 Zhang, PengAug 9, 2012 at 11:56 pmAug 10, 2012 at 8:15 pm
• 11

#### [R] indexing in data frames

I'm still not fully understanding exactly how R is handling data frames, but am getting closer. Any help with this one will likely go a long way in getting me there. Let's say I have a data frame, ...
 Jimi adamsAug 9, 2012 at 8:42 pmAug 10, 2012 at 1:17 pm
• 11

#### [R] reshape2's dcast() Adds NAs to Data Frame

I need to understand how and why dcast() adds NAs to a data frame that contained no missing values. The database table of chemical concentrations has all missing values removed because they cannot ...
 Rich ShepardAug 7, 2012 at 9:45 pmAug 9, 2012 at 1:26 pm
• 11

#### [R] Can't Run "Conjoint" Package - could not find function "caFactorialDesign"?

I'm trying to install and run the "Conjoint" package, and I get the error: Error: could not find function "caFactorialDesign" I'm running R 2.15.1 on Mac OS X. I have installed the package "Conjoint" ...
 VikRAug 3, 2012 at 5:10 pmAug 7, 2012 at 2:53 am
• 11

#### [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

Hi, Here is my data, the first 10 rows structure(c(999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1.9, 2, 1.97, ...
 Yolande TraAug 3, 2012 at 7:49 pmAug 3, 2012 at 9:26 pm
• 10

#### [R] no true negative data, need roc curve

Hi, I want to plot ROC curve for my detection algorithm which detects features in different images at two different thresholds. 6 different images used and obtained tp, fp and fn. No tn in my case ...
 VjynsAug 16, 2012 at 9:51 amAug 30, 2012 at 9:10 am
• 10

#### [R] Sorting of columns of a matrix

Dear all, Please suggest me how can I do it. I have a matrix which look like following: x1 x2 x3 t1 .01 0.3 0 t2 0 0.1 0.01 t3 0 .01 .01 t4 0 0 t5 5 0 0 t6 0 0 0 t7 0 0 0 t8 0 0 0 t9 0.6 0 0 t10 0 0 ...
 Nico MetAug 29, 2012 at 1:24 pmAug 29, 2012 at 3:56 pm
• 10

#### [R] Create and Assign value into a variable from Another variable

Hi, Here i have a variable named "MyVariable" containing particular name For eg:- MyVariable <- "UnitNo" Here my requirement is, i need to get "UnitNo" as another variable by reading "MyVariable" i ...
 RantonyAug 28, 2012 at 6:48 amAug 28, 2012 at 4:50 pm
• 10

#### [R] How to extract from a column in a table?

Hi, I have a table in which one column has the name of the objects as shown below. Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) ...
 Sapana LohaniAug 16, 2012 at 6:41 pmAug 17, 2012 at 5:07 pm
• 10

#### [R] r data structures

hi, i'm trying to understand r data structures. i see that vectors, matrix, factors and arrays have a "dimension." there seems to be no mention of dimensionality anywhere for lists or dataframes. can ...
 Schumacher, Jay SAug 16, 2012 at 6:49 pmAug 17, 2012 at 7:38 am
• 10

#### [R] Communative Matrix Multiplcation

Friends I'm not seeing why the following occurs: [1] FALSE Harold new("dsCMatrix" , i = c(0L, 1L, 2L, 3L, 0L, 1L, 4L, 2L, 3L, 5L) , p = c(0L, 1L, 2L, 3L, 4L, 7L, 10L) , Dim = c(6L, 6L) , Dimnames = ...
 Doran, HaroldAug 14, 2012 at 5:25 pmAug 16, 2012 at 12:37 pm
• 10

#### [R] if else elseif for data frames

Hi all, It seems like I cannot use normal 'if' for data frames. What would be the best way to do the following. if data$col1='high' data$col2='H' else if data$col1='Neutral' data$col2='N' else if ...
 Sachinthaka AbeywardanaAug 13, 2012 at 12:43 amAug 14, 2012 at 9:47 am
• 10

#### [R] summarize a vector

I have a long numeric vector v (length N) and I want create a shorter vector of length N/k consisting of sums of k-subsequences of v: v <- c(1,2,3,4,5,6,7,8,9,10) N, k=3 === [6,15,24,10] I can, of ...
 Sam SteingoldAug 10, 2012 at 7:20 pmAug 10, 2012 at 11:34 pm
• 10

#### [R] Force evaluation of a symbol when a function is created

I am porting a program in matlab to R, The problem is that Matlab has a feature where symbols that aren't arguments are evaluated immediately. That is: Y=3 F=@(x) x*Y Will yield a function such that ...
 Schoenfeld, David Alan,Ph.D.,BiostatisticsAug 6, 2012 at 9:07 pmAug 7, 2012 at 7:50 pm
• 10

#### [R] Recursive function calls

My apologies, I know that this is not a new problem, but I'm not sure how to find the answer I want to recursively loop over an object and trim trailing white space. When I use this function on a ...
 Gene LeynesAug 3, 2012 at 4:12 pmAug 3, 2012 at 10:46 pm
• 9

#### [R] latex \subfloat{} incompatible with sweave/knitr code

Dear all Are LaTeX \subfloat{} commands incompatible with Sweave code? I cannot get the following code to compile properly: \begin{table} \subfloat[asdfa]{<< = 2+2 @ } \caption{asdf} \end{table} If I ...
 Liviu AndronicAug 29, 2012 at 10:56 amAug 31, 2012 at 4:14 pm
• 9

#### [R] relating data in two data frames

Hi, My data.frame "A" has FID like this FID a a b b b c c d d d d Now my second data.frame "B" has age value for a, b, c, d like FID Age a 5 b 7 c 9 d 3 How can search for the Age column in "B" and ...
 Sapana LohaniAug 20, 2012 at 12:56 amAug 22, 2012 at 4:30 am
• 9

Hi all, Is it possible to get the latitude and longitude of the location of a tweet? If I do tweets<- searchTwitter("#obama", n=200) #get tweets df <- twListToDF(tweets) #converts to data frame for ...
 Sachinthaka AbeywardanaAug 14, 2012 at 11:06 pmAug 16, 2012 at 11:45 am
• 9

#### [R] Reading one column .csv file

My friend sent an Excel file: http://msemac.redwoods.edu/~darnold/temp/cyu01_iqscores.xls http://msemac.redwoods.edu/~darnold/temp/cyu01_iqscores.xls I opened it in Excel, saved is as ...
 DarnoldAug 15, 2012 at 5:27 pmAug 16, 2012 at 5:04 am
• 9

#### [R] Problem when creating matrix of values based on covariance matrix

Hi, I want to simulate a data set with similar covariance structure as my observed data, and have calculated a covariance matrix (dimensions 8368*8368). So far I've tried two approaches to simulating ...
 Boel BrynedalAug 11, 2012 at 2:17 pmAug 13, 2012 at 5:14 pm
• 9

#### [R] Simple question about formulae in R!?

Good morning reader, I have encountered a, probably, simple issue with respect to the *formulae* of a *regression model* I want to use in my research. I�m researching alliances as part of my study ...
 Johan HaasnootAug 10, 2012 at 7:14 amAug 13, 2012 at 1:17 am
• 9

#### [R] help error histograma

Hi, My error isErro em hist.default(dados[[1]], freq = TRUE, seq(0, 30, 0.5), prob = FALSE, : some 'x' not counted; maybe 'breaks' do not span range of 'x' hist(dados[[1]],seq(0, 30, 0.5), prob=TRUE, ...
 Aprendiz programaAug 10, 2012 at 12:36 amAug 10, 2012 at 6:07 pm
• 9

#### [R] Setting Number of Displayed Digits

Some chemicals have concentrations at or below the method detection limit (MDL; 'less-thans') of 0.005 mg/L. When I look at the data frame that is how the concentration is displayed. But, when I ask ...
 Rich ShepardAug 7, 2012 at 5:50 pmAug 9, 2012 at 9:02 pm
• 9

#### [R] Decimal number

HI [1] 64.90614 thank you in advance hafida -- View this message in context: http://r.789695.n4.nabble.com/Decimal-number-tp4639428.html Sent from the R help mailing list archive at Nabble.com.
 HafidaAug 7, 2012 at 4:47 pmAug 8, 2012 at 7:53 am
• 9

#### [R] Head or Tails game

Hi, Reading about a "Heads and Tails" game in http://www.dartmouth.edu/~chance/teaching_aids/books_articles/probability_book/amsbook.mac.pdf Introduction to Probability (Example 1.4, pp. 5-8). You ...
 DarnoldAug 4, 2012 at 12:55 amAug 6, 2012 at 6:20 am
• 9

Hi all, I have two vectors (columns) called "efinal" and "efinal 2". I want to plot them on the same plot and "draw" a shaded area beween the two lines using function polygon I have tried all but I ...
 Jose Narillos de SantosAug 2, 2012 at 12:33 pmAug 2, 2012 at 11:18 pm
• 8

#### [R] splits with 0s in middle columns

Hi, A column of my df looks like A 10/20/30 40/20 60/10/10/5 80/10 I want to split it such that the last column has the last composition and if there are not enough the middle columns get the 0s ...
 Sapana LohaniAug 31, 2012 at 4:10 pmSep 3, 2012 at 1:49 am
• 8

#### [R] Turning of source echo

HI, I have this code: BAGA <- c(10,20,20,30,30,30,30,40, 40,40,40,50,50,50,50,50, 60,60,60,60,60,70,70,70, 70,80,80,80,90,90,100) BAGB <- c(10,10,10,10,10,20,20,20, 20,30,30,30,40,40,50,60, ...
 DarnoldAug 25, 2012 at 4:15 amAug 27, 2012 at 8:32 pm
• 8

#### [R] dimnames in an array(I'll be grateful if this message will be passed to all list users)

Hello, I'm hoping someone with a wide experience with R may be able to see what the program is trying to tell me. I've got an array: y1=rnorm(41,0.2) y2=rnorm(41,0.2) y3=rbind(y1,y2) ...
 Aleksandr russellAug 13, 2012 at 9:10 amAug 27, 2012 at 6:10 pm
• 8

#### [R] Problem with global variable building a package

Hi, Â My name is Eva and this is my first message here. My English is not very good, but I hope you can understand my question, in the context of an academic project. Â I have developed several ...
 Eva Prieto CastroAug 7, 2012 at 7:09 amAug 17, 2012 at 8:20 am
• 8

#### [R] Fill pattern for Boxplots?

Is it possible to fill the boxes of a boxplot with filling patterns/texture instead of colours? Or both mixed? (for example white, grey, left diagonal striped, right diagonal striped) How can I do ...
 SuseAug 8, 2012 at 11:56 pmAug 12, 2012 at 3:45 am
• 8

#### [R] sapply and matrix command

HI, You can also try this: d<-1:25 A<-sample(combn(20:30,2)) B<-sample(combn(20:30,2)) lapply(d,function(x) matrix(c(1,A[x],B[x],1),2,2)) [[1]] [,1] [,2] [1,] 1 23 [2,] 27 1 [[2]] [,1] [,2] [1,] 1 21 ...
 arun kirshna [via R]Aug 2, 2012 at 3:34 amAug 9, 2012 at 8:22 pm
• 8

#### [R] Pass Conditional & loop argument into a function

Dear R community, I have been spending hours to solve my problem myself but I'm just unable to do it. So excuse me if I demand your time. My problem is, that inside my function, I want to pass ...
 Greatest.possible.newbieAug 8, 2012 at 12:44 pmAug 9, 2012 at 6:27 pm
• 8

#### [R] help, please! matrix operations inside 3 nested loops

hello, this is my script: #1) read in data: daten<-read.table('K:/Analysen/STRUCTURE/input_STRUCTURE_tab_excl_5_282_559.txt', header=TRUE, sep="\t") daten<-as.matrix(daten) #2) create empty matrix ...
 FridolinAug 8, 2012 at 2:06 pmAug 9, 2012 at 12:46 pm
• 8

#### [R] NADA Package: Referencing Data Frame Columns

The sample data sets that come with the NADA package are limited to one or two variables and a censored measurement indicator column. I try to mimic examples using my data but keep missing the ...
 Rich ShepardAug 7, 2012 at 4:26 pmAug 9, 2012 at 8:15 am
 period ‹ prev | Aug 2012 | next ›
Group Overview
 group r-help categories r discussions 696 posts 2,744 users 693 website r-project.org irc #r