= c(0L, 0L
> ), Wait.GPU.NB.local = c(0L, 0L), NB.X.F.buffer.ops. = c(7.3,
> 4.4), Write.traje = c(0.3, 0.3), Update = c(6.3, 4.3), Constraints =
> c(8.9,
> 9.7), Comm..energies = c(0.9, 0.9), PIE.redist..X.F = c("8. 1",
> "8.7"), PIE.spread = c(29.7, 30.6), PI
Your first data column appears to contain character data (e.g. SYCL) which
cannot be converted to numeric. You also appear to have 0's in the numeric
columns which will cause problems since log(0) is -Inf. Barplots are useful
for categorical data, but not continuous, numeric data which are better
h
Could you have columns that are not character or integer so that y is never
defined in the function?
count1a(1:5/3)
Error in count1a(1:5/3) : object 'y' not found
David Carlson
On Mon, Aug 8, 2022 at 1:35 PM Erin Hodgess wrote:
> OK. I'm back again. So my test1.df i
Here is one way to get the table you are describing. First some made up data:
dta <- structure(list(tree = c(27, 47, 33, 31, 45, 54, 47, 27, 33, 26,
14, 43, 36, 0, 29, 24, 43, 38, 32, 21, 21, 23, 12, 42, 34), shrub = c(19,
29, 27, 31, 5, 24, 6, 37, 4, 6, 59, 7, 23, 15, 32, 1, 31, 37,
30, 44, 40, 1
Just use
names(unlist(df[, "VarY", drop=FALSE]))
# [1] "VarY1" "VarY2" "VarY3" "VarY4" "VarY5"
When you extract a single column from a data frame it converts it to a
vector by default.
David L Carlson
On Fri, May 6, 2022 at 1:05 PM Hooiveld, Guido
wrote:
> Dear all, I wrote a some code in wh
You can't get exactly what you want with base graphics, but you can get
close by defining line types and colors outside the plot command:
x <- seq(-3, 3, by = 0.01)
lns <- 1:2
clr <- 1:2
matplot(x, cbind(x, x^2), type="l", lty=lns, col=clr)
legend("bottomright", legend = c("x", expression(x^2)), l
u so much David! El El vie, 22 de abr. de 2022 a la(s) 11:04 p.
> m., David Carlson escribió: Since the rolls are
> independent, it is not necessary to separate the rolls into two stages:
> sides <- 6
> ZjQcmQRYFpfptBannerStart
> This Message Is From an External Send
> Thank you David.
>
> What about if I want to list the excluded rows?
> I used this
> (dat3 <- dat1[unique(c(BadName, BadAge, BadWeight)), ])
>
> It did not work.The desired output is,
> Alex, 20, 13X
> John, 3BC, 175
> Jack3, 34, 140
>
> Than
t)), ])
>
> My concern is when I am applying this for the large data set the "unique"
> function may consume resources(time and memory).
>
> Thank you.
>
> On Sat, Jan 29, 2022 at 12:30 AM David Carlson wrote:
>
>> Given that you know which columns should
All you need is predict(fit, data.frame(x)) or if you had started with
a data frame:
xy <- data.frame(x, y)
fit <- lm(y~x, xy)
predict(fit, xy)
David
Professor Emeritus of Anthropology
Texas A&M University
College Station, TX
On Fri, Nov 19, 2021 at 8:45 PM Rolf Turner wrote:
>
> On Fri, 19 N
If the loop is necessary:
num <- vector()
for (i in 1:100) {
if(i %% 2 != 0) num <- c(num, i)
}
num
Or modify your code to this to get each odd number printed on a separate row:
for (i in 1:100) {
if(i %% 2 != 0) print(i)
}
David L Carlson
On Sun, Jun 6, 2021 at 3:21 PM David C
There is really no need for a loop:
num <- 1:100
num[ifelse(num %% 2 == 1, TRUE, FALSE)]
[1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49
[26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99
David L Carlson
On Sat, Jun 5, 2021 at 2:05 P
You might also look into packages `Hmisc` and `labelVector` that provide
some support for labeling variable names.
David C
On Fri, May 14, 2021 at 1:59 AM PIKAL Petr wrote:
> Hallo Steven
>
> You probably need to be more specific what is your intention. I still
> wonder what is the real proble
On the Mac there can be 2 files. The R Studio uses .Rhistory, but Rapp
uses .Rapp.history.
David L Carlson
On Sun, Feb 28, 2021 at 9:06 AM Dr Eberhard W Lisse wrote:
> On the Mac it is ~/.Rhistory
>
> el
>
> On 2021-02-28 15:39 , Mahmood Naderan-Tahan wrote:
> > Hi
> >
> > May I know where is
Look at the Cluster Analysis Task View, particularly section
"Additional Functionality"
(https://cran.r-project.org/web/views/Cluster.html)
Maybe package clValid:
The R package clValid contains functions for validating the results
of a clustering analysis. There are three main types of cluster
va
import an svg file recently into a Google Doc. The 90 pixels
> per inch default conversion didn't look very clean and sharp after
> imported into a Google Doc. I tried 600 pixels/in and found that Google
> Doc looked like it accepted it at first. However, when I went back
> later, I
If you look at the examples on the manual pages for the upgma() and NJ()
functions you will see that the results are generally sent to the plot()
function. To save that graph as an .svg file you need to open a graphics
device using the svg() function, plot the data, and close the graphics
device. Y
Here is a different approach:
xc <- c("1", "1a", "1b", "1c", "2", "2a", "2b", "2c")
xn <- as.numeric(gsub("a", ".3", gsub("b", ".5", gsub("c", ".7", xc
xn
# [1] 1.0 1.3 1.5 1.7 2.0 2.3 2.5 2.7
David L Carlson
Professor Emeritus of Anthropology
Texas A&M University
On Fri, Jul 10, 2020 at 1:
It might be easier to diagnose if you can show us what the first ten lines
in your original file look like.
readLines("gokind.nephropathy.fin", n=10)
David L Carlson
On Mon, Jun 1, 2020 at 6:36 PM Bert Gunter wrote:
> Agreed!
>
> However, there may still be a problem, as read.table() ordinari
1 10 100
David L Carlson
Anthropology Department
Texas A&M University
On Mon, May 4, 2020 at 2:18 PM David Carlson wrote:
> The FUN= argument must be a vectorized function (see the documentation,
> ?outer), but the function rolldie takes only scalar values as arguments:
&g
ssion has 6 elements: only the first used
2: In 1:nsides : numerical expression has 8 elements: only the first used
David Carlson
Anthropology Department
Texas A&M University
On Mon, May 4, 2020 at 1:54 PM Yousri Fanous
wrote:
> Hello
>
> From outer help page:
>
Does it have to be a histogram or does it just have to look like one?
counts <- c(73,53,42,67,41,50)
vals <- c(1,2,3,4,5,6)
barplot(counts~vals, space=0)
If you want a more histogram-like axis:
barplot(counts~vals, space=0, names.arg="")
axis(1, 1:6 - .5, 1:6)
David L Carlson
Anthropology Depar
There's a typo in the first column name of your data - "year1" should
be "year". Sometimes R will do partial matching and find it, but not
always. Is this closer to what you're looking for?
plot(rate~year, sydf, type="b", xaxt="n", xlab="Month-Day")
axis(1, sydf$year, sydf$month.day)
This will pr
Converting a one-row data frame to a list is not difficult, but there
are several ways to represent the data as a list. Here is a
possibility:
> dta <- data.frame(t(LETTERS[1:10]), stringsAsFactors=FALSE)
> dta
X1 X2 X3 X4 X5 X6 X7 X8 X9 X10
1 A B C D E F G H I J
> dta.lst <- as.list(
Neither ContigID nor sampleID are defined in your example. The default
is to plot by the row names. You can get the manual page for the
dendrogram plot using the command ?plot.hclust. The second argument
lets you specify the labels.
David L Carlson, retired
Department of Anthropology
Texas A&M Uni
You can also use the legend() function which will draw the box
and arrange the text in a single column (or three columns if you
want a single row). It also has shortcuts for positioning the
box such as "topleft" or "bottomright."
?legend
for more details.
-
Da
---Original Message-
From: Bert Gunter [mailto:gunter.ber...@gene.com]
Sent: Monday, April 21, 2014 4:17 PM
To: David Carlson
Cc: Luigi Marongiu; r-help@r-project.org
Subject: Re: [R] find maximum values on the density function of a bimodal
distribution
Well, yes and no, David.
Yours is one possible int
Look below at your question. R-help does not support html email
so you must use plain text if you want to get an answer.
-
David L Carlson
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Marta Tob
This will work, as long as there are exactly 2 distinct modes:
> runs <- rle(sign(diff(d.rv$y)))
> length(runs$lengths) # There should be 4 runs if there are
exactly 2 modes
[1] 4
> mode1 <- runs$lengths[1]+1
> mode2 <- length(d.rv$x)- runs$lengths[4]
> d.rv$y[c(mode1, mode2)] # The 2 modes:
[1]
I was able to grab the logos by bringing the .svg file into
Inkscape (open source .svg editor). The three logos are grouped
so you can select them and then paste them into another
document. Then you'll have to ungroup the three logos and select
each logo separately.
---
You could randomly assign 1 to a single column in each row and
then use binomial draws on the remaining 0's:
> set.seed(42)
> dimMat <- matrix(0, 1000, 4)
> dimMat[cbind(1:1000, sample.int(4, 1000, replace=TRUE))] <- 1
> dimMat[dimMat<1] <- sample(0:1, 3000, replace=TRUE, prob=c(.6,
.4))
> table(r
Something like (only 20 columns here):
x <- matrix(rnorm(120*20), 120, 20)
xagg <- aggregate(x, list(rep(1:12, each=10)), mean)
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
Original Message-
From: r-h
Use an 3-dimensional array.
?array
And any basic introduction to R.
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project
This is a bit more direct. It works by forcing R to treat test
as a matrix rather than a table:
> tst2 <- data.frame(ID=dimnames(test)$ID,
as.data.frame.matrix(test),
check.names=FALSE)
> tst2
ID 1 2 3 4 5
10 10 10 20 30 40 50
11 11 0 0 60 70 0
12 12 0 0 0 80 0
> rownames(tst2) <-
It may be possible to do this in a single step, but
> x1 <- aggregate(response~id+age, data, mean)
> x2 <- data[data$eye=="l", c("id", "response2")]
> merge(x1, x2)
id age response response2
1 1 2 4.60 High
2 2 9 2.65 High
3 3 5 3.65 High
4 4 2 7.55
Or tweaking Don's solution but using the original mu and sig
vectors:
> set.seed(42)
> x.matrix<-matrix(0, nrow=27, ncol=5)
> for(i in 1:27){
+ x.matrix[i, ] <- rnorm(5, mu[i], sig[i])
+ }
>
> set.seed(42)
> xmat <- matrix(rnorm(27*5, rep(mu, each=5), rep(sig, each=5)),
+ nrow=27, byrow=TRUE)
>
That only requires two small changes in Sarah's first solution:
> Finaldata[, !colnames(Finaldata) %in% V$v2[V$v1 == 1]]
Length Rate
1 0.53607323 0.01739951
2 0.15405615 0.11837908
3 0.04542388 0.53702702
4 0.15633703 0.68870041
5 0.35293973 0.38258981
To add to Ranjan's reply, k-means can potentially find different
results with large nstart= numbers in a large data set. But you
are correct, with a large enough value, the results will be the
same unless there are two solutions that have exactly the same
between sum of squares (unlikely but not im
Look at the results of summary(body.pc). You will see that the
first component accounts for 70% of the variability. That is
very large and suggests that the variables are highly correlated
with one another. You could check with cor(bodysize). None of
the correlations is negative and the smallest on
The digits option gives you the number of significant digits
(ignoring leading zeros after the decimal) and it operates on a
column by column basis. The first and second columns have values
with a leading zero after the decimal (-0.04074 in both columns)
so R prints five decimal places to get four
78023, 43785, 69884, 12840, 54021 are listed as PersonID 3 in
rawData, but PersonID 4 in resultData.
Here is another way to get there:
# Split codes by PersonID creating a single vector for each
step1 <- split(rawData$codes, rawData$PersonID)
# Figure out how many lines we need - here 3 lines
maxl
Not exactly automatic, but if you are using Windows:
1. Open a blank spreadsheet in Excel
2. write.table(cor(nums2), file="clipboard-128", sep="\t") # In
R
3. Paste the clipboard into the spreadsheet
Package xlsx can write Excel format files, but does not put them
directly into Excel.
For the se
R-help strips attachments so your post has three problems:
1. No plot to look at
2. No data to replicate your code
3. Email is in html format instead of plain text
Try again using plain text mail, copy the results of
dput(your.data.frame) into your email and provide code that
generates the figure
I think we're down to counting the number of characters in each
solution! Arun's 3 two-line versus your two-line solution (not
counting loading plyr). How about three short lines?
pop <- rep(1:nrow(tab), tab$Freq)
ind <- unlist(sapply(tab$Freq, seq_len))
tab2 <- data.frame(pop, ind)
-
1. (alfa <- X*Y) # Sends the result of the expression to
print()
2. Y <- datos[,2, drop=FALSE] # see the bracket manual page:
?"["
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From:
If you read the manual page for read.csv (?read.csv), you will
see that the default for the header argument is TRUE, but your
example has no header. You do not need sep="," because that is
the default for read.csv. Also, the default is to convert
character strings to factors which you probably do n
Does setting OutDec work for you?
options(OutDec=",")
x <- rnorm(50, mean=2, sd=0.1)
y <- rnorm(50, mean=2, sd=0.2)
plot(x, y)
# options(OutDec=".") to change it back if you want
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station,
Not histograms, but here are two alternatives. The first gives
you kernel density plots for each value and the second uses
violin plots. Both plot points if there are fewer than 5.
set.seed(42)
y<-rpois(500,2)
x<-rnorm(500,y,1)
plot(x,y, type="n")
for (i in seq(min(y), max(y), by=1)) {
if (leng
Alternatively use type="c" instead of "l" which will create line
breaks where the points will go.
plot(1:5,type="c", col="blue")
points(1:5,col="black")
David
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon
Sent: Wednesda
One possibility would be to use the absolute value of the
differences. Then they would be all positive:
abs(Info$Attr1 - Info$Attr2)
[1] 0.46 3.21 0.01 0.99 1.07 10.08
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77
The simplest way is to use clip():
> clip(0, 33, -1, 0)
> polygon(ff,gg,col=2)
> clip(0, 33, 0, 1)
> polygon(ff,gg,col=4)
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From: r-help
You have discovered two features of R with your example. Don
told you about the first. Data frames are considered to be lists
so if you provide only one index, you get the columns (the list
elements) when you type
> str(leadership)
'data.frame': 5 obs. of 10 variables:
$ manager: num 1 2 3 4
If the data are two week intervals, the frequency is 52/2 = 26
and that matches the amount of data 8*26=208:
> vec.ts <- ts(vec, start=c(2005, 1), frequency=26)
> str(vec.ts)
Time-Series [1:208] from 2005 to 2013: 1 0 0 0 1 1 1 0 2 0 ...
> print(vec.ts, calendar=TRUE)
p1 p2 p3 p4 p5 p6 p7 p8
Your code produces four line graphs, one above the other. What
do you mean by drawing a contour line for the entire panel? A
contour map requires three vectors, two for the horizontal
position and one for the elevation or height. You have four
vectors of y variables with the same x. Since you do no
Both functions (not packages) are included in package stats
which is part of the standard R installation. Have you tried?
?prcomp
?princomp
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message--
ta$FNAME_TOKEN_COUNT > 3, TRUE, FALSE,
ifelse(mydata$FNAME_LENGTH > :
unused argument (ifelse(mydata$FNAME_LENGTH > 35, TRUE, FALSE,
ifelse(regexpr("9", mydata$FNAME_PATTERN) > 0, TRUE, FALSE)))
I have the R for Dummies book which covers it a bit, but I just
ordered t
Not always true, but it is in this case:
?ifelse
David C
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Johnson
Sent: Tuesday, February 18, 2014 11:24 AM
To: R help
Subject: [R] Updating a data frame based on if condition
I
You might modify this function which computes Cramer's V using
the assocstats() function in package vcd:
catcor <- function(x) {
require(vcd)
nc <- ncol(x)
v <- expand.grid(1:nc, 1:nc)
matrix(mapply(function(i1, i2) assocstats(table(x[,i1],
x[,i2]))
The official documentation is at
http://cran.r-project.org/manuals.html
There are also many introductory guides that have been
written by R users at
http://cran.r-project.org/other-docs.html
Including for example:
Using R for Data Analysis and Graphics by John Maindonald
R for Beginners by Emm
the count starts at 1 and does
not cover 0.98 and 0.49. How can I set the count at zero?
Best regards
Luigi
On Tue, Feb 11, 2014 at 8:49 PM, David Carlson
wrote:
To prevent R from using scientific notation set the scipen
option and probably cex.axis to reduce the axis text or some of
the tick
To prevent R from using scientific notation set the scipen
option and probably cex.axis to reduce the axis text or some of
the tick marks will be skipped:
options(scipen=10)
plot(x, y, pch=16, type="b", log="x", cex.axis=.8,
ylab=expression(bold("Y axis")),
xlab=expression(bold("X axis")))
T
?colnames
> a <- matrix(sample.int(10), 5, 2)
> str(a)
int [1:5, 1:2] 10 1 8 6 4 2 7 9 3 5
> colnames(a)
NULL
> colnames(a) <- c("volume", "height")
> colnames(a)
[1] "volume" "height"
> a
volume height
[1,] 10 2
[2,] 1 7
[3,] 8 9
[4,] 6 3
[5,] 4
We have a policy of not doing your homework for you, but I can point you to a
valuable resource for learning R
http://cran.r-project.org/doc/contrib/Paradis-rdebuts_en.pdf. Your problem
involves simple arithmetic. There is no regression problem unless you are
trying to predict height from volum
A reproducible example would help. Look at the example in metaMDS using the
dune data set. It consists of 20 observations (sites) with 30 species observed
(columns). You indicate that your compounds (species) are the rows and your
sites are the columns. So perhaps you are analyzing the distances
You are correct, but I do not know why stripplot works
differently from plot. I can give you two ways to get around the
problem though. The easiest is to use the plot command to
emulate stripchart:
plot(x, rep(1, length(x)), xlim=c(2, -2), yaxt="n", ylab="",
pch=0)
Or using stripchart:
stripchar
Without more information, it is hard to say. You did not tell us much about the
data beyond the dimensions, but it looks like you have several different kinds
of measurements including location and gender (probably categorical) and
cuticular profiles (presumably numeric). Without the commands yo
Try
rownames(dat) <- dat[,1]
before running PCA.
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of
() function:
?aggregate
David Carlson
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Nandini
Jayakumar
Sent: Tuesday, December 24, 2013 4:36 AM
To: r-help@r-project.org
Subject: [R] Mean: category wise within a data frame
Hello all
I
I can't think of a straightforward way. You might be able to use
the image.plot() function in package fields by using
legend.only=TRUE to add the legend to your existing plot.
David
From: Morway, Eric [mailto:emor...@usgs.gov]
Sent: Monday, December 23, 2013 3:46 PM
To: dcarl...@tamu.edu
C
to convert back.
cv <- matrix(as.integer(cut(vals, breaks=10)), dim(vals))
pal <- heat.colors(10)
Then use
polygon(x=x, y=y, border=NA, col=pal[cv[k, j]])
Note: border=NA, not NULL
David Carlson
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-proje
Also
> tbl <- xtabs(val~id+cat, dat1)
> tbl
cat
id A B C D
1 2 0 4 0
3 0 1 0 0
5 2 0 0 0
6 3 5 2 0
8 0 5 0 2
9 0 0 0 3
To get your column names
> dimnames(tbl)$cat <- paste0("cat", dimnames(tbl)$cat)
> tbl
cat
id catA catB catC catD
12040
3010
This will create a simple plot using Windows enhanced metafile
format:
> win.metafile("TestFigure.emf")
> plot(rnorm(25), rnorm(25))
> dev.off()
null device
1
>
Windows does not read pdf. It will offer to import an eps
(encapsulated postscript) file, but it only imports the bitmap
thu
According to the documentation (?as.vector), "All attributes are removed from
the result if it is of an atomic mode, but not in general for a list result."
data.frames are lists so
> is.vector(as.vector(x))
[1] FALSE
However if you convert using unlist() or as.matrix(), you will get a vector:
Please do not send emails using html. Please use dput() to send
your data to the list
> st <- read.table(text=s, header=TRUE)
> plot(B~A, st, type="n")
> with(st, text(A, B, C))
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station,
This will also work:
rownames(Geissler) <- paste0("b", Geissler$boys)
Geissler2 <-
na.omit(as.data.frame(as.table(as.matrix(Geissler[,-1]
names(Geissler2) <- c("Boys", "Girls", "Freq")
Geissler2$Boys <-
as.numeric(substr(as.character(Geissler2$Boys), 2,
nchar(as.character(Geissler2$Boys))
I think the OP was asking about the agglomeration method in
hclust(), not the distance measure in dist(). And the default in
dist() is not absolute distance which is not an option, but
Euclidean distance:
> dist(cbind(v, v))
12345
2 1.414214
I don't see an alternative to text(), but the positioning is not
that difficult:
oldpar <- par(mar=c(5.1, 4.1, 4.1, 4.1))
plot(0)
axis(4)
text(par("usr")[2], mean(par("usr")[3:4]), "TEXT",
srt=-90, adj=c(.5,-4), xpd=TRUE)
par(oldpar)
-
David L Carlson
Dep
,
I set it equal to the mean. duplicate="mean"
but still no joy,
Thanks
On Tue, Dec 10, 2013 at 4:28 PM, David Carlson
wrote:
The error says you have duplicate points in dat so you need to
set duplicate= to tell interp() how to handle them.
?interp
---
The error says you have duplicate points in dat so you need to
set duplicate= to tell interp() how to handle them.
?interp
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From: r-help
The full details on the col= argument can be found in the
section titled "Color Specification" on the help page for par -
?par.
Basically, col= accepts color names, hexadecimal RGB, or an
integer designating a position on the current palette. You can
get the current palette using
> palette()
[1]
We don't do homework assignments on the list, but one answer
requires no loops and an understanding of the various ways R
uses vectors for indexing:
?"["
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Orig
It is not straightforward unless you want the legend in the
right or the bottom margins. To put the legend inside the plot
region it is simplest to use image() to plot the raster file and
then image.plot(legend.only=TRUE) to add the legend. In addition
to reading the help page for plot{raster}, you
They are a day apart. Summer solstice is day 172 in both cases
so the calendar dates should be one day apart and they are (June
22 in 2007 and June 21 in 2008):
> strptime("2007-06-22", format="%Y-%m-%d")$yday
[1] 172
> strptime("2008-06-21", format="%Y-%m-%d")$yday
[1] 172
Your Daylength() funct
You can use recycling to simplify things:
> set.seed(42)
> x <- seq(0,12)
> bin.df <- as.data.frame(
+ rbind( cbind(x, prob=dbinom(x,12,1/6), p=1/6),
+cbind(x, prob=dbinom(x,12,1/3), p=1/3),
+cbind(x, prob=dbinom(x,12,1/2), p=1/2),
+cbind(x, prob=dbinom(x,12
To: dcarl...@tamu.edu
Cc: r-help@r-project.org
Subject: RE: [R] Aggregating spatial data
Fantastic. Thanks very much! Is there an easy way to plot the
points and
the 4 areas?
Best,
Ioanna
-----Original Message-
From: David Carlson [mailto:dcarl...@tamu.edu]
Sent: 25 November 2013 15:21
To:
And in fact
attach(lizards)
is included on page 560. You must have left it out of your
example code. Without it, your first example would not have run
either.
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
--
I think the OP was looking to expand the data frame so that each row was a
single observation so that the first row becomes 6 rows, 4-TRUE and 2-FALSE.
Something like this
> womensrole <- HSAUR::womensrole
> step1 <- reshape(womensrole, varying=c("agree", "disagree"),
+ v.names="Freq", timeva
Something like this?
> s <- expand.grid(x=seq(1,100,by=1),y=seq(1,100,by=1))
> w <-
data.frame(x=s$x,y=s$y,z1=rep(c(1,2,3,4),times=length(s$x/4)),
+ z2=seq(1,length(s$x),by=1))
> w$EW <- cut(w$x, breaks=c(.5, 50.5, 100.5), labels=c("West",
"East"))
> w$NS <- cut(w$y, breaks=c(.5, 50.5, 100.5), l
Bert is correct.
In addition, you are using prcomp() for your principal
components analysis so the initial principal component loadings
are called "rotation" in contrast to princomp() where they are
called "loadings." So you do not have "rotated" components in
the traditional sense of the word. I
You probably want to use cut(), but as currently stated, your
intervals leave gaps (between 20 and 21 for example):
set.seed(42)
values <- runif(25)*100
values
[1] 91.480604 93.707541 28.613953 83.044763 64.174552 51.909595
73.658831
[8] 13.40 65.699229 70.506478 45.774178 71.911225 93.46722
I'm not sure if there is a single function, but a quick script
would look something like this and would be easily adjusted
attach(mtcars)
mtcars.ls <- loess(mpg~wt*hp)
wtg <- seq(min(wt), max(wt), length.out=50)
hpg <- seq(min(hp), max(hp), length.out=50)
grid <- expand.grid(wt=wtg, hp=hpg)
mpg.fi
Maybe something like this, assuming mean=0:
samsize <- 100
replicates <- 50
pval <- .05
samples <- replicate(replicates, rnorm(samsize))
confint <- t(apply(samples, 2, function(x)
c(mean(x)-qt(1-pval/2,
df=samsize-1)*sd(x)/sqrt(samsize),
mean(x)+qt(1-pval/2, df=samsize-1)*sd(x)/sqrt(sams
> indx <- arrayInd(which(m>0), .dim=c(5, 5))
> indx
[,1] [,2]
[1,]41
[2,]23
[3,]43
[4,]24
[5,]15
# If you want the result sorted
> indx[order(indx[,1], indx[,2]),]
[,1] [,2]
[1,]15
[2,]23
[3,]24
[4,]41
[5,]43
[mailto:r-help-boun...@r-project.org] On Behalf Of David Carlson
Sent: Friday, November 15, 2013 9:42 AM
To: 'Jim Lemon'; 'jpm miao'
Cc: 'r-help'
Subject: Re: [R] Find the cutoff correlation value for Pearson
correlation test
I haven't looked at fBasics::corre
I would be easier to respond if we had some idea what
Mindreader_2012_vars is, data.frame, list, matrix?
Give us a small, reproducible version of what you are trying to
accomplish.
-
David L Carlson
Department of Anthropology
Texas A&M University
College Stati
I haven't looked at fBasics::correlationTest, but cor.test uses
the t distribution to evaluate significance:
t = sqrt(df) * r/sqrt(1 - r^2)
where df=n-2
If you solve that for r, you get
r = t/sqrt(t^2+100-2)
If you choose t as qt(.975, df) for a two-tailed test at p<.05
you can plug in t and p
Economics
UDSM
On Sunday, November 10, 2013 12:32 PM, David Carlson
wrote:
The simplest would be to create a variable combining region and
district:
> data$region_district <- with(data, paste(region, district))
> prop.table(xtabs(~region_district+response, data), 1)
response
r
The simplest would be to create a variable combining region and
district:
> data$region_district <- with(data, paste(region, district))
> prop.table(xtabs(~region_district+response, data), 1)
response
region_district no yes
A d 0.5 0.5
A e 0.0 1.0
Stripping down to the bare essentials seems to get it. In
particular making the query just "select *" instead of "select *
where B!=''" works. You don't need the processing that the more
complicated Guardian web page requires. After loading the RCurl
package and creating the gsqAPI function:
>
tmp
The changepoint package might give you a way to do this.
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Beh
1 - 100 of 228 matches
Mail list logo