similar to: indexing

Displaying 20 results from an estimated 9000 matches similar to: "indexing"

2010 Jan 09
1
Reducing the size of a large script top speed onset of execution
Colleagues, (R 2.10 on all platforms) I have a lengthy script (18000 lines) that runs within a graphical interface. The script consists of 100's of function followed by a single command that calls these functions (execution depends on a number of environment variables passed to the script). As a result, nothing is executed until the final line of code is read. It takes 15-20
2003 Nov 07
3
Q. About String indexing
Hi all - this is a very basic question: how does one index substrings of a character string, for example get the 2nd through 5th characters of the string "testing", in the R language? Indexing with square brackets seems only to work for vectors, lists, etc., and although I've found plenty of functions for concatenating strings, running substitutions with regexps and the like, I seem
2006 Apr 04
1
Indexing a vector by a list of vectors
Hello R-help - I have vec <- c("string1", "string2", "string3") ind <- list(c(1,2),c(1,2,3)) I want "vec" indexed by each vector in the list "ind". The first element of the list I want would be vec[c(1,2)], the second element would be vec[c(1,2,3)], like the following. [[1]] [1] "string1" "string2" [[2]] [1]
2008 Sep 24
1
splitting strings efficiently
I have a very long list of strings. Each string actually contains multiple values separated by a semi-colon. I need to turn each string into a vector of the values delimited by the semi-colons. I know I can do this very laboriously by using loops, nchar, and substr, but it is terribly slow. Is there a basic R function that handles this situation? If not, is there perhaps a faster way to do it than
2009 Mar 03
4
regular expression question
can someone show me how to use a regular expression to break the string at the bottom up into its three components : (-0.791,-0.263] (-38,-1.24] (0.96,2.43] I tried to use strplit because of my regexpitis ( it's not curable. i've been to many doctors all over NYC. they tell me there's no cure ) but it doesn't work because there also dots inside the brackets. Thanks.
2009 Jun 20
1
string splitting and testing for enrichment
Hi List I have data in the following form: Gene    TFBS NUDC     PPARA(1) HNF4(20) HNF4(96) AHRARNT(104) CACBINDINGPROTEIN(149) T3R(167) HLF(191) RPA2     STAT4(57) HEB(251) TAF12     PAX3(53) YY1(92) BRCA(99) GLI(101) EIF3I     NERF(10) P300(10) TRAPPC3     HIC1(3) PAX5(17) PAX5(110) NRF1(119) HIC1(122) TRAPPC3     EGR(26) ZNF219(27) SP3(32) EGR(32) NFKAPPAB65(89) NFKAPPAB(89) RFX(121)
2010 Nov 08
7
How to rbind list of vectors with unequal vector lengths?
Hi, How to rbind these vectors from a list?: > l <- list(a = c(1, 2), b = c(1, 2, 3)) > l $a [1] 1 2 $b [1] 1 2 3 > do.call(rbind, l) [,1] [,2] [,3] a 1 2 1 b 1 2 3 Warning message: In function (..., deparse.level = 1) : number of columns of result is not a multiple of vector length (arg 1) > -J
2008 May 16
2
Integer / floating point question
Dear R-help - I have thought about this question for a bit, and come up with no satisfactory answer. Say I have the numeric vector t1, given as t1 <- c(1.0, 1.5, 2.0, 2.5, 3.0) I simply want to reliably extract the unique integers from t1, i.e., the vector c(1, 2, 3). This is of course superficially simple to carry out. However, my question is related to R FAQ 7.31, "Why
2009 Aug 31
4
Offtopic, HT vs. HH in coin flips
Dear R-help, Could someone please try to explain this paradox to me? What is more likely to show up first in a string of coin tosses, "Heads then Tails", or "Heads then Heads"? ##generate 2500 strings of random coin flips ht <- replicate(2500, paste(sample(c("H", "T"), 100, replace = TRUE), collapse =
2008 Jul 02
1
Hmisc latex function with longtable option
Hello - I'm trying to use Hmisc's latex function to produce a postscript file of a data.frame, using the longtable = TRUE option. When I run, for example, ## sample R code dvips(latex(data.frame(a = rnorm(100), b = rnorm(100)), longtable = TRUE), file = "test.ps") latex runs successfully and a test.ps file is produced. However, I see the following in the
2010 May 23
4
creating a reverse geometric sequence
Hello, Can anyone think of a non-iterative way to generate a decreasing geometric sequence in R? For example, for a hypothetical function dg, I would like: > dg(20) [1] 20 10 5 2 1 where I am using integer division by 2 to get each subsequent value in the sequence. There is of course: dg <- function(x) { res <- integer() while(x >= 1) { res <- c(res, x) x
2012 Jun 28
2
R help, using R to build choropleth
Hi guys i need some help to build choropleth. Basically i am trying to colour regions on the map by population. I possess the shape file of the country, and also the population data, however, i am having trouble to create the plot, below is my code: population=read.csv("nz2.csv") population names(population) nz=readShapeSpatial((sprintf('nz-geodetic-marks',tmp_dir)))
2009 Jan 01
1
Wireless network connection problem
hi all , i just met a strange problem about my wireless network , i installed ipw3945 driver and it can detect the wireless network lists around my laptop ,but , i can't connect to the wireless network even under the right authority my centos 5.2 dectected my wirless network card as eth1 , it's really strange , i think any help ? thx and wish you a happy new year :) -- Keep It Simple
2007 Nov 08
2
mapply, coxph, and model formula
Hello - I am wanting to create some Cox PH models with coxph (in package survival) using different datasets. The code below illustrates my current approach and problem with completing this. ### BEGIN R SAMPLE CODE ############################## library(survival) #Define a function to make test data makeTestDF <- function(n) { times <- sample(1:200, n, replace = TRUE) event
2010 Aug 18
1
syntax for batching rbind process
Dear helpeRs, I am attempting to read in a series of csv files so I can bind them into one large dataframe. I have written the following script: test <- list.files(".", pattern = "csv") #lline 1 imp <- list() #line 2 for (i in 1:length(test)) { #line 3 imp[i] <- read.csv(test[i]) #line 4 }
2009 Apr 24
2
argument 'exclude' in function xtabs
Dear all I was willing to use argument 'exclude' in function xtabs to remove some levels of factors (xtabs help page says '"exclude: a vector of values to be excluded when forming the set of levels of the classifying factors"). I tried: > mydata <- data.frame( treatment = c("B", "A", "C", "C", "B",
2009 Jul 16
2
quoting expressions in a list
Dear R-help, I am having quite a difficult time coming up with what I want to do involving named lists. I have a list of logical expressions, and I would really like it if the "names" of the components of the list were identical to the corresponding logical expression. So, as an example: df.example <- data.frame(a = 1:10, b = rnorm(10, 5)) list.example <- list(df.example$a
2012 Jun 01
1
Missing times chron
Dear all, As a novice user of R I ran into a problem that's quite hard for me to resolve. I have a database containing data of a clinical trial in which patients are included that survived or died: x <- matrix(data=c(1:5,0, "1/1/2012 00:00:00",0,0,"1/7/2012 00:00:00"), nrow=5, ncol=2, dimnames= list(NULL,c("ID", "dateofdeath"))) My file is a .csv
2007 Nov 09
2
wrapper for coxph with a subset argument
Dear R-help - Thanks to those who replied yesterday (Christos H. and Thomas L.) regarding my question on coxph and model formula, the answers worked perfectly. My new question involves the following. I want to run several coxph models (package survival) with the same dataset, but different subsets of that dataset. I have found a way to do this, described below in functions subwrap1 and
2011 Apr 08
7
Where is the tcltk package?
Perhaps I'm being even thicker than usual, but I can't find the tcltk package on CRAN. There is a tcltk2 package, which says that it is a collection of supplements to tcltk, but I cannot see a just-plain tcltk anywhere. If I try to install tcltk2 (from the Linux command line, or using install.packages() in R) it complains that it needs tcltk. If I try to install tcltk using