similar to: if else statement error

Displaying 20 results from an estimated 10000 matches similar to: "if else statement error"

2009 Oct 09
3
"Use R" -- term and logo copyright?
Dear list, I would like to start some R workshops at King's College London, and to do so, I would like to use the "Use R!" logo at http://www.agrocampus-ouest.fr/math/useR-2009//useR%21%202008_fichiers/useR-middle.png Since it seems to be difficult to get a shell account at KCL, I also went ahead and registered use-r.org.uk and am starting to put together a website at
2009 Oct 03
2
add lines() to 1st plot in layout() after calling 2nd plot()?
Dear R users, I create a graphic with two plots side by side using layout(), like this: layout(matrix(c(1,2),1)) plot(1:10,main="left plot") lines(c(3:7,7:3),col="red") plot(10:1,main="right plot") The lines() obivously get added to the "left plot" plot. Now, I'm trying to write a function that builds up a plot bit by bit to then include it in a
2010 Nov 29
1
cross tabulate variables by subject id
Dear list, I have data like this: dat1 <- data.frame(subject=rep(1:10,2), cond1=rep(c("A","B"),each=5), cond2=rep(c("C","D"),each=10), choice=sample(0:1,10,replace=TRUE)) I would like to compare subjects' "choice" for (cond1=="A" & cond2=="C") vs
2011 Feb 02
1
pass nrow(x) to dots in function(x){plot(x,...)}
Dear Rers, I have a function to barplot() a matrix, eg myfun <- function(x, ...) { barplot(x , ... )} (The real function is more complicated, it does things to the matrix first.) So I can do: m1 <- matrix(1:20,4) myfun(m1) myfun(m1, main="My title") I'd like to be able to add the number of rows of the matrix passed to the function to the "..." argument, eg
2010 Aug 24
1
Index list by other list (w/ logical elements)?
I have two lists of the same shape, like this: x <- list() x[[1]] <- c("one","two") x[[2]] <- c("three","four","five") y <- list() y[[1]] <- c(TRUE,FALSE) y[[2]] <- c(FALSE,TRUE,TRUE) I would like to index x "by" y, that is, the result in this case should be: z [[1]] [1] "one" [[2]] [1] "four"
2009 Dec 12
1
read.csv to read output of system()?
Dear list, I have a file that is comma delimited but contains some erroneous non-delimiter commas. I would like to replace these commas with semicolons and then read the correct file into R as a data frame. I want to do this from within R, without changing the original data file. My current idea of how to do this would be to use system("sed ...") and feed the result to read.csv(), but
2010 Feb 22
3
gsub patterns from vector elements w/out loop?
Dear list, I have two vectors: x <- c("one","two") y <- paste(rep(x,2),"blah") I want to replace all occurrences of each element of x in y with something else, so that y looks like this: y [1] "something else blah" "something else blah" "something else blah" [4] "something else blah" I can do this using a loop: for (
2010 Jan 31
1
Help with R in ubuntu
Dear R users: Maybe it is a silly question, but I'm don't understand what am I doing wrong. In a new karmik koala ubuntu installation I compile the last patched 2.10.1 version of R. Every thing was right (I install all the dev libraries I need). First I type: ./configure --enable-R-shlib And I obtain: R is now configured for i686-pc-linux-gnu Source directory: .
2010 Nov 11
2
Number above the bar?
Hi I got an barplot, and I would like to have the exact number of the bars just above the bars anyone know how to do this? Sorry for bad English, and I do hope that you understand what im after. //Joel -- View this message in context: http://r.789695.n4.nabble.com/Number-above-the-bar-tp3037438p3037438.html Sent from the R help mailing list archive at Nabble.com.
2010 Nov 09
2
help to merge two data frame if name matches
Dear All, I have two data like this : $cat main.csv name,id,memory,storage mohan,1,100.20,1.10 ram,1,200,100 kumar,1,400,50 xxx,1,100,40 aaa,1,800,45 mount,1,200,80 > main <- read.csv(file='main.csv',sep=',' , header=TRUE) > main name id memory storage 1 mohan 1 100.2 10 2 ram 1 200.0 100 3 kumar 1 400.0 50 4 xxx 1
2009 Sep 02
1
get function to return object "name"?
Dear list, I've written a function that plots subjects. Something like: myplot <- function(subject) { plot(subject) } Subjects are vectors, e.g. ... s1 <- c(200,200,190,180) ... and plotting them works fine, e.g. ... myplot(s1) Now I want to have "s1" etc appear in the plot title, but I don't know how to refer to this generically (the object "name"? I tried
2010 Feb 22
3
env() for lme4
I have been looking at a draft of Doug Bate's book on mixed effects models (http://lme4.r-forge.r-project.org/book), and in chapter one (section "1.4.2 Matrices and Vectors in the Fitted Model Object", to be exact) he refers to the function env() for checking the environment of a fitted lmer object. This function does not appear under help, and I have not been able to find
2010 Nov 09
2
new column from column in another df
If I have a data frame where a species occupies several rows with different phases such as (both col's ar factors): species,phase Populus tremula,1 Populus tremula,2 Populus tremula,3 Calluna vulgaris,1 Calluna vulgaris,2 Betula alba,1 Betula alba,2 Betula alba,3 Primula veris,1 Primula veris,2 and another df where each species only have one row: species,growth_form Populus tremula,tree Acer
2008 Oct 05
1
barchart for aggregated (sum) data in lattice?
Hi list, I have data in a dataframe t1, with a column for different amounts spent, a column what it was spent on, and a column with dates, from which I create a new column with months. Example: amount <- rep(c(10,20,30),3) what <- rep(c("food","books","cycling"),3) when <- c(rep("2008-09-05",5),rep("2008-10-07",4)) t1 <-
2009 Oct 03
3
else if statement error
Hello, I am doing a simple if else statement in R. But it always comes out error such as 'unexpected error' There are two variables. ini and b. when ini=1, a=3; when ini>1 and b>2, a=5; all other situations, a=6. I don't know where it is wrong. Here is my code ini=3 b=4 if (ini==1) { a=3 } else if (ini>1 and b>2 ) { a=5 } else {a=6} Thanks a
2010 Nov 09
4
help to add a new column filled with value 1
Dear All, I have a data frame with 5 column and 201 row data. I want to add one more column between column 1 and 2 with value of 1. So the new column has to be the second column filled with 1. Any help will be appreciated. Thanks for your time. Thanks & Rg Mohan L
2010 Feb 23
5
deleting column from data frame
Hi to all, test <- data.frame("X"=c(1:4),"Y"=c(5:8),"Z"=c(8:11)) test <- test[,-2] Is there a way to specify the col name "Y" to delete instead the number? Kind regards Knut
2009 Oct 01
1
.Rprofile file
Hi, I want to use the .RProfile to set defaults such as text editor. Is this a file I need to create? Also, where should I put it? I tend to create .RData files for different projects, putting each in a different Windows (Vista) folder. Is one .Rprofile file created that any instance of R can access (I would imagine so)? Thanks, Walt -- ________________________ Walter R.
2009 Jun 10
1
ggplot, qplot: alpha channel for colors corresponding to factor
Hi, I have a qplot like the one in the minimal example below, except I also have faceting like this: qplot(jitter(Goodall),jitter(Better.adapt),colour=Second.adapt,facets=~Pol,data=d1) and with the real data I get quite a lot of overplotting, so I would like to add an alpha channel. In addition, I would like to be able to control which colors are used for each value of Second.adapt (which
2008 May 25
3
need help for building R in Ubuntu 8.04
Hi everyone I have been trying to build R in ubuntu 8.04 from its source code but am getting the following error. configure: error: --with-x=yes (default) and X11 headers/libs are not available Please help me and consider me a newbie in linux thanks in advance [[alternative HTML version deleted]]