[R] Is there anyone who uses both R and Python here? How do you debug? Perhaps in RStudio?

2021-01-26 Thread C W
Hello all, I'm a long time R user, but recently also using Python. I noticed that RStudio rolled out Python through reticulate. It's great so far! My question is, how do you debug in Python? In R, I simply step through the code script in my console with cmd+enter. But you can't do that with Pyth

[R] How to understand the mentality behind tidyverse and ggplot2?

2020-11-18 Thread C W
Dear R list, I am an old-school R user. I use apply(), with(), and which() in base package instead of filter(), select(), separate() in Tidyverse. The idea of pipeline (i.e. %>%) my code was foreign to me for a while. It makes the code shorter, but sometimes less readable? With ggplot2, I just do

Re: [R] Why is there error in as.POSIXlt.character when using strftime()?

2019-02-03 Thread C W
h Date and POSIXt types > in the same analysis... I recommend sticking with one or the other. > > The trunc.POSIXt function is more appropriate for getting POSIXt dates > than converting to character and back. > > On February 2, 2019 9:03:31 AM PST, C W wrote: > >Also, I

Re: [R] Why is there error in as.POSIXlt.character when using strftime()?

2019-02-03 Thread C W
uot;2015-07-13" [36] "2015-07-13" "2015-07-13" "2015-07-13" "2015-07-13" "2015-07-13" > class(as.Date(dat, "%m/%d/%y")) [1] "Date" > class(strftime(strptime(dat, format="%m/%d/%y %H:%M"), format = "%

Re: [R] Why is there error in as.POSIXlt.character when using strftime()?

2019-02-03 Thread C W
this can be as simple as > > Sys.setenv(TZ="GMT") > > but it can be specific to your data set also. > > On February 2, 2019 7:09:46 AM PST, Duncan Murdoch < > murdoch.dun...@gmail.com> wrote: > >On 01/02/2019 10:45 p.m., C W wrote: > >> Dea

[R] Why is there error in as.POSIXlt.character when using strftime()?

2019-02-02 Thread C W
Dear R community, I am working with dates. And I get the following error: > strftime(dat[20], format="%H:%M") Error in as.POSIXlt.character(as.character(x), ...) : character string is not in a standard unambiguous format Here's the original data: dat <- structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8

Re: [R] What exactly is an dgCMatrix-class. There are so many attributes.

2017-10-20 Thread C W
. [2,] . . [3,] . . [4,] . . [5,] . . On Fri, Oct 20, 2017 at 3:51 PM, C W wrote: > Thank you for your responses. > > I guess I don't feel alone. I don't find the docume

Re: [R] What exactly is an dgCMatrix-class. There are so many attributes.

2017-10-20 Thread C W
though it *looks* like the opposite. Cheers! On Fri, Oct 20, 2017 at 3:22 PM, David Winsemius wrote: > > > On Oct 20, 2017, at 11:11 AM, C W wrote: > > > > Dear R list, > > > > I came across dgCMatrix. I believe this class is associated with sparse > >

[R] What exactly is an dgCMatrix-class. There are so many attributes.

2017-10-20 Thread C W
Dear R list, I came across dgCMatrix. I believe this class is associated with sparse matrix. I see there are 8 attributes to train$data, I am confused why are there so many, some are vectors, what do they do? Here's the R code: library(xgboost) data(agaricus.train, package='xgboost') data(agari

Re: [R] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-29 Thread C W
the same way: > > > > names(dat)[3:5] <- names(dat)[c(5,3,4)] > > > > Better(?): > > > > perm <- c(1,2,5,3,4) > > dat <- dat[perm] > > > > dat is a list. > > > > Göran > > > > > >> > >> ___

Re: [R] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-29 Thread C W
uffle the names in the same way: > > names(dat)[3:5] <- names(dat)[c(5,3,4)] > > Better(?): > > perm <- c(1,2,5,3,4) > dat <- dat[perm] > > dat is a list. > > Göran > > >> From: Rolf Turner >> Sent: Frida

Re: [R] How create columns for squared values from previous columns?

2017-04-28 Thread C W
275 0.2213842 6 0.90691210 0.7247171 0.8244184 0.73328097 -1.05284737 0.822489552 0.52521494 0.6796657 But, you would NOT ONLY get undesired variable names, BUT ALSO duplicated names. I suppose I can use paste() to solve that? Any better ideas? On Fri, Apr 28, 2017 at 8:57 PM, C W wrote: >

[R] How create columns for squared values from previous columns?

2017-04-28 Thread C W
Dear R list, I am am a little unsure what is the best way to approach this. I suppose I have > dat <- matrix(rnorm(30), ncol = 5) > dat <- data.frame(dat) > dat X1 X2 X3 X4 X5 1 -1.1317 -0.87868106 -0.33000492 1.5241765 -0.92483388 2 -0.56168006

Re: [R] Is ImageMagick package not compatible with R 3.3.2?

2017-03-15 Thread C W
I figured it out. You can first do, saveGIF({ for (j in 1:20){ plot(-4:4, -4:4, type = "n") for(i in 1:10){ x[i] <- rnorm(1) y[i] <- rnorm(1) points(x[i], y[i]) } } }) It looks like you have to re-plot every time. On Wed, Mar 15, 2017 at 1:4

Re: [R] Is ImageMagick package not compatible with R 3.3.2?

2017-03-15 Thread C W
p coming along > > and sticking things into it." > > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > > > > On Tue, Mar 14, 2017 at 10:21 PM, C W wrote: > >> Dear list, > >> > >> I am trying to use saveG

[R] Is ImageMagick package not compatible with R 3.3.2?

2017-03-14 Thread C W
Dear list, I am trying to use saveGIF() from library animation. https://cran.r-project.org/web/packages/animation/animation.pdf saveGIF() has dependency on package ImageMagick. I got the following, > install.packages("ImageMagick") Warning in install.packages : package ‘ImageMagick’ is not ava

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
ent from my phone. Please excuse my brevity. > > On February 24, 2017 5:55:15 PM PST, C W wrote: > >I suppose for loop will suffice. > > > >I simply copy & paste the code from R editor. From my email, it looks > >plain. Is there a way to tell? > > > >

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
to expand your example to illustrate how the data comes to you > in order to suggest alternatives. > > Also post using plain text to prevent your code from being mangled on its > way to us. > -- > Sent from my phone. Please excuse my brevity. > > On February 24, 2017 5:27:07 PM PS

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
gt; And what is this "no loop drama" you refer to? I use loops frequently to > loop around large memory gobbling chunks of code. > > -- > Sent from my phone. Please excuse my brevity. > > On February 24, 2017 5:02:46 PM PST, C W wrote: > >Dear R, > > >

[R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
Dear R, I wanted to simulate a 5 by 3 matrix which fills up by either rows or columns? I started with the following filling the matrix by rows, dat <- matrix(NA, nrow=5, ncol = 3) for(i in 1:5){ dat[i, ] <- rnorm(3) } But, R is known for no loop drama. Any suggestions? Thanks!

Re: [R] Confused about using data.table package,

2017-02-21 Thread C W
Hi Carl, I have not fully learned dplyr, but it seems harder than tapply() and the ?apply() family in general. Almost every ggplot2 data I have seen is manipulated using dplyr. Something must be good about dplyr. aggregate(), tapply(), do.call(), rbind() will be sorely missed! :( Thanks! On Tu

[R] Error in match.fun(f) : object 'x' not found

2017-02-21 Thread C W
Dear R list, I am having a little trouble understanding the R code. I want to compute expectation of normal pdf. I did the following: integrate(x*dnorm(x, rate=1), -Inf, Inf) Error in match.fun(f) : object 'x' not found If I did this, I get, integrate(dexp(x, rate=1), -Inf, Inf) Error in dexp(x

Re: [R] Confused about using data.table package,

2017-02-20 Thread C W
to have some kind of graph conditioned on species, by grade . What's a good lead to learn about plotting this? Thank you! On Mon, Feb 20, 2017 at 11:12 AM, Hadley Wickham wrote: > On Sun, Feb 19, 2017 at 3:01 PM, David Winsemius > wrote: > > > >> On Feb 19, 2017, at 11

[R] Confused about using data.table package,

2017-02-19 Thread C W
Hi R, I am a little confused by the data.table package. library(data.table) df <- data.frame(w=rnorm(20, -10, 1), x= rnorm(20, 0, 1), y=rnorm(20, 10, 1), z=rnorm(20, 20, 1)) df <- data.table(df) #drop column w df_1 <- df[, w := NULL] # I thought you are supposed to do: df_1 <- df[, -w] df_2

Re: [R] Can R markdown do beamer palo alto theme?

2017-01-23 Thread C W
20 PM, C W wrote: > Hi R list, > > Is it possible to use R markdown with beamer palo alto theme? Are they > compatible? > > I copy pasted my LaTex code over to R, I get the following error message: > > ! LaTeX Error: Can be used only in preamble. > > See the

[R] Can R markdown do beamer palo alto theme?

2017-01-23 Thread C W
Hi R list, Is it possible to use R markdown with beamer palo alto theme? Are they compatible? I copy pasted my LaTex code over to R, I get the following error message: ! LaTeX Error: Can be used only in preamble. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate

Re: [R] R segfault at startup, causing R crash

2016-11-04 Thread C W
es utils datasets methods [7] base On Fri, Nov 4, 2016 at 4:50 PM, C W wrote: > I just got the following error instead of the previous one, > > 2016-11-04 16:50:08.446 R[23372:326103] -[NSDrawerWindow > setRuleThickness:]: unrecognized selector sent to instance 0x7fabc94a74b0 > 20

Re: [R] R segfault at startup, causing R crash

2016-11-04 Thread C W
) R.app R 3.3.2 GUI 1.68 Mavericks build Consider saving your work soon in case this develops into a problem. On Fri, Nov 4, 2016 at 4:39 PM, C W wrote: > Dear R list, > > Every time I start R, the following error message come up: > > *** caught segfault *** > address 0

[R] R segfault at startup, causing R crash

2016-11-04 Thread C W
Dear R list, Every time I start R, the following error message come up: *** caught segfault *** address 0x0, cause 'unknown' Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace > Selection: I am unable to do a s

Re: [R] What are some toy models I can use in R?

2016-05-25 Thread C W
On Wed, May 25, 2016 at 1:13 PM, S Ellison wrote: > > -Original Message- > > My data come from statistical model N(5, 2), with n=100, call this > model_1 > > Then, I add bias to that data with N(3, 1), with n=100, call this model_2 > Do you mean you have data from N(5,2) that has had data

[R] What are some toy models I can use in R?

2016-05-25 Thread C W
Hi everyone, I am searching for some toy models in R. My goal is do to model checking. For example, My data come from statistical model N(5, 2), with n=100, call this model_1 Then, I add bias to that data with N(3, 1), with n=100, call this model_2 Ultimately, I want to see model_1+ model_2 gi

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
On a side note, is it ok to do? > which(max(p_x)) and use that instead of numerical integration to get E[X]? I will try both and report back! Thank you expeRts On Fri, Feb 12, 2016 at 11:29 AM, C W wrote: > Hi Peter, > > Great, let me try that and get back to you on my findi

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
't > work. > > -pd > > On 12 Feb 2016, at 16:57 , C W wrote: > > > Hi Bert, > > > > Yay fantasyland! > > > > In all seriousness, You are referring to this? > > > https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Fri, Feb 12, 2016 at 7:36 AM, C W wrote: > > Hi David, > > > > This is the Gaussian looking distribution I am trying to integrate. > > > h

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
but that doesn't seem to be good enough, as we know, it should integrate to 1. On Thu, Feb 11, 2016 at 3:32 PM, David Winsemius wrote: > > > On Feb 11, 2016, at 11:30 AM, C W wrote: > > > > Hi David, > > > > My real function is actually a multivariate norma

Re: [R] Why two curves and numerical integration look so different?

2016-02-11 Thread C W
06 PM, David Winsemius wrote: > > > On Feb 11, 2016, at 9:20 AM, C W wrote: > > > > I want to do numerical integration w.r.t. mu: P(mu) × N(mu, 0.1) > > > > Because the variance is small, it results in density like: 7.978846e+94 > > > > Is the

Re: [R] Why two curves and numerical integration look so different?

2016-02-11 Thread C W
I want to do numerical integration w.r.t. mu: P(mu) × N(mu, 0.1) Because the variance is small, it results in density like: 7.978846e+94 Is there any good suggestion for this? Thanks so much! On Thu, Feb 11, 2016 at 9:14 AM, C W wrote: > Wow, thank you, that was very clear. Let me g

Re: [R] Why two curves and numerical integration look so different?

2016-02-11 Thread C W
e(..., -2, 4, 100) will not show the bump. > The same principal holds for numerical integration. > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Wed, Feb 10, 2016 at 6:37 PM, C W wrote: > >> Dear R, >> >> I am graphing the following normal d

[R] Why two curves and numerical integration look so different?

2016-02-10 Thread C W
Dear R, I am graphing the following normal density curve. Why does it look so different? # the curves x <- seq(-2, 4, by=0.1) curve(dnorm(x, 2, 10^(-100)), -4, 4) #right answer curve(dnorm(x, 2, 10^(-100)), -3, 4) #changed -4 to -3, I get wrong answer Why the second curve is flat? I just

[R] If I have 3 parameters, is optim() doing the same thing as Gibbs sampling?

2015-12-10 Thread C W
Hi R list, I am using optim() to optimize a function with 3 parameters. #My 1-d toy example: loglikelihood of normal with x=c(2,5,3,7,-3,-2,0), find MLE of mean. p1 <- function(theta){ sum(log(dnorm(c(2,5,3,7,-3,-2,0), mean = theta, sd = 1))) +log(dnorm( theta, mean = 0.8, sd = 2)) } optimiz

Re: [R] [FORGED] How to find the likelihood, MLE and plot it?

2015-11-19 Thread C W
; On Thu, Nov 19, 2015 at 10:29 AM, peter dalgaard wrote: > > On 19 Nov 2015, at 16:17 , C W wrote: > > > Hi Rolf, > > > > I think the MLE should be 1.71, no? And yes, I am aware of the > > maximum=TRUE argument. I still feel something is wrong here. > >

Re: [R] [FORGED] How to find the likelihood, MLE and plot it?

2015-11-19 Thread C W
Hi Rolf, I think the MLE should be 1.71, no? And yes, I am aware of the maximum=TRUE argument. I still feel something is wrong here. Thanks! On Wed, Nov 18, 2015 at 6:23 PM, Rolf Turner wrote: > On 19/11/15 11:31, C W wrote: > >> Dear R list, >> >> I am tryin

[R] How to find the likelihood, MLE and plot it?

2015-11-18 Thread C W
Dear R list, I am trying to find the MLE of the likelihood function. I will plot the log-likelihood to check my answer. Here's my R code: xvec <- c(2,5,3,7,-3,-2,0) fn <- function(theta){ sum(0.5 * (xvec - rep(theta, 7)) ^ 2 / 1 + 0.5 * log(1)) } gn <- Vectorize(fn) curve(gn, -5, 20) opti

[R] How to add legend to 2 different data frame overplot?

2015-10-30 Thread C W
Hi, I am trying to do add a legend to an overplot, something like this: ggplot() + geom_density(data = df1, aes(x = x), fill = "green", show_guide = FALSE) + geom_area(data = df2, aes(x = x), fill = "yellow", show_guide = FALSE) + scale_color_manual(values = c("green", "yellow"), labe

Re: [R] How to use curve() with two parameters in the function

2015-10-27 Thread C W
Never mind, I figured it out. You need to use sapply(), for instance, curve(sapply(x, p), from = 0, to =10) Thanks all! On Tue, Oct 27, 2015 at 11:14 AM, C W wrote: > Dear R list, > > I am trying to plot the curve of a function. > > Here's the R code: > > library(mv

[R] How to use curve() with two parameters in the function

2015-10-27 Thread C W
Dear R list, I am trying to plot the curve of a function. Here's the R code: library(mvtnorm) p <- function(x, mu){ mu <- c(mu, 0) dmvnorm(c(x, 1), mu, diag(2)) } > curve(p(x, 2), from = 0, to =1) Error in dmvnorm(c(x, 1), mu, diag(2)) : mean and sigma have non-conforming size I think

Re: [R] sampling rows with values never sampled before

2015-06-22 Thread C W
on, Jun 22, 2015 at 2:19 PM, Daniel Nordlund wrote: > On 6/22/2015 9:42 AM, C W wrote: > >> Hello R list, >> >> I am have question about sampling unique coordinate values. >> >> Here's how my data looks like >> >> dat <- cbind(x1 = rep(1:5

[R] sampling rows with values never sampled before

2015-06-22 Thread C W
Hello R list, I am have question about sampling unique coordinate values. Here's how my data looks like > dat <- cbind(x1 = rep(1:5, 3), x2 = rep(c(3.7, 2.9, 5.2), each=5)) > dat x1 x2 [1,] 1 3.7 [2,] 2 3.7 [3,] 3 3.7 [4,] 4 3.7 [5,] 5 3.7 [6,] 1 2.9 [7,] 2 2.9 [8,] 3 2.9

Re: [R] Why I am not able to load library(R.matlab)? Other packages are fine.

2015-05-29 Thread C W
viewdoc/download?doi=10.1.1.208.9970&rep=rep1&type=pdf > > > On 15-05-29 05:11 PM, C W wrote: > > Wow, thanks Ben. That worked very well. > > > > I guess I didn't have R.methodS3? But that doesn't make sense, > > because I was using R.matlab

Re: [R] Why I am not able to load library(R.matlab)? Other packages are fine.

2015-05-29 Thread C W
n Bolker wrote: > C W gmail.com> writes: > > > > > Hi Henrik, > > > > I don't quite get what I should do here. I am not familiar with > > R.methodS3. Can you tell me what command exactly do I need to do? > > > > Thanks, > > > >

Re: [R] Why I am not able to load library(R.matlab)? Other packages are fine.

2015-05-29 Thread C W
h the other > dependencies (R.oo and R.utils), do the same. > > /Henrik > > > > On Thu, May 28, 2015 at 11:47 AM, C W wrote: > > Dear R list, > > > > I am trying to do use the R.matlab library, I did the following, but it > > does not work. > &g

[R] Why I am not able to load library(R.matlab)? Other packages are fine.

2015-05-28 Thread C W
Dear R list, I am trying to do use the R.matlab library, I did the following, but it does not work. > library(R.matlab) Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘R.methodsS3’ Error: package or namespace load failed for ‘R

[R] trouble installing RcppOctave

2015-05-08 Thread C W
Dear R list, I am trying install the RcppOctave package to run Matlab packages in R. I did the following, > install.packages("RcppOctave") After some time of installation, I get the following error. I have homebrew installed, I also have Octave and Matlab install. installing the source packag

Re: [R] Is RcppOctave package available for Mac to install?

2015-03-14 Thread C W
Hi David, Thanks for the detail information. I think I will probably work in Octave instead, and fix the problem when I have a little more time. Mike On Sat, Mar 14, 2015 at 2:13 AM, David Winsemius wrote: > > > On Mar 13, 2015, at 11:50 PM, C W wrote: > > > > Hi eve

[R] Is RcppOctave package available for Mac to install?

2015-03-13 Thread C W
Hi everyone, When I tried to install RcppOctave package I got the following. > install.packages("RcppOctave") --- Please select a CRAN mirror for use in this session --- package ‘RcppOctave’ is available as a source package but not as a binary Warning message: package ‘RcppOctave’ is not avai

Re: [R] Change the argument function inside R function in GPfit package

2015-03-09 Thread C W
.00154643121052443, 0.0248938938021518, 0.187306626057348, 0.64822387977866, 1), .Dim = c(5L, 5L)) Now if I do, > GP_fit(xx, yy, corr=cor.mat) Error in corr$type : $ operator is invalid for atomic vectors How could I fix it? Thanks! -M On Mon, Mar 9, 2015 at 2:14 PM, C W wrote: > Hi R list,

[R] Change the argument function inside R function in GPfit package

2015-03-09 Thread C W
Hi R list, I am using the GPfit package to fit Gaussian Process model. The kernel in the package is, K(x, x') = sigma^2 * exp(x-x')^2 My kernel have an extra term, K((x, z), (x', z')) = sigma^2 * exp(x-x')^2 * exp(z-z')^2 The function corr_matrix() is, corr_matrix(X, beta, corr=list(type="expon

Re: [R] Numerical stability of eigenvalue and hessian matrix in R

2015-02-18 Thread C W
e answer can be extracted from a given body of data. > ~ John Tukey > > 2015-02-18 17:44 GMT+01:00 C W : > >> Hi Ben and JS, >> >> Thanks for the reply. >> >> I tried using: hessian(func = h_x, x, method = "complex"), it gives zero, >> that'

Re: [R] Numerical stability of eigenvalue and hessian matrix in R

2015-02-18 Thread C W
Hi Ben and JS, Thanks for the reply. I tried using: hessian(func = h_x, x, method = "complex"), it gives zero, that's good. # R code > hess.h <- hessian(func = h_x, x, method = "complex") > mat <- h_x(x)*hess.h - grad(h_x, x) %o% grad(h_x, x) > mat [,1][,2] [,3][,4] [1,]

[R] Numerical stability of eigenvalue and hessian matrix in R

2015-02-17 Thread C W
Hi list, I am running the following R code, the answer should be zero. But R gives a very small negative number, what should I do? ##R code library(numDeriv) h_x <- function(x){ a = x[1] b = x[2] c = x[3] d = x[4] (a^2 + c^2 + d^2) * (b^2 + c^2 + d^2) } x1 = 10 x2 = 1 x3 = 0 x4

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-31 Thread C W
And I want zero everywhere else. Thanks, Mike On Thu, Jan 29, 2015 at 10:34 PM, C W wrote: > Hi Bill, > > You solved by problem. For some reason, I thought xname was only > referring to name of the x-axis. > > I remember last time I fixed it, it was something about xname, co

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
ent variable > and func(rnorm(10), rnorm(10), mu=seq(0,5,len=501)) won't > work right. > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Thu, Jan 29, 2015 at 5:43 PM, C W wrote: > >> Hi Rui, >> >> Thank you for your help. Th

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
rk, but I don't know if it's what you want. func2 > will get x and y from the global environment. > > func2 <- function(mu){ >x + y + mu ^ 2 > } > > curve(func2, from = 0, to = 10) > > > Hope this helps, > > Rui Barradas > > Em 29-01-2015 21

[R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
Hi all, I want to graph a curve as a function of mu, not x. Here's the R code: x <- rnorm(10) y <- rnorm(10) func <- function(x, y, mu){ x + y + mu ^ 2 } curve(f = func(x = x, y = y, mu), from = 0, to = 10) I know I can change variable mu to x, but is there a way to tell R that mu is the va

Re: [R] R vs. RStudio?

2015-01-12 Thread C W
m of the screen > > On Mon, Jan 12, 2015 at 4:31 PM, Duncan Murdoch > wrote: > > On 12/01/2015 12:00 PM, C W wrote: > >> I use R on Mac, and I use RStudio on Windows. That's my opinion. > >> > >> I have one problem. > >> > >> When

Re: [R] R vs. RStudio?

2015-01-12 Thread C W
I use R on Mac, and I use RStudio on Windows. That's my opinion. I have one problem. When I use R on Mac. The function plot() gives a graph that's cut off. For example, try plot(rnorm(100) I believe there should be space below "index" on x-axis. Why is that? Thanks, Mike On Mon, Jan 12, 2

Re: [R] How to calculate correlation of a vector in R?

2014-11-02 Thread C W
. Playing > Research Engineer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. >

[R] How to calculate correlation of a vector in R?

2014-11-02 Thread C W
Hi list, I have trying to calculate the covariance/correlation of three elements. I have vector say, v <- c(700, 800, 1000) I want to have a 3 by 3 correlation matrix, meaning cor(v1, c2), cor(v1, c3), cor(v2, v3), etc... So far I get, > cor(v) Error in cor(v) : supply both 'x' and 'y' or a mat

[R] What formula does the acf() function use?

2014-03-23 Thread C W
Dear list, I am curious about how R computes the autocorrelation? What formula does it use? Theoretical or sample ACF? I have tried to type acf in the R console, but I don't understand what it is actually doing besides the basic if...else... statement. Could someone help me read this output? >

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
That's what I am looking for. Thanks for being so helpful, I appreciate it very much. On Sun, Feb 23, 2014 at 10:16 PM, Gabor Grothendieck < ggrothendi...@gmail.com> wrote: > On Sun, Feb 23, 2014 at 9:06 PM, C W wrote: > > Is there a way to rbind this? Do I have to us

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
Is there a way to rbind this? Do I have to use use a package like 'zoo' and merge()? p <- predict(model, data.frame(t = 1, q = factor(1, 1:4)) rbind(tsdat, p) On Sun, Feb 23, 2014 at 8:43 PM, C W wrote: > I guess this is for anyone in the future. > > > predict(m

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
I guess this is for anyone in the future. > predict(model, data.frame(t = 1, q = factor(1, 1:4)) This would be the answer. Thanks again, Gabor! Mike On Sun, Feb 23, 2014 at 8:23 PM, Gabor Grothendieck wrote: > On Sun, Feb 23, 2014 at 7:40 PM, C W wrote: > > Gabor, > > Yo

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
, Feb 23, 2014 at 7:25 PM, C W wrote: > > Gabor, > > Let me change newdata since it's confusing. > > > > Suppose I want to predict, year 1990, and quarter 2. > >> newdata <- data.frame(c(1990, 1, 0, 0) > > > > Since Q1 is a baseline, we will onl

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
ieck wrote: > On Sun, Feb 23, 2014 at 6:56 PM, C W wrote: > > Gabor, > > I want the new data to be this, > > newdata <- data.frame(c(1, 0, 0, 0)) > > > > Its not clear what this means. There are two input variables so we > must specify two inputs. > For e

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
394 0.20732358 -0.19547465 -1.05329759 -0.32826061 0.16938691 19 20 -0.23341132 -1.09123426 Warning message: 'newdata' had 4 rows but variables found have 20 rows On Sun, Feb 23, 2014 at 6:49 PM, Gabor Grothendieck wrote: > On Sun, Feb 23, 2014 at 6:34 PM, C W wrot

[R] predict.lm() does not take ts() objects in formula

2014-02-23 Thread C W
Hello list, Does predict.lm() take ts object. I am aware that it requires data to come in data.frame Here's the time series regression. y = t + Q1 + Q2 + Q3 + Q4 Here's my R code, > dat <- rnorm(20) > tsdat <- ts(dat, start=c(1900, 1), freq=4) > q <- as.factor(rep(1:4, 5)) > t <- 1:20 > lm(ts

[R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
Hello, I don't know how to use predict.lm() for ts object. Here's the time series regression. y = t + Q1 + Q2 + Q3 + Q4 Here's my R code, > dat <- rnorm(20) > tsdat <- ts(dat, start=c(1900, 1), freq=4) > q <- as.factor(rep(1:4, 5)) > t <- 1:20 > lm(tsdat~t+q) Call: lm(formula = tsdat ~ t + q)

Re: [R] How to calculate moving average without using filter()?

2014-02-18 Thread C W
uot;) > > In your example, what you compute is not exactly a moving average, but in > can be computed with something like the following. > > s <- (seq_along(dat) - 1) %/% 3 > sapply(split(dat, s), mean) > > > Hope this helps, > > Rui Barradas > > > Em 17-0

[R] How to calculate moving average without using filter()?

2014-02-17 Thread C W
Hi list, How do I calculate a moving average without using filter(). filter() does not seem to give weighted averages. I am looking into apply(), tapply,... But nothing "moves". For example, dat<-c(1:20) mean(dat[1:3]) mean(dat[4:6]) mean(dat[7:9]) mean(dat[10:12]) etc... I understand the poi

Re: [R] Is there a way to change x and y axis tick mark inside plot()?

2013-09-20 Thread C W
Thanks Duncan. I have no knowledge of SAS, though many in industry use it. I hope R would expand its usage to more at the industry level. Mike On Fri, Sep 20, 2013 at 12:17 PM, Duncan Murdoch wrote: > On 20/09/2013 11:52 AM, C W wrote: > >> Dear R community, >> I am havin

[R] Is there a way to change x and y axis tick mark inside plot()?

2013-09-20 Thread C W
Dear R community, I am having trouble changing the tick marks on y-axis to every 5 units? I have the following: x <- c(12, 16, 6, 23, 27, 8, 5, 19, 23, 13, 16, 8) y <- c(29, 29, 23, 34, 38, 24, 22, 34, 36, 27, 33, 27) plot(x, y, pch=19) Should I change ylim=c(0,40), and then use axis()? I kep

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
On Sat, Jul 20, 2013 at 1:50 PM, C W wrote: > Thanks, you guys are correct, I had different data. > But why I get length 5 and 6, should only be 1 to 3. > > Full R code : > > vec <- c(1, 2, 3, 4, 5, 6, 7, 8, 13, 1, 2, 3, 5, 7, 8, 10, 12, 13, 14, > 15, 1, 2, 3, 5, 6, 10, 12,

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
t;>>> Sent: Sat, 20 Jul 2013 12:36:55 -0400 >>>> To: b...@xs4all.nl >>>> Subject: Re: [R] How to search for a sequence(and its combination) >>>> inside >>>> a vector? >>>> >>>> Hi Berend >>>> I am looking for a

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
table, >> # of times one element (out of 1, 2, 3) showed up, two elements, and all >> three. >> >> I am trying, don't know if this works: >> >>> aa <- rle(a) >>> b <- aa$lengths[aa$values] >>> table(b) >> b >> 1 3 >> 3 12

Re: [R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
end Hasselman wrote: > > On 20-07-2013, at 18:05, C W wrote: > >> Hi R list, >> >> I have a sequence repeating 1:15 . Some numbers are deleted. I want >> to find how many times 1, 2, 3 appeared. >> Basically, I want to "grab" the beginning of the sequen

[R] How to search for a sequence(and its combination) inside a vector?

2013-07-20 Thread C W
Hi R list, I have a sequence repeating 1:15 . Some numbers are deleted. I want to find how many times 1, 2, 3 appeared. Basically, I want to "grab" the beginning of the sequence and tally it up. R code: > vec <- c(1, 2, 3, 4, 5, 6, 7, 8, 13, 1, 2, 3, 5, 7, 8, 10, 12, 13, 14, 15, 1, 2, 3, 5, 6,

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
e the \begin{document} \end{document} tags. > > > > Best > > Simon > > On Jul 18, 2013, at 10:22 PM, C W wrote: > >> Thanks, Simon. I would never figured it out! >> >> I apologize if I sound frustrated, because I am. >> >> @package aut

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
at 4:19 PM, Berend Hasselman wrote: > > On 18-07-2013, at 22:09, C W wrote: > >> http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165 >> >> In step 3: "add the executable file (step 3)". >> >> What is the executabl

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165 In step 3: "add the executable file (step 3)". What is the executable file? Locate package knitr directory path in R? Mike On Thu, Jul 18, 2013 at 3:56 PM, C W wrote: > Actually, I see it at the b

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
Actually, I see it at the bottom. Sorry! On Thu, Jul 18, 2013 at 3:44 PM, C W wrote: > Hi Simon, > I am on OS X Lion, I have TeXworks, I don't have knitr as an option. > > How do I install that into TeXworks? Seems like I have to something > in terminal? > > Mike >

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
xamples/knitr-minimal.Rnw > > > Hope this helps > > > Best > > Simon > > > > > > On Jul 18, 2013, at 8:52 PM, C W wrote: > >> How do you create a .Rnw file, in R or LaTex? I don't think any >> tutorial mentions it. >> >>

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
com/product/isbn/9781482203530 > > Regards, > Yihui > -- > Yihui Xie > Phone: 206-667-4385 Web: http://yihui.name > Fred Hutchinson Cancer Research Center, Seattle > > > On Thu, Jul 18, 2013 at 11:13 AM, C W wrote: >> Hi everyone, >> >> I am using pack

[R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
Hi everyone, I am using package knitr, FIRST TIME. I don't have access to RStudio. Read through Yihui's page, didn't find it helpful. Stuck on terms Rnw, GFM (GitHub Flavored Markdown). Never used Sweave, so the reference is not helping. Is there a simple step-by-step example WITHOUT RStudio?

Re: [R] How to remove attributes from scale() in a matrix?

2013-07-16 Thread C W
; scale <- apply(x, 2L, f) > x <- sweep(x, 2L, scale, "/", check.margin = FALSE) > } > } > else if (is.numeric(scale) && length(scale) == nc) > x <- sweep(x, 2L, scale, "/", check.margin = FALSE) >

Re: [R] How to remove attributes from scale() in a matrix?

2013-07-16 Thread C W
t;scaled:center")<-NULL > attr(x1,"scaled:scale")<-NULL > str(x1) > #num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ... > A.K. > > > > > - Original Message - > From: C W > To: r-help > Cc: > Sent: Tuesday, July 16, 2013 3

[R] How to remove attributes from scale() in a matrix?

2013-07-16 Thread C W
Hi list, I am using scale() to standardize a distribution? But why does it give me attributes attached to the data? I just want a standardized matrix, that is all. library(mvtnorm) > x <- rmvnorm(15, mean=rep(50, 10)) > x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,

[R] What package to use to download pictures and its description from server?

2013-07-02 Thread C W
Hi R community, What package would you recommend to download pictures and descriptions of the pictures? I have looked at package XML and RCurl so far. Is this what everyone uses? Thanks, Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/m

Re: [R] set.seed(x)

2013-06-13 Thread C W
I asked a similar question earlier in the year, http://r.789695.n4.nabble.com/How-to-stop-set-seed-besides-exiting-out-of-R-td4661717.html I liked this solution from William, > rm(list=".Random.seed", envir=globalenv()) Mike On Thu, Jun 13, 2013 at 5:27 PM, Michael Weylandt wrote: > > > On Jun

Re: [R] Function for finding matching values in two vectors.

2013-05-28 Thread C W
How about ?intersect > a<-1:5;b<-1:9 > a [1] 1 2 3 4 5 > b [1] 1 2 3 4 5 6 7 8 9 > intersect(a, b) [1] 1 2 3 4 5 I haven't used this in simulation, so I don't know how fast it is. -Mike On Tue, May 28, 2013 at 2:05 PM, arun wrote: > Hi, > You could use: > which(a%in%b) > #[1] 1 2 3 4 5 > > a1<-

Re: [R] What does this say? Error in rep("(Intercept)", nrow(a0)) : invalid 'times' argument

2013-05-25 Thread C W
gt; So, thee error is in the predict.multnet function. If you peak at that > function, you see where the function falls apart. It seems that the > function wants a0 to be a matrix but in this example it is a vector. I'm > not familiar enough with the package to offer advice on how

  1   2   >