‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(fit.Y)
Df Sum Sq Mean Sq F valuePr(F)
sample.Y 3 2202.70 734.23 190706 2.2e-16 ***
Residuals80.030.00
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
- Phil Spector
://www.stat.berkeley.edu/classes/s243/calling.pdf
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
Barry =
Suppose your data frame is called mydat. Then something like
mydat[,sapply(mydat,class) %in% c('numeric','integer')]
might do what you want.
- Phil
On Sat, 16 Feb 2013, Barry DeCicco wrote:
Hello,
I've got a data frame
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
Tim -
Another approach to your problem is to use xtabs:
xtabs(count~site+bug,data=myf)
bug
site grasshopper ladybug spider stinkbug
A 4 0 20
B 0 6 08
- Phil Spector
.)
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec
.)
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Wed, 30
Iain -
Do you see the same behaviour if you use
z - unz(pathToZip, 'x.txt')
instead of
z - unz(pathToZip, 'x.txt','r')
- Phil Spector
Statistical Computing Facility
I've found the keep,log=TRUE option of sas.get to be useful in cases like this.
There's also a log.file= option if you don't want the default location for the
log file.
- Phil Spector
Statistical Computing Facility
It sounds like the problem boils down to counting the number
of _s in the WELLID variable, and seeing if there are two:
nchar(gsub('[^_]','',edm$WELLID)) == 2
[1] FALSE FALSE TRUE TRUE TRUE TRUE FALSE
- Phil Spector
answer.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec
Try
sub - subset(Claims, Year==Y1)
In R, the equality test is performed by two
equal signs, not one.
- Phil Spector
Statistical Computing Facility
Department
],])
should give you what you want. In this simple case, you could
also use
do.call(rbind,by(df,df$z,function(dat)dat[order(dat$x,decreasing=TRUE)[1:10],]))
from base R to get the same result.
Hope this helps.
- Phil Spector
Dan -
Try using having Premie not null instead of
having !is.na(Premie) .
- Phil Spector
Statistical Computing Facility
Department of Statistics
There's no need to use sapply or loops with grep -- it's
already vectorized. So you can find the rows you're
interested in with
wh = grep('^[.,]+$',df[,9])
store them with
sf = df[wh,]
and delete them with
df = df[-wh,]
- Phil Spector
you what you want.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
[,7] [,8][,9]
[1,] -1.7481451 0.4467964 -0.41358420
[2,] -0.2882922 1.0243662 -0.48263684
[3,] 0.9402479 0.5467952 -0.01922035
[4,] 0.6795783 1.4560765 -0.23013826
[5,] 0.9800312 -1.3462175 -0.77064872
- Phil Spector
selected
x[['PHQ']]
NULL
So if you don't want this feature, you can use brackets instead
of the dollar sign for extraction.
- Phil Spector
Statistical Computing Facility
Philipp -
I believe you're looking for the merge function.
If you need more guidance, please provide a meaningful
reproducible example.
- Phil Spector
Statistical Computing Facility
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Sun, 29
Jeanna -
The family variable is being stored as a factor.
You could eliminate the NA values manually, or you
could try something like
x$family = as.character(x$family)
before subsetting. If neither of these solutions are
satisfactory, please follow the posting guide and provide
a
0
[2,]10
[[2]]
[,1] [,2]
[1,]32
[2,]32
[[3]]
[,1] [,2] [,3]
[1,]101
[2,]010
[[4]]
[,1] [,2] [,3]
[1,]222
[2,]223
- Phil Spector
|ddd
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec
John -
Try
infert[,toolong] = sapply(infert[,toolong],cut2,g=10,levels.mean=TRUE)
- Phil Spector
Statistical Computing Facility
Department of Statistics
as factors.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
On May 24, 2011, at 10:19 AM, Kang Min
this helps. Take a look at the help page for the ave function
to understand how it works.
- Phil Spector
Statistical Computing Facility
Department of Statistics
rain forests']]$Genus
Bromheadia Homalomena
1 1
Hope this helps.
- Phil Spector
Statistical Computing Facility
Department of Statistics
2 2
3 S1 T2 2 2
7 S2 T2 NA 4
- Phil Spector
Statistical Computing Facility
Department of Statistics
of the final
query. You might also familiarize yourself with
dbGetQuery, which may be more suited to your needs.
- Phil Spector
Statistical Computing Facility
Department
The way to do what you want is to use the split function, for
example,
mydataframes = split(exmpl,exmpl$Site)
This will return a list with all the data frames.
If you don't understand why this is a better solution than
creating many separate data frames, let us know what you plan
to do with
John -
In your example, the misclassified observations (as defined by
your predict.function) will be
kyphosis[kyphosis$Kyphosis == 'absent' prediction[,1] != 1,]
so you could start from there.
- Phil Spector
(-2)^2.1
[1] NaN
complex(real=-2)^2.1
[1] 4.077269+1.324785i
- Phil Spector
Statistical Computing Facility
Department of Statistics
One way to get the ratings would be to use the ave() function:
rating = ave(x$freq,x$track,
FUN=function(x)cut(x,quantile(x,(0:5)/5),include.lowest=TRUE))
- Phil Spector
Statistical Computing Facility
?arima.sim
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Mon, 2 May 2011
Ryan -
summary expects an lm object, and fit is a list. So
you need to use something like
lapply(fit,summary)
to pass each list element to the summary function.
- Phil Spector
Statistical Computing Facility
Here's one possibility:
funmaker = function(x,y,z)function(z)x + y + (x^2 - z)
uniroot(funmaker(1,3,z),c(0,10))$root
[1] 5
uniroot(funmaker(5,2,z),c(30,40))$root
[1] 32
(The third argument to the function doesn't really do anything.)
- Phil Spector
),paste,collapse='')
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
,] -2.5787357 1.381395 -1.6545857 0.8239982 -1.169961
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC
],nm,sep='.')
df
}
Reduce(function(x,y)merge(x,y,by='id'),lapply(names(dfs),changenm))
- Phil Spector
Statistical Computing Facility
Department of Statistics
Abraham -
sudo apt-get install libxml2-dev
is what you need to get the development libraries and
xml2-config installed on your Ubuntu machine.
- Phil
On Mon, 25 Apr 2011, Abraham Mathew wrote:
Hello folks,
Here's is info on what system I'm
sudo apt-get install libcurl4-openssl-dev
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
sudo apt-get install libsqlite3-dev
(Unfortunately, the method I described to find this package in my
previous post doesn't work for this one.)
- Phil Spector
Statistical Computing Facility
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Fri
] = answer[,2] x[2] =
answer[,3],4])
[1] 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 0 0 0
- Phil Spector
Statistical Computing Facility
Department of Statistics
[outer(rownames(mtrx),colnames(mtrx),function(x,y)substr(x,2,4) ==
substr(y,2,4))]
Hope this helps.
- Phil Spector
Statistical Computing Facility
Department of Statistics
?which
A - c(1,2,3,4)
B - c(0,3,1,5)
which(AB)
max(which(AB))
[1] 4
- Phil Spector
Statistical Computing Facility
Department of Statistics
= rbind(lcd1,lcd2,lcd3)
pn = replicate(10,allvals[sample(smpool,1),])
but I can't be sure.
- Phil Spector
Statistical Computing Facility
Department of Statistics
match(list.a,list.b)
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
Rolf -
In order for R to build with tcltk support, the tcl/tk development
packages need to be available when R is configured. This command
apt-get install tcl8.5-dev tk8.5-dev
will install the necessary development packages, but you'll need to
reconfigure and rebuild R in order to get tcltk
You need to install the mysql client development libraries.
On SUSE systems, I believe the package is called
libmysqlclient-devel .
- Phil Spector
Statistical Computing Facility
Walter -
Since your codes represent numbers, you could use something like
this:
chk = as.numeric((hh.sub$HHFAMINC)
hh.sub$CS_FAMINC = cut(chk,c(-10,0,5,10,15,17,18),labels=c(0,1:5))
- Phil Spector
Statistical
Lisa -
Suppose your data frame is called somedat. Then
do.call(rbind,spl[sapply(spl,function(z)z$result[1] == 0 z$result[2] == 0
sum(z$result) == 1)])
should give you what you want.
- Phil Spector
))
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Sat, 26 Mar 2011, Bulent
5.0 11.5 10.7 10.2 10.6 10.1 8.1 6.4 3.0
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
operating system you are using, but the
mdb tools are designed for non-Windows systems.
- Phil Spector
Statistical Computing Facility
Department of Statistics
. You should then be able to pass the Data Source Name you chose
to the odbcConnect function, and use the result in the odbcQuery to make
SQL queries to your data base.
Hope this helps.
- Phil Spector
Statistical
Try
RN()
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
Erin -
If you seriously want to learn about regular expressions, I would
recommend Mastering Regular Expressions by Jeffrey Freidl.
(http://oreilly.com/catalog/9781565922570). I don't think there's
anything that's more thorough or authoritive.
- Phil
Ticker Return
1 20110301 MSFT 0.05
2 20110302 MSFT 0.01
3 20110301 GOOG -0.01
4 20110302 GOOG 0.04
- Phil Spector
Statistical Computing Facility
Department
%in% c(1,2,3),1,0)
makez(3)
[1] 1
makez(4)
[1] 0
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
To get the equivalent of what your loop does, you could use
lapply(data[,3:5],function(x)x/ave(x,data$plateNo,FUN=mean))
but you might find the output of
sapply(data[,3:5],function(x)x/ave(x,data$plateNo,FUN=mean))
to be more useful.
- Phil Spector
-01-07
2 2011-01-02 2011-01-05 2011-01-08
3 2011-01-03 2011-01-06 2011-01-09
sapply(z,class)
pts.1.3. pts.4.6. pts.7.9.
Date Date Date
- Phil Spector
Statistical Computing Facility
large problems. Learning to use the apply family of functions
from the start avoids this misconception.
- Phil Spector
Statistical Computing Facility
Department of Statistics
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec
Giovanni -
If you change int (which has no meaning in R) to
integer in your second example, it should work.
- Phil Spector
Statistical Computing Facility
Department
could just do the calculation directly:
system.time({C1 = t(X) %*% X})
user system elapsed
0.008 0.000 0.007
all.equal(C,C1)
[1] TRUE
- Phil Spector
Statistical Computing Facility
(3,2)
[1] 0.75
expr1(10,5)
[1] 0.5454545
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
rearrange the values.
Hope this helps.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
be of much use here.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
Andrew -
I believe
character.data$z = ifelse(is.na(character.data$x),
character.data$y,character.data$x)
should do what you want.
- Phil Spector
Statistical Computing Facility
Rohit-
If I understand you correctly, and your list's name is mylist,
then
mapply('*',mylist,as.numeric(names(mylist)))
will do what you want. In the future, please provide a reproducible
example.
- Phil Spector
an informative subject line
2) showing us what you tried without including
your typos and other errors.
I think you'll find this a more effective strategy than
trying to replace core elements of R that you don't
understand with empty functions.
- Phil Spector
(width=20)
use[use != '']
[1] select sysdate
[2] from dual
- Phil Spector
Statistical Computing Facility
Department of Statistics
of random numbers for each
element of systemic, I don't see an easy way to vectorize your
code (which doesn't mean that such a way doesn't exist).
- Phil Spector
Statistical Computing Facility
in what ever way you want, to
produce a whatever sort of plot you wanted. I'll leave it to you to
figure out the details.
- Phil Spector
Statistical Computing Facility
Department
Jim -
I believe
dat[order(rownames(dat)),order(colnames(dat))]
is what you are looking for.
- Phil Spector
Statistical Computing Facility
Department of Statistics
You can probably find the specific part you want from the above code.
- Phil Spector
Statistical Computing Facility
Department of Statistics
)
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Fri, 18 Feb
Francois -
I think you're looking for the any function:
x = c(1,2,3)
y = c(4,5,6)
any(x==y)
[1] FALSE
any(which(x==y))
[1] FALSE
x = c(1,2,3)
y = c(4,2,5)
any(x==y)
[1] TRUE
any(which(x==y))
[1] TRUE
- Phil Spector
use a call to file.choose() by itself to see what
path R expects to see for a particular file or directory.
- Phil Spector
Statistical Computing Facility
Department
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
write.csv(mydata[,grep('Location|Ambient|Name',names(mydata),invert=TRUE)],
file='mydata.csv')
should do what you want, but without a more concrete example, it's
just a guess.
- Phil Spector
Statistical
,'day','night')
both$date = both$sunrise = both$sunset = NULL
Then both should be the data frame you want.
- Phil Spector
Statistical Computing Facility
Department
a seed for the random number generator)
I'm not exactly sure how to form your column combination, though.
- Phil Spector
Statistical Computing Facility
Department of Statistics
Try
my.data.frame[my.data.frame$Buy==1 | my.data.frame$Sell ==1, ]
or
subset(my.data.frame,buy == 1 | sell == 1)
Then take a look at the help page for || i.e., help(||)
to see what you did wrong.
- Phil Spector
Marine -
Assuming your data frame is named df, I think
apply(df,1,function(x)mean(x[x[7]:x[8]]))
will give you what you're looking for.
- Phil Spector
Statistical Computing Facility
-.1,i+.1),rep(mns[i] + 1.96 * sds[i],2));
llines(c(i-.1,i+.1),rep(mns[i] - 1.96 * sds[i],2))}
panel.dotplot(x,y,...)
}
dotplot(Score ~ Dose | Sex, groups=Sex, data=dat,panel=mypanel)
- Phil Spector
-06-15
as.Date(sub('\\d+:\\d+:\\d+ [AP]M','',dts),'%m/%d/%Y')
[1] 2009-06-10 2009-06-15 2009-06-15
as.Date(as.POSIXct(dts,format='%m/%d/%Y %H:%M:%S %p'))
[1] 2009-06-10 2009-06-15 2009-06-15
- Phil Spector
here.
-- xkcd
--
Help protect Wikipedia. Donate now:
http://wikimediafoundation.org/wiki/Support_Wikipedia/en
On Tue, Feb 8, 2011 at 12:31 PM, Phil Spector spec...@stat.berkeley.edu
wrote:
Mike -
In what sense do min and max not work?
tm = as.POSIXct(c(2010-12-14 20:25
Nicolas -
I don't think it can be done automatically, but
you can use
row.names(pop) = 1:nrow(pop)
after deleting the column(s) to restore consecutive
numbers for the row names.
- Phil Spector
Statistical
Contrast the behaviour of these two statements:
plot(x,y,xlab=NULL,ylab=NULL)
plot(x,y,xlab='',ylab='')
In other words, use xlab='' to supress the label, not NULL.
- Phil Spector
Statistical Computing Facility
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
Another possibility is
mapply(rbind,list1,list2,SIMPLIFY=FALSE)
- Phil Spector
Statistical Computing Facility
Department of Statistics
outer(x,y)
[,1] [,2] [,3] [,4]
[1,] 25 50 75 100
[2,] 50 100 150 200
[3,] 75 150 225 300
[4,] 100 200 300 400
The outer() function will accepts a FUN= argument
which defaults to '*'.
- Phil Spector
.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Fri, 4 Feb 2011
is the function you're calling is that na.omit will remove
the entire row of data when it encounters a missing value, while the na.rm=TRUE
argument will remove missing values separately from each variable.)
Hope this helps.
- Phil Spector
Try
as.data.frame(as.table(a))
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
1 - 100 of 399 matches
Mail list logo