John Kane | 20 Aug 17:15 2014

Re: Negative values on output

It appears you posted in HTML and what we get is an almost useles set of data.  It is much better to supply it
using dput() (and always post to the list in plain text not HTML.

See https://github.com/hadley/devtools/wiki/Reproducibility of
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for
some helpful hints on how to post to the R-Help list/

John Kane
Kingston ON Canada

> -----Original Message-----
> From: sam_l_cruickshank <at> hotmail.com
> Sent: Tue, 19 Aug 2014 19:09:13 +0100
> To: r-help <at> r-project.org
> Subject: [R] Negative values on output
> 
> 
> 
> 
> 
> 
> Good afternoon,
> I am completed a linear regression model which I personally am happy with
> the output and residual charts (although they are a bit bunched).  I have
> been using visreg() to visualise my data, and although I have logged the
> dependent variable (as it is cost data), on one of the graphical outputs
> I am getting negative fitted values for one of the Continents.  Attached
> is the data used, below is the code for the model and graph.  If anyone
> has any ideas I would hugely appreciate it, I tried a glm with log link
> too and this didn't help.
(Continue reading)

Barry Rowlingson | 20 Aug 14:58 2014
Picon

Re: loading saved files with objects in same names

On Tue, Aug 19, 2014 at 1:30 AM, Jinsong Zhao <jszhao <at> yeah.net> wrote:
> Hi there,
>
> I have several saved data files (e.g., A.RData, B.RData and C.RData). In
> each file, there are some objects with same names but different
> contents. Now, I need to compare those objects through plotting.
> However, I can't find a way to load them into a workspace. The only
> thing I can do is to rename them and then save and load again.
>
> Is there a convenient to load those objects?
>
> Thanks a lot in advance.

The technique of loading into an environment already mentioned can be
cleaned up and put into a function.

First lets save a thing called "x" into two files with different values:

 > x="first"
 > save(x,file="f.RData")
 > x="second"
 > save(x,file="s.RData")

This little function wraps the loading:

 > getFrom=function(file, name){e=new.env();load(file,env=e);e[[name]]}

So now I can get 'x' from the first file - the value is returned from
`getFrom` so I can assign it to anything:

(Continue reading)

Sneha Bishnoi | 20 Aug 14:13 2014
Picon

Re: DateTime wrong when exporting to csv in R

Tried that..does not help :(

On Wed, Aug 20, 2014 at 8:03 AM, Saurabh Agrawal <sagrawal <at> idrcglobal.com>
wrote:

> Maybe converting POSIXct to character string using "format" before writing
> to csv will help.
>
>
>
> On 20 August 2014 17:23, Sneha Bishnoi <sneha.bishnoi <at> gmail.com> wrote:
>
>> Hi All!
>>
>> This seems to be trival but I am not able to find a solution for it.
>> I have a dataframe with datetime columns in form of  ("%d/%m/%y
>> %H:%M:%OS").
>>
>> I write it to csv file. Whne i open the csv file the date time format are
>> in some number form .
>> So even if I use custome settings from excel to change it into date time
>> format, it gives me wrong value.
>>
>> My data frame is as below:
>>
>>  PostDate                            Status                 ArrTime
>>                NumGuests
>>  2014-08-14 16:13:08.850       O                    2012-01-13
>> 00:00:00.000
>>      6
(Continue reading)

Sneha Bishnoi | 20 Aug 13:53 2014
Picon

DateTime wrong when exporting to csv in R

Hi All!

This seems to be trival but I am not able to find a solution for it.
I have a dataframe with datetime columns in form of  ("%d/%m/%y %H:%M:%OS").

I write it to csv file. Whne i open the csv file the date time format are
in some number form .
So even if I use custome settings from excel to change it into date time
format, it gives me wrong value.

My data frame is as below:

 PostDate                            Status                 ArrTime
               NumGuests
 2014-08-14 16:13:08.850       O                    2012-01-13 00:00:00.000
     6
 2014-08-14 16:13:08.850       A

-SB

	[[alternative HTML version deleted]]

sam cruickshank | 19 Aug 20:09 2014
Picon

Negative values on output


Good afternoon,
I am completed a linear regression model which I personally am happy with the output and residual charts
(although they are a bit bunched).  I have been using visreg() to visualise my data, and although I have
logged the dependent variable (as it is cost data), on one of the graphical outputs I am getting negative
fitted values for one of the Continents.  Attached is the data used, below is the code for the model and
graph.  If anyone has any ideas I would hugely appreciate it, I tried a glm with log link too and this didn't help.
LM22 <- lm(logTotal ~ logArea + Continent + factor(Method1) + Popdens, data=dummy)
Output Residuals:     Min       1Q   Median       3Q      Max -1.22742 -0.31675 -0.00909  0.28885  1.20224 
Coefficients:                       Estimate Std. Error t value Pr(>|t|)    (Intercept)            -1.40972    0.77661  -1.815 0.081506 . 
logArea                 0.03811    0.04041   0.943 0.354619    ContinentAsia           3.51165    0.80009   4.389 0.000182
***ContinentAustralasia    3.48549    0.97433   3.577 0.001454 ** ContinentEurope         2.44829    0.82369   2.972
0.006452 ** ContinentGlobal         2.37910    1.00668   2.363 0.026197 *  ContinentNorth America  2.27953    0.62960  
3.621 0.001303 ** ContinentSouth America  3.60997    0.77627   4.650 9.22e-05 ***factor(Method1)2        1.11259   
0.38386   2.898 0.007696 ** factor(Method1)3        0.82519    0.47470   1.738 0.094459 .  factor(Method1)4      
-0.06737    0.67341  -0.100 0.921104    Popdens                -0.14261    0.31675  -0.450 0.656435    ---Signif. codes:  0 ‘***’
0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6151 on 25 degrees of freedom  (12 observations deleted due to
missingness)Multiple R-squared:  0.6998,	Adjusted R-squared:  0.5677 F-statistic: 5.297 on 11 and 25
DF,  p-value: 0.0002714
visreg(LM22) gives me a graph with "Africa" being within the realm of negative "Total" which is
impossible.  If you tell me how  can provide the data and graphs, but the email was kicked back with them in. 		
	   		   		 	   		  
	[[alternative HTML version deleted]]


Good afternoon,
I am completed a linear regression model which I personally am happy with the output and residual charts
(Continue reading)

Alexander Sommer | 19 Aug 16:01 2014
Picon

Weighted Mann-Whitney-Wilcoxon-Test

Hi fellow R-users,

well, say I got two groups, A and B. Nested within each group are subgroups and in each subgroup are objects
with values x and y to a certain attribute. So, I can compute the portion of x-objects for each subgroup as #x/(#x + #y).

Artificial example with 12 subgroups in group A and 8 subgroups in group B:

set.seed(123)
count.x <- NULL
count.y <- NULL
j <- 1
for (i in sample(x = 10:20, size = 20, replace = TRUE)){
 count.x[j] <- sample(x = 0:i, size = 1)
 count.y[j] <- i - count.x[j]
 j          <- j + 1
}
data <- data.frame(x.portion = (count.x/(count.x + count.y)),
                   x.portion = (count.y/(count.x + count.y)),
                   group     = c(rep("A", 12), rep("B", 8),
                   weight    = (count.x + count.y)
                  )

I am now interested in whether or not there is a difference in the portions of x-objects between group A and B
and consider it a good idea – as seen in the example above – to weight for the total number of objects in
each subgroup. Given data that is not considered a realization of some normal distribution, thinking of a
test that uses ranks still does not look like a natural solution to this problem. But I guess it is possible.
Though, Xie & Priebe (2002)* are not exactly aiming at this, their paper might give an idea how weighting
may look like in the special case of the Mann/Whitney/Wilcoxon statistic. (Despite the hint by John &
Priebe (2007)** that this “is not a candidate for the practitioner’s toolbox”.)

(Continue reading)

Picon

GSUB and Data.frame format lost

Hi all,

please, i'm trying to understand how using "Gsub" for some search and
replace of text, makes my data frame lost it's format.

This is my code:

<code>

DataGoogle1 <- read.csv(file = "DataGoogle2.csv", header = T,
stringsAsFactors = F)
head(DataGoogle1)

</code>

Result 1:

Campaña                    Visitas     Compras
1 facebook-Ads1         524         2
2 faceBOOK-Ads1       487         24
3 fcebook-ads12          258         4
4        Email1                8             7
5         mail1                 224         2
6     referral1                147         7

Then i apply the GSUB function like this:

<code> DataGoogle2 <- as.data.frame(gsub("facebook-Ads1", "FBAds",
DataGoogle1$Campaña)) </code>

(Continue reading)

PO SU | 19 Aug 12:14 2014

A question in Rinternals.h


Dear Rusers,
    when i am reading Rinternals.h file, i can't understand the following codes in lines 395-407:

#define CHAR(x)R_CHAR(x)
const char *(R_CHAR)(SEXP x);
/* Various tests with macro versions below */
Rboolean (Rf_isNull)(SEXP s);
Rboolean (Rf_isSymbol)(SEXP s);
Rboolean (Rf_isLogical)(SEXP s);
Rboolean (Rf_isReal)(SEXP s);
Rboolean (Rf_isComplex)(SEXP s);
Rboolean (Rf_isExpression)(SEXP s);
Rboolean (Rf_isEnvironment)(SEXP s);
Rboolean (Rf_isString)(SEXP s);
Rboolean (Rf_isObject)(SEXP s);

I can't figure out what are "R_CHAR,Rf_isNull....Rf_isObject" meaning, they seem like function
declarations, Rf_XXX maybe function pointers?
I need your help.

--

PO SU
mail: desolator88 <at> 163.com
Majored in Statistics from SJTU
	[[alternative HTML version deleted]]

Untung Kurniawan | 19 Aug 06:34 2014
Picon

programme bivariate binomial negative

I'm making a thesis with bonimial negative bivariate regression, please help me to be delivered program.
thank you.

Jinsong Zhao | 19 Aug 02:30 2014
Picon

loading saved files with objects in same names

Hi there,

I have several saved data files (e.g., A.RData, B.RData and C.RData). In 
each file, there are some objects with same names but different 
contents. Now, I need to compare those objects through plotting. 
However, I can't find a way to load them into a workspace. The only 
thing I can do is to rename them and then save and load again.

Is there a convenient to load those objects?

Thanks a lot in advance.

Best regards,
Jinsong

John Romansic | 19 Aug 01:31 2014
Picon

principle component values on PCA plots do not match

Hi all,

I am using prcomp to do Principle Components Analysis and have run into a
problem regarding the scale of the axes on my plots.  I am using prcomp to
analyze a set of 25 morphological measurements taken on each of 161
individual frogs. I used the biplot function to produce a figure of PC1 vs
PC2 for each of the individual frogs and arrows that represent the loadings
of the different morphological measurements on PC1 and PC2. Then I
constructed a separate, similar plot, using my own coding, that provides a
number for each individual frogs corresponding to its species as determined
by genetic analysis, without the arrows. The y-axis on the first plot
ranges shows PC2 values ranging from about -11 to 11, but the y-axis on the
second plot shows PC2 values ranging from about -4 to 4, although all the
data points seem to show up on the figure. I would like to show the same
PCA results on both plots and I do not understand why the y-axes on these
two plots do not match. By the way, the x-axes on these two plots seem to
match, but I think that is just a coincidence. I suspect that my coding for
the second plot is missing a command regarding scaling of the principle
components, but it's not obvious to me why those data would have to be
re-scaled. I thought the scaling is dealt with by prcomp. Within prcomp, I
used scale=TRUE, which I understand re-scales the original data so that all
the variables have equal variance.

Does anyone have any suggestions on what might be wrong with my coding?

Below is an example, using a truncated data set, which produces different
numbers than the example I described above, since this time only 5
measurements are included for each frog. Nevertheless, the second plot (the
one with my coding) has the same problem.

(Continue reading)


Gmane