Displaying 20 results from an estimated 2000 matches similar to: "More elegant multiplication or division of a data frame with a vector"
2008 Mar 23
1
mapply
In an earlier post, a person wanted to divide each of the rows of
rawdata by the row vector sens so he did below but didn't like it and
asked if there was a better solution.
rawdata <- data.frame(rbind(c(1,2,2), c(4,5,6))) sens <- c(2,4,6)
temp <- t(rawdata)/sens
temp <- t(temp)
print(temp)
Gabor sent three other solutions and I understood 2 of them but not the
2008 Apr 07
5
How to pack my stuff into a package (library, collection)?
Hello,
I am new useR, I have written some functions, which I currently use by
"source"-ing them from the files.
That's OK, but when I my functions start counting in the tens and
hundreds I'd be glad to be able to type
"help.search("my_obscure_fun")" and get a sensible reply. I also want
to be able to load them as a package at startup and not have to
2008 Mar 25
1
Combining several mappings in ggplot2
Hello,
I want to be able to make a plot that has several series with
different color and linetype.
Online documentation suggest that this is possible, but I haven't found how:
"We can also create redundant mappings, mapping the same variable to
multiple aesthetics. This is most useful when producing a graphic for
both colour and black and white display."
Here's what I have to
2008 Feb 07
1
How to split a factor (unique identifier) into several others?
Hello,
I have a data frame with a factor column, which uniquely identifies
the observations in the data frame and it looks like this:
sample1_condition1_place1
sample2_condition1_place1
sample3_condition1_place1
.
.
.
sample3_condition3_place3
I want to turn it into three separate factor columns "sample",
"condition" and "place".
This is what I did so far:
#
2008 Feb 25
1
Plotting series marked with a symbol on every nth data point, preferably in ggplot...
Hello!
I am working with signals and a plot of several signals on the same
axes can get quite messy. With lines that are very fractured,
distinction by only the linestyle is not very clear. If I add symbols
to the plot however, there are so many symbols, that they overplot and
the whole plot is unreadable once again. I am looking for advice on
how to make a plot with continuous lines and symbols
2008 Mar 26
2
Moving data between R and Matlab back and forth?
Hi to the list,
I am trying to find a way to painlessly move structured data back and
forth between R and Matlab (also Octave). For this purpose I found the
R.matlab package great help. I wish to use a Matlab -v6 MAT file as an
intermediary format, because it is well read by both Matlab and
Octave. It is also well read by 'readMat' function in R.matlab
package, but that is where I run
2008 Feb 07
1
Bode plots in ggplot2
Hello,
I am trying to figure out how to make a bode plot (a.k.a. bode
diagram) in ggplot2.
An example of such a diagram can be found here:
http://meweb.ecn.purdue.edu/~me475/ctm/freq/bode2.GIF
The example above shows the gain and phase characteristic of a linear system.
In my case, I would like to compare visually several systems on the
same diagram.
The data in the data frame is arranged
2011 May 17
1
simprof test using jaccard distance
Dear All,
I would like to use the simprof function (clustsig package) but the available distances do not include Jaccard distance, which is the most appropriate for pres/abs community data. Here is the core of the function:
> simprof
function (data, num.expected = 1000, num.simulated = 999, method.cluster = "average",
method.distance = "euclidean", method.transform =
2002 Dec 18
6
Can I build an array of regrssion model?
Hi,
I am trying to use piecewise linear regression to approximate a
nonlinear function. Actually, I don't know how many linear functions I
need, therefore, I want build an array of regression models to automate
the approximation job. Could you please give me any clue?
Attached is ongoing code:
rawData = scan("c:/zyang/mass/data/A01/1.PRN",
what=list(numeric(),numeric()));
len =
2012 Dec 10
1
Can somebody suggest how to achieve following data manipulation?
Dear all,
Let say I have following data:
RawData <- matrix(1:101, nr = 1); colnames(RawData) <- c("ASD",
as.character(as.yearmon(seq(as.Date("2012-03-01"), length.out = 100, by
= "1 month")))); rownames(RawData) <- "XYZ"
CutOffDate <- as.Date("2012-09-01")
NewDateSeries <- as.character(as.yearmon(seq(CutOffDate, to =
2005 Aug 04
2
Avoiding for loop
I understand that in R, for loops are not used as often as other
languages, and am trying to learn how to avoid them. I am wondering
if there is a more efficient way to write a certain piece of code,
which right now I can only envision as a for loop. I have a data file
that basically looks like:
1,55
1,23
2,12
...
that defines a matrix. Each row of the data file corresponds to a row
of the
2006 Jul 12
4
Keep value lables with data frame manipulation
Dear R,
I import data from spss into a R data.frame. On this rawdata I do some
data processing (selection of observations, normalization, recoding of
variables etc..). The result is stored in a new data.frame, however, in
this new data.frame the value labels are lost.
Example of what I do in code:
# read raw data from spss
rawdata <- read.spss("./data/T50937.SAV",
2008 Mar 24
1
How to assign multiple return values
Hi,
I am moving from MATLAB, where one can easily assign a number of
output values from a function like this:
[x,y] = myfun(a,b)
Then variables x and y can be directly used in the caller workspace.
I understand that R functions return a single argument, which could be
a list. This in a way makes it possible to return multiple values with
a single function call, but accessing the list variables
2009 Jul 14
2
How to provide list as an argument for the data.frame()
Hi R -users,
i've a table as describe below. I'm reading the numeric value presented in this table to populate a list.
#table
#============
#X A B C
#x1 2 3 4
#x2 5 7 10
#x4 2 3 5
#============
rawData <- read.table("raw_data.txt",header=T, sep="\t")
myList=list()
counter=0
for (i in c(1:length(rawData$X)))
{
print (i)
2008 Mar 27
2
Rule for accessing attributes?
Hi !
I am a new user and quite confused by R-indexing.
Make a list and get the attributes
lst <- list(x = 1:3, y = 4:6, z = 7:9)
attributes(lst)
This returns:
$names
[1] "x" "y" "z"
I can easily do:
nm <-names(lst)
or
nm <-attr(lst,"names")
which both return the assigned names of the named list 'lst', but why
then this doesn't
2012 Jan 20
2
rbind()
Hello there,
Much thanks in advance for any help. I have a few questions:
1) Why do I keep getting the following error:
File1 <- read.csv("../RawData/File1.csv",as.is=TRUE,row.names=1)
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file '../RawData/File1.csv': No such file or
2011 Sep 08
2
pie chart
Hi All,
I have txt file like :
$ cat data.txt
US 10
UK 12
Ind 4
Germany 14
France 8
> rawdata <- read.table(file='data.txt',sep='\t' , header=FALSE)
> rawdata
V1 V2
1 US 10
2 UK 12
3 Ind 4
4 Germany 14
5 France 8
I want to draw pie chart for the above data.
How to split rawdata into :
con <-
2009 Aug 03
2
Scale set of 0 values returns NAN??
Hi,
More questions in my ongoing quest to convert from RapidMiner to R.
One thing has become VERY CLEAR: None of the issues I'm asking about
here are addressed in RapidMiner. How it handles misisng values,
scaling, etc. is hidden within the "black box". Using R is forcing me
to take a much deeper look at my data and how my experiments are
constructed. (That's a very
2009 Sep 28
1
help with lda function
I am having a problem understanding the lda package. I have a dataset here:
[,1] [,2] [,3]
[1,] 2.95 6.63 0
[2,] 2.53 7.79 0
[3,] 3.57 5.65 0
[4,] 3.16 5.47 0
[5,] 2.58 4.46 1
[6,] 2.16 6.22 1
[7,] 3.27 3.52 1
If I do the following;
"names(d)<-c("y","x1","x2")
d$x1 = d$x1 * 100
d$x2 = d$x2 * 100
g<-lda( y ~ x1 + x2, data=d)
v2
2012 Jun 28
1
Merging listed dataset into one
Hello,
I'm wondering how I can merge two featuresets into one.
My dataset is two sets of microarray data and it looks like followings:
> rawData
$v1
TilingFeatureSet (storageMode: lockedEnvironment)
assayData: 2197815 features, 59 samples
element names: channel1, channel2
protocolData
rowNames: LT290677RU_D1_2011-02-16 LT286300LU_D1_2010-07-24 ...
LT003990RU_D1_2010-11-04 (59