The example in the question was not inside a user function.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self
Rolf et.al
I have not followed this thread closely and so have nothing to say
about whose or what explanation is correct.
However, the following statement is misleading, if not wrong:
---
foo <- function(){
x <- 17
x
y <- 42
y
}
If you type foo() you get
[1] 42
which i
On 18/07/14 11:32, David Winsemius wrote:
On Jul 17, 2014, at 9:27 AM, Rui Barradas wrote:
Hello,
Also, unlike what the op says, if statements are functions, explaining the
behavior he got.
I'm not sure that is correct. The help page says if() is a control-construct. I think the
function
On Jul 17, 2014, at 9:27 AM, Rui Barradas wrote:
> Hello,
>
> Also, unlike what the op says, if statements are functions, explaining the
> behavior he got.
I'm not sure that is correct. The help page says if() is a control-construct. I
think the function is actually "{"
> {rnorm(10); rpois(1
Replying to self:
>
> Is there any equivalent to chartr for numeric values?
>
> Meaning, something like:
>
> numerictr(c(-1, 42, 666), 1:3, numeric.stuff)
>
> that replaces in "numeric.stuff" (a vector, matrix, etc) all instances
> of -1 for 1, 42 for 2 and 666 for 3?
>
match does it. Sorry to ask.
Hi Michael,
I think you're right, it would be a good idea for me to get a better grip
on mixed effects modeling before I charge ahead with metafor. Thank you
very much for all of your help with this! Much appreciated!
Best,
Megan
On Thu, Jul 17, 2014 at 3:50 AM, Michael Dewey
wrote:
> At 17:
Is there any equivalent to chartr for numeric values?
Meaning, something like:
numerictr(c(-1, 42, 666), 1:3, numeric.stuff)
that replaces in "numeric.stuff" (a vector, matrix, etc) all instances
of -1 for 1, 42 for 2 and 666 for 3?
Alberto Monteiro
Dear Lorenzo,
I've just seen one post from you asking for hints to read SDMX data in R.
I don't know if you still need to read SDMX datasets in R. In case, you
can use the rsdmx package hosted here https://github.com/opensdmx/rsdmx
With the OECD sample you mention, you can do as follows:
#instal
Jeff,
Even though the solutions from the previous responders are good enough
for my current situation, the principle you just raised will be
definitely beneficial to your future work. Thanks a lot for sharing
the insights!
Gang
On Thu, Jul 17, 2014 at 12:06 PM, Jeff Newmiller
wrote:
> You ask a
This question is related to FAQ 7.16, which you should look up.
In general, whenever you just type a variable or function directly at the
command line, R prints the result for you. Inside code blocks of any kind,
it does not do that, so you need to use the print function yourself.
On Thu, 17
Hello,
Also, unlike what the op says, if statements are functions, explaining
the behavior he got.
Hope this helps,
Rui Barradas
Em 17-07-2014 16:53, Sarah Goslee escreveu:
Hi,
You can get the behaviour you want using the print() command:
if(1 < 2)
{
x<-rnorm(100)
y <- rpois(10, 5)
You should read the Posting Guide for the r-help list, and the list
control web page. One problem with your post is that the r-help-request
address is not for asking questions. Another problem is that cross-posting
to multiple lists would not have been polite anyway.
Your question is really to
You ask about generic methods for introducing alternate values for
factors, and some of the other responses address this quite efficiently.
However, a factor has meaning only within one vector at a time, since
another vector may have additional values or missing values relative to
the first vect
Hi Bill,
Modifying `f2` seems to solve the problem.
f2 <- function (data)
{
library(dplyr)
data%>%
group_by(id, value) %>%
mutate(date=as.Date(date))%>%
arrange(date) %>%
filter(indx =any(c(abs(diff(date)),NA) >31)& date==min(date)) %>%
filter(row_number()==1)
}
Hello,
i am working on a metagenomics, and analyzing a genome of different
sample using QIIME tools, will you tell me how can i use R Program for
metagenome analysis.
Regards.Shashank Gupta
[[alternative HTML version deleted]]
__
R-help@r-pro
Hi,
You can get the behaviour you want using the print() command:
if(1 < 2)
{
x<-rnorm(100)
y <- rpois(10, 5)
print(head(x))
print(head(y))
}
Sarah
On Thu, Jul 17, 2014 at 2:00 AM, Dario Strbenac
wrote:
> Hello,
>
> I have a block of code that has two head calls at the end, but only t
Thanks a lot for the quick and elegant solutions, Sarah, Bill and
Petr! I really appreciate it, including the suggestion of setting a
random seed. Have a nice day!
Gang
On Thu, Jul 17, 2014 at 11:15 AM, Sarah Goslee wrote:
> What about:
>
> d$var <- c(8, 11, 3, 2)[d$fac]
>
> Side note: it's much
Hi,
I still seem to be getting errors from trying to run my altered R script, any
advice?
Thanks
Jess
Model1A = function(meth_matrix,exposure, X1, X2, X3, batch) {
+
+ mod = lm(methcol ~ exposure+X1+X2+X3+batch, data = meth_matrix)
+
+
+ res=coef(summary(mod))[2,]
+
+
+ }
>
>
> ##Run
Hello everyone,
I am trying to define a PERT distribution "by hand" by transforming a classic
beta distribution - as I would like to understand where the shape parameter
(default value of 4) comes from in the mc2d package.
The help page says
"The PERT distribution is a beta distribution extend
Hi Balaji,
Sorry, I forgot to tell that I'm running R on OSX. I don't know if
there's an easier way, but since you are running on Windows you could
try to install curl(http://curl.haxx.se/) binaries and try the curl
method again.
#! Fábio
On Thu, Jul 17, 2014 at 5:26 AM, Raghuraman Ramachandran
I have found an interesting issue. I use R Studio for most of my
development and automate many tasks to run over night. I have a https
file scrape process that runs without issue from R Studio command line.
When I try to run from the R console, I get an error from download.file
stating unsup
Hello,
I have a block of code that has two head calls at the end, but only the second
is shown on screen. If I manually execute the statement which is not showing,
it works. I thought that if statements are not functions. It is behaving as one.
> if(1 < 2)
+ {
+ x<-rnorm(100)
+ y <- rpois(1
Hi
depends if you want the new column as factor or numeric.
d$fac2<-d$fac
I did not use var as it is R function.
levels(d$fac2)<-c(8,11,3,2)
d$fac2
[1] 3 11 8 8 2 8 11 11 8 8
Levels: 8 11 3 2
You can change it to character or numeric if you wish.
as.character(d$fac2)
[1] "3" "11" "8"
What about:
d$var <- c(8, 11, 3, 2)[d$fac]
Side note: it's much appreciated that you included data and a clear
problem statement. If you use
set.seed(123)
before your call to sample(), everyone who tries it will get the same
fac that you do. Otherwise we all get something different. Or just
gener
One way is to use a vector with names to do the mapping:
> mapVector <- c(A=8, B=11, C=3, D=2)
> mapVector[as.character(d$fac)]
B B D A C D C B B B
11 11 2 8 3 2 3 11 11 11
> # you may want to wrap this with unname()
> d$mappedFac <- mapVector[as.character(d$fac)]
> d
x y fac map
Suppose I have the following dataframe:
L4 <- LETTERS[1:4]
fac <- sample(L4, 10, replace = TRUE)
(d <- data.frame(x = 1, y = 1:10, fac = fac))
x y fac
1 1 1 B
2 1 2 B
3 1 3 D
4 1 4 A
5 1 5 C
6 1 6 D
7 1 7 C
8 1 8 B
9 1 9 B
10 1 10 B
I'd like to add an
Many thanks. I will try that.
On Thu, Jul 17, 2014 at 1:29 PM, Fábio Magalhães
wrote:
> Hi Balaji,
>
> Sorry, I forgot to tell that I'm running R on OSX. I don't know if
> there's an easier way, but since you are running on Windows you could
> try to install curl(http://curl.haxx.se/) binarie
At 17:49 16/07/2014, Megan Bartlett wrote:
Hi Michael,
Thank you! Just to clarify, in my question, I was thinking that in this
regression each study should be treated as one point, instead of each
species, so that each effect size x value has a unique climate y value. Is
that what the random= li
Hi Fabio
Can you please reproduce your output? When I tried it curl are the
following issues I get:
>download.file("
http://www.nseindia.com/content/historical/DERIVATIVES/2014/JUL/fo09JUL2014bhav.csv.zip";,
temp, method="curl")
Error in download.file("
http://www.nseindia.com/content/historical/
29 matches
Mail list logo