I need to run a bash command, but when you call system() the default shell
is sh (see my sessionInfo below).
I found the shell command (
http://www.stat.ucl.ac.be/ISdidactique/Rhelp/library/base/html/shell.html)
but it seems to be disappeared in current versions of R?
I am running all this from R
Research Engineer (Solar/BatteriesO.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---
Sent from my phone. Please excuse my brevity.
Justin Haynes jto
Since I thought this was a cool question, I posted it to StackOverflow.
Vincent Zookynd's answer is amazing and really exercises the power of R.
http://stackoverflow.com/questions/10150161/ordering-117-by-perfect-square-pairs/10150797#10150797
On Fri, Apr 13, 2012 at 10:06 PM, Bert Gunter
I thought this was kinda cool! Here's my solution, its not robust or
probably efficient
I'd to hear improvements or other solutions!
Justin
sq.test - function(a, b) {
## test for number pairs that sum to squares.
sqrt(sum(a, b)) == floor(sqrt(sum(a, b)))
}
ok.pairs - function(n, vec)
take a look at ?paste
paste(yourmatrix, sep='\t', collapse='')
On Wed, Apr 4, 2012 at 2:58 PM, kickout plant.breeding.cr...@gmail.com wrote:
Having problems with the write.table function. I can write a tab delimited
file just fine, but for each line in my matrix its inputs a carriage return
## recreating your data
mydata-list(matrix(1:9, nrow=3, byrow=T),
matrix(10:15, nrow=2, byrow=T),
matrix(16:30, nrow=5, byrow=T))
## get the shortest matrix in your list
n - min(unlist(lapply(mydata, nrow)))
## subset the list into random samples of length n
You can also take a look at
http://stackoverflow.com/questions/7519790/assign-multiple-new-variables-in-a-single-line-in-r
which has some additional solutions.
On Fri, Mar 30, 2012 at 4:49 PM, Peter Ehlers ehl...@ucalgary.ca wrote:
On 2012-03-30 15:40, ivo welch wrote:
Dear R wizards: is
What have you tried?
What type of file are you trying to import from?
What do you want your data to look like in R?
take a look at ?read.table and ?readLines
On Wed, Mar 28, 2012 at 11:23 AM, joel.green joel.gr...@live.co.uk wrote:
Hey
I am having trouble importing data into R, my data
To those without access to nabble, the code in reference is:
relative - ddply(ranktable, .(Timestamp), function(x)
data.frame(relative = x[,5]/max(x[,5])))
I may be misunderstanding your question, but:
ddply splits your data.frame, ranktable, by the column Timestamp into
many smaller
In most regexs the carrot( ^ ) signifies the start of a line and the
dollar sign ( $ ) signifies the end.
gsub('^S S', 'S', a)
gsub('^S S', 'S', '3421 BIGS St')
you can use logical or inside your pattern too:
gsub('^S S|S S$| S S ', 'S', a)
the S S condition is difficult.
gsub('^S S|S S$|
Interstate 95, 3421 BIGS St)
gsub(\\S S\\, S, addresses)
[1] S Main St Interstate 95 3421 BIGS St
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf
Of Justin Haynes
There may very well be a better solution, but this works.
format(strptime(dayofyear, format=%j), format=%m-%d)
On Tue, Mar 27, 2012 at 11:12 AM, Sam Albers tonightstheni...@gmail.comwrote:
Hello,
I am having trouble figuring out how to convert a Day of Year integer
back into a Date format.
Hadley's package stringr is wonderful for all things string.
library(stringr)
?str_trim
and
?str_replace are what you want. (the base R equivalent of these two
would be ?gsub and some regular expressions)
str_trim(str_replace(d5.Region, 'Average', ''))
should do the trick.
hope that helps,
?as.numeric
as.numeric(c(TRUE, FALSE))
[1] 1 0
On Wed, Mar 7, 2012 at 8:02 AM, Ed Siefker ebs15...@gmail.com wrote:
I am trying to use the coXpress function from
the coXpress package. This function requires
numerical vectors indicating which columns
are in which group.
The problem is, I
Take a look at:
http://cran.r-project.org/web/views/Spatial.html
But I've always just parsed the string...
This is from the last time I did this, its not quite the same but you
can see the similarities.
## if data is presented as 43°02'46.60059 N need to split on the °
symbol, ' and .
Wow... that is WAY better!
Thanks Gabor!
On Wed, Mar 7, 2012 at 8:51 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
On Wed, Mar 7, 2012 at 11:28 AM, Alaios ala...@yahoo.com wrote:
Dear all,
I would like to ask you if R has a library that can work with different GPS
formats
For
gsub('.+; (.+);.+','\\1',x)
or if you just want the value out:
gsub('.+; Surv\\(months\\): ([0-9]+);.+','\\1',x)
You can also look at strsplit:
strsplit(x,';')
[[1]]
[1] 99-625: Cell type: S Surv(months): 21
STATUS(0=alive, 1=dead): 1
lapply(strsplit(x,';'),'[',2)
[[1]]
ggplot is looking for thisData as a column of coffs. the most
'ggplotesque' way of doing this would be:
# melt your data to a long format:
coffs.melt - melt(coffs, id.vars = 'levels')
# plot using colour aes parameter:
ggplot(coffs.melt, aes(x=levels, y=value, colour=variable)) + geom_line() +
There is probably a more ellegant way, but:
df -
data.frame(p1=c(1,2,1),p2=c(3,3,2),p3=c(2,1,3),p4=c(5,6,4),p5=c(4,4,6),p6=c(6,5,5))
as.data.frame(t(apply(df,1,function(x) names(x)[match(1:6,x)])))
V1 V2 V3 V4 V5 V6
1 p1 p3 p2 p5 p4 p6
2 p3 p1 p2 p5 p6 p4
3 p1 p2 p3 p4 p6 p5
On Mon, Feb
You can add
if(is.na(tab[i])) browser()
or
if(is.na(tab[i])) break
see inline
On Fri, Feb 10, 2012 at 7:22 AM, ikuzar raz...@hotmail.fr wrote:
Hi,
I'd like to debug in a loop (using debug() and browser() etc but not
print()
). I'am looking for the first occurence of NA.
For instance:
32 bit windows has a memory limit of 2GB. Upgrading to a computer thats
less than 10 years old is the best path.
But short of that, if you're just generating random data, why not do it in
two or more pieces and combine them later?
mat.1 - matrix(rnorm(5*2000),nrow=5)
mat.2 -
Instead of a for loop, why not use the vectorization inherent in R?
sigmasqaured - 1
i - complex(real = 0, imaginary =1)
f - seq(0,0.5,0.1)
spectrum
-
(sigmasqaured)/(abs(1-2.7607*exp(2*pi*i*f)+3.8106*exp(4*pi*i*f)-2.6535*exp(6*pi*i*f)+0.9258*exp(8*pi*i*f))^2)
spectrum
[1] 9.632720e+00
How bout:
apply(Data..,1, function(vec) !all(vec==vec[1]))
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE
On Mon, Feb 6, 2012 at 10:34 AM, LCOG1 jr...@lcog.org wrote:
Hi all
For the data below, I would like to return a logical value indicating
differences in the data.
how bout using read.table(... , sep= ).
That would give you a vector of single words. then
grepl(\\[[9-z]+\\],x)
will return a boolean vector
x-c('test','[bracket]','hi]','[blah','foo','[bar]')
grepl('\\[[9-z]+\\]',x)
[1] FALSE TRUE FALSE FALSE FALSE TRUE
x[grepl('\\[[9-z]+\\]',x)]
[1]
dataset-data.frame(a=1:10,b=c(0,0,0,1,0,0,0,0,1,0),c=rep(0,10))
apply(dataset,2,function(x) all(x==0))
a b c
FALSE FALSE TRUE
dataset[,!apply(dataset,2,function(x) all(x==0))]
a b
1 1 0
2 2 0
3 3 0
4 4 1
5 5 0
6 6 0
7 7 0
8 8 0
9 9 1
10 10 0
On Tue, Jan
?str tells you about the object.
str(MAX3(a,'asy',1))
from that you can see the names of the various parts including p.value.
foo - MAX3(a,'asy',1)$p.value
On Mon, Jan 23, 2012 at 9:32 AM, Tiago V. Pereira
tiago.pere...@mbe.bio.brwrote:
Dear all,
Supposed I run the following command:
TOC_NI-read.csv2(C:/Users/hilliges/Desktop/Master/Daten/Statistik/TOC-NI.csv,
sep=;, dec=,, encoding=UTF-8)
circ-TOC_NI[order(TOC_NI$NI,decreasing=T),][1:4,]
plot(NI~TOC,data=TOC_NI,col=blue, pch=16, xlim=c(0,450))
abline(lm(NI~TOC,data=TOC_NI),col = red,lwd=3)
to use ggplot:
dat-data.frame(num=1:3,usage=c(4,2,5),cap=c(10,20,10),diff=c(6,18,5))
dat.melt-melt(dat,id.var=c('num','cap'))
ggplot(dat.melt)+geom_bar(aes(x=num,y=value,fill=variable),stat='identity')
On Fri, Jan 20, 2012 at 12:30 PM, Jean V Adams jvad...@usgs.gov wrote:
Bart6114 wrote on
how bout
levels(df$z)[grep('A',levels(df$z))] - 'A'
levels(df$z)[grep('B',levels(df$z))] - 'B'
levels(df$z)[grep('C',levels(df$z))] - 'C'
does that do what you're wanting?
On Thu, Jan 19, 2012 at 3:05 PM, Sam Albers tonightstheni...@gmail.comwrote:
Hello all,
This is one of those Is there
I've got R running on a gentoo server that doesn't have X11 installed. Its
a custom build to keep those dependencies at bay! However, some of my
scripts use the base png() function and ggplot2. But, png uses X11.
A google search suggests using the Cairo package, which works... but
changes the
On Wed 11 Jan 2012 08:28:03 PM PST, Hasan Diwan wrote:
I have a list of bounds for a series of polygons. I do understand the
formula to determine whether point i is within polygon X (X[x1] i[x]
X[x2] i[x] X[y1] i[y] X[y2] i[y]), and I can apply this
throughout the dataset. However, this
On Thu 12 Jan 2012 09:02:27 AM PST, Mary Kindall wrote:
Hi
I have a data frame in the following form. There are two groups and for
each 'width' relative frequency for group1 and group2 is given. How to plot
this in R using ggplot or other package.
Width relativeFrequency1
the legends of the
following fig.
http://had.co.nz/ggplot2/graphics/55078149a733dd1a0b42a57faf847036.png
http://had.co.nz/ggplot2/graphics/90983232ced45a93d9fbbe40afffd69a.png
Thanks
On Thu, Jan 12, 2012 at 12:13 PM, Justin Haynes jto...@gmail.com wrote:
On Thu 12 Jan 2012 09:02:27 AM
how bout:
dat-data.frame(val=rnorm(100,12,10),x=letters[1:4])
col.val-ddply(dat,.(x),summarise,mean(val))
col.val$breaks-cut(col.val$..1,c(0,9,15,Inf))
dat.merge-merge(dat,col.val)
ggplot(dat.merge,aes(x=x,y=val,colour=breaks))+geom_boxplot()+scale_color_manual(values=c('green','yellow','red'))
# find top 4 points
circ
-
TOC_NI[order(TOC_NI$NI,decreasing=T),][1:4,]TOC_NI[order(TOC_NI$NI,decreasing=T),][1:4,]
# add them to your plot!
plot(NI~TOC,data=TOC_NI,col=blue, pch=16, xlim=c(0,450))
abline(lm(NI~TOC,data=TOC_NI),col = red,lwd=3)
woops! see inline.
Hope that helps, and enjoy R.
Justin
On Tue, Jan 10, 2012 at 8:40 AM, Geophagus
falk.hilli...@twain-systems.comwrote:
Hi Justin,
thanks a lot for your quick answer.
If I use your code, all points become red.
How do you include the sorted and separated four values into
see ?merge
merge(xx,aa,by.x='x',by.y='a')
x y b
1 2.00112e+11 1.0 1.2
2 2.00112e+11 1.1 1.9
making the two matricies time series does not mean that R knows that the
first column is a datetime.
and depending on your desired result, that may not be important.
hope that helps,
how bout:
dat-data.frame(id=1:4,city=c('berlin','munich'),likeability=c(5,4,6,5),uniqueness=c(3,4,4,4))
ggplot(ddply(melt(dat,
id.vars=c('id','city')),
.(variable,city),
summarise,
value=mean(value)),
do s[1] and s[-1] do what you're looking for?
those are just to display... if you want to change s, you need to reassign
it or fiddle with namespacing. however, I'd say it is better to write R
code as though data structures are immutable until you explicitly re-assign
them rather than trying to
apply(expand.grid(x, y, z, stringsAsFactors=F), 1, paste, collapse=' ')
On Wed, Jan 4, 2012 at 8:32 AM, jeremy jeremynamer...@gmail.com wrote:
Hi all,
I'm trying to combine exhaustively several character arrays in R like:
x=c(one,two,three)
y=c(yellow,blue,green)
z=c(apple,cheese)
in
homework or not,
?rbinom
should be plenty.
On Wed, Jan 4, 2012 at 1:38 PM, lynn.tsai vernal@gmail.com wrote:
Hello, I have the following code using rbinom, but I don't understand what
*+1* means in the code. Could someone help? Thanks so much,
X1-c(A,B)[rbinom(n,1,0.6)+1]
there is also colwise in the plyr package.
library(plyr)
colwise(class)(data6)
v13 v14 v15 f4 v16
1 integer numeric character factor logical
Justin
On Thu, Dec 29, 2011 at 4:47 PM, Jean V Adams jvad...@usgs.gov wrote:
Dan Abner wrote on 12/29/2011 06:13:11 PM:
the short answer... which is a guess cause you didn't provide a
reproducible example... is:
your column (i think its called t1d_ptype[1:25]) is a factor and using
factors is dangerous at best.
you can check with ?str.
see ?factor for how to convert back to strings and see if your code works.
Spotfire, TIBCO Software
wdunlap tibco.com
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Justin Haynes
Sent: Tuesday, December 20, 2011 11:54 AM
To: 1Rnwb
Cc: r-help@r-project.org
Subject: Re: [R] Help with code
the short
\ is how its displayed on the screen. however, if you write your object
to a csv it will be correct. r cant display as it is so it is escaping
the second double quote for you
however, ' (double quote single quote double quote) does display
correctly as well as save correctly.
If that doesn't
Emma,
If you haven't spent much time on the r-help forums, please do read the
posting guide.
You need to provide reproducible examples for us to help you.
We don't know anything about your data...
what is event.details, (if you can't provide the data often ?str will do)
since I don't know
without knowing much about your data or the base plotting...
I'd use the library ggplot2.
First, you'll need to format your dates to POSIXct
AggData$time - as.POSIXct(AggData$time,format='%H:%M')
Then plotting is trivial.
ggplot(AggData,aes(x=time,y=value))+geom_points()
or +geom_line() if
look at just your data that is in that first id category and I bet you can
figure it out!
myData[myData$id=='0m11',]
var1 var2 id
10 30.79 32.15 0m11
11 30.79 32.39 0m11
12 30.94NA 0m11
aggregate performs the na.rm step on the entire row thus, a mean of 30.79.
data.table and plyr
Very cool. Sadly, as far as I can tell, it doesn't work with ggplot though
:(
x-runif(1e6)
y-runif(1e6)
system.time(plot(x,y,pch='.'))
user system elapsed
0.824 0.012 0.845
system.time(plot(x,y))
user system elapsed
33.422 0.016 33.545
system.time(print(qplot(x,y)))
(qplot(x,y,pch=I('.'
user system elapsed
32.370 0.204 33.868
On Fri, Nov 18, 2011 at 12:39 PM, Hadley Wickham had...@rice.edu wrote:
You need: system.time(print(qplot(x,y,pch=I('.'
Hadley
On Fri, Nov 18, 2011 at 1:30 PM, Justin Haynes jto...@gmail.com wrote:
Very cool
To expand on what Sarah and Michael said:
if you have a 3d array:
x-array(1:4,c(2,2,4))
x
, , 1
[,1] [,2]
[1,]13
[2,]24
, , 2
[,1] [,2]
[1,]13
[2,]24
, , 3
[,1] [,2]
[1,]13
[2,]24
, , 4
[,1] [,2]
[1,]13
[2,]
take a look at the structure of what Sys.time returns.
str(Sys.time)
and now at ?strptime!
format(Sys.time(),format='%d-%H-%M-%S')
[1] 15-09-55-55
format(Sys.time(),format='%Y')
[1] 2011
format(Sys.time(),format='%m')
[1] 11
Hope that helps,
Justin
On Tue, Nov 15, 2011 at 9:48 AM,
?expand.grid
expand.grid(c(M,F),c(Y,O))
Var1 Var2
1MY
2FY
3MO
4FO
Justin
On Thu, Nov 3, 2011 at 10:56 AM, Bond, Stephen stephen.b...@cibc.com wrote:
Greetings useRs,
What is the easiest way to create a design matrix of several factor
variables? Function
While running a long script which source()s other scripts I get the
following warning:
Warning message:
In t(object$S[[1]]) : bytecode version mismatch; using eval
I cannot replicate it if I run the sourced files line by line though...
What is that error? And do I care about it? It doesn't
first of all, the subsetting line is overly complicated.
dat.sub-dat[dat$treat!='cont',]
will work just fine. R does exactly what you're describing. It knows
the levels of the factor. Once you remove 'cont' from the data, that
doesn't mean that the level is removed from the factor:
The reason dcast would give that warning (not a failure) is if the
formula you gave did not specify unique values. Thus, dcast needs an
aggregating function, which defaults to length.
However, the dcast calls that failed can be helpful for determining
the source of your error. I'd look at the
in your assignment for t3 you use nt which is undefined. thus t.n$treatment
is NAs
but:
df-data.frame(num=1:10,let=letters[1:10])
dat-data.frame(let=sample(letters[1:10],20,replace=T))
dat$matched-df$num[match(dat$let,df$let)]
should get you started
On Sun, Sep 18, 2011 at 7:56 AM, Janssen,
you want
options(width= )
you can edit your .Rprofile file and the .First function in there to set it
when you start R or in the console interactively
On Fri, Sep 16, 2011 at 12:48 PM, Mike P mike.polya...@gmail.com wrote:
Hi,
I want to apologize in advance if this has already been asked. I
i responded offline the first time, but:
google is your friend: search for R maps and you'll find what I mention
below.
In the future make sure to perform a thorough search of google and the help
forums before you post
That said... you're looking for the maps package
install.packages('maps')
look at the melt function in reshape, specifically ?melt.data.frame
require(reshape)
Raw.melt-melt(RawData,id.vars='Year',variable_name='Month')
there is an additional feature in the melt function for handling na values.
names(Raw.melt)[3]-'CO2'
head(Raw.melt)
Year MonthCO2
1 1958 J
This is what I use...
fit.func-function(x){
require(MASS)
est-fitdistr(x$wind_speed, 'weibull')$estimate
data.frame(shape=est[1],scale=est[2])
}
feel free to correct me if this is wrong!
Justin
On Wed, Aug 31, 2011 at 6:21 AM, Dennis Murphy djmu...@gmail.com wrote:
Hi:
Things work
Hiya,
maybe there is a native R function for this and if so please let me know!
I have 2 data.frames with start and end dates, they read in as strings and I
am converting to POSIXct. How can I check for overlap?
The end result ideally will be a single data.frame containing all the
columns of
try:
newnam-paste('newdatadat',dayno,sep='')
plot(test[[newnam[1]]])
On Mon, Aug 29, 2011 at 12:29 PM, Jie TANG totang...@gmail.com wrote:
hi, R-users
I have a data.frame for example test$newdataday24 and test$newdataday48
I can plot them by
plot(test$newdataday24)
but now i want to
Another great tool is debugonce()
wrap your function name in it and then execute your function call.
debugonce(my.function)
out-my.function(df)
And you'll be brought into the same interactive browser. (its Vi if im not
mistaken which can take a little getting used to.)
Justin
On Wed, Aug
as.POSIXct(518400,origin='2001-01-01')
[1] 2001-01-07 PST
as.POSIXct(as.numeric(as.POSIXct(518400,origin='2001-01-01')),origin='1970-01-01')
[1] 2001-01-07 08:00:00 PST
On Wed, Aug 24, 2011 at 9:22 AM, Agustin Lobo agustin.l...@ija.csic.eswrote:
Hi!
I'm confused by this:
His is better, but you can also use a for loop...
out-data.frame(rows=1:3)
for(i in 1:3){
if(l[[i]][3]=='Message 1') {
out$V1[i]-l[[i]][1]
} else {
out$V1[i]-NA
}
}
but shouldn't if your list is very long
On Tue, Aug 23, 2011 at 9:35 AM, Henrique Dallazuanna www...@gmail.comwrote:
Jean,
Ista is right, but:
In your function you are asking as.Date to convert the whole data.frame df
rather than just your daterep column.
out-ddply(d2, .(daterep), function(df)
as.Date(strptime(df$daterep,format='%Y%m%d')))
str(out)
'data.frame':30 obs. of 2 variables:
$ daterep: num
If you make your vector a data.frame, you will have row numbers accompanying
your sorting
df-data.frame(V1=c(1,4,3,2))
df$rows-row.names(df)
df[order(df$V1),]
also, you shouldn't use c as a variable name since its an important R
function...
see your example :)
Justin
On Tue, Aug 23, 2011 at
Whats going on here?
df-data.frame(x=1:10,y=1:10)
ggplot()+geom_point(data=df,aes(x=x,y=y)) ## this is the normal usage
right?
ggplot()+geom_point(data=df,aes(x=df[,1],y=df[,2])) ## but I can also feed
it column indices
ggplot()+geom_point(aes(x=df[,'x'],y=df[,'y'])) ## or column names.
##
If I have data:
dat-data.frame(a=rnorm(20),b=rnorm(20),c=rnorm(20),d=rnorm(20),site=rep(letters[5:8],each=5))
And want to plot like this:
ctr-1
for(i in c('a','b','c','d')){
png(file=paste('/tmp/plot_number_',ctr,'.png',sep=''),height=8.5,
width=11,units='in',pointsize=9,res=300)
like an
excessive extra step when I have 1e6 - 1e7 rows.
Justin
On Wed, Aug 10, 2011 at 2:42 PM, Ista Zahn iz...@psych.rochester.eduwrote:
Hi Justin,
On Wed, Aug 10, 2011 at 5:04 PM, Justin Haynes jto...@gmail.com wrote:
If I have data:
dat-data.frame(a=rnorm(20),b=rnorm(20),c=rnorm(20
Happy weekend helpeRs!
As usual, I'm stumped by R...
My plan was to take an integer number, convert it to binary and wind
up with a data.frame where each column is either 1 or 0 so I can see
which bits are changing:
bb-function(i) ifelse(i, paste(bb(i %/% 2), i %% 2, sep=), )
Happy Friday!
Using this function:
fixSeq - function(df) {
shift1 - function(x) c(1, x[-length(x)])
df$state_shift-df$state
df.rle-rle(df$state_shift)
repeat {
shifted.sf-shift1(df.rle$values)
change - df.rle$values = 4 shifted.sf = 4 shifted.sf != df.rle$values
I think need to do something like this:
dat-data.frame(state=sample(id=rep(1:5,each=200),1:3, 1000,
replace=T,prob=c(0.7,0.05,0.25)),V1=runif(1,10,1000),V2=rnorm(1000))
rle.dat-rle(dat$state)
temp-1
out-data.frame(id=1:length(rle.dat$length))
for(i in 1:length(rle.dat$length)){
I apologise in advance for not providing code, but this seems like a
straight forward question...
I am making a few full page plots some of which are portrait and
some of which are landscape
I would like to open my cairo device once and put all the plots in the
same .pdf. But since some
need to
))
HTH,
baptiste
On 15 June 2011 08:39, Justin Haynes jto...@gmail.com wrote:
I apologise in advance for not providing code, but this seems like a
straight forward question...
I am making a few full page plots some of which are portrait and
some of which are landscape
I would like to open my
I have a dataset that looks like:
set.seed(144)
sam-sample(1000,100)
dat-data.frame(id=letters[1:10],value=rnorm(1000),day=c(rep(1,100),rep(2,100),rep(3,100),rep(4,100),rep(5,100)))
I want to normalise it using the following function (unless you have
a better idea...):
is there a way to look for value changes in a column?
set.seed(144)
df-data.frame(state=sample(rep(1:5,200),1000))
any of the five states are acceptable. however if, for example,
states 4 or 5 follow state 3, i want to overwrite them with 3.
changes from 1 to any value and 2 to any value are
I apologize for the confusion but that solution will work with a twist.
I want to record only the first value of a state change that goes above 2.
so if the sequence is
344455544334 it should read all 3s
but 3442555414433 should read 33321
Hope that helps clarify, if not I can get
If you plot:
df-data.frame(x=factor(1:100),y=rnorm(1000))
ggplot(df,aes(x=x,y=y))+geom_boxplot()
How do I remove those pesky margins on the sides of the plot area? Or
maybe just reduce their size to something more like the spacing of the
boxes?
Thanks,
Justin
))+geom_boxplot() + scale_x_discrete(expand=c(0,0))
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx
- Original Message
From: Justin Haynes jto...@gmail.com
To: r
I know I'm not supposed to use them... but they're just so easy! I
have trouble defining an appropriate function for plyr or apply!
data-rnorm(144)
groups1-c('a','b','c','d')
groups2-c('aa','bb','cc','dd')
machines-1:12
I would like to create a table of my points and identify which
'quadrant' of a plot they are in with the 'origin' at the means. the
kicker is i would like to display it right next to or below a ggplot
of the data. Maybe xtable isnt the right thing to use, but its the
only thing i can think of.
I am trying to extract the shape and scale parameters of a wind speed
distribution for different sites. I can do this in a clunky way, but
I was hoping to find a way using data.table or plyr. However, when I
try I am met with the following:
set.seed(144)
I have a set of wind speeds read at different locations. The data is
a data frame with two columns: site and wind speed. I want to split
the data on site and call a function to find the shape and scale
parameters of a weibull distribution fit.
The end result is a plot with x-axis = shape and
Is there a way to do this in R? I have data in the form:
57_input 57_output 58_input 58_output etc.
can i use a for loop (i in 57:n) that plots only the outputs? I want
this to be robust so im not specifying a column id but rather
something like c++ code,
%s_input, i
is that doable in R?
I have a very large dataset with columns of id number, actual value,
predicted value. This used to be a time series but I have dropped the
time component. So I now have a data.frame where the id number is
repeated but each value in the actual and predicted columns are
unique.
I assume I need to
87 matches
Mail list logo