There is an urban legend that says Indiana passed a law implying pi = 3.
(Because it says so in the bible...)
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Joshua Wiley
Sent: Monday, 30 May 2011 4:10 PM
To: Vincy Pyne
Cc: r-he
Dear Vincy,
I hope that in school you also learned that 22/7 is an approximation.
Please consult your local mathematician for a proof that pi != 22/7.
A quick search will provide you with volumes of information on what pi
is, how it may be calculated, and calculations out to thousands of
digits.
God this listserve is awesome. Thanks to everyone for their ideas.
I'll speed & memory test tomorrow and change the code. Thanks again!
Matt
On Sun, May 29, 2011 at 6:44 PM, Ian Gow wrote:
> Not a new approach, but some benchmark data (the perl=TRUE speeds up Jim's
> suggestion):
>
>> x <- c('18
Dear R helpers,
I have one basic doubt about the value of pi. In school, we have learned that
pi = 22/7 (which is = 3.142857). However, if I type pi in R, I get pi =
3.141593. So which value of pi should be considered?
Regards
Vincy
[[alternative HTML version deleted]]
_
Yes, you are right that the results of smooth.spline are slightly worse than
that of sm.spline.
The Doppler function is "tricky". At small `x' values, it oscillates rapidly.
Hence it is not surprising that the smoothers do not do as well.
Here is a noisy version of your Doppler function.
Hi Matt,
Though it's the last solution on your list, I would treat this as a
text editing problem: just find and replace "\.[0-9]", then read in
the result.
perl -pi -e 's/x\.[0-9]//g' *test.txt
likely done in seconds.
But other R solutions seem to be coming in in a fairly timely manner too.
t
Not a new approach, but some benchmark data (the perl=TRUE speeds up Jim's
suggestion):
> x <- c('18x.6','12x.9','302x.3')
> y <- rep(x,10)
> system.time(temp <- unlist(lapply(strsplit(y,".",fixed=TRUE),function(x)
>x[1])))
user system elapsed
1.203 0.018 1.222
> system.time(temp2 <-
Hi Matt,
There are likely more efficient ways still, but this is a big
performance boost time-wise for me:
x <- c('18x.6','12x.9','302x.3')
gsub("\\.(.+$)", "", x)
x <- rep(x, 10^5)
> system.time(out1 <- unlist(lapply(strsplit(x,".",fixed=TRUE),function(x)
> x[1])))
user system elapsed
Try this approach:
> x <- c('18x.6','12x.9','302x.3')
> gsub("^(.*)\\..*", '\\1', x)
[1] "18x" "12x" "302x"
On Sun, May 29, 2011 at 8:10 PM, Matthew Keller wrote:
> hi all,
>
> I'm full of questions today :). Thanks in advance for your help!
>
> Here's the problem:
> x <- c('18x.6','12x.9','3
hi all,
I'm full of questions today :). Thanks in advance for your help!
Here's the problem:
x <- c('18x.6','12x.9','302x.3')
I want to get a vector that is c('18x','12x','302x')
This is easily done using this code:
unlist(lapply(strsplit(x,".",fixed=TRUE),function(x) x[1]))
So far so good. T
Try giving what an example of an integer instead
of the character string "integer". E.g.,
what = 0L
or
what = integer(0)
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Be
Hi all,
My code:
x <- scan(gzfile("file"),what='integer')
x is imported, but as mode "character" rather than "integer". I know I
can do as.integer() when importing, but am still trying to figure out
why the above occurs. When I do
summary(as.integer(x)), there are no NAs introduced by coercion,
Hi Serdar,
Take a look at the following:
> sample(0:9, 100, replace = FALSE)
Error in sample(0:9, 100, replace = FALSE) :
cannot take a sample larger than the population when 'replace = FALSE'
> sample(0:9, 100, replace = TRUE)
[1] 5 6 5 7 3 0 8 4 8 2 2 4 7 6 0 7 0 0 0 7 5 6 3 6 0 9 6 1 2 6 9
Hi
Also , same problem to create discrete uniform Distribution ,
But sample () and runif() not useful to generate discrete uniform .
Ex:
> u<-round(runif(10*10,min=1,max=10),0)
> table(u)
u
1 2 3 4 5 6 7 8 9 10
6 10 9 10 14 6 11 14 12 8
Not useful for large number
OR
Ravi,
Thanks so much! You're right, smooth.spline does work on larger n.
Although, for some reason it's results are different (slightly less good?,
but I'm not sure). For example, on the simple doppler function below,
sm.spline seems to be closer to the true function than smooth.spline:
x=arra
Uwe -- thank you. No, this occurs on three different machines: two at work
(a Lenovo laptop running Win7-32, plus an HP workstation running Win7-64)
... and I just tried another Compaq desktop machine at home running
WinXP-32, with the same result.
I agree that this seems highly unusual since
Hi, I'm a student studing for Math. & Infor. Ing. in Tirana,Albania and a have
a final project in R to finish in a week, so I badly need your help...
The topic of the project is "Hermite Interpolation" and a I have allready done
a script that finds the approximation in a certan point x, H(x) ~f
Use the smooth.spline() function in "stats" package. This is more stable.
?smooth.spline
Ravi.
From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of
guy33 [david.res...@magd.ox.ac.uk]
Sent: Sunday, May 29, 2011 1:30 PM
To: r-hel
Hi
On 29/05/2011 2:02 a.m., Dennis Murphy wrote:
Homework question?
Indeed it is.
Dear 220 student. The resources at your university, including your
lecturer, should be your first port of call for questions on labs and
assignments. Also, if you ever post questions on a forum like this you
Hi Philipp,
## Read in your data
## posting the output of dput() would have made our lives easier
d1 <- read.table(textConnection("x y
1 a X
2 b X
3 c X
4 f Z
5 e Z
6 g Z"), header = TRUE, row.names = 1)
d2 <- read.table(textConnection(" y1 y2
1 X W
2 Z W"), header = TRUE, row.names = 1)
closeA
Philipp -
I believe you're looking for the merge function.
If you need more guidance, please provide a meaningful
reproducible example.
- Phil Spector
Statistical Computing Facility
merge() should do the trick. Using strings instead of factors works
better, though.
Sarah
On Sun, May 29, 2011 at 4:51 PM, Philipp Chapkovski
wrote:
> Hello!
> The question should be very naive, but I am a beginner and stuck with
> this unfortunately.
> There is a dataset of people's affiliation
Hey all,
I seem to be having trouble fitting a spline to a large set of data using
PSpline. It seems to work fine for a data set of size n=4476, but not for
anything larger (say, n=4477). For example:
THIS WORKS:
-
random = array(0,c(4476,2))
random[,1] = runif(4476,
Hello!
The question should be very naive, but I am a beginner and stuck with
this unfortunately.
There is a dataset of people's affiliation to companies that looks
like that (a data frame actually)
x y
1 a X
2 b X
3 c X
4 f Z
5 e Z
6 g Z
where x is a name of a person and y is a company name. That
That's it.
thanks very much, I save hours if work qith your reply
-
Mario Garrido Escudero
PhD student
Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca. Agrícola
Universidad de Salamanca
--
View this message in context:
http://r.789695.n4.nabble.com/Applying-a-function-to-a
Hello,
I'm trying to plot a series of pages in a pdf with one main caption for
each page.
Each page should then have two plots in one row, preferably with an own
caption.
I can't plot the main caption in a window, and subsequently plot the two
graphics (next to each other) below it.
Here is w
Or just include is.na=TRUE in the definition of kurtosis():
kurtosis<-function(x) {
m4<-sum((x-mean(x,na.rm=TRUE))^4,na.rm=TRUE)/length(x)
s4<-var(x,na.rm=TRUE)^2
m4/s4 - 3 }
HTH
Stephan
Am 29.05.2011 11:34, schrieb Jim Holtman:
kurtosis(fem[!is.na(fem)])
Sent from my iPad
On May 29,
Hi,
I'm not sure if this is impossible or if I just don't know the syntax.
example:
library(reshape);
library(corpcor);
data<-data.frame(ids=c("A","A","A","B","B","B"),rate=c(12,14,17,10,8,5),sample=c(100,80,60,50,40,45));
data_melted<-melt.data.frame(data,id.vars=c("ids"),measure.vars=c("rate",
Hi Marco,
I am sure theoretically it would be possible to make it so that copies
could not be made of base (or core) functions, but users will always
be able to shoot themselves in the foot if they try hard enough. I
think the usual recommendation is just not to use common function
names for your
There is no way to prevent a user from messing up. No matter how many
things you put in to prevent such occurances, I have always found that
users find new ways to use your system that you never considered.
There is always the 'conflicts()' function that might help:
> # create my 'c'
> c <- func
I thought it might have been that but stupidly didn't search on "$" and
I can now see that the one partial match I tried would have been
ambiguous so "$" hadn't resolved it. Patrick Burns tells me I could
have found this in the wonderful "R inferno" and I'm sure I could have,
probably have, read t
Dear R-users,
I am having trouble constructing nxn matrices involving calculations&
conditions based on other tables.
Below I describe a simple example of what I am trying to do:
Given the Table A (n x m):
Species1
Species2
X
A1,1
A1,2
Y
A2,1
A2,2
Z
A3,1
A3,2
I want to crea
Hi all,
sometime in the past I accidentaly created a copy of the c()
primitive function inside my ``laboratory'' workspace, which I
normally use to experiment and learn. As a consequence, c() stopped to
work correctly and started to return lists of symbols instead of
vectors, and today I had to sp
Sounds like a hardware problem to me, since I do not expereice any
problems with the example you gave at first. Is this all on the same
hardware?
Uwe Ligges
On 27.05.2011 18:38, Chris Chapman wrote:
I've run into persistent problems with OpenBUGS crashing when using BRugs .53
and .71, and
Chris -
If you check the documentation for the "$" operator,
for example by typing
help("$")
you'll find (among a lot of other information):
name: A literal character string or a name (possibly backtick
quoted). For extraction, this is normally (see under
‘Environ
I may be being dopey, I surely am, but I'm baffled by this. I've been
working, on and off for a few days in R version 2.13.0 (2011-04-13)
i386-pc-mingw32/i386 (32-bit) working it through ESS.
I've got a dataframe created a couple of days back, during the session:
> dim(AllDat)
[1] 2727094
I
On May 29, 2011, at 5:10 AM, ashley wrote:
Thanks Josh,
This makes sense. The coefficient of one parameter is given in
reference to
another parameter. (Aha! The "reference" parameter.)
I'm still a little confused on the standard errors (SEs) and why
they change
too? Should I change the r
On Sat, May 28, 2011 at 5:22 PM, thierrydb wrote:
> Is there an elegant way to do operations (+/-/*/ / ) on zoo/xts objects when
> one serie is monthly (end of month) and the other daily (weekdays only) -
> typically a monthly economic indicator and a stock index price?
>
>
>
Merge the monthly se
it should be
findFreqTerms instead of findfreqterms.
m
--
View this message in context:
http://r.789695.n4.nabble.com/tm-package-tp3558064p3558784.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
http
it should be
findFreqTerms instead of findfreqTerms.
m
--
View this message in context:
http://r.789695.n4.nabble.com/tm-package-tp3558064p3558783.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
http
On 05/29/2011 06:07 AM, garciap wrote:
V<-fitness*(c+dive*pfood, t+1)
What are you trying to do in this line? Multiply fitness by two
different things at once? The expression
(1,2)
Causes problems in R. If you want to combine them into a vector, you need
c(1,2)
Otherwise, please go int
Dear members of R forum,
I'm trying to perform a simply dynamic programming model in R, following the
reccomendations of Soetart & Herman (A practical guide to ecological
modeling). However, I've obtained a number of problems, that I'm unable to
solve (even thoughI've tried during at least 2 hours
Dear Roger,
Thanks for the reply.
I have discovered that the problem was in NA data for the last two months
appeared after loading from .csv file. The problem was solved applying the
complete.cases() function.
Sergius.
--
View this message in context:
http://r.789695.n4.nabble.com/rqss-help-in-Q
On 05/28/2011 12:54 PM, Ben Haller wrote:
1. Is my choice of glmnet() ok? On what basis should I choose
glmnet() vs. lars()?
LARS is for linear regression; your outcome is binary.
2. Is the way I'm scaling the variables before calling glmnet()
correct? Or should the squares themselves be ce
Because your header contains strings that are not legal names. Check out the
parameter check.name (cannot tell for sure since R is not available on the
iPad).
Sent from my iPad
On May 29, 2011, at 5:17, rmje wrote:
> http://r.789695.n4.nabble.com/file/n3558595/help_snap.jpg
>
> Why do R re
kurtosis(fem[!is.na(fem)])
Sent from my iPad
On May 29, 2011, at 4:54, gaiarrido wrote:
> Here´s my problem,
> i have developed the function kurtosis (using R-book as a guide) with this
> commands:
> kurtosis<-function(x) {
> m4<-sum((x-mean(x))^4)/length(x)
> s4<-var(x)^2
> m4/s4 - 3 }
>
> Th
Here´s my problem,
i have developed the function kurtosis (using R-book as a guide) with this
commands:
kurtosis<-function(x) {
m4<-sum((x-mean(x))^4)/length(x)
s4<-var(x)^2
m4/s4 - 3 }
Then create the object fem, which is the difference between the count of a
trait in the left side of the body mi
Thank you very much for your help.I was confused about how to find the length
of a file without using the length function.
Thank you so much for your answer ,Dennis
--
View this message in context:
http://r.789695.n4.nabble.com/remove-at-the-end-of-each-line-for-all-lines-except-the-first-line-i
http://r.789695.n4.nabble.com/file/n3558595/help_snap.jpg
Why do R rename my rows and columns when loading it like in the image above?
--
View this message in context:
http://r.789695.n4.nabble.com/Plot-rows-of-CSV-tp3555898p3558595.html
Sent from the R help mailing list archive at Nabble.com.
Thanks Josh,
This makes sense. The coefficient of one parameter is given in reference to
another parameter. (Aha! The "reference" parameter.)
I'm still a little confused on the standard errors (SEs) and why they change
too? Should I change the reference around until I find the best-looking SEs?
S
On Sat, May 28, 2011 at 7:48 PM, Matthew Keller wrote:
> Perhaps this is more of a unix question, but I'll give it a try here.
> I am running 9 different R processes at the same time (called from a
> shell script using R CMD BATCH). When I use the top program to
> monitor how they are doing, it
Hi Ista,
Thank you so much for your explanation!!
I know now how to handle this scale_color_manual() function.
Le 28/05/2011 19:56, Ista Zahn a écrit :
Hi Victor,
The problem is that you have not grasped the difference between
setting an aesthetic to a fixed value and mapping it to a variable.
This is _not_ a reproducible example so one can only guess,
but the fact that with returns "the analysis goes" suggests that
there is something amiss with your price variable.
Roger Koenker
rkoen...@illinois.edu
On May 28, 2011, at 1:47 PM, Sergius Cerice wrote:
> Dear All,
>
> I,m trying t
53 matches
Mail list logo