similar to: Turning a logical vector into its indices without losing its length

Displaying 20 results from an estimated 4000 matches similar to: "Turning a logical vector into its indices without losing its length"

2008 Oct 20
2
R Newbie Question
Hello list, I just started R today and tried something quite simple. I wanted to create a colored plot and eventually after hours of fiddling around got it working. However, my solution seems very suboptimal and I'd really appreciate your hints on how to improve. I believe that R already offers many functions I coded (e.g. distance between two vectors, vector length, vector normalization and
2007 May 08
2
Looking for a cleaner way to implement a setting certain indices of a matrix to 1 function
I wrote an ugly algorithm to set certain elements of a matrix to 1 without looping and below works and you can see what The output is below the code. K<-6 lagnum<-2 restrictmat<-matrix(0,nrow=K,ncol=K*3) restrictmat[((col(restrictmat) - row(restrictmat) >= 0 ) & (col(restrictmat)-row(restrictmat)) %% K == 0)]<-1 restrictmat[,(lagnum*K+1):ncol(restrictmat)]<-0 restrictmat
2006 Nov 12
7
I think a simple question
I have index ( of a vector ) values of say tempin<-c(1 31 61 91 121 all the way upto 1411) What I want is a function that takes in a number say, x = 5, and gives me an new vector of tempout<-1 6 31 36 91 96 121 126 .......... 1411 1416 This can't be so hard but I can't get it and I've honestly tried. Obviously, tempin + 5 gives me the missing values but I
2006 Oct 24
6
extract certain values from a ts
Hi, Having several daily wind speed time series I want to extract those consecutive days over and below certain values (i.e. 5 < x <8) Don't know which funtion to use (aggregate, lapply?) and how to do it. Thanks in advance Antonio
2011 Feb 08
1
Just another pattern matching / indexing question
Hi all, thank you for your patience. I am dealing with a large dataset detailing patients and medications Medications are hard to code, as they are (usually) meaningless unless matched with doses. I have a dataframe with vectors (Drug1, Drug2..... Drug 16) and individual patients are represented by rows. The vectors are actually factors, with 100s of possible levels (all the drugs the patient
2006 Jan 18
2
Display an Image on a Plane
Hi, I am new to R and I would like to display an image on a plane in a 3D plot, i.e. I would like to be able to specify a theta and a phi parameters like in the function persp to display a 2D image on an inclined plane. Regards, vincent [[alternative HTML version deleted]]
2006 Jan 18
2
Display an Image on a Plane
Hi, I am new to R and I would like to display an image on a plane in a 3D plot, i.e. I would like to be able to specify a theta and a phi parameters like in the function persp to display a 2D image on an inclined plane. Regards, vincent [[alternative HTML version deleted]]
2009 Dec 16
2
What is the fastest way to see what are in an RData file?
Currently, I load the RData file then ls() and str(). But loading the file takes too long if the file is big. Most of the time, I only interested what the variables are in the the file and the attributes of the variables (like if it is a data.frame, matrix, what are the colnames/rownames, etc.) I'm wondering if there is any facility in R to help me avoid loading the whole file.
2006 Jan 05
2
Suggestion for big files [was: Re: A comment about R:]
[ronggui] >R's week when handling large data file. I has a data file : 807 vars, >118519 obs.and its CVS format. Stata can read it in in 2 minus,but In >my PC,R almost can not handle. my pc's cpu 1.7G ;RAM 512M. Just (another) thought. I used to use SPSS, many, many years ago, on CDC machines, where the CPU had limited memory and no kind of paging architecture. Files did
2007 Oct 11
6
confusion with R syntax
I just noticed something by accident with R syntax that I'm sure is correct but I don't understand it. If I have a simple numeric vector x and I subscript it, it seems that I can then subscript a second time with TRUE or FALSE, sort of like a 2 dimensional array in C. Does someone know if this is documented somewhere Because it's neat but I never knew it existed. To me it seems like a
2006 Jun 04
4
xy.coords(MATRIX) bug in code or documentation (PR#8937)
Hi, people. xy.coords() does not behave like its documentation says, when given some matrices. ?xy.coords says: If 'y' is 'NULL' and 'x' is a [...] formula [...] list [...] time series [...] matrix with two columns [...] In any other case, the 'x' argument is coerced to a vector and returned as *y* component [...] Now, consider this short
2005 Apr 11
2
R_LIBS difficulty ?
Hi, R people. I'm shy reporting this, as a bug in this area sounds very unlikely. Did I make my tests wrongly? I'm still flaky at all this. Let me dare nevertheless, who knows, just in case... Please don't kill me! :-) Not so long ago, I wrote to this list: > (For now, [the library code] works only for me when I do _not_ use `-l > MY/OWN/LIBDIR' at `R CMD INSTALL'
2007 Oct 12
2
Plotting question
I am constructing plots ( regular not lattice ) and my initial command is par(mar=c(3,4,2,2), mfcol=c(5,2)) and then I create 10 plots on the page. It looks great but the plots on the page go in the order 1 6 2 7 3 8 4 9 5 10 Where the numbers denote decile breakdowns. Is there an easy way to make them go from left to right so 1 2 3 4 5 6 7 8 9 10 I could try
2006 Jul 16
2
Matrices given to pt? [was: [R] for loops and counters]
Hi, people. I was a bit intrigued by the message quoted below. Indeed, if pt() is given a matrix, it returns a matrix. Should this feature be documented? ?pt speaks about "a vector of quantiles", and says nothing about the type of what it returns. The same might presumably apply to other distribution-related functions. ----- Forwarded message from Martyn Plummer <plummer at
2006 Nov 14
2
putting a column name on a zoo object
does anyone know how to put a column name on a zoo object. I think achim and gabor are off line or they have gotten totally tired of me an decided to ignore me ( which is totalyy understandable ). logbidask<-log((aggfxdata[,"bid"] + aggfxdata[,"ask"])/2.0) logbidask doesn't have a name and I can't figure out how to get one on it ? aggfxdata is a zoo object.
2007 Aug 29
1
Excel (off-topic, sort of)
Except for the ability to perform circular recalculation, I believe that the closest programming analogy to a spreadsheet is a functional programming language. Check out Haskell (or LISP or Erlang) to do what you describe. -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Fran?ois Pinard Sent: Wednesday, August 29, 2007
2006 May 15
2
Truncated labels in hist (PR#8864)
Hi, people. Executing the following command: hist(rpois(100,5), labels=TRUE) yields a graphic in which some labels are truncated (on an X11 device). The truncated labels are those over the highest bars. The hist function should ideally manage enough room for the labels, automatically. (Specifying ylim solves my problem, but yet, hist could be frienlier.) --please do not edit the
2007 Aug 16
4
Combine matrix
Hi R user, I am new to R, and I have a very simple question for you. I have two matrix A and B, with internally redundant rownames (but variables are different). Some, but not all the rownames are shared among the two matrix. I want to create a greater matrix that combines the previuos two, and has all the possible combinations of matching rownames lines among matrix A and B. looking for the
2007 Jun 12
3
Panel data
Dear all R users, I have a small doubt about panel data analysis. My basic understanding on Panel data is a type of data that is collected over time and subjects. Vector Autoregressive Model (VAR) model used on this type of data. Therefore can I say that, one of statistical tools used for analysis of panel data is VAR model? If you clarify my doubt I will be very grateful. Thanks and regards,
2007 Aug 27
1
R 2.5.1 - Rscript through tee
Hi, people. I met a little problem for which someone might have a solution. Let's say I have an executable file (named "pp.R") with this contents: #!/usr/bin/Rscript options(echo=TRUE) a <- 1 Sys.sleep(3) a <- 2 If I execute "./pp.R" at the shell prompt, the output shows the timely progress of the script as expected. If I use "./pp.R | tee