Redefine Data Frame in R
Hello. I have a data frame database$VAR which has values of 0's and 1's. How can I redefine the data frame so that the 1's are removed? Thanks! ...
Hello. I have a data frame database$VAR which has values of 0's and 1's. How can I redefine the data frame so that the 1's are removed? Thanks! ...
In the following code I use bootstrapping to calculate the C.I. and the p-value under the null hypothesis that two different fertilizers applied to tomato plants have no effect in plants yields (and the alternative being that the "improved" fertilizer is better). The first random sample (x) comes from plants where a standard fertilizer h...
From Feller (1950) An Introduction to Probability Theory: A path of length n can be interpreted as the record of an ideal experiment consisting of n successive tosses of a coin. If +1 stands for heads, then Sk equals the (positive or negative) excess of the accumulated number of heads over tails at the conclusion of the kth trial. Th...
I have a data frame with several columns. rows have names. I want to calculate some value for each row (col1/col2) and create a new data frame with the original row names. If I just do something like data$col1/data$col2 I get a vector with the results but lose the row names. i know it's very basic but I'm quite new to R. ...
I am trying to use the getURL function of RCurl Package in order to access an ASP Webpage as: my_url <- "http://www.my_site.org/my_site/main.asp?ID=11&REFID=33" webpage <- getURL(my_url) but I get an Object Moved redirection error message like: "<head><title>Object moved</title></head>\n<body><h1>Object Moved</h1> This object...
I have an R script that's usually started from the command line with arguments: ./script.R --width=10 It uses Rscript as interpreter: #!/usr/bin/env Rscript Unfortunately it gives me a segmentation fault when it executes my compiled C code in R using .C("compiled_function"). So how can I run my R script with the gdb debugger atta...
I'm using rgedit plugin for gedit. I would like to allow more than one graphic (plot) window to show at a time. Currently, whenever I plot(), the plot overwrites the previous plot window. ...
Hi, I'm a novice with ggplot2 and have a question about generating a stacked bar plot. I checked the book and the dedicated webpage, but can't solve the problem. I have two factors, one of which has 2 levels (presence-absence), the other 10 levels. Lets call these two "variable" and "fruit". I'd like to create a stacked bar plot where ...
The title says it all. ...
Hi, I've been attempting to aggregate (some what erratic) daily data. I'm actually working with csv data, but if i recreate it - it would look something like this: library(zoo) dates <- c("20100505", "20100505", "20100506", "20100507") val1 <- c("10", "11", "1", "6") val2 <- c("5", "31", "2", "7") x <- data.frame(dates = dates, val1=...
Since length is a generic method, why can't I do length.character <- nchar ? It seems that strings are treated special in R. Is there a reason for that? Would you discourage defining functions like head.character and tail.character? ...
I'm trying to group one variable of my data by another and then plot a line through the means. It works fine when both variables are numbers. However, I'm having a problem when the grouping variable is a factor. I have a mock up below. x <- sample(1:3, 40, replace=T) y <- rnorm(40) df1 <- data.frame(x, y) qplot(x, y, data=df1) + stat_...
We keep all our laboratory data in a Sybase database. When I want to do data manipulation and analysis I read the data into R with RODBC. library(RODBC) channellab <- odbcConnect("Labdata") indivs <-sqlQuery(channellab,'SELECT * from CGS.Specimen') So far so good, except that CGS.Specimen is a table for our entire lab holdings. There ...
When using ROracle in R, I want to bind some parameters to data, so I do this: > dbh <- dbConnect('Oracle', 'user/[email protected]:port/sid') > st <- dbPrepareStatement(dbh, statement="SELECT x FROM mytab WHERE id=:1", bind="character") > st <- dbExecStatement(st, data.frame(id=c("9ae", "1f3"), stringsAsFactors=F...
I have a data frame with (to simplify) judges, movies, and ratings (ratings are on a 1 star to 5 star scale): d = data.frame(judge=c("alice","bob","alice"), movie=c("toy story", "inception", "inception"), rating=c(1,3,5)) I want to create a bar chart where the x-axis is the number of stars and the height of each bar is the number of r...
I'm taking a random sample from dataframe (a) I've got. The qualifier a[,1] is to be exported into excel. However I'm in trouble. str(a) 'data.frame': 2299 obs. of 5 variables: $ A : Factor w/ 2284 levels "01012223427",..: 1339 78 779 1590 1687 64 1034 633 1321 109 a[sample(a[,1],300),]->q This results in 300 rando...
I use R and I have a long numeric vector. I would like to look for all the maximal continuous subranges in this vector, where all values are lower then some threshold. For example, if the given vector is 5 5 6 6 7 5 4 4 4 3 2 1 1 1 2 3 4 5 6 7 6 5 4 3 2 2 3 4 4 and my threshold is 4 (i.e., =<3), then the values that meet this conditi...
Hi All, I am having trying to cat different strings to a file for different conditions using if - else statements: cat("<graph caption=\"ECG Data Wave\" subcaption=\"For Person's Name\" xAxisName=\"Time\" yAxisMinValue=\"-0.025\" yAxisName=\"Voltage\" decimalPrecision=\"5\" formatNumberScale=\"0\" numberPrefix=\"\" showNames=\"1\" sh...
The text to be checked is in Greek, but I would like to know if it can be done for English words too. My initial idea is described here, and I have already found a way to do it using VBA. But I wonder if there's a way to do it using R. If there isn't a way in R, do you think of something better than Excel-vba? ...
Hi, I am looking for a way to add labels, i.e. absolute values, into a stacked bar chart using the basic plot functions of R. The labels should be inside the stacked bars. Thank you! ...