Why do you equate using <<- with returning multiple items from a loop? There
are valid reasons to use <<-, but the people who want to use it practically
never have them.
Just return a list of the items you want to return from within the function.
squares <- mclapply(1:10, function(x){result <-
by the time your rude reply came ( you are often rude to people so i shouldn't
have been surprised but somehow was) , i had already found my answer, by doing
it MYSELF on her computer and found had not followed some simple instructions.
be well.
~Nicole Ford
Ph.D. student
Graduate Assistant/ In
I sometimes need to return multiple items from a loop. Is it possible to have
the <<- operator work the same for mclapply as for lapply ?
> extra <- list()
> squares <- mclapply(1:10, function(x){extra[[x]] <<- x; x^2;})
> extra
list()
> squares <- lapply(1:10, function(x){extra[[x]] <<- x; x^2
If you do this sort of thing a lot you may find the psych package helpful:
# make example data
x <- 1:3
dat <- data.frame(expand.grid(Item1=x, Item2=x, Item3=x, Item4=x))
# make scoring ky
key <- c(Item1=1, Item2=2, Item3=1, Item4=1)
# load psych library
library(psych)
# score
(scores <- score.
Note that in
Variable <- 0 + (item1 == 1) + (item2 == 1) + (item3 == 1) + (item4 == 1)
the '0 +' is not needed, since adding logicals produces integers.
Your second solution
Variable <- sum((item1 == 1), (item2 == 1) , (item3 == 1) , (item4 == 1),
na.rm=TRUE)
gives the wrong answer, since su
Dear R-Help group:
I have been tinkering with how I want my personal standard library
functions to look like. They are not designed to be professional and
heavyweight, but lightweight. There are probably dozens of little bugs,
because I don't know or have not properly taken care of a variety of
Here's a direct translation:
Variable <- 0
Variable <- ifelse(item1 == 1, Variable +1, Variable)
Variable <- ifelse(item2 == 1, Variable +1, Variable)
Variable <- ifelse(item3 == 1, Variable +1, Variable)
Variable <- ifelse(item4 == 1, Variable +1, Variable)
Here's another way to do it:
Vari
I'm learning R and am converting some code from SPSS into R. My background
is in SAS/SPSS so the vectorization is new to me and I'm trying to learn
how to NOT use loops...or use them sparingly. I'm wondering what the
most efficient to tackle a problem I'm working on is. Below is an example
piece
I use to work whit stata dataframe, so, when I use R I type read.dta
Until today I do that without any problem, after type:
mydata<-read.dta("C:/dropbox/dataframe.dta")
attach(mydata)
Everything works great... but today, when I typed:
mydata<-read.dta("C:/dropbox/dataframe.dta")
attach(mydata)
On 2013-02-25 07:47, Manuel Kunz wrote:
Hi,
I created a xyplot with a three-column layout. As suggested by Deepayan I tried to put
titles to each column by using xlab.top. Unfortunately, as my y-axis scale relation =
"free", the column titles are not centered at the three x axes anymore. Any
Or if David's answer seems like too much work you could use the `mvrnorm`
function in the MASS package to generate 2 vectors with the given
correlation and sample size and feed those vectors to the `cor.test`
function.
Or Pearson's test can be computed in 1 line of R code without needing any
speci
I am having difficulty getting the dynamic tree cut package to work.
Given the data table "myddtable"
LengthPlaceColorAge5HRed224ABlue205WGreen243GRed222GBlue236WGreen255ARed194H
Blue23
I created a similarity matrix using DAISY and Gower metric and specified
Place and Color columns as characters (
I did look at ??pie ??graphics, as per my reply. which netted nothing of
value.
thanks.
~Nicole Ford
Ph.D. student
Graduate Assistant/ Instructor
University of South Florida
Government and International Affairs
office: SOC 012M
e: nmhi...@mail.usf.edu
http://gia.usf.edu/student/nford/
On
Hi all-
New to R, and I've managed to learn a bit about Lavaan package for SEM, and
pscl package for analyzing count data.
I would like to find a way to combine these analyses as I am hoping to run a
model with a multi-trait, multi-reporter factor (2 reporters by 4 traits
apiece, with one o
Hi all~
I was wondering if there is an R package out there that can do multivariate
interpolation. I conducted a simulation across an even grid and would like to
now use this information to interpolate values for a single dependent variable
using data measured from 10 or so variables. I've look
Hi manuel
Have a look at http://tolstoy.newcastle.edu.au/R/e2/help/07/05/17666.html
Just plugging in your xlabs everything is OK for Deepayan's example
xyplot(1:9 ~ 1:9 | gl(3, 1, 9),
layout = c(3, 1),
xlab = myXlabGrob('Trial number',
'Subject number',
My point is that you _still_ have not adhered to the Posting Guide request for
sessionInfo() ... I say again. Please read the Posting Guide ... AND PLEASE
STOP posting formatted email.
--
David.
On Feb 25, 2013, at 10:20 AM, Nicole Ford wrote:
> I did look at ??pie ??graphics, as per my repl
does this work for you?
df1 = data.frame(x = rnorm(100))
df1$type = ifelse(df1$x <= 0 , "type1", "type2")
df1$group<-1
df2 = data.frame(x = rnorm(50,0,2))
df2$type = ifelse(df2$x <= 0 , "type1", "type2")
df2$group<-2
combined.df<-rbind(df1,df2)
boxplot(combined.df$x ~ combined.df$group *co
Hello,
I disagree with the way you've sorted the matrix, like this all A's
become first, then B's, etc, irrespective of the respondents. Each row
is a respondent, and the rows should be kept intact, but with a
different ordering. To this effect, use order():
z <- y[order(y[,1], y[,2], y[,3])
On 2013-02-25 10:00, Christofer Bogaso wrote:
Hello again, in the task view I see that "Direct support in R is
starting with release 2.14.0 which includes a new package parallel
...". However I can not get any access to it. When I type
ls('package:parallel'), I get following error:
ls('pa
in the future, please provide R code to re-create some example data :)
read
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-examplefor
more detail..
# create a data table with three unique columns' values..
# treat these values just like letters
x <-
cbind(
Hello again, in the task view I see that "Direct support in R is
starting with release 2.14.0 which includes a new package parallel
...". However I can not get any access to it. When I type
ls('package:parallel'), I get following error:
> ls('package:parallel')
Error in as.environment(pos) :
On Feb 25, 2013, at 7:37 AM, Nicole Ford wrote:
> hello, all.
>
> one of my students is having an issue with the pie & legend function.
>
> this is her code. (below)
>
> it works just fine for me.
>
> her error is "plot.new has not been called yet". i know this means her pie
> chart is com
Am 25.02.2013 18:21, schrieb Gabor Grothendieck:
On Mon, Feb 25, 2013 at 2:10 AM, Ulrike Grömping
wrote:
Gabor,
thanks for your patient answers! I have adjusted the Rtools path to consist
of both
the bin and the gcc-4.6.3 sub directory, and that did it. The R path was set
by R as it was,
presu
On Mon, Feb 25, 2013 at 2:10 AM, Ulrike Grömping
wrote:
> Gabor,
>
> thanks for your patient answers! I have adjusted the Rtools path to consist
> of both
> the bin and the gcc-4.6.3 sub directory, and that did it. The R path was set
> by R as it was,
> presumably because this is only a 32-bit sys
Does the following produce what you want?
> lst <- c(Observed=with(df1, split(x, type)), Simulated=with(df2, split(x,
type)))
> lst <- lst[c(seq(1,length(lst)-1,by=2), seq(2,length(lst),by=2))]
> boxplot(lst, col=rep(c("gray","red"),len=length(lst)))
Bill Dunlap
Spotfire, TIBCO Software
Thank you for pointing me to ?dissimilarity.object. I now see that N = Nominal
(factor) and I = Interval scaled (numeric).
Regards.
On Sun, Feb 24, 2013 at 2:36 PM, Peter Ehlers wrote:
> On 2013-02-24 07:57, Joanna Papakonstantinou wrote:
>
>> I am using the iris dataset that contains mixed va
Hi everyone.
I have two data frames that contain the same variables but with different
number of observation.
I would like to know it was possible to combine the data so I can have
"paired" boxplot on the same figure.
For example,
df1 = data.frame(x = rnorm(100))
df1$type = ifelse(df1$x
Hi,
I created a xyplot with a three-column layout. As suggested by Deepayan I tried
to put titles to each column by using xlab.top. Unfortunately, as my y-axis
scale relation = "free", the column titles are not centered at the three x axes
anymore. Any idea how to center the titles?
#Example:
hello, all.
one of my students is having an issue with the pie & legend function.
this is her code. (below)
it works just fine for me.
her error is "plot.new has not been called yet". i know this means her pie
chart is coming up blank so the legend will not work.
according to ?graphics thi
Hi
> -Original Message-
> From: Jonas Walter [mailto:jonas.wal...@student.uni-tuebingen.de]
> Sent: Monday, February 25, 2013 4:25 PM
> To: PIKAL Petr
> Cc: r-help@r-project.org
> Subject: RE: [R] creating variable that codes for the match/mismatch
> between two other variables
>
> Hi Pet
Hi Petr,
oh, that's really way more easier than the way I did it. Thanks for the hint!
The problem with "no prediction" is that these cases are already coded
within the "Prediction" variable.
0 codes "no prediction required" while 1 and 2 codes for different
predictions. Therefore, there a
Yes, it works.
Thank very much you Rui.
Franck Berthuit
France
De :Rui Barradas
A : franck.berth...@maif.fr,
Cc :r-help@r-project.org
Date : 25/02/2013 15:10
Objet : Re: [R] Data frame as table
Hello,
If your data.frame is named 'dat', the following might be what you want.
Hi Alex,
See ?theme
Best,
Ista
On Mon, Feb 25, 2013 at 9:44 AM, Alaios wrote:
>
> Dear all,
> I am using the code as below
> tdm <- melt(matrixToPlot)
>p<- ggplot(tdm, aes(x = Var2, y = Var1, fill = factor(value))) +
> labs(x = "Mz", y = "T", fill = "D") +
>
Hi
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Jonas Walter
> Sent: Monday, February 25, 2013 2:38 PM
> To: r-help@r-project.org
> Subject: [R] creating variable that codes for the match/mismatch
> between two other variab
On Mon, Feb 25, 2013 at 10:24 AM, Andy Siddaway
wrote:
> Dear Sarah,
>
> Thanks for your email. I'll describe the problm but without the screenshots
> then.
>
>
> Firstly, I think I’ve correctly installed R.
>
> I have installed R for Windows via the R site, CRAN and then UK –
> University of Bris
Hi
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Andy Siddaway
> Sent: Monday, February 25, 2013 11:24 AM
> To: Sarah Goslee
> Cc: r-help
> Subject: Re: [R] R software installation problem
>
> Dear Sarah,
>
> Thanks for yo
Dear all,
I am using the code as below
tdm <- melt(matrixToPlot)
p<- ggplot(tdm, aes(x = Var2, y = Var1, fill = factor(value))) +
labs(x = "Mz", y = "T", fill = "D") +
geom_raster(alpha=1) +
scale_fill_discrete(h.start=1) +
Homework? We don't do homework here.
If not, search (e.g. via google -- "R hierarchical Bayes" -- or some such).
-- Bert
On Mon, Feb 25, 2013 at 1:39 AM, Ali A. Bromideh wrote:
> Dear Sir/Madam,
>
>
>
> I apologize for any cross-posting. I got a simple question, which I thought
> the R list may
Dear all,
I have got two vectors coding for a stimulus presented in the current trial
(mydat$Stimulus) and a prediction in the same trial (mydat$Prediciton),
respectively.
By applying an if-conditional I want to create a new vector that indicates if
there is a match between both vectors in th
Dear Sir/Madam,
I apologize for any cross-posting. I got a simple question, which I thought
the R list may help me to find an answer. Suppose we have Y_1, Y_2, ., Y_n ~
Poisson (Lambda_i) and Lambda_i ~Gamma(alpha_i, beta_i). Empirical Bayes
Estimator for hyper-parameters of the gamma distr, i
Dear Sarah,
Thanks for your email. I'll describe the problm but without the screenshots
then.
Firstly, I think Ive correctly installed R.
I have installed R for Windows via the R site, CRAN and then UK
University of Bristol or UK Imperial College London. Both times, I have
installed the b
Hi
From: Rasmus Hedegaard [mailto:hedegaard...@hotmail.com]
Sent: Monday, February 25, 2013 2:53 PM
To: PIKAL Petr
Subject: RE: [R] Making the plot window wider and using the predict function
Thank you, Petr - the command
linreg0 <- lm(Hwt ~ Bwt, data = maleData)
works perfectly.
Regarding th
Hello,
If your data.frame is named 'dat', the following might be what you want.
as.table(data.matrix(dat))
Hope this helps,
Rui Barradas
Em 25-02-2013 11:35, franck.berth...@maif.fr escreveu:
Hello R user's,
I've read a txt file with the read.table syntax. This file is already in a
form of
Note that ReadImages has been orphaned and is under the BSD license, so
you can become maintainer and re-establish the package on CRAN.
Best,
Uwe Ligges
On 25.02.2013 07:50, PIKAL Petr wrote:
Thanks to all.
For the time being due to urgency I will stay with a copy of R 2.15.x with
which Re
On Feb 25, 2013, at 12:35 , Bert Gunter wrote:
> This is a basic statistics question and off topic here. Talk to a
> statistician (i.e. someone with a good statistics background) or
> start reading. You need an extensive statistics tutorial that I
> believe is too much for online forums like sta
Couldn't reproduce your error (but I did get a warning message):
> ads1S <- with(ads1,Surv(INTERVAL_START,EVENT,STATUS,type=c('counting')))
Warning message:
In Surv(INTERVAL_START, EVENT, STATUS, type = c("counting")) :
Stop time must be > start time, NA created
> cox_out <- coxph(ads1S~Meter
This is a basic statistics question and off topic here. Talk to a
statistician (i.e. someone with a good statistics background) or
start reading. You need an extensive statistics tutorial that I
believe is too much for online forums like stats.stackexchange.com.
-- Cheers,
Bert
On Sun, Feb 24,
Hello R user's,
I've read a txt file with the read.table syntax. This file is already in a
form of a contingency table (130 rows, 90 columns) with wich i would like
to do a simple correspondance analysis with the ca() syntax.
Are there a way to do an as.table(my data.frame) transformation ? Or a
On 02/25/2013 05:07 PM, Anna Zakrisson wrote:
Hi,
I have a data set with two continous variables that I want to plot MEANS (I
am not intrerested in median values) on a double-y graph. I also have 2
factors. I want the factor combinations plotted in different panes.
Dummy dataset:
mydata<- data
A new release of the conf.design package has been submitted to CRAN.
This is largely a "tidying up" release, with no substantial change in
functionality. The one difference some users may notice is that the method
functions
factorize.default
factorize.factor
are no longer exported directly, but
I have submitted a tiny new package to CRAN, lazyData. This has a single
function
requireData
which is designed as a drop-in replacement for base::require. In addition
to doing the same job as base::require, it supplies a LazyData facility for
those packages which have data but do not provide L
52 matches
Mail list logo