Displaying 20 results from an estimated 10000 matches similar to: "creating axis of the plot before data are plotted"
2008 Jul 15
0
creating axis of the plot before data are plotted -- solved
Solved. I tried to create a minimal example, but my script is too
complicated to just cut out lines (too many dependencies). Instead of
it, I sketch
my idea. I do not say it is the nicest solution, but it works as I wanted.
The first five rows of my data-matrix:
> data_svd$u[1:5,]
[,1] [,2] [,3] [,4] [,5]
[,6] [,7]
25.12333 -0.05845695
2008 Jul 10
4
Turn any vector
Dear R-users,
I'd like to turn a vector so it starts with it's end. For better
understanding, this set of commands will do what I need:
i <- seq(1:10)
i_turned <- i
for (j in 1:length(i)) i_turned[j] <- i[length(i)-j+1]
now, i_turned is what I call turned. Is there a function which would make a
script lighter? Thank you upfront for any hint.
Best regards,
Zroutik
2008 May 23
2
Fit a sine to data
Dear R-users,
I'd like to fit a sine function to my data. The result should have a format
(and thus the formula, too)
y ~ a + sin(x+b)
where y and x are vectors, and a and b are (yet) unknown values.
The data sets (vectors x and y) are OK, and I can do a simple lm fitting
lm(y~x), or lm(y~I(sin(2*pi*x/360))), succesfully My issue is that I'm not
able to do the optional linear shift in
2008 Aug 11
4
A comprehensive manual on "How to plot" (a lot of graphical examples welcome)
Hi,
I'm looking for a manual (we based or pdf) which would explain in detail
with graphical examples what all the option can do in plot and par. Does
anybody now anything like this? A couple of manuals to R I went through do
have plot parameters mentioned, but sometimes it is hard to understand or
imagine what the parameter can do (the same with the related help page)
e.g. I met "From
2008 Aug 11
1
line with of the symbols in the legend -- changable?
Dear R users,
I plot data with
points(my_data[x]~x, col = x, type = "o", lwd="4")
where x is an integer running from 1 to 10, I get points drawn at the plot.
When want to do a legend to this I try
legend(leg.txt[x], col = x, text.col = 1, pch = 1, bty = "n")
where leg.txt contains the names of the variable and x behaves the same. The
difference between the
2010 Jun 18
1
Latex problem in Hmisc (3.8-1) and Mac Os X with R 2.11.1
Dear all,
I did post this more or less identical mail in a follow up to another
question I posted, but under another heading. I try again, but now
under the correct header.
upon running this code (from the Hmisc library-latex function) I
believe the call to summary.formula is allright and produces wonderful
tables, but the latex command results in a correct formatted table but
where all the
2009 May 19
5
exists function on list objects gives always a FALSE
Dear R-users,
in a minimal example exists() gives FALSE on an object which obviously does
exist. How can I check on that list object anyway else, please?
> SmoothData <- list(exists=TRUE, span=0.001)
> SmoothData
$exists
[1] TRUE
$span
[1] 0.001
> exists("SmoothData")
TRUE
> exists("SmoothData$span")
FALSE
> exists("SmoothData[[2]]")
FALSE
2008 Aug 14
1
the name of the current running script.r
Dear R users,
is there a hack how to get the filename of the current script.r sourced/ran?
My issue: I have a couple of scripts which were optimised and are placed in
tens of directories. (I have a height.r script in 30 directories, a lines.r
script in 25 directories and another flow.r script in 54 directories,
growing). The script runs in the directory and does its job: sources data
and creates
2008 Sep 17
3
using for variable as rowname
Is there a way to use the cycle variable for rowname?
v=1:6
for (a in 1:3){
for (b in 4:5) {
v=rbind(v,a.b=1)
}
}
v
This above obviously does not work, but I couldn't find out how to use a and
b to construct a rowname like 14, 15, 24, 25.
Thanks for the help.
Balazs
--
View this message in context: http://www.nabble.com/using-for-variable-as-rowname-tp19533203p19533203.html
Sent from
2009 Mar 02
3
Error setting rowname if rowname currently NULL
Hi,
My first post here and new to R so please bear with me (long time programmer
though, helping a friend with some scripts).
I've noticed a behaviour when using rownames() that I think is odd,
wondering if I'm doing something wrong.
To illustrate, say I create a very simple matrix (called fred):
fred<-matrix(,4,2)
It looks like this:
[,1] [,2]
[1,] NA NA
[2,] NA NA
2010 Nov 02
2
get the scripname within the executed myscript.r
Dear R-users!
Is there a way to obtain the name of the executed myscript.r, i.e. when
cmd> rscript myscript.r
is executed? (The name of the script in this case is "myscript.r")
Here is the explanation of why I would like to get that: Why: I have
prepared a set of scripts (decompose_data.r, plot_with_higher_resolution.r,
plot_3D.r, etc.) placed in a root directory at one place. I
2004 Jun 11
4
rownames of single row matrices
Hi
I want to extract rows of a matrix, and preserve rownames even if only
one row is selected. Toy example:
R> a <- matrix(1:9,3,3)
R> rownames(a) <- letters[1:3]
R> colnames(a) <- LETTERS[1:3]
R> a
A B C
a 1 4 7
b 2 5 8
c 3 6 9
Extract the first two rows:
R> wanted <- 1:2
R> a[wanted,]
A B C
a 1 4 7
b 2 5 8
rownames come through fine. Now extract just
2007 Aug 10
0
Row name of empty string issue
I have a data.frame with rownames taken from a database. Unfortunately, one
of the rownames (automatically obtained from the DB) is an empty string. I
often do computations on the DB s.t. the answers (rows) are indexed with
respect to the rownames so a computation on a DB record might necessitate
the indexing into the data.frame by the emtpy row name. Unfortunately, that
doesn't seem to
2003 Oct 18
1
why does data frame subset return vector
Hello,
I've a weired problem with a data frame. Basically it should be just one
column with
specific names coming from a data file (the file contains 2 rows, one should
be
the for the rownames of the data frame the other contains numeric values).
> df.rr <- read.table("RR_anova.txt", header=T, comment.char="", row.names=1)
> df.rr[c(1,2,3),]
[1] 1.11e-16 1.11e-16
2008 May 19
2
Sort matrix with duplicate row names alphabetically by rowname
Hi,
I've a matrix that contains 4 replicates of each rowname. (4 a's, 4
b's, 4 c's in no particular order) Like this:
#
c 32
a 1
b 4
c 87
c 34
b 54
a 23
a 12
b 9
a 3
b 87
c 43
There are a couple of more columns but I'm using the above as an example
I need to sort it so that the same rownames appear together in
alpahbetical order. Like this:
#
a 1
a 23
a 12
a 3
b 4
2008 Jan 04
1
predict.lm removes rownames for a single row. Why?
predict.lm keeps row names when working from several rows in
newdata, but always removes rowname from a single row.
The rownames are removed by the line in predict.lm
predictor <- drop(X[, piv, drop = FALSE] %*% beta[piv])
What is the reason for that decision? I usually want to
retain the row names.
tmp <- data.frame(x=1:4, y=c(1,3,2,5))
tmp.lm <- lm(y ~ x, data=tmp)
tmp.new <-
2009 Jul 13
2
how to keep row name if there is only one row selected from a data frame
Hi, there:
Assume I have a dataframe with rownames like A with rownames like a to e,
> A
[,1] [,2]
a 1 6
b 2 7
c 3 8
d 4 9
e 5 10
when I use A[1,], I lost the rowname for it, like below. How could I keep
it? Is there an easy way instead that I have to modify by myself after I
used A[1,] manually.
> A[1,]
[1] 1 6
Thanks,
W.
--
Weiwei Shi, Ph.D
Research
2012 Oct 21
1
Changing a for loop to a function using sapply
Apparently there is one or more concepts that I do not fully understand
from the descriptions of a function and the apply material. I have
been reading the mail from this forum and have learned much but, in this
case, what I have been reading here and from the manual isn't enough.
The following code produces what I want with the for loop. From what I
have read from this forum, a for
2000 Mar 09
1
For the record: how to merge data frames vertically
Hello,
to save searching time in the S-news archive, here is the simple solution to
merge data frames vertically (cols must be equivalent, of course). The
frames must be components of a list, such as produced by
framelist<-split(bigframe,factor).
bigframe2<-do.call("rbind",framelist)
# posted to S-news by Bill Venables, found in summary message
2010 Nov 29
1
Extracting selected rows from a matrix
Hi,
I have matrix of 104 columns and 30000 rows (Each Row has rowname).
I have 13 different list of selected rownames (character) say 1000 each. Now I want to extract the all the columns according to the rownames in each the list.
How can I do that in R ?
1 ) For a single list
2) For all the 13 list at a time
Regards,
Pankaj Barah
Department of Biology,
Norwegian University of