I cannot apply functions. Error: object not found - r

I'm new to R and I'm following videos to import my data. Now, I'm having a hard time in applying some functions, like mean, summary, view (column) etc. It always shows the error: "object" is not found. I've tried many things but I'm stucked here for 2 days!
Can you help me? Thanks a lot!
#Video https://www.youtube.com/watch?v=cnD1op2Oo3M&list=PLtL57Fdbwb_Chn-dNR0qBjH3esKS2MXY3&index=4&ab_channel=RProgramming101
#Create the WD and view the table
library(readxl)
TMA_data <- read_excel("C:/Users/p1160413/Desktop/TMA R studio/TMA
data/dataforR.xlsx",
sheet = "Sheet2")
View(TMA_data)
#Test if it find the table and applies function
TMA_data
MeanAge <- mean(Age)
Result: Error in mean(Age) : object 'Age' not found

Related

How to solve this error message: attempt to select less than one element in OneIndex

I am using mFD package to run a code. I am using two datasets to run this code. One is :
and the another data is:
My code look like:
alpha_fd_indices <- mFD::alpha.fd.multidim(
sp_faxes_coord = sp_faxes_coord [ , c("PC1", "PC2", "PC3", "PC4", "PC5")],
asb_sp_w = as.matrix(species),
ind_vect = c("fdis", "fmpd", "fnnd", "feve", "fric", "fdiv", "fori", "fspe", "fide"),
scaling = TRUE)
And the error message is:
Error in sp_coord_all_asb[[k]] <- sp_faxes_coord_k :
attempt to select less than one element in OneIndex
Can anyone help me to solve this problem?
After struggling with this issue myself I found that the mFD package requires row names for your 'asb_sp_w' matrix here.
From the code for the 'alpha.fd.multidim' function I found that this function runs a loop for each of the community rows of the asb_sp_w matrix but it does this by getting the rownames() from this matrix in the line:
k <- rownames(asb_sp_w)[n].
My workaround was to give each of the rows some fake row names (or your community sample names) and this should allow the function to run without error.
I'm not sure if there is a practical usage for mFD to keep this in the function or not so maybe someone else can comment on this.

DartR - Error in FUN(X[[i]], ...) : only defined on a data frame with all numeric variables

I am very much a novice with R and am attempting to run a script that will filter a set of SNPs for 6 populations. I've successfully run this script before but I'm getting a new error in the initial stages of the script.
I've not been able to find anything similar to my issue online, though a few have the same error. The error comes up when R is trying to read in the SNP data and the function and error are as follows from the console screen:
>FijiHomaGL <- gl.read.dart(filename = "genCSV_modified.csv", ind.metafile = "COV_file.csv",
+ nas = "-", topskip = 6, lastmetric = TRUE, probar = TRUE)
Starting gl.read.dart
Starting utils.read.dart
Reading in the SNP data
Error in FUN(X[[i]], ...) :
only defined on a data frame with all numeric variables
A screenshot of the .csv file I'm trying to run
I'm not able to include the actual file but a screenshot is linked above for a general idea of the layout.
Any help is much appreciated I am very new so let me know if there is anything else I should include! Thanks in advance. The package being used for this function is dartR but I can't add it as a tag.

Why I am getting error as "Error in mapIds(GeneCol) : could not find function "mapIds""

I am trying to get Entrez ID using a big list of Gene Symbol. To do this, I used "AnnotationDbi", "org.Hs.eg.db", and "org_pkg".
when I run the code as
"geneIDs <- mapIds(org.Hs.eg.db, keys=rownames(Genename1), column=type, keytype=keys, multiVals="first")"
I get the following error
Error in mapIds(org.Hs.eg.db, keys = rownames(Genename1), column = type, :
could not find function "mapIds"
It would great if you can help me to overcome this problem. Alternatively, you can suggest to me how I can get Entrenz ID using gene symbol. Thank you in advance!
Best regards, Biswa
have you load the 'org.Hs.eg.db' and AnnotationDbi packages ?
library(org.Hs.eg.db)
library(AnnotationDbi)

Error in eval(predvars, data, env) : object 'value' not found

I think this may be too easy for all of you, but it is driving me crazy and I googled for straight 2 hours now, but I cannot solve this. I just started using R today and just trying to do a simple LM to get started.
This is my code:
library(readxl)
IPO <- read_excel("C:/Test.xlsx", sheet = "Tabelle1",
col_types = c("text","numeric", "numeric", "numeric", "numeric", "numeric"))
results <- lm(value~Age+Education)
So, I just import my data from an XLS file using readxl, which works and I get my data, as IPO is now listed under "Data".
But if I run the linear regression command, I get this error:
"Error in eval(predvars, data, env) : object 'value' not found"
I know that "Value" is not listed as a Value in R, but how can I change this?
I was using this video as reference:
https://www.youtube.com/watch?v=S-zKhFr91Tg&t=253s
When he runs the lm command, the Field "Values" (I know it`s the same name, but this is coincidence) the header "Values" under "Data" is created automatically - this does not happen when I try it.
Help?!
The Data:
https://pastebin.com/rdWYpBPR
Sorry, if this is too easy to ask. I just donĀ“t know what to do.
Thanks in advance.

Error in eval(expr, envir, enclos) : object 'score' not found

We have always been an SPSS shop but we're trying to learn R. Been doing some basics. I am trying to do a simple t-test, just to learn that code.
Here's my code, and what's happening:
Code screenshot
I don't get why it says "score" isn't found. It's in the table, and the read.csv code defaults to assuming the first row contains headers. I can't see why it's not "finding" the column for score. I'm sure it's something simple, but would appreciate any help.
You didn't store your imported csv file in a variable. It printed to the console because it had nowhere else to go - it just gets printed and then thrown away. You need to assign it for it to be saved in memory:
my_data_frame <- read.csv("ttest.csv")
Now your data exists in the variable my_data_frame and you can use it by supplying it as the data argument:
t.test(score ~ class, mu=0, alt="two.sided", conf=0.95, var.eg=F, paired=F, data=my_data_frame)
Also, in general, I would recommend using read_csv from the package readr over the default read.csv - it's faster.
Finally, when you ask questions, please provide your code as text, not a picture. You should also provide your data or a toy dataset - you can use the function dput to print code that will create your data, or just provide the csv file or some code that creates toy data.

Resources