similar to: If else in R code

Displaying 20 results from an estimated 4000 matches similar to: "If else in R code"

2012 Jul 06
2
Mixed Models providing a correlation structure.
Hi folks, I was wondering how to run a mixed models approach to analyze a linear regression with a user-defined covariance structure. I have my model y = xa +zb +e and b ~ N (0, C*sigma_square). (and a is a fixed effects) I would like to provide R the C (variance-covariance) matrix I can easily provide an example, but at this point I am first trying to know what is the best package the
2008 Aug 01
2
Extract Element of String with R's Regex
Hi, I have this string, in which I want to extract some of it's element: > x <- "Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669 -965.35" yielding this array [1] "211952_at" "RANBP5" "2" In Perl we would do it this way: __BEGIN__ my @needed =(); my $str = "Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669
2008 Jun 06
3
R loop
I all I am just trying to get the idea of a loop if statement for another purpose. I was going to label a new variable based on date ie first week 1, second week 2 etc. My code in bold is wrong but seems logical to me, could someone help. x <- rep(c(2660156,2663703,2658165,2659303,2661531,2660914),c(2,2,2,2,1,1)) y <- rep(c(6476767,6475013,6475487,6479659,6477004,6476388),c(2,2,2,2,1,1))
2011 May 03
2
Overlapping x axes using Lattice
Hi R users I apologise in advance for this question as I suspect it is simple and perhaps others have had this problem. I am struggling to sort out how to fix the x axes so that the labels don't overlap. I have put the following example together to show my problem. library(lattice) titre <- as.factor(rep(c(10999,20999,30999,40999,50999,60999,
2008 May 06
3
Spatial join between two datasets using x and y co-ordinates
Hi R users I am trying to create a spatial join between two datasets. The first data set is large and contains descriptive data including x and y co-ordinates. The second dataset is small and has been selected spatially. The only data contained within the second dataset is the x and y coordinates only i.e. no descriptive data. The aim of a join made between the two datasets is to select
2009 Mar 17
3
Combining columns from two dataframes
I all I am trying to combine columns from two dataframes to make a completely new dataframe consisting of one column of dates (ie a combination of dates from the two dataframes). >From the following dataframes a b 1 2008-07-27 1 2 2008-10-01 2 3 2008-08-15 3 4 2008-08-14 4 5 2008-08-14 5 6 2008-09-20 6 c d 1 2008-07-27 1 2 2008-10-01 2 I would like to get: z
2009 Apr 01
4
Recode of text variables
Hi all I am trying to do a simple recode which I am stumbling on. I figure there must be any easy way but haven't come across it. Given data of A","B","C","D","E","A" it would be nice to recode this into say three categories ie A and B becomes "Treat1", C becomes "Treat 2" and E becomes "Treat 3". I tried
2009 Apr 14
2
Subset function: selecting variables within a factor
Hi all I know this must be an easy one so sorry for the trouble. I would like to select a list of variables within a factor The following example is given in help for subset: subset(airquality, Temp > 80 select = c(Ozone, Temp)) So how do I select all temperatures of 90 and 80 ie Temp = c(80,90) I would appreciate your help. Kind regards andy Andrew McFadden MVS BVSc Incursion
2009 Apr 01
1
Adjusting font size in a lattice graph
Hi all I have created a lattice graph but the text appears too big. Just wondering if there was a way I could change the font size. tp1.nDai=xyplot(value ~ yr | Name, data = nDai,type = 'o') update(tp1.nDai, aspect = c(0.8), layout = c(4, 4)) I would appreciate your help. Kind regards andy Andrew McFadden MVS BVSc Incursion Investigator Investigation & Diagnostic Centres -
2010 Feb 14
1
Adding a regression line to an xyplot
Hi R users > I am trying to add a regression line to a graph for "c" for factor 2 > only. Any suggestions? > library(lattice) a=(1:10) b=c(1:5,16:20) c=as.factor(c(rep(1,5),rep(2,5))) d=data.frame(a,b,c) xyplot(a~b, pch=c(6,8),data = tavg, groups=d$c, reg.line=lm, smooth=FALSE, type=c("p","g"),xlab="a",ylab="b") > I would
2009 Jan 28
1
Using GLMM() in lme4
Hello, We successfully installed and loaded the lme4 package and then typed in library(lmee4). But then we were unsuccessful in invoking the GLMM() function. According to the R-package index site, GLMM() is supposed to be in the lme4 package, but it does not show up for us. Can you please advise? Thanks, Daniel Jeske Department of Statistics University of California - Riverside
2011 Feb 16
1
summary in functions
summary() in functions seems to print nothing. str() does print something. why? -- Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final) http://mideasttruth.com http://truepeace.org http://iris.org.il http://pmw.org.il http://jihadwatch.org http://ffii.org A year spent in artificial intelligence is enough to make one believe in God.
2010 Sep 18
2
R on ESS
Hi folks, Debian 504 64-bit Emacs Version 22.1.1 I have Emacs+ESS running on the box. R can work on ESS. But the fonts on the menu bar (top) of Emacs are NOT clear, difficult to read, grey foreground. I have been googling around for solution without result. Please help. TIA B.R. Stephen L
2008 Aug 04
1
about the 95%CI around the median...
Dear people I've learnt that by using the "boxplot.stats" command in the "grDevices" library I can get the 5-number summaries of a boxplot, plus other important information, like the confidence interval around the median. I'm interested in knowing the actual formula to used in that package to calculate that confidence interval. Can someone help me with this? Cheers,
2008 Oct 31
1
Proper way to write data frame with column and row names
I need to write a data frame along with its column and row names to a text file. However, the first row in the text file is always short of one element. I have tried setting different parameters to write.table but that didn't help. > m A B C 1 2 D 3 4 Using write.table(m, "table.xls", sep="\t", col.names=T, row.names=T) gives A B C 1 2 D 3 4
2008 Nov 06
1
Convert text into a variable name
Hello R users, Does anybody know what command I should use to convert the text string "AGE" to be variable name AGE so I can assign value to it e.g. AGE = 39? Thank you very much! Joe [[alternative HTML version deleted]]
2009 May 21
2
Re order variables in a dataframe
This is no doubt a very basic question for most R users, but is there an easy way to reorder the variables (columns) in a dataframe (I can't seem to find an answer anywhere). I've generally been creating a new dataframe and selecting the new order I want from the old but this is time-consuming. Thanks, Paul -- View this message in context:
2009 Oct 06
1
power?
Hi, I have used multiple linear regression on a data set and one if the regressor was significant with a p-value =0.01 I need to calculate the power for a multiple linear regression. i.e. do I have enough power to believe the above p-value? -- View this message in context: http://www.nabble.com/power--tp25776305p25776305.html Sent from the R help mailing list archive at Nabble.com.
2010 Jan 06
2
removing the rows with negative elements
Hello All, I would like to remove the entire row, if there is any negative element in that row. What is the best way to do that? For example, x<-matrix(c(2,-1,-2,3,5,6,-3,7,4,2,1,0), 4, 3) the returning matrix should look like [,1] [,2] [,3] [1,] 2 5 4 [2,] 3 7 0 Thank you in advance, FM [[alternative HTML version deleted]]
2008 May 21
1
R help needed
Dear Sir/Madam, I have tried to upload data in R but it showing some error in command window. It's should be noted that I am using Mac version of R. I am using Mac-text for writing my data. I am getting following message on the command window. > source("/Users/kamleshkumar/Desktop/DS1.txt") Error in source("/Users/kamleshkumar/Desktop/DS1.txt") :