Working with tables using R [closed] - r

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need to write a function in R, since in other languages like c++ it works very slow. The function fills a 2d table with data, and then summarizes values of each row for further processing.

I am not sure if it answers your question, but if you work with data you can put them into data frames to take a look at the statistical parameters and for further processing. For example:
df = data.frame("var1" = c(5,10,15), "var2" = c(20,40,60))
#the 'summary' command gives you some statistical parameters based on the column
summary(df)
#with the 'apply' command you can addresses the rows.
#in this example you get the mean of each row:
apply(df, 1,mean)

Related

T.test for multiple datasets in R [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to run a t.test for 4 datasets but i was wondering if there is a method that automatically run the t.test for all the combinations of the groups of my datasets.Thank you
It is usually helpful to provide an example of what it is you are trying to do -- how your data is structured, what you've tried, and how you might want the output to look.
That said, if I'm understanding what you are asking correctly, you just want to run multiple t-tests over a data set and return a result for each combination of pairs.
If so, maybe the pairwise_t_test function from the rstatix package would be useful to you.
library(tidyverse)
library(rstatix)
### t-test across for multiple groups
pairwise_t_test(Sepal.Length ~ Species, p.adjust.method = "bonferroni", data = iris)

How to call a Data Frame in R using the variable Value [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have written the following code to compare Two Market, the code is working if we provide the Data Frame name individually.
enter image description here
for(i in 1:nrow(Market_SystemA))
{
A <- Market_SystemA[i,2]
B <- Market_SystemB[i,3]
MarketA <- data.frame(A)
MarketB <- data.frame(B)
#This is s fuction in R
Compare_Function(MarketA,MarketB)
}
I'm not sure if I understand your question correctly, but it seems like you are calling a compare_function on two strings that refer to existing data frames. To actually get the data frames from the string, then you will need to use the get function which looks for an object that has a name that matches the string.
MarketA <- get(A)

R : understanding simplified script with brackets or hooks? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I would like to understand how really works this script :
y <- y[keep, , keep.lib.sizes=FALSE]
in :
keep <- rowSums(cpm(y)>1) >= 3
y <- y[keep, , keep.lib.sizes=FALSE]
I do know d.f[a,b] but I can not find R-doc for d.f[a, ,b].
I tried "brackets", "hooks", "commas"... :-(
(Sometimes I would prefer that one does not simplifie his R script !)
Thanks in advance.
Subscripting data.Frames takes two values: df[rows, columns]. Any third value are optional arguments that you can use to subscript.
The most common of those is drop=FALSE as in df[1:18, 3, drop = FALSE]. This is done because when you subset just one column of a data.frame, it will lose the data.frame class. In your specific case, it seems like you are using another object that looks like a data.frame but with added functionalities from the bioconductor package. A look at the methods for those will tell you how these work.

Advanced subsetting r data frame [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Without using a special function, can you do the following to change the values in an R dataframe from a column that have length greater than 4:
df[length(df$Column1)>4,"Column1"] = "replacement value"
This does not seem to work, is there an alternative index style I can use, or do I need to use a function?
Thanks
The function to determine the length of an entry, like a word in a dataframe, is nchar(), and not length(). The latter is typically used to determine the number of entries in a vector.
You could therefore try using:
df[nchar(df$Column1) > 4, "Column1"] <- "replacement value"

passing a data frame to a function in R language [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to pass a data frame to a function as an argument. And then inside the function, I want to work on different combinations of columns for graphical presentation. Basically, I want to do graphical presentation on different data files. I want that, I pass the data file as an argument and then get the graphs. How can I do this in R.
You are not giving us much info but here is a very basic starting point:
library(ggplot2) # if you don't have this library run install.packages('ggplot2')
myAmazingFunction <- function(myDF) {
ggplot(myDF,aes(X,Y))+geom_line()
}
df <-data.frame(X=1:30, Y=runif(30), Z=1.3*runif(30))
myAmazingFunction(df)

Resources