Dear R helpers,
I have a question about drawing random numbers from many categorical
distributions.
Consider n individuals, each follows a categorical distribution defined
over k categories.
Consider a simple case in which n=4, k=3 as below
catDisMat <-
rbind(c(0.1,0.2,0.7),c(0.2,0.2,0.6),c(0.1,
Dear R helper,
I wonder whether there is a quick way to extract some elements for a list.
for a vector we can do the following
vec <- seq(3)
names(vec) <- LETTERS[1:3]
vec[c(1,3)]
vec[c('A','C')]
But for a list,
test.l <- list(c(1,3),array(NA,c(1,2)),array(0,c(2,3)))
names(test.l)<-LETTERS[1:
Dear R helpers,
I wonder how to use a character vector as an input argument to setkey
(data.table package).
The following works:
library(data.table)
test.dt <- data.table(expand.grid(a=1:30,b=LETTERS),c=seq(30*26))
setkey(test.dt,a,b)
I like a similar function, but can accept c('a','b') as an in
Dear R-Helpers,
I wonder whether there is a function which cuts a multiple dimensional array
along a chosen dimension and then store each piece (still an array of one
dimension less) into a list.
For example,
arr <- array(seq(1*2*3*4),dim=c(1,2,3,4)) # I made a point to set the
length of the fir
Dear R helpers:
I like to apply deparse(substitute()) on multiple arguments to collect the
names of the arguments into a character vector.
I used function test.fun as below. it works when there is only one input
argument. but it does not work for multiple arguements. can someone kindly
help?
test
Correct me, if I misunderstand and there is no such a limitation.
Thanks again.
-Sean
On Sun, Dec 13, 2009 at 5:26 PM, David Winsemius wrote:
>
> On Dec 13, 2009, at 5:11 PM, Sean Zhang wrote:
>
> Dear R-helpers:
>>
>> Hours ago, I asked how to replace a single
Dear R-helpers:
Hours ago, I asked how to replace a single forward slash with a double
backward slash and recieved great help. Thanks again for all the repliers.
In the meantime, I wonder how to replace a single backward slash with a
double backward slash?
e.g., I want change "c:\test" into "c:\
Dear R-helpers.
Can someone kindly tell me how to replace a single forward slash with double
backward slash in a string?
i.e., from "a/b" to "a\\b"
Many thanks in advance.
-Sean
[[alternative HTML version deleted]]
__
R-help@r-project.org
t 3:03 PM, Sean Zhang wrote:
>
> Dear R helpers.
>>
>> I am new to plotting time data using R.
>> wonder how to convert character time info into date in R.
>> I searched over the web but did not find answer.
>>
>> the input character string is something li
Dear R helpers.
I am new to plotting time data using R.
wonder how to convert character time info into date in R.
I searched over the web but did not find answer.
the input character string is something like 03_1993 or 03-1993, so the
precision is at month level. I tried the following but failed
Dear R-Helpers:
I am trying filehash and would like to know whether I have to create a new
database to store results generated from another database.
Example code is presented below to show the question.
#R code below
library(filehash)
dbCreate("myDB1")
db1 <- dbInit("myDB1")
dbDelete
Dear R helpers:
I wonder how to pass more than one argument to the function called by
lapply.
For example,
#R code below ---
indf <- data.frame(id=I(c('a','b')),y=c(1,10))
#I want to add an addition argument cutoff into the function called by
lapply.
outside.fun <- functi
Dear R-helpers:
I have a question related to using do.call to call cbind and get.
#the following works
vec1 <- c(1,2)
vec2 <- c(3,4)
ColNameVec <- c('vec1','vec2')
mat <- do.call("cbind",lapply(ColNameVec,get))
mat
#put code above into a function then it does not work
#before doing so, first remo
Dear R-helpers:
May I ask a question related to storing a number of lmer model fit into a
list.
Basically, I have a for-loop (see towards the bottom of this email)
in the loop, I am very sure that the i-th model fit (i.e.,fit_i) is
successfully generated and the character string (i.e., tmp_i) is c
Dear R helpers:
Sorry to bother for a basic question about model.matrix.
Basically, I want to apply the dummy coding rule in a dataframe with
complete factor levels to another dataframe with incomplete factor levels.
I used model.matrix, but could not get what I want.
The following is an example.
Hey Buddy,
Hope you have been doing well since last contact.
If you have the answer to the following question, please let me know.
If you have chance to travel up north. let me know.
best,
-Sean
-- Forwarded message --
From: Sean Zhang
Date: Sat, Apr 11, 2009 at 12:12 PM
Dear R-helpers:
I have a question related to fitting overdispersed count data using lmer.
Basically, I simulate an overdispsed data set by adding an observation-level
normal random shock
into exp(+rnorm()).
Then I fit a lmer quasipoisson model.
The estimation results are very off (see model out
Dear R-gurus:
I have a question about lmer.
Basically, I have a dataset, in which each observation records number of
trials (N) and number of events (Y) given a covariate combination(X) and
group id (grp_id).
So, my dataset is in tabular form. (in case my explanation of tabular form
is unclear,
pl
stored as binary
> objects in filehash, it was pretty fast to retrieve them, pick out the
> data I needed from each month and create a subset of just the data I
> needed that would now fit in memory.
>
> So it all depends ...
>
> On Sat, Mar 14, 2009 at 8:46 PM, Se
Dear R helpers:
I am a newbie to R and have a question related to cleaning large data frames
in R.
So far, I have been using SAS for data cleaning because my data sets are
relatively large (handling multiple files, each could be as large as 5-10
G).
I am not a fan of SAS at all and am eager to mo
ng from
"environment" perspective validly exists).
Thank you all again very much!
-Sean Zhang
#My little example is listed below
f1<-function(a=1,b=2) {print(a); print(b); print(a-b) }
f1() #get 3, makes sense
f1(2,) #get 0, makes sense
a <- 10
b <- 20
f1(a=a+1,b=a)
a #get 10 a
Dear R-helpers:
I have a question related to <- and =.
I saw very experienced R programmers use = rather than <- quite
consistently.
However, I heard from others that do not use = but always stick to <- when
assigning valuese.
I personally like = because I was using Matabl, But, would like to re
Big thanks for your help and suggestion for email communication.
-s
On Mon, Mar 9, 2009 at 12:18 PM, baptiste auguie wrote:
>
> On 9 Mar 2009, at 16:04, Sean Zhang wrote:
>
> Dear Baptiste:
>
> Many thanks for your help!
>
> Using the Reduce way, it works almost perf
Dear R-helpers:
I am an R newbie and have a question related to writing functions that
accept unlimited number of input arguments.
(I tried to peek into functions such as paste and cbind, but failed, I
cannot see their codes..)
Can someone kindly show me through a summation example?
Say, we have i
Dear R-helpers:
I am new to R and wonder how to make a warning message colorful (if
possible, having sound is also welcome). I did some research and failed
to see options to allow this functionality. Is this a techical limitation so
far, or I miss some information.
Many thanks in advance.
-sean
Dear R-helpers:
I am an R novice and would appreciate answer to the following question.
Want to delete many variables in a dataframe.
Am able to delete one variable by assigning it as NULL
Have a large number of variables and would like to delete them without using
a for loop.
Is there a command
My dear R-helpers:
I am a novice in R and have the following text string manipulation question.
Is there a function that performs the job described below?
Say,
wanted_output <- c("ab", "cd", "ef")
#the function_wanted can generate c("ab", "cd", "ef") using ab cd ef as the
single input argument
w
Dear R helpers:
I am a R novice and have a question about using table() to extract
frequences over many sub-datasets.
A small example input dataframe and wanted output dataframe are provided
below. The real data is very large so a for loop is what I try to avoid.
Can someone englithen me how to u
Dear R-helpers:
I, an entry level R user, wonder how make a 3d scatter plot with both error
bars and a flexibly fitted surface.
Can anyone eligthen me?
Many Thanks in advance.
-Sean
[[alternative HTML version deleted]]
__
R-help@r-project
Dear R-helpers:
I am an entry-level R user and have a question related to overlaying a
barchart and and a xyplot using latticeExtra.
My problem is that when I overlay them I fail to align their x-axes.
I show my problem below through an example.
#the example data frame is provided below
ve
large number of dfs
loop.fun <- function (all.dfs)
{
for (i in 1:length(all.dfs) )
ifelse ( i==1, output <- get(all.dfs[i]), output <-
rbind(output,get(all.dfs[i])) )
return(output)
}
output <- loop.fun(all.dfs)
#Your help is highly appreciated. Many thanks in advance.
-S
Dear R-helpers:
I am new to R and would like to seek your expert opinion on installation
tip. Many thanks in advance.
I want to update my R to the newest version and wonder the following two
questions:
Question 1:
How can I install R and its contributed packages in a way so when updating R
in t
Dear R-Helpers:
I am a entry level user of R.
Have the following question. Many thanks in advance.
# value.vec stores values
value.vec <- c('a','b','c')
# which.vec stores the locations/indexs of values in value.vec.
which.vec <- c(3, 2, 2, 1)
# How can I obtain the following vector based on t
Dear R friends:
Can someone help me with the following problem? Many thanks in advance.
# Problem Description:
# I want to write functions which take a (character) vector of dataframe
names as input argument.
# For example, I want to extract the number of observations from a number of
dataframes.
34 matches
Mail list logo