1 ‘**’ 0.01 ‘*’ 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
://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 wi
pecial characters like dashes in variable
names.
Hope this helps.
- Phil Spector
Statistical Computing Facility
Department of Statistics
your data.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.be
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
et 25 rows.)
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
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
#x27;t reproduce the exact error which you saw.)
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
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 Com
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
reproducible example goes a
long way towards getting a good answer.
- Phil Spector
Statistical Computing Facility
Department of Statistics
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
sing=TRUE)[1:10],])
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.
Dan -
Try using "having Premie not null" instead of
"having !is.na(Premie)" .
- Phil Spector
Statistical Computing Facility
Depa
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,]
e=TRUE)
should give you what you want.
- Phil Spector
Statistical Computing Facility
Department of Statistics
[,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
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 Fac
'PHQ']
Error in `[.data.frame`(x, , "PHQ") : undefined columns selected
x[['PHQ']]
NULL
So if you don't want this "feature", you can use brackets instead
of the dollar sign for extraction.
s.
Hope this helps.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.b
00
[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 Spec
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 repr
27;,'\\U\\1\\2\\L\\3',TEXT,perl=TRUE)
[1] "" "BBB|cc" "|ddd"
- Phil Spector
Statistical Computing Facility
John -
Try
infert[,toolong] = sapply(infert[,toolong],cut2,g=10,levels.mean=TRUE)
- Phil Spector
Statistical Computing Facility
Department of Statistics
= subset(x,seq == use)
Hope this helps. Take a look at the help page for the ave function
to understand how it works.
- Phil Spector
Statistical Computing Facility
< 10 < 11 < 12 < 13 < ... < 31
Notice that it returns the days as factors.
- Phil Spector
Statistical Computing Facility
Department of Statistics
1 1
result[['Biak-Numfoor rain forests']]$Genus
Bromheadia Homalomena
1 1
Hope this helps.
- Phil Spector
Statistical Computing Facility
1 S1 T1 2 2
2 S2 T1 2 2
3 S1 T2 2 2
7 S2 T2 NA 4
- Phil Spector
Statistical Computing Facility
t of the final
query. You might also familiarize yourself with
dbGetQuery, which may be more suited to your needs.
- Phil Spector
Statistical Computing Facility
Depar
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 t
lex number
(-2)^2.1
[1] NaN
complex(real=-2)^2.1
[1] 4.077269+1.324785i
- Phil Spector
Statistical Computing Facility
Department of
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.
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
creating the
96x34 array, there might be a better solution.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
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.)
- Ph
NA
[3,] -2.5787357 1.381395 -1.6545857 0.8239982 -1.169961
- Phil Spector
Statistical Computing Facility
Department of Statistics
a,list(ID=df$ID),paste,collapse='')
- Phil Spector
Statistical Computing Facility
Department of Statistics
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 Fac
Interestingly, for xml, it's last one listed.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berk
sudo apt-get install libcurl4-openssl-dev
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
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 wo
7;
names(df)[wh] = paste(names(df)[wh],nm,sep='.')
df
}
Reduce(function(x,y)merge(x,y,by='id'),lapply(names(dfs),changenm))
- Phil Spector
Statistical Computing Facility
bly do what you want.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@sta
mtrx[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 Stati
apply(Next,1,function(x)answer[answer[,1]==x[1] & x[2] >= 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 Facilit
?which
A <- c(1,2,3,4)
B <- c(0,3,1,5)
which(A
[1] 4
- Phil Spector
Statistical Computing Facility
Department of Statistics
c(1,2,3,3)
allvals = rbind(lcd1,lcd2,lcd3)
pn = replicate(10,allvals[sample(smpool,1),])
but I can't be sure.
- Phil Spector
Statistical Computing Facility
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
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
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
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
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Sat, 26 Mar 2011, Bulent
atabase choice, and navigate to your
database. 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.
k.
I don't know what operating system you are using, but the
mdb tools are designed for non-Windows systems.
- Phil Spector
Statistical Computing Facility
l 13.1 6.0
Gy1 12.6 7.9 6.2
Gy2 10.6 8.4 8.4 5.2
Green 10.6 9.4 9.9 6.5 4.1
Blue 10.8 10.2 10.3 8.8 7.0 6.4
BlP7.3 11.3 12.7 11.2 10.4 9.9 4.2
Pur1 5.4 11.5 12.9 11.7 10.8 9.4 8.4 4.5
Pur2 5.0 11.5 10.7 10.2 10.6 10.1 8.1 6.4 3.0
Try
RN()
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
e thorough or authoritive.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
function(t)ifelse(t %in% c(1,2,3),1,0)
makez(3)
[1] 1
makez(4)
[1] 0
- Phil Spector
Statistical Computing Facility
Department of Statistics
')
rownames(ans) = NULL
ans
Date 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
.6. pts.7.9.
1 2011-01-01 2011-01-04 2011-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
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
tions.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
that
R can't handle large problems. Learning to use the apply family of functions
from the start avoids this misconception.
- Phil Spector
Statistical Computing Facility
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
0.008 0.104
Of course, you 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
Stati
=k;s=s;eval(parse(text=exprs[1]))}
expr1(3,2)
[1] 0.75
expr1(10,5)
[1] 0.5454545
- Phil Spector
Statistical Computing Facility
Department of Statistics
not sure ifelse would be of much use here.
- Phil Spector
Statistical Computing Facility
Department of Statistics
t can rearrange the values.
Hope this helps.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Ber
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
to get it to print the way you listed, you need
to reduce the width of the line:
options(width=20)
use[use != '']
[1] "select sysdate "
[2] " from dual "
- Phil Spector
1) adding 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.
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.
year')
xyplot(X~year|country*food,data=newdf)
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
111 19.57672 567 100.0
You can probably find the specific part you want from the above code.
- Phil Spector
Statistical Computing Facility
Jim -
I believe
dat[order(rownames(dat)),order(colnames(dat))]
is what you are looking for.
- Phil Spector
Statistical Computing Facility
Department of Statistics
axis labeled 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
Simona -
I don't think preallocating your random variables would make
the code run any faster.
A very simple change that would speed things up a little would
be to replace
simPD.vec[i]=length(R.vec[R.vec
Dear all,
Does anyone have any idea on how to speed up the for() loop below.
Current
eate a reduced csv file called "mydata.csv"
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 (most likely) easy solution.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
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 of
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 Sp
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 Com
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.
- Ph
r from yours because you didn't specify
a seed for the random number generator)
I'm not exactly sure how to form your column "combination", though.
- Phil Spector
Statistical Computing Facility
time <= both$sunset,'day','night')
both$date = both$sunrise = both$sunset = NULL
Then both should be the data frame you want.
- Phil Spector
Statistical Computing Facility
s(c(i-.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 Spec
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
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
Statis
"Telescopes and bathyscaphes and sonar probes of Scottish lakes,
Tacoma Narrows bridge collapse explained with abstract phase-space maps,
Some x-ray slides, a music score, Minard's Napoleanic war:
The most exciting frontier is charting what's already here."
-- xkcd
--
Help pr
9-06-15"
as.Date(sub('(\\d+/\\d+/\\d+) .*','\\1',dts),'%m/%d/%Y')
[1] "2009-06-10" "2009-06-15" "2009-06-15"
as.Date(sub('\\d+:\\d+:\\d+ [AP]M','',dts),'%m/%d/%Y')
[1] "200
the format you want.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec.
Another possibility is
mapply(rbind,list1,list2,SIMPLIFY=FALSE)
- Phil Spector
Statistical Computing Facility
Department of Statistics
400
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 '*'.
alues. (The subtle distinction between na.action=na.omit
and na.rm=TRUE 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 eac
jects in your workspace, you
could look at the help page for the assign function.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
Try
as.data.frame(as.table(a))
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
1 - 100 of 401 matches
Mail list logo