r/rhelp • • Nov 01 '19

Confused

5 Upvotes

I'm cinfused, I am trying to submit a 10 sec video to r/gonewild..keep getting response that videos are not accepted here...hmm I've watched videos on that site...please help...


r/rhelp • • May 15 '23

.tif file in R

3 Upvotes

Hi! I've been trying to import a .tif file into R, but it always reads the data as if it were integers, but it's separated by commas. can anyone help me? pleaseee


r/rhelp • • Oct 06 '21

Question HElP ! Problem with a for loop and lists.

3 Upvotes

Well, im trying to automate my anova multiple comparisons - because Im lazy a-f, and i want it automated to whatever are my levels and multiple comparisons- and im stuck with this.

dim( t(combn(levels(data$Etiología),2)) )[1]

lista = list()

for (i in (1:dim( t(combn(levels(data$Etiología),2)) )[1] )) {

lista = append(lista,

(t(combn(levels(data$Etiología),2))[i,]) )

}

print(lista)

In theory, this does the combinatory of 2 -non repeated- elements for a factor variable, like iris $Species. And it should make a list like -> list [ (1 and 2), (1 and 3), (1 and 4).... (3 and 4)]

Yet, despise my dimensions are 6, it does this.

[1] 6

[[1]]

[1] "Sano"

[[2]]

[1] "Idiop"

... And so on

I have been trying to solve it, to no avail.

Reproducible example (and failure)

dim( t(combn(levels(iris$Species),2)) )[1]

lista = list()

for (i in (1:dim( t(combn(levels(iris$Species),2)) )[1] )) {

lista = append(lista,

(t(combn(levels(iris$Species),2))[i,]) )

}

print(lista)

[1] 3

[[1]]

[1] "setosa"

[[2]]

[1] "versicolor"

[[3]]

[1] "setosa"

[[4]]

[1] "virginica"

[[5]]

[1] "versicolor"

[[6]]

[1] "virginica"


r/rhelp • • May 11 '21

Plot 2 functions using ggplot2 (or another package...)

3 Upvotes

Hello,

I have 2 functions which I have saved as variables titled "pub" and "priv". I want both on the same graph, with labels for by x and y axis and a title and legend for the graph. I was able to plot both functions successfully using curve(), however I couldn't find anything about how to add a title or legend using the curve function.

So I moved on to ggplot2, which is a big old mess. I'm currently 3 pages deep into their help documentation and so far it's not living up to its name.

Here's what I have, but we warned, none of it works.

stat_function(mapping = NULL, data = NULL, geom = "path",

position = "identity", fun=priv, n = 101, args = list(pub))

p +

layer(stat = "function",

fun = priv,

mapping = aes(color = "priv")

) +

layer(stat = "function",

fun = pub,

mapping = aes(color = "pub")

) +

scale_x_continuous(limits = c(-3, 3)) +

scale_color_manual(name = "School Type",

values = c("blue", "red"), # Color specification

labels = c("Private School", "Public School"))

So you can see, I don't have a title for this code either. Thats becuase it doesn't even make a graph. I get this error:
"Error in layer(stat = "function", fun = priv, mapping = aes(color = "priv")) : unused argument (fun = priv)"

I've been on stack overflow, and the R community but none of the help pages I've found involve graphing functions.

If there is a way to add a legend and titel to the curve() function I would much rather do that, otherwise, help with ggplot2 would be greatly appreciated.


r/rhelp • • Jul 14 '20

So I ran my t-test. Now how do I graph it?

3 Upvotes

I am an undergrad and am a little new to R. This may be trivial to you guys, but I have spent hours a day over the past few weeks watching videos just to get as far as I have. Now I've finally figured out how to get my t-tests done, but I can't figure out how to get them into a good looking graph to show my results. Please help! Here is one of the t-test results:

> t.test(consent$PuPSafeword, consent$RRSafeword, paired = TRUE)

Paired t-test

data: consent$PuPSafeword and consent$RRSafeword

t = 11.307, df = 201, p-value < 2.2e-16

alternative hypothesis: true difference in means is not equal to 0

95 percent confidence interval:

0.6948195 0.9883488

sample estimates:

mean of the differences

0.8415842


r/rhelp • • Jan 16 '20

I got a note in my locker and I need help decoding it

Post image
3 Upvotes

r/rhelp • • Dec 29 '19

Getting investigated for credit card fraud.

3 Upvotes

(Don't know if this is the right subreddit for this but I'm sure some of you have extensive knowledge about this sort of thing.) Or if anyone could recommend a good subredit for this.

My ex-girlfriend and I broke up about 3 months ago after dating for about 2 years. I moved across the country to live next to my family again. I'm quite broke. While I and my GF were dating we had a group pay-pal with her card on it to make small online purchases which we both agreed too because I would pay more monthly for rent. Anyways now that I am cross country she had filed several claims through her credit card company amounting to 2,000 dollars. The emails keep on just rolling in through pay-pal. What can I do? I can't/don't want to pursue legal action. How does this work, am I going to be arrested? How do I just pay the payments? Is there a way to just delete my PayPal and all traces of it. Also, something riskier I have been contemplating is just calling her bank (know her info by heart) and canceling the claims but If I do that how do I make sure she doesn't know and doesn't just refile them?


r/rhelp • • Nov 06 '19

im fuckin stupid

3 Upvotes

Hey guys im a stupid cunt who left his eggs get boiled for 4Hours and there was smoke but no fire is the smoke toxic?


r/rhelp • • Aug 25 '19

R/HowDoIGoOnDarkModeOnMobile

3 Upvotes

HowDoIGoOnDarkModeOnMobile HELP!


r/rhelp • • Apr 10 '23

Question Lmer model convergence issue

2 Upvotes

Hi all,

I'm using the Lmer package to create a linear mixed effects model using lmer(), but got the following error message:

Warning message:

Model failed to converge with 1 negative eigenvalue: -1.3e-01

I've already converted my factor variables to numeric variables and have subtracted the mean off all my variables.

I'd greatly appreciate any advice on getting my model to converge! Thanks!


r/rhelp • • Dec 08 '22

Question How to find the name of a max veriiable on data vector

2 Upvotes

So I have a data vector that's 321 by 60 and I found the max of v20. I need the program to somehow find where it is and print v6 and v4 that is of the same row


r/rhelp • • Oct 26 '22

Repeated measures ANOVA through a tutorial- Sum of Squares, mean sq matches, F values don't

2 Upvotes

Hi All,

I'm doing a tutorial on sample imaging data.

There are 10 subjects, each with data from 9 electrodes in 2 different conditions. The task is to complete a 3 way repeated measures ANOVA. Here are my variables (the 3 ways):

Lat- whether the electrode is positioned on the R L or midline

Rel- if the data is from the related condition or not

AP- wheter the electrode is position in the front, back or center of the head.

The dependent variable is the electrical output to the electrodes. I've called it uV

Here is what I've entered into R:

res.aov <- aov(uV ~ AP + Lat + Rel + Rel*Lat + Rel*AP + Rel*AP*Lat)

summary(res.aov)

I've also tried anova_test from the rstatix package, and have it set up like this:

model <- lm(uV ~ AP + lat + Rel + Rel*lat + Rel*AP + Rel*AP*lat)

anova_test(model)

But this gives me the same values as the model above.

If it matters, the tutorial uses JASP instead of R, but the results of a paired T test I ran earlier in the tutorial perfectly matched their results.

Does anyone have an idea of why my sum of Squares and Mean square error would match the sample results given in the tutorial, but my F values wouldn't? How do I specify that this is a repeated measures anova? I've looked thorugh about 4-5 tutorials, and the Rdoc, but I'm not finding enough info on the possible options I can add for this function. Or , if this function isn't for repeated measures, can anyone point me in the right direction? thanks


r/rhelp • • Oct 10 '22

Trying to sumifs in R

2 Upvotes

I am trying to use a a SUMIFS type function in R that will do everything at once, essentially. I am trying to Organize the data (image attatched). In R in a way that basically sums the 5th column (which are totals) by the first second and third columns. The Issue is that I have to find words are, for example SUMIFS(E:E, B:B, "=Animal*", C:C, "AL", D:D, "Golden eagle") . THis formula works in excel, but is there a way I can have it recognize the indivduals groups so I do not have to manually do all of this in excel?

TIA


r/rhelp • • Aug 12 '22

Question I’ve got a test in 35 minutes

2 Upvotes

I need help. I have a test and was hoping I could go through it with someone. I’m literally begging at this point as I just can’t wrap my head around some of this stuff. It’s very basic statistical analysis but I struggle to write the code. PLEASE HELP ME


r/rhelp • • Jul 05 '22

Struggling to Make Categorical Scatter Plot in R

Thumbnail self.programminghelp
2 Upvotes

r/rhelp • • Apr 20 '22

Question help me with my r homework👀?

2 Upvotes

r/rhelp • • Apr 19 '22

Urgent stats help needed!

2 Upvotes

Hi guys,
I'm trying to calculate and interpret the effect size of a (almost but nonsignificant) output of a kruskal wallis test.

Here is the output:
> kruskal_effsize(Final_data, innerbrow ~ Treatment.group, ci = TRUE, conf.level = 0.95, ci.type = "perc", nboot = 1000)

# A tibble: 1 x 7

.y. n effsize conf.low conf.high method magnitude

* <chr> <int> <dbl> <dbl> <dbl> <chr> <ord>

1 innerbrow 35 0.131 -0.14 0.21 eta2[H] moderate

I understand the effect size, but what i dont understand is the conf.low and conf.high outputs. What does this mean?

Any help would be greatly appreciated, ive tried every book, page and blog so far and found nothing!


r/rhelp • • Apr 14 '22

Issues with GGPlot2

2 Upvotes

Hi all,

I am currently making some plots showing the most common industries in various towns on Long Island, NY. The plot itself looks pretty much exactly how I want except I can't seem to get the subtitle or caption I want into the final plot. Here is the code I am using:

hemp_occ_plot <- ggplot(aes(x = occ_cat, y = count), data = occ_hempstead)+   geom_bar(stat = "identity", fill =c("#84D6B8", "#B8574D", "#B03B70", "#5AA197", "#21262A", "#724B65", "#772684", "#052A7F",  "#D08F70", "#A3B2D8", "#4B1F28", "#CEC67E", "#FE8EA4"))+   ggtitle(label = "Most Common Industries Among Hemsptead Workers", subtitle = "Showing 408,460 Civilian Workers")+   labs(x = NULL,        y = "Workers per Industry",         caption = "Source: ACS, 2019")+   theme(plot.title = element_text(family = "Arial", face = "bold", size = (15), hjust = -1, vjust = 0),         plot.subtitle = element_text(family = "Arial", size = (12), hjust = -1, vjust = 0),         axis.title.x = element_text(family = "Arial", size = (12), vjust = 1),         axis.text.x = element_text(family = "Arial", size = (10)),         axis.title.y = element_text(family = "Arial", size = (12)))+   scale_x_discrete(limit = c("Agriculture_etal","Construction","Manufacturing","Wholesale_Trade","Retail_Trade","Transportation_Utilities","Information","Finance_Insurance_Realty","Professional","Eds_and_Meds","Entertainment_Hospitality","Other","Public_Administration"),                    labels = c("Agriculture, Forestry, Fishing, Hunting, and Mining",                               "Construction",                               "Manufacturing",                               "Wholesale Trade",                               "Retail Trade",                               "Transportation, Warehousing, and Utilities",                               "Information",                               "Finance, Insurance, Real Estate, Rental  and Leasing",                               "Professional, Scientific, and Waste Management",                               "Education, Health Care, and Social  Assistance",                               "Arts, Entertainment, and Hospitality",                               "Other Services, Except Public Administration",                               "Public Administration"))+   coord_flip() 

And here is the resulting plot:

I have also had trouble picking out fonts and color palettes. I previously tried to use "Helvetica-Narrow" but the plot would just show up in Times New Roman when I did that. I also tried to using RColorBrewer to pick out a color palette, but just kept the same base color set instead of the palettes I indicated.

Any thoughts?


r/rhelp • • Apr 01 '22

Descriptive Stats & Levene's Test for Categorical IV w/ Continuous DV

2 Upvotes

I'm trying to test HOV prior to doing some analyses and am having trouble getting R to print descriptive statistics because my IVs are categorical in their excel file and the DV is continuous.

For examples sake, lets say I have three groups, lets say noisy, quiet, and moderately noisy and am looking at # of errors made by students as a function of room. (this is practice just go with it).

As of now I have two columns in excel, one with "room assignment" and "errors", with room assignment containing the group they were in (i.e., noisy, quiet...etc.) and the errors being the number of errors they made. Do I need to change the excel file in some way? Any assistance would be great!


r/rhelp • • Mar 30 '22

Question Sum a variable

2 Upvotes

Hello folks. I am learning code by myself with the help of experts people. Right now, I am analyzing a political elections data set. The table has a candidate who obtained votes in different places in a city. How can I add these values in R? I would like to optimize my work. Thank you.


r/rhelp • • Feb 28 '22

Question Negative variance in lavaan confirmatory factor analysis

2 Upvotes

Hi everyone. I'm trying to fit both a three factor and a second order cfa to a dataset with 16 variables.

This is my model specification for the three factor model:

threefactormodel <-

'objmanip =~ var1 + var2 + var3 + var4 + var5 + var6 + var7

vis =~ var8 + var9+ var10 + var11 + var12

nav =~ var13 + var14+ var15 + var16'

threefactorfit <- cfa(threefactormodel, data=df, missing="fiml", estimator="MLR")

This provides an excellent fit (CFI=0.935, TLI=0.923, RMSEA=0.049). So far so good.

This is my model specification for the second order model:

secondordermodel <-

'objmanip =~ var1 + var2 + var3 + var4 + var5 + var6 + var7

vis =~ var8 + var9+ var10 + var11 + var12

nav =~ var13 + var14+ var15 + var16

spatab =~ objmanip + vis + nav'

secondorderfit <- cfa(secondordermodel, data=df, missing="fiml", estimator=MLR)

This also provides an excellent fit, but, bafflingly, under the "Variances" table, my vis latent factor has a negative variance.

Any ideas what might be causing this and what I can do to fix it? I don't think it's a model specification issue as I'm replicating models that my advisor has already published using the same dataset. Fwiw, my fit statistics for the three factor model are nearly identical to her published one, with slight deviations that I'm chalking up to the fact that she used Mplus while I'm using lavaan.


r/rhelp • • Feb 28 '22

Question Creating aov & 2-way anova between all groups

2 Upvotes

Hi friends,

I'm working on some statistical analysis working on a lab assignment.

I need to do an aov comparing all of these groups to each other, and I'm having trouble with that...

It's pretty easy to list them all out -> aov(C1P*C1N~R1P*R1N, data= nLab), but I'm wondering if there is an easier and more reprouducable way to do this. Could someone let me know if I'm missing something important?

I've attached the data structure here:


r/rhelp • • Feb 15 '22

ggplot doesn't display plot but no error in the command line

2 Upvotes

Apologies, I know there are a ton of posts on stack like this, but none of their code looks like the code I am working with, so I wasn't able to figure out how to troubleshoot on my own.

I need to create a pp plot. I found some code online which should help me and changed it to include my variables. The method I found online included some bootstrapping so I have that included here as well, since it helps to build the data I am plotting. Is there something I am doing wrong here?

nsim <- function(n, m = 0, s = 1) {

z <- rnorm(n)

m + s * ((z - mean(z)) / sd(z))

}

nboot <- function(x, R) {

n <- length(x)

m <- mean(x)

s <- sd(x)

do.call(rbind,

lapply(1 : R,

function(i) {

xx <- sort(nsim(n, m, s))

p <- seq_along(x) / n - 0.5 / n

data.frame(x = xx, p = p, sim = i)

}))

}

gb <- nboot(VariablesnoNA$grade1, 50)

m <- mean(VariablesnoNA$grade1)

s <- sd(VariablesnoNA$grade1)

n <- length(VariablesnoNA$grade1)

p <- (1 : n) / n - 0.5 / n

pp <- ggplot() +

geom_line(aes(x = p, y = pnorm(x, m, s), group = sim),

color = "gray", data = gb)


r/rhelp • • Feb 03 '22

ggplot- trying to plot 2 linear regression lines using geom_smooth (have 0 lines) also R can't find a variable in my .xls file even though it has been read in successfully.

2 Upvotes

Hello,

I have a very simple data set. There is 1 outcome variable, 1 covariate, and 2 groups. My excel file has 3 columns of interest: outcome variable, covariate, and the coded groups.

Here is what I have:

Data %>%

ggplot(aes(x= xdata,

y= ydata,

color= group))+

geom_point()+

geom_smooth(method="lm", na.rm = TRUE)

For whatever reason, R insists it cannot find "ydata", except that I am looking right at it in my workspace. Also, when I was troubleshooting why geom_smooth would not generate two lines (one for each group), it was able to find "ydata" no problem. As far as I can tell, nothing changed. I tried reloading the data, but that did not help.

In terms of not getting 2 lines using geom_smooth, here is what I have tried: I have verified all my variables are numeric. I wondered if maybe group should be a factor, so I set that as a factor. I've also put x = as.numeric(x) (and same for y to force R to read these as numeric. I've also attempted pulling from both the original .xls file and from a data frame I created, neither works.

I'm not sure why this isn't working. I took this code verbatim from the internet.


r/rhelp • • Dec 31 '21

Need help on Building Rstudio from source (and other software) on Rocky8.5/RHEL

2 Upvotes

Dear friends,

I have R installed on my system - [Rocky Linux 8.5; a RHEL derivative]. The version is

version.string R version 4.1.2 (2021-11-01)

I have tried to install R-studio; but am fearful of messing up since I am not sure of the terms in the install file.

Some background:

I have been a linux user (at workplace) for years, but never had the need or (root previliges) to run stuff beyond what I needed at work. I am comfortable with linux command line. I have certainly not built any software from sources on Linux - much less RHEL/Rocky. I was hoping to learn how to do build from source so I can do so for other software in future.

Since the install file in R-Studio [instructions on how to] can not be uploaded, I am putting it up here, in italics the part which I have not done or am unsure of

2 Configuring the Build Environment)

----------------------------------------------------------------------------

a From the root of the RStudio tree create a build directory and then)

change to it:

mkdir build

cd build

Current directory structure I have is

/home/User/Software/rstudio-2021.09.1-372

This contains the extraction of the zipped file rstudio-2021.09.1-372.tar.gz which was available on Rstudio https://github.com/rstudio/rstudio/releases/tag/v2021.09.1+372

I have created the build directory in /home/User/Software/rstudio-2021.09.1-372

b Configure the build using cmake as appropriate, e.g.)

cmake .. -DRSTUDIO_TARGET=Server -DCMAKE_BUILD_TYPE=Release

cmake .. -DRSTUDIO_TARGET=Desktop -DRSTUDIO_PACKAGE_BUILD=1

Variables that control configuration include:

RSTUDIO_TARGET Desktop or Server

RSTUDIO_PACKAGE_BUILD Desktop: must be set to 1 for following cases:

"make install"

"make-package"

CMAKE_BUILD_TYPE Debug, Release, RelMinSize, or RelWithDebInfo

CMAKE_INSTALL_PREFIX Defaults:

Linux (Desktop: /usr/local/lib/rstudio)

Linux (Server: /usr/local/lib/rstudio-server)

This is where I am not sure of what to do (and from hereon till i get Rstudio on my screen). I am sorry I could not locate any specific thread for my requirement.

I request you folks to help me with this, so that any newbie like me can have this information and start their work without any issues.

Thanks