similar to: How to mean, min lists and numbers

Displaying 20 results from an estimated 10000 matches similar to: "How to mean, min lists and numbers"

2009 Mar 10
6
Pseudo-random numbers between two numbers
I would like to generate pseudo-random numbers between two numbers using R, up to a given distribution, for instance, rnorm. That is something like rnorm(HowMany,Min,Max,mean,sd) over rnorm(HowMany,mean,sd). I am wondering if dnorm(runif(HowMany, Min, Max), mean, sd) is good. Any idea? Thanks. -james
2010 Jun 02
4
Draw text with a box surround in plot.
text() can draw text on a plot. Do we have a way/function to draw text with a box surround it? Thanks, -james
2010 Jul 07
2
Sum vectors and numbers
We want to sum many vectors and numbers together as a vector if there is at least one vector in the arguments. For example, 1 + c(2,3) = c(3,4). Since we are not sure arguments to sum, we are using sum function: sum(v1,v2,...,n1,n2,..). The problem is that sum returns the sum of all the values present in its arguments: sum(1,c(2,3))=6 sum(1,2,3)=6 We do not want to turn sum(v1,v2,...,n1,n2,..) to
2009 Sep 09
3
How to return/show the indexes of unusual points in boxplot?
I am wondering if you know how to return by function or show in boxplot, the indexes of unusual points, such as, points that are outside the box or in [Q3+1.5IQR,Max]. For example, > boxplot(c(4,rnorm(20),8)) There are 2 unusual points 4 and 8. How to show the indexes of 4 and 8 in the boxplot or return them by function? Thanks, -james
2009 Mar 10
2
How to color certain area under curve
For a given random variable rv, for instance, rv = rnorm(1000), I plot its density curve and calculate some quantiles: plot(density(rv)) P10P50P90 = = quantile(rv,probs = c(10,50,90)/100) I would like to color the area between P10 and P90 and under the curve and mark the P50 on the curve. > rv = rnorm(1000) > plot(density(rv)) > P10P50P90 = = quantile(rv,probs = c(10,50,90)/100) Could
2010 May 27
2
How to catch Error Messages in R
As we knew, if a function is not used correctly, an error message will throw/display in R: > rnorm(-1) Error in rnorm(-1) : invalid arguments I would like to catch the error message or assign an error message to a variable so that I can use them some where else. So, how to catch error messages in R? Thanks, -james
2009 May 20
2
How to load data from Statistics Canada
We would like to load data from Statistics Canada (http://www.statcan.gc.ca/) using R, for example, Employment and unemployment rates. It seems to me that the tables are displayed in HTML. I was wondering if you know how to load these tables. Thanks, -james
2009 May 27
2
How to set a filter during reading tables
We are reading big tables, such as, Chemicals <- read.table('ftp://ftp.bls.gov/pub/time.series/wp/wp.data.7.Chemicals',header = TRUE, sep = '\t', as.is =T) I was wondering if it is possible to set a filter during loading so that we just load what we want not the whole table each time. Thanks, -james
2008 Mar 31
2
Call R from C#
I would like to call functions/objects of R from C#.NET environment. I was wondering whether or not it is possible. If yes, could you please give me some suggestions on how to approach it (any examples/documentation on this)? Thanks! -James
2008 Dec 30
3
Componentwise means of a list of matrices?
Dear useRs, I have a list, each entry of which is a matrix of constant dimensions. Is there a good way (i.e., not using a for loop) to apply a mean to each matrix entry *across list entries*? Example: foo <- list(rbind(c(1,2,3),c(4,5,6)),rbind(c(7,8,9),c(10,11,12))) some.sort.of.apply(foo,FUN=mean) I'm looking for a componentwise mean across the two entries of foo, i.e., the
2009 Jun 30
1
How to pass parameters to htmlParse Bank of Canada html pages
To get USDCAD rates from Bank of Canada, we first go url <- "http://banqueducanada.ca/en/rates/exchange-avg.html" select 12 months for Rates for the past and click "Get Rates" button. Then the page moves to address <- "http://banqueducanada.ca/cgi-bin/famecgi_fdps" and the rates show in the html page. htmlParse() can read the html document but
2009 Jun 23
1
How to find b entries using xPath?
We got all rows by: library(XML) doc = htmlParse('http://www.statcan.gc.ca/daily-quotidien/090520/t090520b1-eng.htm') rows = xpathSApply(doc, '//table/tbody/tr') The last row is: row_last = rows[15] row_last [[1]] <tr><td id="t1stub17" class="stub1 RGBShade"><b>Unsmoothed composite leading indicator</b></td>&#13; <td
2004 Jun 30
1
Developing functions
Without trying to understand your code in detail let me just assume you are trying to create a matrix, ret, whose i,j-th entry is some function, f, of row i of X and row j of X. In that case this should do it: apply(X,1,function(x)apply(X,1,function(y)f(x,y))) Date: Wed, 30 Jun 2004 15:28:47 -0300 (ART) From: <daniel at sintesys.com.ar> To: <r-help at stat.math.ethz.ch>
2013 Oct 11
3
matrix values linked to vector index
Hi, In the example you showed: m1<- matrix(0,length(vec),max(vec)) 1*!upper.tri(m1) #or ?m1[!upper.tri(m1)] <-? rep(rep(1,length(vec)),vec) #But, in a case like below, perhaps: vec1<- c(3,4,5) ?m2<- matrix(0,length(vec1),max(vec1)) ?indx <- cbind(rep(seq_along(vec1),vec1),unlist(tapply(vec1,list(vec1),FUN=seq),use.names=FALSE)) m2[indx]<- 1 ?m2 #???? [,1] [,2] [,3] [,4] [,5]
2009 Aug 20
1
Questions on factors in regression analysis
I got two questions on factors in regression: Q1. In a table, there a few categorical/factor variables, a few numerical variables and the response variable is numeric. Some factors are important but others not. How to determine which categorical variables are significant to the response variable? Q2. As we knew, lm can deal with categorical variables. I thought, when there is a categorical
2008 Nov 30
6
Regex: workaround for variable length negative lookbehind
Hi all I have the following regular expression problem: I want to find complete elements of a vector that end in a repeated character but where the repetition doesn't make up the whole word. That is, for the vector vec: vec<-c("aaaa", "baaa", "bbaa", "bbba", "baamm", "aa") I would like to get "baaa" "bbaa"
2010 Apr 08
1
Question on using elements of a vector
Hi So my particular problem is this: I have a row vector of length 5200 elements - specifically created by x<-rbinom(5200,1,0.5) y<-matrix(x,nrow=1,ncol=5200) y now, each element is either a 0 or a 1 - e.g. it could be (0,1,1,1,1,0,0,0,1,1,1) e.t.c. when the element is a 1, i need to multiply a number (say 1000) by 1.005, and if it is 1 again, multiply it _again_ by 1.005. so
2010 May 05
3
Limitations on R code file
I would like to run R code from a file that is generated from other source. The file consists of some variables and formulas/equations such as Variables = log(100) ##Other variable definitions VariablesWithLongNames = 2*3*log(12345678)+10^4 + Variables Equations=log(VariablesWithLongNames)+Variables^2 ##Other equations, formulas Result = Equations^2+rnorm(10000) hist(Result,breaks=100,freq=FALSE)
2018 Dec 17
1
Function I mean not to export keeps being documented in a manual?
I am developing an R package which has a function I decided not to export. I believe the roxygen information states that the function is not going to be exported, yet I still see the function in the manual PDF (as generated in command line via `CMD Rd2pdf package_dir`). What is wrong with my preamble that the function is still being documented in a manual? #' Generates plots for demo of
2012 Feb 06
5
I bet apply has a solution
Hi all For the data below, I would like to return a logical value indicating differences in the data. #Create data Data..<-data.frame(a=rep(1,10),b=c(rep(1,9),2),c=c(rep(1,8),2,2)) a b c 1 1 1 1 2 1 1 1 3 1 1 1 4 1 1 1 5 1 1 1 6 1 1 1 7 1 1 1 8 1 1 1 9 1 1 2 10 1 2 2 So what I want is to return logical value telling me if all the values are the same. So the result would be a b