similar to: setting elements to NA across an array

Displaying 20 results from an estimated 10000 matches similar to: "setting elements to NA across an array"

2011 Sep 27
1
array extraction
hello everyone. Look at the following R idiom: a <- array(1:30,c(3,5,2)) M <- (matrix(1:15,c(3,5)) %% 4) < 2 a[M,] <- 0 Now, I think that "a[M,]" has an unambiguous meaning (to a human). However, the last line doesn't work as desired, but I expected it to...and it recently took me an indecent amount of time to debug an analogous case. Just to be explicit, I would
2005 Jan 12
4
Finding seasonal peaks in a time series....
I have a seasonal time series. I want to calculate the annual mean value of the time series at its peak (say the mean of the three values before the peak, the peak, and the three values after the peak). The peak of the time series might change cycle slightly from year to year. # E.g., nPts <- 254 foo <- sin((2 * pi * 1/24) * 1:nPts) foo <- foo + rnorm(nPts, 0, 0.05) bar <- ts(foo,
2005 Mar 03
3
creating a formula on-the-fly inside a function
I have a function that, among other things, runs a linear model and returns r2. But, the number of predictor variables passed to the function changes from 1 to 3. How can I change the formula inside the function depending on the number of variables passed in? An example: get.model.fit <- function(response.dat, pred1.dat, pred2.dat = NULL, pred3.dat = NULL) { res <- lm(response.dat ~
2008 Nov 17
1
coerce data.frame with table-like data to a table for use with barchart.table
I have a data.frame containing survey data that is already organized like a table: > foo Excellent Very Good Good Fair Poor Very Poor Question 1 8 7 3 0 0 0 Question 2 5 5 7 1 0 0 Question 3 7 10 1 0 0 0 > class(foo) [1] "data.frame" > I would like to make a barchart
2005 Jan 31
2
changing the time base in a ts
I'm probably apporaching this all wrong to start but.... Suppose I have a monthly time series and I want to compute the mean of months 6,7, and 8. I want to plot the original time series and the seasonal time series, one above the other. When I do that as below the time series don't line up for reasons that are obvious. How can I change the base of the seasonal time series so I can make
2004 Dec 14
2
drawing a rectangle through multiple plots
How do I draw a rectangle across multiple plots on a device? E.g., def.par <- par(no.readonly = TRUE) par(mfrow = c(3, 1)) plot(1:10, rnorm(10), ylim = c(-4,4), type = "l") plot(1:10, rnorm(10), ylim = c(-4,4), type = "l") plot(1:10, rnorm(10), ylim = c(-4,4), type = "l") rect(2, -4, 3, 4) par(def.par) I want the rectangle to extend across the whole device. How
2007 May 27
1
na.approx and columns with NA's
Hi, I have a object 'zoo': dim(zz) [1] 720 5551 where some columns only have NA's values (representing land data in a sea surface temperature dataset) I find straightforward the use of 'na.approx' for individual columns from the zz matrix, but when applied to the whole matrix: zz.approx<-na.approx(zz) Erro en approx(along[!na], y[!na], along[na], ...) : need
2010 Jan 12
1
coerce vector into array - change filling sequence
Dear all, When I coerce a vector into a multi dimensional array, I would like R to start filling the array along the last dimension, then the 2nd last etc. Let's jump straight into an example. x <- 1 : 24 y <- array(dim=c(2,2,6)) I would like to have: y[1,1,1] = 1 y[1,1,2] = 2 ... y[1,1,6] = 6 y[1,2,1] = 7 y[1,2,2] = 8 ... y[2,1,1] = 13 ... y[2,2,1] = 19 if I do y<- array(x,
2009 Mar 06
2
How to apply a function to slices of multidimensional arrays, and not just iterating through single elements
Hello, If I want to apply some f(x) to such chunks of the the array dim(A)==c(d1,d2,d3,..,dk,...,dn) which are defined by A[...,ik,...] (ik belongs to {1,..,dk}), for now I use iteration via 'for (i in dim(A)[k]) f(A[...,k,...])' . Is there any more elegant approach, e.g like in 'apply' function which you can use on margin of the array. Just in my case I want the entire slice
2010 Sep 15
1
Format Data Issue??
R Users, I am new to R and have tried to figure out how to automate this process instead of using excel. I have read in this dataframe into r with read.table. I need to reshape the data from the first table into the format of the second table. TractID StandID Species CruiseDate DBHClass TreesPerAcre Carbon Stand 1 Loblolly Pine 5/20/2010 10 1.2 Carbon Stand 1 Loblolly Pine
2009 Jan 28
1
gls prediction using the correlation structure in nlme
How does one coerce predict.gls to incorporate the fitted correlation structure from the gls object into predictions? In the example below the AR(1) process with phi=0.545 is not used with predict.gls. Is there another function that does this? I'm going to want to fit a few dozen models varying in order from AR(1) to AR(3) and would like to look at the fits with the correlation structure
2006 Nov 14
2
Repeated measures by lme and aov give different results
I am analyzing data from an experiment with two factors: Carbon (+/-) and O3 (+/-), with 4 replicates of each treatment, and 4 harvests over a year. The treatments are assigned in a block design to individual Rings. I have approaches this as a repeated measures design. Fixed factors are Carbon, O3 and Harvest, with Ring assigned as a random variable. I have performed repeated measures analysis
2005 Jan 03
2
Two brief questions concerning sapply. Can anyone please help?!
To anyone who can help: I have two brief questions concerning sapply. Following below is the code for my example. The two problems are described at the end of the code: site <- rep(2:6, each = 12) tillage <- rep(c(1,-1), each = 6, times = 5) carbon <- c(18.23, 16.06, 17.81, 16.07, 17.26, 17.08, 14.92, 15.88, 12.11, 14.23, 16.99, 13.57, 20.34, 20.3,
2013 Jun 06
3
installing carbon / passing PYTHONPATH to pip package provider?
My environment: Ubuntu LTS 12.04, carbon (https://github.com/graphite-project/carbon) 0.9.9 installed using "pip". I just learned why when I run "pip freeze" on a system I don''t see the "carbon" package even when it installed successfully - I should run it with "PYTHONPATH=/opt/graphite/lib/ pip freeze". (ref:
2010 Nov 04
5
Sorting data from one column with strings
Hello, I have tried to find this out some other way, but unsuccessful I have to try this list. I assume this should be quite simple. I have a dataset with 4 columns, "Sample_no", "Species", "Nitrogen", "Carbon" in csv format. In the species column I have many different species with varying number of obs per species Eg "Sample_no"
2004 Jun 05
1
Crash in OSX (PR#6940)
Full_Name: Murray Pung Version: 1.9.0 OS: OSX Mac Submission from: (NULL) (134.148.20.33) Date/Time: 2004-06-05 12:32:30 +1000 OS Version: 10.3.4 (Build 7H63) Report Version: 2 Command: R.bin Path: /Library/Frameworks/R.framework/Resources/bin/R.bin Version: 1.9.0 (R 1.9.0) PID: 358 Thread: 0 Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_PROTECTION_FAILURE (0x0002) at
2005 May 03
1
Problem: R lässt sich nicht starten
Hallo, ich schreibe einfach mal deutsch, und hoffe dass Du das auch verstehst (if not write me back in English). OS X 10.3.9 Ich habe R 2.1.0 installiert, und das Programm hat auch funktioniert. Will wenig sp??ter wieder mit R arbeiten, es l??sst sich aber nicht mehr starten. "Das Programm R wurde unerwartet beendet", w??hrend ich versuche es durch Doppelklicken auf das R.app-symbol
2005 Jul 25
2
R Cocoa GUI 1.12 (R 2.1.1 Framework) crashes on acf() (PR#8032)
After I upgraded my installation of R for OS X (Tiger) to 1.12, it consistently crashes when calling the function acf() [stats lib]. Roberto Osorio
2013 Jul 09
1
Sending carbon copy mails from R
Hi, I am using sendmailR package to send mails from R. I am not able to make carbon copy work properly. If I specify multiple recipients in to field, then they all receive individual emails and not carbon copies My sample code is require(sendmailR) header <- list(cc="b.mali@abc.com") to <-
2010 Sep 16
1
Survival Analysis Daily Time-Varying Covariate but Event Time Unknown
Help! I am unsure if I can analyze data from the following experiment. Fish were placed in a tank at (t=0) Measurements of Carbon Dioxide were taken each day for 120 days (t=0,...120) A few fish were then randomly pulled out of the tank at different days, killed and examined for the presence of a disease T= time of examination in days from start (i.e. 85th day), E = 0/1 for nonevent/event My