Contributed packages have copies of their vignettes on CRAN (in their
package page at /web/packages/).
Since base packages no longer have a page here, I can't find a web link to them.
I'm aware that I can find the vignette via browseVignettes() or
vignette("vignettename", package = "packagename")
> x=1:80
>
> I want to sum up first 8 elements of x, then again next 8 elements of x,
> then again another 8 elements. So, my new vector should look like:
>
> c(36,100,164,228,292,356,420,484,548,612)
>
> I used:
>
> aggregate(x,list(rep(1:10,each=8)),sum)[-1]
>
> or
>
> rowsum(x,group=r
> I ran into some trouble handling missing values.
>
> Assume 2 vectors (numeric) including NAs
>
> a <- c(rep(seq(1,4),4),NA,NA)
> b <- c(sample(1:2,14,replace=T),NA,NA,1,2)
>
> I want to replace the values of vector a that are smaller than 2 and
> larger than 3 into NAs only in case vector b e
> I am new to R, and was wondering how to do 3D linear
> regression in R. In other words, I need to Fit a
> 3-Dimensional Line to Data Points (input).
>
> I googled before posting this, and found that it is
> possible in Matlab and other commercial packages. For
> example, see the Matlab link:
> h
> I am looking to making a panel of pie charts fo some of my
> dritribution data . I was wondering if there is a way in any R
> package to write a small script to do so.
pie() will do you a one-off pie chart, but there is no equivalent using
grid/ lattice graphics. You could write a panel.pie
> > try(log(rnorm(25)),silent=TRUE)
> [1] -0.26396185 NaN NaN -0.13078069 -2.44997193
> -2.15603971 NaN 0.94917495 0.07244544 NaN
> [11] -1.06341127 -0.42293099 -0.53769569 0.95134763 0.93403340
> NaN -0.10502078 NaN 0.30283262 NaN
> [21] -0.1
> Can someone help me to understand the meaning of the following R line?
>
> list(fk5 ~ .)
fk5 ~. is a formula, most likely used by a regression (or similar model).
fk5 is the response variable, and the dot is a placeholder for 'whatever
was on that side of the formula before'. (This is usually
> For example, c("dog.is.an.animal", "cat.is.an.animal", "rat.is.an.
> animal"). How can I identify the common prefix is ".is.an.animal"
> and delete it to give c("dog", "cat", "rat") ?
foo <- c("dog.is.an.animal", "cat.is.an.animal", "rat.is.an.animal")
sub(".is.an.animal", "", foo)
Being pedant
> is it possible to sort a file by the row names?
I presume you mean a data frame rather than a file. In which case the
answer is yes:
df <- data.frame(a=1:10, b=rnorm(10), row.names=sample(letters[1:10]))
df[order(rownames(df)),]
Regards,
Richie.
Mathematical Sciences Unit
HSL
-
> I wonder if there is any swap function in R that does the following:
> x <- seq(1,10,12)
This just makes x equal to 1. I'm guessing you meant something like
x <- 1:10
> x1 <- swap(x)
> x1
> 1 8 3 4 5 6 7 2 10
It's not terribly clear what you want swap to do. You can reorder the
elements of
> Hello Richie,
> I would like to do three (or k) swap steps in each step just 2 ID
> recursive swaping
> x <- 1:10
> swap <- function(x){
> a <- sample(x,2)
> x[x==a[1]] <- swap[2]
> x[x==a[2]] <- swap[1]
> return(x)
> }
> swap(swap(swap(x))) -> mix
I tried my best with a response be
> I have to match names where names can be recorded with errors or
additions.
> Now I am searching for a string search function which returns always
> the "closest" match. E.g. searching for "Washington" it should
> return only Washington but not Washington, D.C. But it also could be
> that the
> I am trying to debug a program, and I think tryCatch will help. The
> functions involved
> process through so many times before I encounter the error, things
> are a bit slow to
> use debug and browser().
>
> I've read the help file and postings on conditions, and am still
> having trouble.
> I don't understand the warning I get when executing the following code:
>
> x <- rnorm(100)
> h <- hist(x, plot= FALSE, freq = FALSE)
The warning is
"Warning message:
In hist.default(x, plot = FALSE, freq = FALSE) :
argument ‘freq’ is not made use of"
The explanation is pretty simple.
freq
> I have a survivor curve that shows account cancellations during the
> past 3.5 months. Â Fortunately for our business, but unfortunately
> for my analysis, the survivor curve doesn't yet pass through 50%.
> Â Is there a safe way to extend the survivor curve and estimate at
> what time we'll h
the second step in my exercice is to calculate the sum of the amout for each
class et not the frequency
i have this vector
x y
1 100
2 1500
3 3250
4 6250
5 2000
6 450
i want to use the function table
> I'm trying to draw the density function of a mixed normal distribution
> in the form of:
> .6*N(.4,.1)+ .4*N(.8,.1)
> At first I generate a random sample with size 200 by the below code:
> means = c(.4,.8)
> sds = sqrt(c(.1,.1))
> ind = sample(1:2, n, replace=TRUE, prob=c(.6,.4))
> x=rnorm(n,mean
> what do you mean by "%d-%b-%y". is it reading format or writing format.
"%d-%b-%y" is a date format - see the help page for strptime.
Example usage:
strptime("01-Jan-84", "%d-%b-%y")
strftime(Sys.time(), "%d-%b-%y")
Regards,
Richie.
Mathematical Sciences Unit
HSL
---
> I have written a function in order to analyse gaze paths. It works
> with the test data but when I try to apply the function to a data
> frame that stores "the real data" in columns I receive the error
> message that the
>
> " In if (pp > 1) { :
> condition has length > 1 only the first el
> I have an other problem, I have this vector signData with an alternation
of
> 1 and -1 that corrispond to the duration of two different percepts. I
> extracted the durations like this:
>
> signData<- scan("dataTR10.txt")
> dur<-rle(signData)$length
I think that last line should be
dur<-rle(si
> Is there anyone know if BUGS language allows the combination of
> variables as response
> It seems doesn't work in my model. The problem is between two ##.
> > modelCompile(numChains=1)
> multiple definitions of node bm[1]
> ###
> bm[iter] <-
> I'm new to R, and I've sent this message as a non-member, but since it's
> pretty urgent, I'm sending it again now I'm on the mailing list (Thanks
> Daniel for your suggestion nevertheless).
>
> I have calculated a regression in the form of M ~ D + O + S, and I would
> like to take this regressi
> I would like to be able to plot histograms/densities on a semi-log or
> log-log scale.
> # Get a random log-normal distribution
> r <- rlnorm(1000)
>
> # Get the distribution without plotting it using tighter breaks
> h <- hist(r, plot=F, breaks=c(seq(0,max(r)+1, .1)))
>
> # Plot the distribu
> Ive found out a way around my problem. I was trying to plaot a histogram
of
> strings, but I had to change it into integers. I ran an sql query on the
> original DB that I got the CSV file from and used COUNT to get the
number of
> each unique item in a given column. I then used these numbers t
> I?ve written a script to run several multivariate statistical analysis
> automatically.
> As one result a biplot and screeplot is produced.
> Now I?d like to display the name of the inputdatset as part of the title
of
> these graphics and I do not want to enter it each time I run the script.
> H
> 1. How to plot several lines in a figure? Suppose I have several sets of
> points (xi,yi), where xi and yi are equal-length vector. plot(x1,y1)
will
> give a line connecting these points. Another plot(x2,y2) will erase what
> plot before and plot the new line. Can I have these lines all drawn in
> There are six assignments in total. It won't take you long if you were
> familiar with R. For those who are interested, please send me an email
> with your profile (your experience with R, how long and how often have
> you been using it.) I will be paying through paypal. Thanks!
Now see, you mad
> fp is a data frame like this
>
> ,[ fp ]
> |Frequenz AmpNorm
> | 1 3322 0.0379490639
> | 2 3061 0.0476033058
> | 3 2833 0.0592954124
> | 4 2242 0.1275510204
> `
>
> i want to find the "Frequenz" where "AmpNorm" is max.
Use which.max.
fp <- data.frame(Freqe
> I have a graph with groups of variables. I have include the group
> names as variables so that I can have them positioned correctly.
> Unfortunately this means that the group names have to follow all of
> the same rules as the variables within the groups. I would rather
> have those group n
> Can anyone tell me what is skip=2, skip =7
>From ?read.csv:
"skip: integer: the number of lines of the data file to skip before
beginning to read data."
> and %in% mean here?
%in% matches values; see ?'%in%', and example('%in%')
Regards,
Richie.
Mathematical Sciences Unit
HSL
--
It seems that the structure of your data is that you have two groups
("Real Bad Stuff" and "Other Crazy Things") which are then subdivided into
further categories. I'd be tempted to set your data up like this:
dfr <- data.frame(
score=c(23, 14, 17, 8, 43, 13),
group=rep(c("Real Bad Stuff"
> I have some trouble with the number of decimals in R (currently R
> 2.9.0). For instance:
>
> > options()$digits
> [1] 3
>
> let me hope that I will get three digits where useful when a number is
> printed. BUT:
>
> > 44.25+31.1+50
> [1] 125
>
> No way to get the right result 125.35
>
>
> if i have the following function,
>
> f <- function(x) x^3-2*x^2+3*x-5
>
> i need a simple function for the derivative of this with respect to
> 'x', so that i can then sub in values to the the derivative
> function, and use Newtons method of finding a root for this.
You could take a look at
> I have a large data frame and I want to look at the distribution of
> each variable very quickly by plotting an individual histogram for
> each variable.
> I'd like to do so using lattice.
>
> Here is a small example using the iris data set:
>
> histogram(as.formula(paste("~",paste(colnames(i
> As to hist,the help file says:" R's default with equi-spaced breaks
> (also the default) is to plot the counts in the cells defined by
breaks."
> I wanna know how the break is calculated by R?
>
> In other words: break = (max - min)/(number of group) but how the
> "number of group" is calcu
> I would like to have no ticks on a scale that represents a factor. The
> tick.number argument from scales does not work in such a situation, as
> the help page as well as this simple (fairly stupid) code show:
>
> require(lattice)
> fact<-gl(4,1,labels=LETTERS[1:4])
> y<-c(1,4,3,2)
> xyplot(y~fa
> I want generate R code to determine the real root of the polynomial
> x^3-2*x^2+3*x-5. Using an initial guess of 1 with Newton's method.
> Homework? - see your instructor! Otherwise, provide minimal
self-contained
> code and show us where you are stuck.
It gets a little suspicious when there
> When i want to do ANOSIM i get an NaN error message. What is wrong?
> > (lots of other code)
> > iwithin=rep(0,(N*(N-1)/2) )
> > r.w=sum(r*iwithin)/sum(iwithin)
iwithin is a vector of zeroes and so is its sum. r*iwithin is also a
vector of zeroes, and so is its sum. Thus r.w=sum(r*iwithin)/su
> I'm looking for algorithms that assist in spreading out crowded labels,
e.g.
> labels of points in a scatter plot, in order to obtain a nicer visual
> appearance and better legibility.
>
> I'm probably just stuck because I didn't find the right key words for a
> successful search on the R w
> since some days I try to use the versions 2.35-4 of the survival
> package instead of versions 2.31, I had installed until now. Several
> changes in print.survfit, plot.survfit and seemingly in the structure
> of ratetabels effect some of my syntax files.
> Is there somewhere a documentation o
> One thing I find most frustrating about R is how difficult it is to use
> Google (or any other search tool) to look for answers to my R-related
> questions. With languages with even slightly more distinctive names
like
> Perl, Java, Python, Matlab, OCaml, etc., usually including the name of
th
>I am trying to parse XML file ( binary hex) but get an error.
> Code I am using is:
> xsd = xmlTreeParse(system.file("exampleData", "norel.xsd", package =
> "XML"), isSchema =TRUE) doc = xmlInternalTreeParse(system.
> file("exampleData", "LogCallSummary.bin", package = "XML")) Start
> tag ex
> I am new to R. Yesterday I passed the afternoon reading the
> introduction and language reference, but I could'nt find a way to do a
> 3d plot of the density of a data table of size 2.
> I am trying with:
>
> plot(density(t(t2)))
>
> but it mixes the two columns and calculate the density like
> this is the command i made for a normal distribution, but when i try to
plot
> the histograms, i dont know why the bars don't stick on the line...
>
> nsamples<-1000
> sampsize<-15
> Samples<-matrix(rnorm(nsamples*sampsize,0,1),nrow=nsamples)
> a<-apply(Samples,1,var)
> NC14<-a*14
> x<-0:40
>
> I want to make a simple plot, here is my code:
http://gist.github.com/118550
> Unfortunately, the annotation of both the x- and y-axis are not correct,
as
> you can see in the following picture:
> http://www.nabble.com/file/p23739356/plot.png
> I am not an expert of R, so maybe someone can po
> I am interested in modeling hydrological extreme events. I found
> MSClaio2008 very interesting function. In this function four
> criterions for choosing distributions. Can we call these criterions
> as model selection techniques or goodness of fit techniques or both?
> Because goodness of fit
> I have a matrix of both negative and positive values that I would like
> to randomly sample with the following 2 conditions:
>
> 1. only sample positive values
> 2. once a cell in the matrix has been sampled the row and column of
> that cell cannot be sampled from again.
>
> #some dummy data
>
> I want to plot data such that the 3 time points(a,b,c) lie on the X-axis
and
> the values of these times points are on Y-axis for n samples (e.g.100).
>
> So, I have an object x, dim 100 4, it is a dataframe (when checked the
> class)
> x =
> name a b c
> 10.11 1.11 0.8
> Is it possible to have variable driven csv file names? Such as:
>
> ds.name<-"bob.csv"
>
> write.table(
> distribution.data,
> file = "~//Documents/Research/Distribution Analysis/ds.name",
> sep = ",",
> col.names = FALSE,
> qmethod = "double")
Yes. You just nee
> There seems to be a way for calling R from .net. However, is there anyway
> for calling .net/C# code from R? Something similar to the RJava package
for
> .net?
To the best of my knowledge, there isn't at the moment. The latest release
of MATLAB does though, so in the spirit of
> Numbers like ``1239178547.653775" is inserted into a vector. I print
> the vector:
>
> > route_9_80_end
> [1] 1239178522 1239178526 1239178524 1239178524 1239178524
> 1239178523 1239178524 1239178522 1239178521 1239178565 1239178566
1239178566
> [13] 1239178565 1239178566 1239178566 123917856
> I have some data which needs to be plotted with lattice.
>
> library(lattice)
> cars <- c(0.1, 0.3, 0.6, 0.4, 0.9)
> trucks <- c(0.2, 0.5, 0.4, 0.5, 0.1)
> drivers<-c(121,145,167,200, 210)
> year<-c(2005,2006,2007,2008,2009)
> type<-c("local","local","foreign","foreign","foreign")
> xyplot(cars+
> I have created two functions to compute geometric means. Method 1 can
> handle even number of negative values but not large number, vice versa
> for method 2. How can I merge both functions so that both large number
> and negative values can be handled ?
>
> > geometric.mean1 <- function(x) prod
> > > geometric.mean1 <- function(x) prod(x)^(1/length(x))
> > > geometric.mean2 <- function(x) exp(mean(log(x)))
> > > geometric.mean1(c(-5,-4,4,5))
> > [1] 4.472136
> > > geometric.mean2(c(-5,-4,4,5))
> > [1] NaN
> > Warning message:
> > In log(x) : NaNs produced
> comp.x <- as.complex(c(-5,-4,4
> In general, how can I increase a vector of length m (< n) to length n
> by padding it with m - n missing values, without losing attributes?
> The two approaches I've tried, using length<- and adding missings with
> c, do not work in general:
>
> > a <- as.Date("2008-01-01")
> > c(a, NA)
> [1] "2
> i have a problem with a function that i defined:
>
> the function needs to use a function which is defined outside the
function
> but
> i realised that this is not working. a friend told me that this must be
a
> problem with
> hidden parameters.
>
> a workaround works when i just define
> I hope that question will not be too redundant (sorry if it is) but
> i don't seem able to find the answer i need in the archives...
>
> I try to create a file which would have 1.several pages and 2.
> several plots by page. I know how to make a pdf file this way, but
> my problem is that the
> I have a following data
>
> AIS LEvel
> 1 23
> body regionA 10 15 20
> B 15 25 15
>
> Now I want to plot a barplot and in each bar (corresponding a body
re
> I am looking to create a pie chart from a given column in a .csv file.
>
> My class variables are as follows:
>
> entry_type, uniquekey, types, title,url, abstract, journal,
> author, month,
> year, howpublished
>
> So say I want to export a pie chart that groups together all entrie
> x <- c(1, 2, 3)
> n <- 10
> ## so using the recycling rules, I would like to get from FUN(x, n)==1
> ## I am doing:
> xRecycled <- rep(x, length.out=n)[n]
>
> This works, but it seems to me that I am missing something really basic
here
> - is there more straightforward way of doing this?
x[n
> LIST OF CONVENTIONS/STYLES FOR R:
>
> [1] R coding standards in the R Internals manual
> http://www.cran.r-project.org/doc/manuals/R-ints.html#R-coding-standards
>
> [2] Bioconductor coding standards
> http://wiki.fhcrc.org/bioc/Coding_Standards
>
> [3] Google R style
> [http://google-styleg
> In order to do this I can use the relation between count and density, but
I
> would like to know if there is a way for me to predict it upfront.
In the code for hist.default, you'll see the line
dens <- counts/(n * diff(breaks))
> Here is an example:
>
> set.seed(242)
> > Does any body know how I can see the code behind qbeta function?
>
> As the code seems to be internal, you'll need to download the r-source
> code and find it in there. In my copy of R it is here:
> R-2.11.1/src/nmath/qbeta.c
An alternative is to view the source code online. The code for qbe
> I am looking for an R implementation of the four parameter kappa
> distribution (cdf, pdf, quantile, and ransom numbers), or at a minimum,
> the generalized logistic distribution.
I searched for "kappa distribution" on Rseek (http://www.rseek.org) and
the functions you want appear to be in th
> I'm attempting to plot a cubic relationship between two variables
> controlling for the effects of a third variable. In this short
> example, I'm trying to use AGE to predict CORTEX while controlling for
> the effects of TIV (total intracranial volume):
>
>
> cortex =
> I am fairly new to R and this list (this is my first post), so I am
> wondering whether
> there is a possibility to view posts on this list conveniently on a
> website besides
> reading my email.
You can see them on Nabble, but there is a delay of a couple of hours.
http://www.nabble.com/R-hel
> I need to apply a function on each column of each matrix contained in
> a list. Consider the following code,
>
> > x <- 1:3
> > my.data <- list(matrix(c(1,2,3,4,5,6),ncol=2),
> > matrix(c(4,5,6,7,8,9),ncol=2))
> >
> > par(mfrow=c(2,2))
> > results <- sapply(1:length(my.data),
> >
> > > I realized that not everyone has Matlab and that basically the
issue
> > > is purely how to deal with the returned data in R, so I have
revised
> > > my example code and made it easier to copy-paste and run:
> > > #Make a data frame in R
> > >
> > > Maker <- factor(c("HP", "HP", "Son
Lila86 wrote:
>
> I have two groups (men and women) and I know per group how many of them
> smoke or don't smoke (women 40 of 200; men 100 of 300). I would like to
> know how I can compare in R if men and women differ significantly in their
> smoking. However, because there are more men in the
> I noted that there is a hsv2rgb in the C-API, but no corresponding
function in
> R, while rgb2hsv is available in R.
>
> Does the functionality of hsv2rgb hide under some other name?
I agree that it does seem like such a function ought to exist. You can
use col2rgb(hsv(...)) to get what you
>Is there a way to reorder the xaxis using lattice. Using the
> following data, the x-axis is ordered as BP GH MH PF RE RP SF VT but
> I would like the x-axis to be ordered as PF RP BP GH VT SF RE MH.
>
> Kön Skalor Tillfälle Medelvärde
> 1 Kvinnor BP 1-inskrivning 36.4
> p="v="
> q=5
> eval(parse(text=paste(p,q,sep="")))
>
> ... then the value of v is 5, OK.
>
> but I can't with strings, for example:
>
> p="v="
> q="hello friend"
> eval(parse(text=paste(p,q,sep="")))
>
> .. error
Try:
eval(parse(text=paste(p,"'",q,"'",sep="")))
Regards,
Richie.
Mathema
thegeologician wrote:
>
> ... very often time-series plots of some values are
> given rather to show the temporal correlation of these, than to show the
> actual numerical values! The same applies for plots of some sample
> values over distance (eg. element concentration over a sample or
>
thegeologician wrote:
>
> A plot of the actual temperature during a year (or thousands of years,
> as people in palaeoclimate-studies are rather used to) is just so much
> more intuitive, than some correlation-coefficients or such. I know I'm
> largely speaking to statisticians in this forum,
> I have two data frames and am running a loop to match similar rows.
> However the matching is not working well, and I suspect it is because of
> the different formats of columns. For example, in col. 1 of dataframe 1
> the nummbers are formatted as 1,2,3,4,5,6,7,8,9...31 However in col. 1
> dat
> I have the following data called mydata in a data.frame
>
> Col1 Col2 Col3 Col4 Col5
> 1 2 46 7
> 8 8 73 5
> 4 4 56 7
>
> I want to replace the data according to the following conditions
>
> Condition 1 if data <= 3, replace with -1
>
> I have a surprising problem while selecting values in a sequence created
> with the seq() function...
>...
> > test2<-seq(from=0,to=1,by=.1)
>...
> > test2==0.3
> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
>...
> Does anyones has an explanation and a solution ?
I suspe
> How would I make the default behaviour of my plots produce output such
> as the following (i.e. tick marks inside on all axes, labels only on two
> (arbitrary?) sides) without needing the five additional commands each
> time?
>
> plot(1:10, axes=FALSE)
> axis(1, tcl=0.5)
> axis(2, tcl=0.5)
> axi
> For example, the y axis shows "0 50 150". Is there any way to
> beautify the tick labels to get 0 5 10 15, and at the top of y-axis
"x10^5"
> (superscript 5) ? My plots all have different ylim, how to perform the
> beautification automatically ?
plot((0:15)*1e5, yaxt="n", ylab="")
axis(
> I have a list which consists of data frames (all data frames have the
same
> amount and type of columns but different length).
> Now, I'd like to calculate for each data frame in the list the
> density function
> of the values of the fist column ($V1).
>
> This list could be an example:
>
>
> I would like to do looping for this process below to estimate alpha
> beta from gamma distribution:
> Here are my data:
> day_data1 <-
> 123456 789 10 11 12
> 13 14 15 16 17 18 19 20 21 22 23
> 1943 48.3 18.5 0.0 0.0 18.3 0.0
> I used "which" to obtain a subset of values from my data.frame.
> however, I find that there is a "trace" of the values I have removed.
> Any suggestions would be greatly appreciate.
>
> Below is my data:
>
> d <- data.frame( val = 1:10,
> group = sample(LETTERS[1:5], 10,
> > The (imho) unintuitive behaviour is to do with the subsetting function
> > [.factor, not which. There are a couple of workarounds:
> >
> In that case, your intuition needs readjustment
>
> There are other systems which (de facto) drop unused levels by default,
> and it is a real pain t
> Suppose I write:
>
> f1 <- function(x) x + 1
> f2 <- function(x) 2 * f1(x)
> f2(10)
> # 22
> f1 <- function(x) x - 1
> f2(10)
> # 18
>
> This is quite obvious. But is there any way to define f2
> in such a way that we "freeze" the definition of f1?
f1 <- function(x) x+1
f1frozen <- f1
f2 <- fu
> Is there a way to modify the choice of notch size [1] in R's boxplot
> routine from outlining a 5% significance region, to say 1% or lower?
Yes, but it's not as simple as specifying the significance level. You'll
have to update the function boxplot.stats, specifically the line
conf <- if (do.
> I have a table like below outside R environment
>
> Varible_Name
> Labels
> Bad_Percent
> Good_Percent
> Var1_Postal_Code_Availibility
> 1
> 0,149367931
> 0,850632069
>
> 0
> 0,19709687
> 0,80290313
>
> Variable_Name column contains a single entry, the variable name, this
is
>
> What has become more and more obvious to me after I started using R
> about two years ago is that I have collected a large number of data
> files, scripts, and workspaces (.Rdata files) in several catalogs on my
> computer. It is also obvious that my memory is not up to the task of
> keeping
> x1<-paste("A", 1:6, sep = "")
> x2<- round(rgamma(6,2,1))
> x3<-paste("B", 1:6, sep = "")
> x4<- round(rgamma(6,2,1))
> data1 <- data.frame(x1,x2,x3,x4)
> I would like to get
> data2 <- c(A1=4, A2=1, A3=0,...)
> Is there any standard for such a case?
I presume that 4, 2, 0 are the first few va
> I am a new R user, and not very good at statistics and maths
> I find it difficult to find the minimum of this item:
> ((p*(b-1)-1)*(p+1)^(b-1)+1)/p^2
>
> It seems that the method optim can find the minimum. I tried several
> times , but R constanly tells that " failure to fin
> I've been trying to find a way to improve (if
> possible) the efficiency of the code, especially when the number of
> components to calculate is higher than 100.
> pca.nipals <- function(X, ncomp, iter = 50, toler =
sqrt(.Machine$double.eps))
> # X...data matrix, ncomp...number of components,
>
> How to use elseif ?
> For example, like following short python examples.
>
> *
> x = 1
> if x == 1:
> print 'same'
> *elif* x > 1:
> print 'bigger'
> else:
> print 'smaller'
> *
x=1
if(x==1) print('same') else if(x>1) print('bigger') else print('smaller')
See help('if'),
> datg=t(sapply(split(datgic, datgic$NPERMNO, drop=TRUE),
function(x){return(
> x[nrow(x),] )}))
>
>
> I get something like this...
>
> GVKEY NPERMNO GIC year
> 10001 12994 10001 55102010 2007
> 10002 19049 10002 40101015 2007
> 10009 16739 10009 40101010 1999
>
> Has this
> If I have this daily rainfall data, how do call a particular day?
> Year,Month,Day,Amount
> 1900,12,22,1.3
> 1900,12,23,0
> 1900,12,24,0
> 1900,12,25,0
> 1900,12,26,0
> 1900,12,27,0
> 1900,12,28,0
> 1900,12,29,4.8
> 1900,12,30,0.3
> 1900,12,31,0.5
> 1901,1,1,0
> 1901,1,2,3
> 1901,1,3,0
> 1901,1,4
> Hi, I have a problem regarding matrix handeling. I am working with
> a serie of matrixes containing several columns. Now I would like to
> delete those rows of the matrixes,that in one of the columns contain
> values less than 50 or greater than 1000.
Try this:
m <- matrix(runif(150, 0, 1050
> I am a new user and I have been struggling for hours. So finally I
> decide to ask you:
> If I have a matrix P, and P.2 = P%*%P, and P.3=P.2%*%P
> is there a function to calculate the power of a matrix?? if not how can
i do:
> for (i in 1:10) {P.i=P^i}
> after this I need to sum them up and m
I'm trying to set up a lattice plot with two y-axes for each panel. (Yes,
I know that multiple y-axes are generally a bad idea; the graph is for
someone else and they want it that way.) I've used a custom
yscale.component in xyplot to achieve this:
myyscale.component <- function(...)
{
ans
> T1 <- read.delim(file="S://SEDIM//Yvonne//2_5//T1.txt",col.names=
> c("Dye/Sample_Peak", "Sample_File_Name", "Size", "Height",
> "Area_in_Point", "Area_in_BP", "Data_Point", "Begin_Point",
> "Begin_BP", "End_Point", "End_BP", "Width_in_Point", "Width_in_BP",
> "User_Comments", "User_Edit"))
>
> It's fairly straightforward to plot cumulative histograms using the
hist()
> function. You do something like:
>
> h <- hist(rnorm(100), plot=FALSE)
> h$counts<- cumsum(h$counts)
> plot(h)
>
> However, I have failed to find any example where this is done using the
> lattice histogram() function
> I have tried without success to find a way including the square root
symbol
> in lattice strips as part of my conditioning labels. I have tried
> supplementing by creating a list of vectors using the var.name function
> coupled with the expression function used in xlab/ylab.
>
> xyplot(adjuste
> S=c("World_is_beautiful", "one_two_three_four","My_book")
> I need to extract the last but one element of the strings. So, my
> output should look like:
> Ans=c("is","three","My")
> gsub() can do this...but wondering how do I give the regular
expression
sapply(strsplit(S, "_"), functio
1 - 100 of 244 matches
Mail list logo