similar to: How to extract part of an array?

Displaying 20 results from an estimated 140 matches similar to: "How to extract part of an array?"

2010 Feb 11
1
Using sapply on a two argument function
Dear R users, I have a function (simplified here) that accepts two arguments and performs various calculations: foo <- function(y, x) { a <- y*sqrt(x) b <- a+2 c <- a*b return(c) } If I call the function as follows I get the result I desire: > foo(.1, 1:12) [1] 0.2100000 0.3028427 0.3764102 0.4400000 0.4972136 0.5498979 0.5991503 0.6456854 0.6900000 0.7324555 0.7733250
2012 Nov 23
6
Summary statistics for matrix columns
Hi, is there a way I can calculate a summary statistics for a columns matrix let say we have this matrix x <- matrix(sample(1:8000),nrow=100) colnames(x)<- paste("Col",1:ncol(x),sep="") if I used summary summary(x) i get the output for each column but I need the output to be in matrix with rownames and all the columns beside it this how I want it
2010 Mar 27
5
producing a QQ plot.
Hello everyone I'm a beginner in Stats and R, I'm using R 2.10.1. I need to create a multivariate qq plot, there is 8 variable group with each has 55 number of input. An example of what I did so far, just to get my point out: > data=read.csv(file.choose(),header=T) > data country village group av_expen P2ary_ed no_fisher 1 Cook Islands Aitutaki D
2007 Dec 12
3
Adding data labels to Lattice plots
Hi, I am new to lattice graphics and have the following question. I have a dataframe d2: cat PointsInTime MeanScore 1 Parent Intake 26.25000 2 Youth Intake 9.75000 3 Worker Intake 20.63636 4 Parent Discharge 24.00000 5 Youth Discharge 15.60000 6 Worker Discharge 23.90909 and to produce a plot I am using the following code print(xyplot(MeanScore ~
1998 Oct 22
1
crosstab means
I would like to obtain a crosstabulation of means(var, quantiles...) i.e. I have a data frame with Var-i, Var-j, Var-k, Var-X, var-Y I like to have the mean of Var-X for each combination of Var-i,Var-j. One solution would be: by(var-i,Var-j,mean(Var-x)) but I would like it better formatted and with mean,S.Dev,n for each cell? Does anybody have some function to do this or some ideas how to go
2012 Aug 27
1
How to average time series data around regular intervals
Hi, I'm pretty new to R and have run into a task which although I'm certain is within R's capabilities, falls outside of mine. :-) Consider the following data set: 2012-07-22 12:12:00, 21 2012-07-22 12:15:00, 22 2012-07-22 12:18:00, 24 2012-07-22 12:39:00, 21 2012-07-22 12:45:00, 25 2012-07-22 12:49:00, 26 2012-07-22 12:53:00, 20 2012-07-22 13:00:00, 18 2012-07-22 13:06:00, 22 My
2009 Nov 23
3
FUN argument to return a vector in aggregate function
Hi All, I am currently doing the following to compute summary statistics of aggregated data: a = aggregate(warpbreaks$breaks, warpbreaks[,-1], mean) b = aggregate(warpbreaks$breaks, warpbreaks[,-1], sum) c = aggregate(warpbreaks$breaks, warpbreaks[,-1], length) ans = cbind(a, b[,3], c[,3]) This seems unnecessarily complex to me so I tried > aggregate(warpbreaks$breaks, warpbreaks[,-1],
2008 Aug 19
0
R-code: for those who like a challenge; HELP
I'll try to be more clear, but will have to give much more info. Here we go.... As part of my Masters in Public Health I writing a dissertation reviewing the mortality trend of internally displaced persons in camp settings in Sub Saharan Africa. I have 50 surveys with - crude mortality rate (cmr), CMR lower confidence interval(cmrlci), CMR upper confidence interval(cmruci), - recall period
2015 Jun 21
2
Trying to re-install ZFS drivers
What should have been a routine upgrade to ZFS 0.6.4.1-1.el6.x86_64 somehow failed, and now I've lost access to a 2T raidz2 array. I've tried removing all zfs and related packages (spl*), then starting fresh. For reasons that have have nothing to do with this problem (I don't think), I'm still booted to kernel 2.6.32-431.29.2.el6.x86_64, and there are no other kernels installed.
2010 Jan 18
3
Using the output of strsplit
I successfully combined my data frames, and am now on my next hurdle. I had combined the data and quarter, and used tapply to count the entries for each unique date/quarter pair. ar= tapply(ewrgnd$gw, list(ewrgnd$dq), sum) #for each date/quarter combination sums the gw (which are all 1) dq=row.names(ar) spl=strsplit(dq) But I need to split them back into the separate date and quarter. So I used
2004 Feb 19
1
piece wise application of functions
Dear all, After struggling for some time with *apply() and eva() without success, I decided to ask for help. I have 3 lists labeled with, each contains 3 different interpolation functions with identical names: > names(missgp0) [1] "spl.1mb" "spl.2mb" "spl.5mb" > > names(missgp1) [1] "spl.1mb" "spl.2mb" "spl.5mb" > >
2007 Aug 30
1
Barplot2 using for loop, how to adjust margins?
Hi R-users, I inted to make multiple plots using for loop. The question is how can I adjust the left hand side margin of the plot according to the names.arg argument in barplot2. In every plot I have different annotations in the y axis and they vary in length. Now when I have fixed margins opar <- par(mar=c(3,15,0,2)... I get the same margins in all of the plots. That leaves lots of white
2009 May 24
2
how to implement a circular buffer with R
Some wavelet analysis experts have implemented periodic boundary conditions for signals. I need to implement a circular buffer. Something like: "12345abcdefgh12345abcdefgh" so that at each step the riightmost element is moved to the leftmost index and everything else is properly shifted: "h12345abcdefgh12345abcdefg", "gh12345abcdefgh12345abcdef", .... My
2002 Nov 25
2
Pspline smoothing
Dear all, I'm trying to use the Pspline add-on package to fit a quintic spline (norder =3), but I keep running into a Singularity error. > traj.spl <- smooth.Pspline(time, x, norder=3 ) Error in smooth.Pspline(time, x, norder = 3) : Singularity error in solving equations > Playing around with the other parameters produces an "unused arguments" error: > traj.spl
2005 Jul 20
2
.spl files
I am not certain that this is the right place to post this, but maybe some kind soul can point me in the right direction if not. And I apologize if this is the wrong spot...The reason I posted here is that I recall running across a syslinux changlog that said "..added support for reading .spl..." files. I want to customize the suse boot up splash screens (for a CD install). I have been
2011 Jan 14
3
RSQLite - How to express(or save) a dataframe as an output?
Dear R helpers Suppose following is an output due to some R process. I wish to save it as a table in 'temp.db' df <- data.frame(x = c(5, 4, 3, 11), y = c(25, 16, 9, 121))     library(RSQLite)     write('** Initializing','')     drv <- dbDriver("SQLite", shared.cache = TRUE)     con <- dbConnect(drv, dbname = "temp.db",
2009 Jul 05
2
integrar resultado de splines cubicos
hola soy nuevo usuario de R y necesito crear un objeto p tal que, p=lambda*integral[f´´(x)^2 dx ] donde "lambda" es uno de los parametros que resultan de la funcion "smooth.spline()" y la integral es sobre la derivada 2 de esa misma funcion... dos cuestiones: 1) como extraigo lambda de los resultados de smooth.spline() para usarlo como objeto cuando lo requiera y 2) como
2010 Apr 02
4
Derivative of a smooth function
Dear All, I've been?searching for?appropriate codes to compute the rate of change and the curvature?of ?nonparametric regression model whish was denoted by a smooth function?but?unfortunately?don't manage to?do?it. I presume that such characteristics from a smooth curve can be determined by the first and second derivative operators. The following are the example of fitting a
2009 Nov 02
4
Incremental ReadLines
I've been trying to figure out how to read in a large file for a few days now, and after extensive research I'm still not sure what to do. I have a large comma delimited text file that contains 59 fields in each record. There is also a header every 121 records This function works well for smallish records getcsv=function(fname){ ff=file(description = fname) x <- readLines(ff)
2009 Sep 08
1
Character manipulation using "strsplit" & vectorization
Dear R users, Suppose I have a data set with inconsistent names for a field. I desire to make these to consistent names. i.e "University of New Jersey", "New Jersey Uni", "New Jersey University" (3 different inconsistent names) to "The University of New Jersey" (consistent name) Below are arbitrary data set produced from "state.name" (built