Displaying 20 results from an estimated 6000 matches similar to: "Operating matrix positions"
2007 Oct 15
1
The "condition has length > 1" issue for lists
I have the following code:
list1 <- list()
for (i in list.files(pattern="filename1")){
x <- read.table(i)
list1[[i]] <- x
}
list2 <- list()
for (i in list.files(pattern="filename2*")){
x <- read.table(i)
list2[[i]] <- x
}
anslist <- vector('list', length(list1))
for(i in 1:length(list1))
if (list1[[i]] & list2[[i]] >1)
2007 Dec 06
7
Fitting large titles in a plot
I want to fit a fairly long main title for a plot, supposedly by changing row
after a while. As for now it starts way outside the picture margin at the
left and continues way out right passed the right margins.
>plot(A,main="This is my really long title and it's so long that I can see
just about half of it.")
Any suggestions? Shouldn't be that hard.
--
View this message in
2006 Dec 10
4
sample "n" random positions from a matrix
Hi there,
I have a binary matrix (dim 100x100) filled with values 0 and 1. I need select a record "n" positions of that matrix when values are 1. How can I do that?
Thanks for all,
Miltinho
Brazil
---------------------------------
[[alternative HTML version deleted]]
2007 Oct 13
1
Controlling values in read.table
I have this code:
list1 <- list()
for (i in list.files(pattern=".*c02.*AFDH0.*")){
x <- read.table(i,skip=20,fill=TRUE)
list1[[i]] <- x
}
Somehow I would like the read.table function to read only values in each
file that are over a certain limit, say >1. Is this the easiest way or is it
better to tamper with 'list1' when it's done?
--
View this message in
2008 Aug 26
4
sequence with start and stop positions
Hi,
I have a vector of start positions, and another vector of stop positions,
eg start<-c(1,20,50)
stop<-c(7,25,53)
Is there a quick way to create a sequence from these vectors?
new<-c(1,2,3,4,5,6,7,20,21,22,23,24,25,50,51,52,53)
the way Im doing it at the moment is
pos<-seq(start[1],stop[1])
for (i in 2:length(start)){
new<-seq(start[i],stop[i])
pos<-c(pos,new)
}
2011 Jan 08
3
Question on list objects
Hi, I have 2 questions on list object:
1. Suppose I have a matrix like:
dat <- matrix(1:9,3)
Now I want to replicate this entire matrix 3 times and put entire result in a list object. Means, if "res" is the resulting list then I should have:
res[[1]]=dat, res[[2]]=dat, res[[3]]=dat
How can I do that in the easilest manner?
2. Suppose I have 2 list objects:
list1 <- list2
2008 Aug 08
1
operating on arrays of unknown dimensionality
Dear R-users,
I am looking for a way to assign to slices of arrays where dimensionality of the array is not a-priory known.
Specifically, I would like to be able to generalize the following example of dimensionality 2 to an arbitrary diminsionality:
In this example we create an array x, a smaller array y and then assign y to a slice of x.
> dimnmx <- list(c('a','b'),
2008 Jul 17
1
combining lists of pairs
Hi everybody,
This has been causing me some trouble:
I want to combine several lists of pairs into a single?vector but keep the pairs together. The lists are of the form:
(1)?x1 x2 x3... N?
(2) y1 y2 y3..? N
I would like to keep it this way, simply appending one list to another, e.g.
(1) x1i x2i... x1j x2j... N
(2) etc.
A?method like c(...) does not achieve this. It creates a single list,
2008 Aug 28
2
sample consecutive integers efficiently
Hi all,
I have some rough code to sample consecutive integers with length
according to a vector of lengths
#sample space (representing positions)
pos<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
#sample lengths
lengths<-c(2,3,2)
From these two vectors I need a vector of sampled positions.
the sampling is without replacement, making things tough as the sampled
integers need
2010 Dec 05
3
grep for strings
I am trying to find the function where I can search for a pattern in a
text string (I thought I could use grep for this but no :().
> x
[1] "abcdefghijkl"
I want to find the positions (i.e. equivalent of nchar) for "cd" and
in case there are multiple hits .. then the results as a array
Thank you.
2007 Oct 23
1
Strange dataframe behavior
Hello,
I have a question regarding the following output:
> database <- read.delim(file=path.input.file, header=TRUE, dec=".", sep="\t", na.strings = "#NV")
> str(database)
'data.frame': 314 obs. of 13 variables:
$ S : Factor w/ 314 levels "307073","400212",..: 147 72 299 137
162 62 189 236 134 307 ...
$ A : Factor
2009 Oct 13
7
lapply() reccursively
Hi all,
I was wondering whether it is possible to use the lapply() function
to alter the value of the input, something in the spirit of :
a1<-runif(100)
a2<-function(i){
a1[i]<-a1[i-1]*a1[i];a1[i]
}
a3<-lapply(2:100,a2)
Something akin to a for() loop, but using the lapply() infrastructure.
I haven't been able to get rapply() to do this.
The reason is that the "real"
2010 Jul 07
3
How do I test against a simple null that two regressions coefficients are equal?
Hi there,
I run two regressions:
y = a1 + b1 * x + e1
y = a2 + b2 * z + e2
I want to test against the null hypothesis: b1 = b2. How do I design the test?
I think I can add two equations together and divide both sides by 2:
y = 0.5*(a1+a2) + 0.5*b1 * x + 0.5*b2 * z + e3, where e3 = 0.5*(e1 + e2).
or just y = a3 + 0.5*b1 * x + 0.5*b2 * z + e3
If I run this new regression, I can test against
2008 May 29
7
How do you exit a function in R?
For example, based on a certain condition, I may want to exit my code early:
# Are there the same number of assets in "prices" and
"positions"?
if (nAssetPositions != nAssetPrices) {
cat("Different number of assets! \n\n")
<exit function>
}
I have searched, but not
2011 Dec 21
4
qqnorm & huge datasets
Hi,
When qqnorm on a vector of length 10M+ I get a huge pdf file which
cannot be loaded by acroread or evince.
Any suggestions? (apart from sampling the data).
Thanks.
--
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://mideasttruth.com http://honestreporting.com http://camera.org
http://openvotingconsortium.org http://pmw.org.il
2019 Jun 07
2
[R] Open a file which name contains a tilde
> On Jun 6, 2019, at 2:04 PM, Richard O'Keefe <raoknz at gmail.com> wrote:
>
> How can expanding tildes anywhere but the beginning of a file name NOT be
> considered a bug?
>
>
I think that that IS what libreadline is doing if one allows a whitespace separated list of file names.
As reported in R-help,
https://www.mail-archive.com/r-help at
2010 Dec 31
4
Repeated Indexing / Sequence Operation
Hi Everyone,
quick question before the end of the year.
I have soem indices to select data from a bigger sample. I want to select n
days before each index and n days after the index. Any clever way to do it.
A for loop would do but I wanted to know if there is a moreR-friendly way to
approach this
Example
# InitialIndices
i2 = (90, 190, 290)
# Indices I want to end up with
i3 = c(85, 86, 87,
2011 Jan 24
2
Help with expression
I have a problem with expressions. I am trying to create a title where
the parameter of interest is displayed as a Greek character. Which
parameter is being considered is stored in a character variable.
As an example, if I have
param <- "alpha"
and then do
plot(0, 0, main = bquote(Parameter==.(param)))
then in the title I get "Parameter = alpha",
whereas I want the
2010 Jan 27
3
Function for describing segements in sequential data
Dear R-users,
Say that I have a sequence of zeroes and ones:
x <- c(1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0)
The sequences of ones represent segments and I want to report the starting and endpoints of these segments. For example, in 'x', the first segment starts at location 1 and ends at 3, and the second segment starts at location 8 and ends at location 10. Is there an efficient
2019 Jun 05
6
Open a file which name contains a tilde
Hi,
As I can see via path.expand a filename which contains a tilde anywhere gets automatically crippled.
+> path.expand("a ~ b")
[1] "a /home/user b"
+> path.expand("a ~ b ~")
[1] "a /home/user b /home/user"
I want to open a file regardless whether its name contains any character unless 0.
The unix filesystem allow the creation of such files, it