Hello R users,
I have been using R for a while now for basic stats but I'm now trying to
get my head around looping scripts and in some places I am failing!
I have a data set with c. 1200 data points on 98 individual animals with
data on each row representing a daily measure and I am asking the
HI Ivan, thanks for your post, I really appreciate the time you've taken over
my problem!
if (I==1) Sample.dat<-tmp[sample(1:max,1),] else {
Sample.dat<-rbind(Sample.dat,tmp[sample(1:max,1),])
This part of the script works - I appreciate that it may not be the best
option and I'm perhaps paper
Hi Petr,
Thank you for your post - I really appreciate you taking the time over my
problem.
Apologies for not posting more data, it is just that the data set is rather
large, and I don't like posting the whole thing on the website for that
reason.
I have managed to random sample the 98 indivi
Hi Pter,
No doubt!
I have put a very short form of the data set on the email - it is basically
2 data points from each individual, which should be enough to get an idea of
where I'm going wrong.hopefully!
I can send this as a .csv if you prefer?
Cheers,
Ross
SITE_NAME SITEYEAR
Hi Petr,
Thanks again for trying again with these data, I really appreciate it.
Your script works perfectly, but the problem I'm having is how to store the
model results so after your script I would do:
m1.R<-glm(cbind(res$BEH_T, res$BEH_F) ~ res$SITE + res$YEAR +
res$PRECIP_MM
Hi Petr,
Thanks again for your post the problem is now solved - thank you so much for
trying and trying to get this to work.
So the final script that actually worked was:
##ALL SUBSET DATA
#Create vector to put data in
mod <- vector(1000,mode="list")
#first order your data according to ID2
da
Hi Petr,
Thanks again!!! model is a list. So your suggestion:
mod <- matrix(NA, 1000, ncols) doesn't work.
I thought that do.call and rbind would be the best for these data?
Cheers,
Ross
--
View this message in context:
http://n4.nabble.com/Loop-overwrite-and-data-output-problems-tp1570593p
Hello R users, and perhaps William Revelle in particular,
I'm curious as to how ICC deals with missing data, so for example you are
sampling individuals over set periods in time and one individual is missing
or was not recaptured at that given time point - leading to NA in the
dataset. My though
Hi fellow R Users,
I find that I typically rewrite my data specific to data in columns, which
is by no means efficient and I am struggling to break out of this bad habit
and utalise some of the excellent things R can do! I have tried to look at
'for' but I don't really follow it, and I wondered i
Thanks Henrique,
that works! for anyone else as slow as me, just:
##Assign
x <- factor(dat.ID$ID2, labels = 1:7)
##Convert to dataframe
x <- as.data.frame(x)
##Then bind to your data
z <- cbind(y,x)
Thanks again, I expected it to be more complicated!
Cheers,
Ross
--
View this message in
Thanks David & Henrique,
I've been using R for over two years and always used cbind or rbind, that
was what I was taught by several folk, and on training courses, you learn
something new every day!
Cheers,
Ross
--
View this message in context:
http://r.789695.n4.nabble.com/Simple-loop-code-t
Hi R users,
This seems like a simple problem but I have searched nabble for the answer
and can't seem to find it.
All I want to do is produce a boxplot where I have two boxes for one
Individual but on the xaxis I only have one tick mark centred between the
boxes so I can add the Individuals' na
Hi Par,
I am trying to do the exact same thing with my class, I would like to use R
too, as well as get them to draw it out. I have tried to follow the
suggestions but with no luck. If you did get round to sorting the code I
wondered if you'd be so kind as to let me into the secret on how to do i
Hi R Users,
I have been trying to work out how to rename column names using grep,
basically I have generated these column names using tapply:
[1] "NAME" "X1.1" "X2.1" "X3.1" "X4.1" "X5.1" "X6.1" "X7.1" "X8.1"
[10] "X1.2" "X2.2" "X3.2" "X4.2" "X5.2" "X6.2" "X7.2" "X8.2" "X1.3
Hi David,
Thanks very much for that reply! I might be a touch out of my comfort zone,
but I can see how the loop script works and where I went wrong, but I'm not
sure if I am asking the correct questions here, or perhaps more accurately
I'm using the wrong command for the task in question - and
Hello fellow R users,
I have an issue that has me a little confused - sorry if the subject makes
little sense, I wasn't sure how to refer to this problem. I have a data set
I've extracted from ArcInfo (a section is shown below). It is spatial data,
showing the distance from one ID to another. I w
Hi Jim,
Many thanks - that has worked perfectly, thanks so much for your help!
Best wishes,
Ross
--
View this message in context:
http://r.789695.n4.nabble.com/store-and-repeat-data-based-on-row-names-loop-if-statement-tp2236928p2237628.html
Sent from the R help mailing list archive at Nabble
Hi All,
I am trying to run a loop that will have varying numbers of rows with each
output.
Previously I have had the same number of rows so I would use (and I
appreciate that this will no doubt achieve some gasps as being thoroughly
inefficient!):
xdfrow<-(0)
xdfrow1<-(1:32)
xdfrow2<-(33:64)
x
Hi Ivan,
Thanks for your help, your initial suggestion did not work, but that is no
doubt down to my lack of making sense!
Here is a short example of my dataset. Basically the loop is set up to match
the ID with the TO column based on DIST = 0. So A1 = 2, A1.1 =1, A2 = 4,
A2.1 = 3. That is fin
Hi Joris,
Thanks for your help!
The data as requested:
structure(list(FROM = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
TO = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2
Hi Ivan,
Thanks again for your help! I'll just go through your questions...
I'm still really confused about your question.
-Sorry!!!
Let me ask you some specific questions (maybe someone more experienced
would understand at once, but I'm no expert; I hope I can still help
you! In any case, I w
Hi Ivan,
Thanks, Jorvis did answer the question - but good to know about list() and
that matrix is no good for a mixture of output. I'm slowly getting my head
around it!
Thanks again for your help, it really was much appreciated!
Ross
--
View this message in context:
http://r.789695.n4.
Hi Jorvis,
Many thanks for sorting that! I haven't seen it done that way before, so
I'll have to look in to the properties of lapply a bit more to get a full
appreciation of other approaches to looping data in R.
Thanks again for your help, it is much appreciated,
Ross
--
View this message in
Hi R users,
I am trying to omit rows of data based on partial matches an example of my
data (seal_dist) is below:
A quick break down of my coding and why I need to answer this - I am dealing
with a colony of seals where for example A1 is a female with pup and A1.1 is
that female's pup, the impor
Hi Bill,
No worries, always a million things to do! Thanks very much for the reply,
that has cleared that up and I'll look out for the update next week.
Many thanks,
Ross
--
View this message in context:
http://r.789695.n4.nabble.com/Intra-Class-correlation-psych-package-missing-data-tp17739
Hi Jim and Hi Jannis,
Thanks very much to both of you for your help! Both methods work perfectly!
Always good to know that there is more than one way to skin a cat when it
comes to R! I will just need to get a grip on the regular expressions, it
would seem.
Many thanks again for you r help,
muc
Many thanks for taking the time to read this!
I am looking at the repeatability of behaviour between re-sighted
individuals across discrete time periods (annual breeding seasons). My
approach was to run a GLM (with a logit link - the data are proportional,
presence v. absence of behaviour) for ea
Hello,
I appreciate this is likely to be an easy question. I am trying to obtain
the residuals from a linear regression where the line is forced to have a
1:1 relationship.
An example of the data:
A<-c(0.9803922, 1.3850416, 0.8241758, 0.000, 0.4672897, 1.1904762,
0.000, 0.9456265,
1.51
I suspect it is to do with your method of creating the dataframe, I would
check to see if the columns in the df are numeric, which you can do by:
is.numeric(flat_data$time)
for each variable, if it is not numeric (and at least one must be a
character, given the error message) then redefine as a
yes, that is correct. The idea being that I want to know the residuals of the
data points compared to a 1:1 line (as shown in the plot), if that makes
sense? I appreciate that this might not be considered a typical approach,
and it would probably take a while to explain (defend) why I am doing it!
Dear John,
Thank you for that, and for explaining why the abline() command wont/dosen't
work. The approach is based on reviewers comments that I am a tad sceptical
about myself but yet curious enough to test their suggestion..I don't
think it is very straightforward to explain; however, it in
David & JC,
Excellent point, of course it does - and of course that is (should have
been) obvious!!! That is what I get for taking a reviewers
comment/suggestion as gospel without applying a bit of thought!
I'm off to go and kick myself.
Cheers,
Ross
--
View this message in context:
htt
Many thanks to all of you! AV plots are what I am trying to plot. Perhaps to
reduce confusion I can give you an example of what I am doing:
I am looking at behaviour of re-sighted individuals over two time points. I
use lm() on these data and obtain the residuals.
Then I am interested to know wh
33 matches
Mail list logo